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/>.
25 Tet Finite Element scalar matrix member functions and operators
27 \*---------------------------------------------------------------------------*/
29 #include "objectRegistry.H"
31 #include "tetFemScalarMatrix.H"
32 #include "tetPointFields.H"
33 #include "tetPolyPatchFields.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 lduSolverPerformance tetFemMatrix<scalar>::solve
45 const dictionary& solverControls
50 Info<< "tetFemMatrix<scalar>::solve(const dictionary&) : "
51 << "solving tetFemMatrix<scalar>"
55 // Add boundary source for gradient-type conditions
56 addBoundarySourceDiag();
58 // Store the boundary coefficients for insertion of boundary conditions
59 storeBoundaryCoeffs();
61 // Set component boundary conditions
62 scalarField sourceCpy = source_;
64 // Store the boundary coefficients for insertion of boundary conditions
65 setComponentBoundaryConditions(0, psi_, sourceCpy);
67 // Add the coupling coefficients
69 addCouplingSource(sourceCpy);
71 // prepare for coupled interface update
72 FieldField<Field, scalar> coupledBouCoeffs(psi_.boundaryField().size());
73 FieldField<Field, scalar> coupledIntCoeffs(psi_.boundaryField().size());
75 forAll(psi_.boundaryField(), patchI)
77 const tetPolyPatchScalarField& ptf = psi_.boundaryField()[patchI];
82 new scalarField(ptf.cutBouCoeffs(*this))
88 new scalarField(ptf.cutIntCoeffs(*this))
92 eliminateCouplingCoeffs();
94 lduSolverPerformance solverPerf
96 "tetFemMatrix<scalar>::solve",
100 // Make a copy of interfaces: no longer a reference
102 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
104 solverPerf = lduSolver::New
112 )->solve(psi_.internalField(), sourceCpy);
120 Info<< "tetFemMatrix<scalar>::solve(const scalar, const scalar) : "
121 << "correcting boundary conditions"
125 psi_.correctBoundaryConditions();
131 // Return the matrix residual
133 tmp<scalarField> tetFemMatrix<scalar>::residual()
135 // Store the boundary coefficients for insertion of boundary conditions
136 storeBoundaryCoeffs();
138 // Set component boundary conditions
139 scalarField sourceCpy = source_;
141 setComponentBoundaryConditions(0, psi_, sourceCpy);
143 // Add the coupling coefficients
145 addCouplingSource(sourceCpy);
147 // Prepare for coupled interface update
148 FieldField<Field, scalar> coupledBouCoeffs(psi_.boundaryField().size());
150 forAll(psi_.boundaryField(), patchI)
152 const tetPolyPatchScalarField& ptf = psi_.boundaryField()[patchI];
156 new scalarField(ptf.cutBouCoeffs(*this))
160 eliminateCouplingCoeffs();
162 // Make a copy of interfaces: no longer a reference
164 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
166 tmp<scalarField> tres
170 psi_.internalField(),
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 } // End namespace Foam
188 // ************************************************************************* //