1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Tetrahedral Finite Element matrix.
34 \*---------------------------------------------------------------------------*/
36 #ifndef tetFemMatrix_H
37 #define tetFemMatrix_H
39 #include "tetPointFields.H"
40 #include "elementFields.H"
41 #include "lduMatrix.H"
44 #include "dimensionedTypes.H"
46 #include "constraints.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
59 Ostream& operator<<(Ostream&, const tetFemMatrix<Type>&);
62 /*---------------------------------------------------------------------------*\
63 Class tetFemMatrix Declaration
64 \*---------------------------------------------------------------------------*/
74 //- Reference to GeometricField
75 GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi_;
78 dimensionSet dimensions_;
83 //- Are boundary conditions set?
84 mutable bool boundaryConditionsSet_;
86 //- Equation triangle map
87 mutable Map<constraint<Type> > fixedEqns_;
89 direction solvingComponent;
92 // Private static data
94 //- Matrix constraint fill-in
95 // Equals to the estimated fraction of fixed nodes in the matrix
96 static const label fixFillIn;
98 // Private Member Functions
100 //- Add boundary source and diagonal for gradient-type conditions
101 void addBoundarySourceDiag();
103 //- Store boundary coefficients
104 void storeBoundaryCoeffs() const;
106 //- Add coupling coefficients
107 // In parallel computations, the consequence of cell-by-cell
108 // matrix assembly is the fact that the "other part" of all the
109 // edge coefficients on the coupled edge and the diagonal
110 // coefficient is assembled on the neighbouring processor. The
111 // matrix assembly is therefore completed only once the matrix is
112 // completed, by adding the contribution from the neighbouring
114 // Note: There will be an additional component of
115 // vector-matrix multiply, for the edges originating on the
116 // parallel patch and protruding into the neighbouring domain.
117 // This is treated by doing a "local" multiplication on the
118 // neighbouring side and then adding the result.
120 void addCouplingCoeffs();
122 void eliminateCouplingCoeffs();
124 void addCouplingSource(scalarField&) const;
126 //- Set component boundary conditions
127 void setComponentBoundaryConditions
130 scalarField& psiCmpt,
131 scalarField& sourceCmpt
134 //- Reconstruct matrix
135 void reconstructMatrix();
137 //- Distribute source. Given an element field construct a source
138 // by distributing the volume integral over the element points
139 tmp<Field<Type> > distributeSource(const Field<Type>&) const;
144 // No tetFemSolver: boundary coefficients are not cached
147 ClassName("tetFemMatrix");
149 typedef constraint<Type> ConstraintType;
154 //- Construct given a field to solve for
157 GeometricField<Type, tetPolyPatchField, tetPointMesh>&,
161 //- Construct as copy
162 tetFemMatrix(const tetFemMatrix<Type>&);
164 //- Construct from Istream given field to solve for
167 GeometricField<Type, tetPolyPatchField, tetPointMesh>&,
174 virtual ~tetFemMatrix();
181 const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
187 GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi()
192 const dimensionSet& dimensions() const
197 Field<Type>& source()
202 const Field<Type>& source() const
207 //- Does the matrix need a reference level for solution
208 //bool needReference();
213 //- Set constrained value in a prescribed point
220 //- Relax matrix (for steady-state solution).
221 // alpha = 1 : diagonally equal
222 // alpha < 1 : ,, dominant
223 // alpha = 0 : do nothing
224 void relax(const scalar alpha);
226 //- Relax matrix (for steady-state solution).
227 // alpha is read from controlDict
230 //- Check matrix for diagonal dominance
233 //- Solve returning the solution statistics.
234 // Convergence tolerance read from dictionary
235 lduSolverPerformance solve(const dictionary&);
237 //- Solve returning the solution statistics.
238 // Solver controls read from tetFemSolution
239 lduSolverPerformance solve();
241 //- Return the matrix residual
242 tmp<Field<Type> > residual();
247 void operator=(const tetFemMatrix<Type>&);
248 void operator=(const tmp<tetFemMatrix<Type> >&);
252 void operator+=(const tetFemMatrix<Type>&);
253 void operator+=(const tmp<tetFemMatrix<Type> >&);
255 void operator-=(const tetFemMatrix<Type>&);
256 void operator-=(const tmp<tetFemMatrix<Type> >&);
260 const GeometricField<Type, elementPatchField, elementMesh>&
264 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
269 const GeometricField<Type, elementPatchField, elementMesh>&
274 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
277 void operator+=(const dimensioned<Type>&);
278 void operator-=(const dimensioned<Type>&);
280 void operator*=(const dimensioned<scalar>&);
284 friend Ostream& operator<< <Type>
287 const tetFemMatrix<Type>&
292 // * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
297 const tetFemMatrix<Type>&,
298 const tetFemMatrix<Type>&,
306 const tetFemMatrix<Type>&,
307 const GeometricField<Type, elementPatchField, elementMesh>&,
315 const tetFemMatrix<Type>&,
316 const dimensioned<Type>&,
321 //- Solve returning the solution statistics given convergence tolerance
322 // Solver controls read from Istream
324 lduSolverPerformance solve(tetFemMatrix<Type>&, Istream&);
327 //- Solve returning the solution statistics given convergence tolerance,
328 // deleting temporary matrix after solution.
329 // Solver controls read from Istream
331 lduSolverPerformance solve(const tmp<tetFemMatrix<Type> >&, Istream&);
334 //- Solve returning the solution statistics given convergence tolerance
335 // Convergence tolerance read from controlDict
337 lduSolverPerformance solve(tetFemMatrix<Type>&);
339 //- Solve returning the solution statistics given convergence tolerance,
340 // deleting temporary matrix after solution.
341 // Convergence tolerance read from controlDict
343 lduSolverPerformance solve(const tmp<tetFemMatrix<Type> >&);
346 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
349 tmp<tetFemMatrix<Type> > operator-
351 const tetFemMatrix<Type>&
355 tmp<tetFemMatrix<Type> > operator-
357 const tmp<tetFemMatrix<Type> >&
361 tmp<tetFemMatrix<Type> > operator+
363 const tetFemMatrix<Type>&,
364 const tetFemMatrix<Type>&
368 tmp<tetFemMatrix<Type> > operator+
370 const tmp<tetFemMatrix<Type> >&,
371 const tetFemMatrix<Type>&
375 tmp<tetFemMatrix<Type> > operator+
377 const tetFemMatrix<Type>&,
378 const tmp<tetFemMatrix<Type> >&
382 tmp<tetFemMatrix<Type> > operator+
384 const tmp<tetFemMatrix<Type> >&,
385 const tmp<tetFemMatrix<Type> >&
389 tmp<tetFemMatrix<Type> > operator-
391 const tetFemMatrix<Type>&,
392 const tetFemMatrix<Type>&
396 tmp<tetFemMatrix<Type> > operator-
398 const tmp<tetFemMatrix<Type> >&,
399 const tetFemMatrix<Type>&
403 tmp<tetFemMatrix<Type> > operator-
405 const tetFemMatrix<Type>&,
406 const tmp<tetFemMatrix<Type> >&
410 tmp<tetFemMatrix<Type> > operator-
412 const tmp<tetFemMatrix<Type> >&,
413 const tmp<tetFemMatrix<Type> >&
417 tmp<tetFemMatrix<Type> > operator==
419 const tetFemMatrix<Type>&,
420 const tetFemMatrix<Type>&
424 tmp<tetFemMatrix<Type> > operator==
426 const tmp<tetFemMatrix<Type> >&,
427 const tetFemMatrix<Type>&
431 tmp<tetFemMatrix<Type> > operator==
433 const tetFemMatrix<Type>&,
434 const tmp<tetFemMatrix<Type> >&
438 tmp<tetFemMatrix<Type> > operator==
440 const tmp<tetFemMatrix<Type> >&,
441 const tmp<tetFemMatrix<Type> >&
445 tmp<tetFemMatrix<Type> > operator+
447 const tetFemMatrix<Type>&,
448 const GeometricField<Type, elementPatchField, elementMesh>&
452 tmp<tetFemMatrix<Type> > operator+
454 const tmp<tetFemMatrix<Type> >&,
455 const GeometricField<Type, elementPatchField, elementMesh>&
459 tmp<tetFemMatrix<Type> > operator+
461 const tetFemMatrix<Type>&,
462 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
466 tmp<tetFemMatrix<Type> > operator+
468 const tmp<tetFemMatrix<Type> >&,
469 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
473 tmp<tetFemMatrix<Type> > operator+
475 const GeometricField<Type, elementPatchField, elementMesh>&,
476 const tetFemMatrix<Type>&
480 tmp<tetFemMatrix<Type> > operator+
482 const GeometricField<Type, elementPatchField, elementMesh>&,
483 const tmp<tetFemMatrix<Type> >&
487 tmp<tetFemMatrix<Type> > operator+
489 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&,
490 const tetFemMatrix<Type>&
494 tmp<tetFemMatrix<Type> > operator+
496 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&,
497 const tmp<tetFemMatrix<Type> >&
501 tmp<tetFemMatrix<Type> > operator-
503 const tetFemMatrix<Type>&,
504 const GeometricField<Type, elementPatchField, elementMesh>&
508 tmp<tetFemMatrix<Type> > operator-
510 const tmp<tetFemMatrix<Type> >&,
511 const GeometricField<Type, elementPatchField, elementMesh>&
515 tmp<tetFemMatrix<Type> > operator-
517 const tetFemMatrix<Type>&,
518 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
522 tmp<tetFemMatrix<Type> > operator-
524 const tmp<tetFemMatrix<Type> >&,
525 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
529 tmp<tetFemMatrix<Type> > operator-
531 const GeometricField<Type, elementPatchField, elementMesh>&,
532 const tetFemMatrix<Type>&
536 tmp<tetFemMatrix<Type> > operator-
538 const GeometricField<Type, elementPatchField, elementMesh>&,
539 const tmp<tetFemMatrix<Type> >&
543 tmp<tetFemMatrix<Type> > operator-
545 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&,
546 const tetFemMatrix<Type>&
550 tmp<tetFemMatrix<Type> > operator-
552 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&,
553 const tmp<tetFemMatrix<Type> >&
557 tmp<tetFemMatrix<Type> > operator+
559 const tmp<tetFemMatrix<Type> >&,
560 const dimensioned<Type>&
564 tmp<tetFemMatrix<Type> > operator+
566 const dimensioned<Type>&,
567 const tmp<tetFemMatrix<Type> >&
571 tmp<tetFemMatrix<Type> > operator-
573 const tmp<tetFemMatrix<Type> >&,
574 const dimensioned<Type>&
578 tmp<tetFemMatrix<Type> > operator-
580 const dimensioned<Type>&,
581 const tmp<tetFemMatrix<Type> >&
585 tmp<tetFemMatrix<Type> > operator==
587 const tetFemMatrix<Type>&,
588 const GeometricField<Type, elementPatchField, elementMesh>&
592 tmp<tetFemMatrix<Type> > operator==
594 const tmp<tetFemMatrix<Type> >&,
595 const GeometricField<Type, elementPatchField, elementMesh>&
599 tmp<tetFemMatrix<Type> > operator==
601 const tetFemMatrix<Type>&,
602 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
606 tmp<tetFemMatrix<Type> > operator==
608 const tmp<tetFemMatrix<Type> >&,
609 const tmp<GeometricField<Type, elementPatchField, elementMesh> >&
613 tmp<tetFemMatrix<Type> > operator==
615 const tetFemMatrix<Type>&,
616 const dimensioned<Type>&
620 tmp<tetFemMatrix<Type> > operator==
622 const tmp<tetFemMatrix<Type> >&,
623 const dimensioned<Type>&
628 tmp<tetFemMatrix<Type> > operator*
630 const dimensioned<scalar>&,
631 const tetFemMatrix<Type>&
635 tmp<tetFemMatrix<Type> > operator*
637 const dimensioned<scalar>&,
638 const tmp<tetFemMatrix<Type> >&
642 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
644 } // End namespace Foam
646 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
649 # include "tetFemMatrix.C"
650 # include "tetFemMatrixSolve.C"
651 # include "tetFemMatrixTools.C"
652 # include "tetFemMatrixCheck.C"
655 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
659 // ************************************************************************* //