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 Finite-Area scalar matrix member functions and operators
28 \*---------------------------------------------------------------------------*/
30 #include "faScalarMatrix.H"
31 #include "zeroGradientFaPatchFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 // Set reference level for a component of the solution
41 // on a given patch face
43 void faMatrix<scalar>::setComponentReference
51 const unallocLabelList& faceLabels =
52 psi_.mesh().boundary()[patchI].edgeFaces();
54 internalCoeffs_[patchI][edgeI] +=
55 diag()[faceLabels[edgeI]];
57 boundaryCoeffs_[patchI][edgeI] = value;
62 autoPtr<faMatrix<scalar>::faSolver> faMatrix<scalar>::solver
64 const dictionary& solverControls
69 Info<< "faMatrix<scalar>::solver(const dictionary&) : "
70 "solver for faMatrix<scalar>"
74 scalarField saveDiag = diag();
75 addBoundaryDiag(diag(), 0);
77 // Make a copy of interfaces: no longer a reference
79 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
81 autoPtr<faMatrix<scalar>::faSolver> solverPtr
83 new faMatrix<scalar>::faSolver
105 lduSolverPerformance faMatrix<scalar>::faSolver::solve
107 const dictionary& solverControls
110 scalarField saveDiag = faMat_.diag();
111 faMat_.addBoundaryDiag(faMat_.diag(), 0);
113 scalarField totalSource = faMat_.source();
114 faMat_.addBoundarySource(totalSource, false);
116 solver_->read(solverControls);
117 lduSolverPerformance solverPerf =
118 solver_->solve(faMat_.psi().internalField(), totalSource);
122 faMat_.diag() = saveDiag;
124 faMat_.psi().correctBoundaryConditions();
131 lduSolverPerformance faMatrix<scalar>::solve
133 const dictionary& solverControls
138 Info<< "faMatrix<scalar>::solve(const dictionary&) : "
139 "solving faMatrix<scalar>"
143 scalarField saveDiag = diag();
144 addBoundaryDiag(diag(), 0);
146 scalarField totalSource = source_;
147 addBoundarySource(totalSource, 0);
149 // Make a copy of interfaces: no longer a reference
151 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
154 lduSolverPerformance solverPerf = lduSolver::New
162 )->solve(psi_.internalField(), totalSource);
168 psi_.correctBoundaryConditions();
174 // Return the matrix residual
176 tmp<scalarField> faMatrix<scalar>::residual() const
178 scalarField boundaryDiag(psi_.size(), 0.0);
179 addBoundaryDiag(boundaryDiag, 0);
181 // Make a copy of interfaces: no longer a reference
183 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
185 tmp<scalarField> tres
189 psi_.internalField(),
190 source_ - boundaryDiag*psi_.internalField(),
197 addBoundarySource(tres());
205 tmp<areaScalarField> faMatrix<scalar>::H() const
207 tmp<areaScalarField> tHphi
213 "H("+psi_.name()+')',
221 zeroGradientFaPatchScalarField::typeName
224 areaScalarField Hphi = tHphi();
226 Hphi.internalField() = (lduMatrix::H(psi_.internalField()) + source_);
227 addBoundarySource(Hphi.internalField());
229 Hphi.internalField() /= psi_.mesh().S();
230 Hphi.correctBoundaryConditions();
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 } // End namespace Foam
240 // ************************************************************************* //