1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 autoPtr<fvMatrix<scalar>::fvSolver> solverPtr
75 new fvMatrix<scalar>::fvSolver
78 lduMatrix::solver::New
84 psi_.boundaryField().interfaces(),
97 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
99 const dictionary& solverControls
102 scalarField saveDiag = fvMat_.diag();
103 fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
105 scalarField totalSource = fvMat_.source();
106 fvMat_.addBoundarySource(totalSource, false);
108 // assign new solver controls
109 solver_->read(solverControls);
111 lduMatrix::solverPerformance solverPerf =
112 solver_->solve(fvMat_.psi().internalField(), totalSource);
116 fvMat_.diag() = saveDiag;
118 fvMat_.psi().correctBoundaryConditions();
125 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
127 const dictionary& solverControls
132 Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : "
133 "solving fvMatrix<scalar>"
137 scalarField saveDiag = diag();
138 addBoundaryDiag(diag(), 0);
140 scalarField totalSource = source_;
141 addBoundarySource(totalSource, false);
144 lduMatrix::solverPerformance solverPerf = lduMatrix::solver::New
150 psi_.boundaryField().interfaces(),
152 )->solve(psi_.internalField(), totalSource);
158 psi_.correctBoundaryConditions();
165 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Foam::scalar>::residual() const
167 scalarField boundaryDiag(psi_.size(), 0.0);
168 addBoundaryDiag(boundaryDiag, 0);
170 tmp<scalarField> tres
174 psi_.internalField(),
175 source_ - boundaryDiag*psi_.internalField(),
177 psi_.boundaryField().interfaces(),
182 addBoundarySource(tres());
189 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H() const
191 tmp<volScalarField> tHphi
197 "H("+psi_.name()+')',
205 zeroGradientFvPatchScalarField::typeName
208 volScalarField& Hphi = tHphi();
210 Hphi.internalField() = (lduMatrix::H(psi_.internalField()) + source_);
211 addBoundarySource(Hphi.internalField());
213 Hphi.internalField() /= psi_.mesh().V();
214 Hphi.correctBoundaryConditions();
221 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H1() const
223 tmp<volScalarField> tH1
236 dimensions_/(dimVol*psi_.dimensions()),
237 zeroGradientFvPatchScalarField::typeName
240 volScalarField& H1_ = tH1();
242 H1_.internalField() = lduMatrix::H1();
243 //addBoundarySource(Hphi.internalField());
245 H1_.internalField() /= psi_.mesh().V();
246 H1_.correctBoundaryConditions();
252 // ************************************************************************* //