OpenFOAM logo
Open Source CFD Toolkit

tetFemMatrix.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     tetFemMatrix<Type>
00027 
00028 Description
00029     Tetrahedral Finite Element matrix.
00030 
00031 SourceFiles
00032     tetFemMatrix.C
00033     tetFemMatrixSolve.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef tetFemMatrix_H
00038 #define tetFemMatrix_H
00039 
00040 #include "tetPointFields.H"
00041 #include "elementFields.H"
00042 #include "lduMatrix.H"
00043 #include "tmp.H"
00044 #include "dimensionedTypes.H"
00045 #include "Map.H"
00046 #include "constraints.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00054 
00055 template<class Type>
00056 class tetFemMatrix;
00057 
00058 template<class Type>
00059 Ostream& operator<<(Ostream&, const tetFemMatrix<Type>&);
00060 
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class tetFemMatrix Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 template<class Type>
00067 class tetFemMatrix
00068 :
00069     public refCount,
00070     public lduMatrix
00071 {
00072     // Private data
00073 
00074         //- Reference to GeometricField
00075         GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi_;
00076 
00077         //- Dimension set
00078         dimensionSet dimensions_;
00079 
00080         //- Source term
00081         Field<Type> source_;
00082 
00083         //- Are boundary conditions set?
00084         mutable bool boundaryConditionsSet_;
00085 
00086         //- Equation triangle map
00087         mutable Map<constraint<Type> > fixedEqns_;
00088 
00089         direction solvingComponent;
00090 
00091 
00092     // Private static data
00093 
00094         //- Matrix constraint fill-in
00095         //  Equals to the estimated fraction of fixed nodes in the matrix
00096         static const label fixFillIn;
00097 
00098     // Private Member Functions
00099 
00100         //- Add boundary source and diagonal for gradient-type conditions
00101         void addBoundarySourceDiag();
00102 
00103         //- Store boundary coefficients
00104         void storeBoundaryCoeffs() const;
00105 
00106         //- Add coupling coefficients
00107         //  In parallel computations, the consequence of cell-by-cell
00108         //  matrix assembly is the fact that the "other part" of all the
00109         //  edge coefficients on the coupled edge and the diagonal
00110         //  coefficient is assembled on the neighbouring processor.  The
00111         //  matrix assembly is therefore completed only once the matrix is
00112         //  completed, by adding the contribution from the neighbouring
00113         //  domain.
00114         //  Note: There will be an additional component of
00115         //  vector-matrix multiply, for the edges originating on the
00116         //  parallel patch and protruding into the neighbouring domain.
00117         //  This is treated by doing a "local" multiplication on the
00118         //  neighbouring side and then adding the result.
00119         //  
00120         void addCouplingCoeffs();
00121 
00122         void eliminateCouplingCoeffs();
00123 
00124         void addCouplingSource(scalarField&) const;
00125 
00126         //- Set component boundary conditions
00127         void setComponentBoundaryConditions
00128         (
00129             const direction,
00130             scalarField& psiCmpt,
00131             scalarField& sourceCmpt
00132         );
00133 
00134         //- Reconstruct matrix
00135         void reconstructMatrix();
00136 
00137         //- Distribute source.  Given an element field construct a source
00138         //  by distributing the volume integral over the element points
00139         tmp<Field<Type> > distributeSource(const Field<Type>&) const;
00140 
00141 
00142 public:
00143 
00144     ClassName("tetFemMatrix");
00145 
00146 
00147     // Constructors
00148 
00149         //- Construct given a field to solve for
00150         tetFemMatrix
00151         (
00152             GeometricField<Type, tetPolyPatchField, tetPointMesh>&,
00153             const dimensionSet&
00154         );
00155 
00156         //- Construct as copy
00157         tetFemMatrix(const tetFemMatrix<Type>&);
00158 
00159         //- Construct from Istream given field to solve for
00160         tetFemMatrix
00161         (
00162             GeometricField<Type, tetPolyPatchField, tetPointMesh>&,
00163             Istream&
00164         );
00165 
00166 
00167     // Destructor
00168 
00169         virtual ~tetFemMatrix();
00170 
00171 
00172     // Member functions
00173 
00174         // Access
00175 
00176             const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
00177             psi() const
00178             {
00179                 return psi_;
00180             }
00181 
00182             GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi()
00183             {
00184                 return psi_;
00185             }
00186 
00187             const dimensionSet& dimensions() const
00188             {
00189                 return dimensions_;
00190             }
00191 
00192             Field<Type>& source()
00193             {
00194                 return source_;
00195             }
00196 
00197             const Field<Type>& source() const
00198             {
00199                 return source_;
00200             }
00201 
00202             //- Does the matrix need a reference level for solution
00203             //bool needReference();
00204 
00205 
00206         // Operations
00207 
00208             //- Set reference level for solution
00209             void addConstraint
00210             (
00211                 const label vertex,
00212                 const Type& value
00213             );
00214 
00215             //- Relax matrix (for steady-state solution).
00216             //  alpha = 1 : diagonally equal
00217             //  alpha < 1 :    ,,      dominant
00218             //  alpha = 0 : do nothing
00219             void relax(const scalar alpha);
00220 
00221             //- Relax matrix (for steady-state solution).
00222             //  alpha is read from controlDict
00223             void relax();
00224 
00225             //- Check matrix for diagonal dominance
00226             void check();
00227 
00228             //- Solve returning the solution statistics.
00229             //  Convergence tolerance read from controlDict
00230             lduMatrix::solverPerformance solve();
00231 
00232             //- Return the matrix residual
00233             tmp<Field<Type> >  residual();
00234 
00235 
00236     // Member operators
00237 
00238         void operator=(const tetFemMatrix<Type>&);
00239         void operator=(const tmp<tetFemMatrix<Type> >&);
00240 
00241         void negate();
00242 
00243         void operator+=(const tetFemMatrix<Type>&);
00244         void operator+=(const tmp<tetFemMatrix<Type> >&);
00245 
00246         void operator-=(const tetFemMatrix<Type>&);
00247         void operator-=(const tmp<tetFemMatrix<Type> >&);
00248 
00249         void operator+=
00250         (
00251             const GeometricField<Type, tetPolyPatchField, elementMesh>&
00252         );
00253         void operator+=
00254         (
00255             const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00256         );
00257 
00258         void operator-=
00259         (
00260             const GeometricField<Type, tetPolyPatchField, elementMesh>&
00261         );
00262 
00263         void operator-=
00264         (
00265             const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00266         );
00267 
00268         void operator+=(const dimensioned<Type>&);
00269         void operator-=(const dimensioned<Type>&);
00270 
00271         void operator*=(const dimensioned<scalar>&);
00272 
00273     // Ostream operator
00274 
00275         friend Ostream& operator<< <Type>
00276         (
00277             Ostream&,
00278             const tetFemMatrix<Type>&
00279         );
00280 };
00281 
00282 
00283 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
00284 
00285 template<class Type>
00286 void checkMethod
00287 (
00288     const tetFemMatrix<Type>&,
00289     const tetFemMatrix<Type>&,
00290     const char*
00291 );
00292 
00293 template<class Type>
00294 void checkMethod
00295 (
00296     const tetFemMatrix<Type>&,
00297     const GeometricField<Type, tetPolyPatchField, elementMesh>&,
00298     const char*
00299 );
00300 
00301 template<class Type>
00302 void checkMethod
00303 (
00304     const tetFemMatrix<Type>&,
00305     const dimensioned<Type>&,
00306     const char*
00307 );
00308 
00309 //- Solve returning the solution statistics given convergence tolerance
00310 //  Convergence tolerance read from controlDict
00311 template<class Type>
00312 lduMatrix::solverPerformance solve(tetFemMatrix<Type>&);
00313 
00314 //- Solve returning the solution statistics given convergence tolerance,
00315 //  deleting temporary matrix after solution.
00316 //  Convergence tolerance read from controlDict
00317 template<class Type>
00318 lduMatrix::solverPerformance solve(const tmp<tetFemMatrix<Type> >&);
00319 
00320 
00321 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
00322 
00323 template<class Type>
00324 tmp<tetFemMatrix<Type> > operator-
00325 (
00326     const tetFemMatrix<Type>&
00327 );
00328 
00329 template<class Type>
00330 tmp<tetFemMatrix<Type> > operator-
00331 (
00332     const tmp<tetFemMatrix<Type> >&
00333 );
00334 
00335 template<class Type>
00336 tmp<tetFemMatrix<Type> > operator+
00337 (
00338     const tetFemMatrix<Type>&,
00339     const tetFemMatrix<Type>&
00340 );
00341 
00342 template<class Type>
00343 tmp<tetFemMatrix<Type> > operator+
00344 (
00345     const tmp<tetFemMatrix<Type> >&,
00346     const tetFemMatrix<Type>&
00347 );
00348 
00349 template<class Type>
00350 tmp<tetFemMatrix<Type> > operator+
00351 (
00352     const tetFemMatrix<Type>&,
00353     const tmp<tetFemMatrix<Type> >&
00354 );
00355 
00356 template<class Type>
00357 tmp<tetFemMatrix<Type> > operator+
00358 (
00359     const tmp<tetFemMatrix<Type> >&,
00360     const tmp<tetFemMatrix<Type> >&
00361 );
00362 
00363 template<class Type>
00364 tmp<tetFemMatrix<Type> > operator-
00365 (
00366     const tetFemMatrix<Type>&,
00367     const tetFemMatrix<Type>&
00368 );
00369 
00370 template<class Type>
00371 tmp<tetFemMatrix<Type> > operator-
00372 (
00373     const tmp<tetFemMatrix<Type> >&,
00374     const tetFemMatrix<Type>&
00375 );
00376 
00377 template<class Type>
00378 tmp<tetFemMatrix<Type> > operator-
00379 (
00380     const tetFemMatrix<Type>&,
00381     const tmp<tetFemMatrix<Type> >&
00382 );
00383 
00384 template<class Type>
00385 tmp<tetFemMatrix<Type> > operator-
00386 (
00387     const tmp<tetFemMatrix<Type> >&,
00388     const tmp<tetFemMatrix<Type> >&
00389 );
00390 
00391 template<class Type>
00392 tmp<tetFemMatrix<Type> > operator==
00393 (
00394     const tetFemMatrix<Type>&,
00395     const tetFemMatrix<Type>&
00396 );
00397 
00398 template<class Type>
00399 tmp<tetFemMatrix<Type> > operator==
00400 (
00401     const tmp<tetFemMatrix<Type> >&,
00402     const tetFemMatrix<Type>&
00403 );
00404 
00405 template<class Type>
00406 tmp<tetFemMatrix<Type> > operator==
00407 (
00408     const tetFemMatrix<Type>&,
00409     const tmp<tetFemMatrix<Type> >&
00410 );
00411 
00412 template<class Type>
00413 tmp<tetFemMatrix<Type> > operator==
00414 (
00415     const tmp<tetFemMatrix<Type> >&,
00416     const tmp<tetFemMatrix<Type> >&
00417 );
00418 
00419 template<class Type>
00420 tmp<tetFemMatrix<Type> > operator+
00421 (
00422     const tetFemMatrix<Type>&,
00423     const GeometricField<Type, tetPolyPatchField, elementMesh>&
00424 );
00425 
00426 template<class Type>
00427 tmp<tetFemMatrix<Type> > operator+
00428 (
00429     const tmp<tetFemMatrix<Type> >&,
00430     const GeometricField<Type, tetPolyPatchField, elementMesh>&
00431 );
00432 
00433 template<class Type>
00434 tmp<tetFemMatrix<Type> > operator+
00435 (
00436     const tetFemMatrix<Type>&,
00437     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00438 );
00439 
00440 template<class Type>
00441 tmp<tetFemMatrix<Type> > operator+
00442 (
00443     const tmp<tetFemMatrix<Type> >&,
00444     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00445 );
00446 
00447 template<class Type>
00448 tmp<tetFemMatrix<Type> > operator+
00449 (
00450     const GeometricField<Type, tetPolyPatchField, elementMesh>&,
00451     const tetFemMatrix<Type>&
00452 );
00453 
00454 template<class Type>
00455 tmp<tetFemMatrix<Type> > operator+
00456 (
00457     const GeometricField<Type, tetPolyPatchField, elementMesh>&,
00458     const tmp<tetFemMatrix<Type> >&
00459 );
00460 
00461 template<class Type>
00462 tmp<tetFemMatrix<Type> > operator+
00463 (
00464     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&,
00465     const tetFemMatrix<Type>&
00466 );
00467 
00468 template<class Type>
00469 tmp<tetFemMatrix<Type> > operator+
00470 (
00471     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&,
00472     const tmp<tetFemMatrix<Type> >&
00473 );
00474 
00475 template<class Type>
00476 tmp<tetFemMatrix<Type> > operator-
00477 (
00478     const tetFemMatrix<Type>&,
00479     const GeometricField<Type, tetPolyPatchField, elementMesh>&
00480 );
00481 
00482 template<class Type>
00483 tmp<tetFemMatrix<Type> > operator-
00484 (
00485     const tmp<tetFemMatrix<Type> >&,
00486     const GeometricField<Type, tetPolyPatchField, elementMesh>&
00487 );
00488 
00489 template<class Type>
00490 tmp<tetFemMatrix<Type> > operator-
00491 (
00492     const tetFemMatrix<Type>&,
00493     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00494 );
00495 
00496 template<class Type>
00497 tmp<tetFemMatrix<Type> > operator-
00498 (
00499     const tmp<tetFemMatrix<Type> >&,
00500     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00501 );
00502 
00503 template<class Type>
00504 tmp<tetFemMatrix<Type> > operator-
00505 (
00506     const GeometricField<Type, tetPolyPatchField, elementMesh>&,
00507     const tetFemMatrix<Type>&
00508 );
00509 
00510 template<class Type>
00511 tmp<tetFemMatrix<Type> > operator-
00512 (
00513     const GeometricField<Type, tetPolyPatchField, elementMesh>&,
00514     const tmp<tetFemMatrix<Type> >&
00515 );
00516 
00517 template<class Type>
00518 tmp<tetFemMatrix<Type> > operator-
00519 (
00520     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&,
00521     const tetFemMatrix<Type>&
00522 );
00523 
00524 template<class Type>
00525 tmp<tetFemMatrix<Type> > operator-
00526 (
00527     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&,
00528     const tmp<tetFemMatrix<Type> >&
00529 );
00530 
00531 template<class Type>
00532 tmp<tetFemMatrix<Type> > operator+
00533 (
00534     const tmp<tetFemMatrix<Type> >&,
00535     const dimensioned<Type>&
00536 );
00537 
00538 template<class Type>
00539 tmp<tetFemMatrix<Type> > operator+
00540 (
00541     const dimensioned<Type>&,
00542     const tmp<tetFemMatrix<Type> >&
00543 );
00544 
00545 template<class Type>
00546 tmp<tetFemMatrix<Type> > operator-
00547 (
00548     const tmp<tetFemMatrix<Type> >&,
00549     const dimensioned<Type>&
00550 );
00551 
00552 template<class Type>
00553 tmp<tetFemMatrix<Type> > operator-
00554 (
00555     const dimensioned<Type>&,
00556     const tmp<tetFemMatrix<Type> >&
00557 );
00558 
00559 template<class Type>
00560 tmp<tetFemMatrix<Type> > operator==
00561 (
00562     const tetFemMatrix<Type>&,
00563     const GeometricField<Type, tetPolyPatchField, elementMesh>&
00564 );
00565 
00566 template<class Type>
00567 tmp<tetFemMatrix<Type> > operator==
00568 (
00569     const tmp<tetFemMatrix<Type> >&,
00570     const GeometricField<Type, tetPolyPatchField, elementMesh>&
00571 );
00572 
00573 template<class Type>
00574 tmp<tetFemMatrix<Type> > operator==
00575 (
00576     const tetFemMatrix<Type>&,
00577     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00578 );
00579 
00580 template<class Type>
00581 tmp<tetFemMatrix<Type> > operator==
00582 (
00583     const tmp<tetFemMatrix<Type> >&,
00584     const tmp<GeometricField<Type, tetPolyPatchField, elementMesh> >&
00585 );
00586 
00587 template<class Type>
00588 tmp<tetFemMatrix<Type> > operator==
00589 (
00590     const tetFemMatrix<Type>&,
00591     const dimensioned<Type>&
00592 );
00593 
00594 template<class Type>
00595 tmp<tetFemMatrix<Type> > operator==
00596 (
00597     const tmp<tetFemMatrix<Type> >&,
00598     const dimensioned<Type>&
00599 );
00600 
00601 
00602 template<class Type>
00603 tmp<tetFemMatrix<Type> > operator*
00604 (
00605     const dimensioned<scalar>&,
00606     const tetFemMatrix<Type>&
00607 );
00608 
00609 template<class Type>
00610 tmp<tetFemMatrix<Type> > operator*
00611 (
00612     const dimensioned<scalar>&,
00613     const tmp<tetFemMatrix<Type> >&
00614 );
00615 
00616 
00617 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00618 
00619 } // End namespace Foam
00620 
00621 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00622 
00623 #ifdef NoRepository
00624 #   include "tetFemMatrix.C"
00625 #   include "tetFemMatrixSolve.C"
00626 #   include "tetFemMatrixTools.C"
00627 #   include "tetFemMatrixCheck.C"
00628 #endif
00629 
00630 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00631 
00632 #endif
00633 
00634 // ************************************************************************* //
For further information go to www.openfoam.org