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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fvScalarMatrix.H"
27 #include "zeroGradientFvPatchFields.H"
29 #include "profiling.H"
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 void Foam::fvMatrix<Foam::scalar>::setComponentReference
42 if (psi_.needReference())
44 if (Pstream::master())
46 internalCoeffs_[patchi][facei] +=
47 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
49 boundaryCoeffs_[patchi][facei] +=
50 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
58 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
60 const dictionary& solverControls
63 profilingTrigger profSolve("fvMatrix::solve_"+psi_.name());
67 Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : "
68 "solving fvMatrix<scalar>"
72 // Complete matrix assembly. HJ, 17/Apr/2012
75 scalarField saveDiag = diag();
76 addBoundaryDiag(diag(), 0);
78 scalarField totalSource = source_;
79 addBoundarySource(totalSource, false);
81 // Make a copy of interfaces: no longer a reference
83 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
86 lduSolverPerformance solverPerf = lduSolver::New
94 )->solve(psi_.internalField(), totalSource);
98 // Diagonal has been restored, clear complete assembly flag?
101 psi_.correctBoundaryConditions();
108 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Foam::scalar>::residual() const
110 // Complete matrix assembly. HJ, 17/Apr/2012
111 fvMatrix<scalar>& m = const_cast<fvMatrix<scalar>&>(*this);
112 m.completeAssembly();
114 // To avoid copying the diagonal, execute boundary diag multiplication
115 // separately. See source provided to lduMatrix::residual
117 scalarField boundaryDiag(psi_.size(), 0.0);
118 addBoundaryDiag(boundaryDiag, 0);
120 // Bug fix: boundary source must be added on rhs
122 scalarField totalSource = source_;
123 addBoundarySource(totalSource, false);
125 // Make a copy of interfaces: no longer a reference
127 lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();
129 tmp<scalarField> tres
133 psi_.internalField(),
134 totalSource - boundaryDiag*psi_.internalField(),
146 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H() const
148 tmp<volScalarField> tHphi
154 "H("+psi_.name()+')',
162 zeroGradientFvPatchScalarField::typeName
165 volScalarField& Hphi = tHphi();
167 Hphi.internalField() = (lduMatrix::H(psi_.internalField()) + source_);
168 addBoundarySource(Hphi.internalField());
170 Hphi.internalField() /= psi_.mesh().V();
171 Hphi.correctBoundaryConditions();
178 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H1() const
180 tmp<volScalarField> tH1
193 dimensions_/(dimVol*psi_.dimensions()),
194 zeroGradientFvPatchScalarField::typeName
197 volScalarField& H1_ = tH1();
199 H1_.internalField() = lduMatrix::H1();
200 //addBoundarySource(Hphi.internalField());
202 H1_.internalField() /= psi_.mesh().V();
203 H1_.correctBoundaryConditions();
209 // ************************************************************************* //