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
25 \*---------------------------------------------------------------------------*/
27 #include "fvScalarMatrix.H"
28 #include "zeroGradientFvPatchFields.H"
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 void Foam::fvMatrix<Foam::scalar>::setComponentReference
41 if (psi_.needReference())
43 if (Pstream::master())
45 internalCoeffs_[patchi][facei] +=
46 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
48 boundaryCoeffs_[patchi][facei] +=
49 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
57 Foam::autoPtr<Foam::fvMatrix<Foam::scalar>::fvSolver>
58 Foam::fvMatrix<Foam::scalar>::solver
60 const dictionary& solverControls
65 Info<< "fvMatrix<scalar>::solver(const dictionary& solverControls) : "
66 "solver for fvMatrix<scalar>"
70 scalarField saveDiag = diag();
71 addBoundaryDiag(diag(), 0);
73 // Make a copy of interfaces: no longer a reference
75 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
77 autoPtr<fvMatrix<scalar>::fvSolver> solverPtr
79 new fvMatrix<scalar>::fvSolver
101 Foam::lduMatrix::solverPerformance
102 Foam::fvMatrix<Foam::scalar>::fvSolver::solve
104 const dictionary& solverControls
107 scalarField saveDiag = fvMat_.diag();
108 fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
110 scalarField totalSource = fvMat_.source();
111 fvMat_.addBoundarySource(totalSource, false);
113 // assign new solver controls
114 solver_->read(solverControls);
115 lduSolverPerformance solverPerf =
116 solver_->solve(fvMat_.psi().internalField(), totalSource);
120 fvMat_.diag() = saveDiag;
122 fvMat_.psi().correctBoundaryConditions();
129 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
131 const dictionary& solverControls
136 Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : "
137 "solving fvMatrix<scalar>"
141 scalarField saveDiag = diag();
142 addBoundaryDiag(diag(), 0);
144 scalarField totalSource = source_;
145 addBoundarySource(totalSource, false);
147 // Make a copy of interfaces: no longer a reference
149 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
152 lduSolverPerformance solverPerf = lduSolver::New
160 )->solve(psi_.internalField(), totalSource);
166 psi_.correctBoundaryConditions();
173 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Foam::scalar>::residual() const
175 scalarField boundaryDiag(psi_.size(), 0.0);
176 addBoundaryDiag(boundaryDiag, 0);
178 // Make a copy of interfaces: no longer a reference
180 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
182 tmp<scalarField> tres
186 psi_.internalField(),
187 source_ - boundaryDiag*psi_.internalField(),
194 addBoundarySource(tres());
201 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H() const
203 tmp<volScalarField> tHphi
209 "H("+psi_.name()+')',
217 zeroGradientFvPatchScalarField::typeName
220 volScalarField& Hphi = tHphi();
222 Hphi.internalField() = (lduMatrix::H(psi_.internalField()) + source_);
223 addBoundarySource(Hphi.internalField());
225 Hphi.internalField() /= psi_.mesh().V();
226 Hphi.correctBoundaryConditions();
233 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H1() const
235 tmp<volScalarField> tH1
248 dimensions_/(dimVol*psi_.dimensions()),
249 zeroGradientFvPatchScalarField::typeName
252 volScalarField& H1_ = tH1();
254 H1_.internalField() = lduMatrix::H1();
255 //addBoundarySource(Hphi.internalField());
257 H1_.internalField() /= psi_.mesh().V();
258 H1_.correctBoundaryConditions();
264 // ************************************************************************* //