1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Tet Finite Element scalar matrix member functions and operators
28 \*---------------------------------------------------------------------------*/
30 #include "tetFemScalarMatrix.H"
31 #include "tetPointFields.H"
32 #include "tetPolyPatchFields.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 lduSolverPerformance tetFemMatrix<scalar>::solve
44 const dictionary& solverControls
49 Info<< "tetFemMatrix<scalar>::solve(const dictionary&) : "
50 << "solving tetFemMatrix<scalar>"
54 // Add boundary source for gradient-type conditions
55 addBoundarySourceDiag();
57 // Store the boundary coefficients for insertion of boundary conditions
58 storeBoundaryCoeffs();
60 // Set component boundary conditions
61 scalarField sourceCpy = source_;
63 // Store the boundary coefficients for insertion of boundary conditions
64 setComponentBoundaryConditions(0, psi_, sourceCpy);
66 // Add the coupling coefficients
68 addCouplingSource(sourceCpy);
70 // prepare for coupled interface update
71 FieldField<Field, scalar> coupledBouCoeffs(psi_.boundaryField().size());
72 FieldField<Field, scalar> coupledIntCoeffs(psi_.boundaryField().size());
74 forAll(psi_.boundaryField(), patchI)
76 const tetPolyPatchScalarField& ptf = psi_.boundaryField()[patchI];
81 new scalarField(ptf.cutBouCoeffs(*this))
87 new scalarField(ptf.cutIntCoeffs(*this))
91 eliminateCouplingCoeffs();
93 lduSolverPerformance solverPerf
95 "tetFemMatrix<scalar>::solve",
99 // Make a copy of interfaces: no longer a reference
101 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
103 solverPerf = lduSolver::New
111 )->solve(psi_.internalField(), sourceCpy);
119 Info<< "tetFemMatrix<scalar>::solve(const scalar, const scalar) : "
120 << "correcting boundary conditions"
124 psi_.correctBoundaryConditions();
130 // Return the matrix residual
132 tmp<scalarField> tetFemMatrix<scalar>::residual()
134 // Store the boundary coefficients for insertion of boundary conditions
135 storeBoundaryCoeffs();
137 // Set component boundary conditions
138 scalarField sourceCpy = source_;
140 setComponentBoundaryConditions(0, psi_, sourceCpy);
142 // Add the coupling coefficients
144 addCouplingSource(sourceCpy);
146 // Prepare for coupled interface update
147 FieldField<Field, scalar> coupledBouCoeffs(psi_.boundaryField().size());
149 forAll(psi_.boundaryField(), patchI)
151 const tetPolyPatchScalarField& ptf = psi_.boundaryField()[patchI];
155 new scalarField(ptf.cutBouCoeffs(*this))
159 eliminateCouplingCoeffs();
161 // Make a copy of interfaces: no longer a reference
163 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
165 tmp<scalarField> tres
169 psi_.internalField(),
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // ************************************************************************* //