1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "totalFlowRateAdvectiveDiffusiveFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "IOobjectList.H"
32 #include "turbulenceModel.H"
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
37 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
40 const DimensionedField<scalar, volMesh>& iF
43 mixedFvPatchField<scalar>(p, iF),
49 valueFraction() = 0.0;
53 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
54 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
57 const DimensionedField<scalar, volMesh>& iF,
58 const dictionary& dict
61 mixedFvPatchField<scalar>(p, iF),
62 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
63 rhoName_(dict.lookupOrDefault<word>("rho", "none"))
68 valueFraction() = 0.0;
70 if (dict.found("value"))
72 fvPatchField<scalar>::operator=
74 Field<scalar>("value", dict, p.size())
79 fvPatchField<scalar>::operator=(refValue());
83 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
84 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
86 const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& ptf,
88 const DimensionedField<scalar, volMesh>& iF,
89 const fvPatchFieldMapper& mapper
92 mixedFvPatchField<scalar>(ptf, p, iF, mapper),
93 phiName_(ptf.phiName_),
94 rhoName_(ptf.rhoName_)
98 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
99 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
101 const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& tppsf
104 mixedFvPatchField<scalar>(tppsf),
105 phiName_(tppsf.phiName_),
106 rhoName_(tppsf.rhoName_)
109 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
110 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
112 const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& tppsf,
113 const DimensionedField<scalar, volMesh>& iF
116 mixedFvPatchField<scalar>(tppsf, iF),
117 phiName_(tppsf.phiName_),
118 rhoName_(tppsf.rhoName_)
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::autoMap
126 const fvPatchFieldMapper& m
129 scalarField::autoMap(m);
133 void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::rmap
135 const fvPatchScalarField& ptf,
136 const labelList& addr
139 mixedFvPatchField<scalar>::rmap(ptf, addr);
142 void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::updateCoeffs()
150 const label patchI = patch().index();
152 const compressible::turbulenceModel& turbulence =
153 db().lookupObject<compressible::turbulenceModel>
158 const fvsPatchField<scalar>& phip =
159 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
161 const scalarField alphap = turbulence.alphaEff()().boundaryField()[patchI];
171 alphap*patch().deltaCoeffs()*patch().magSf()/max(mag(phip), SMALL)
174 mixedFvPatchField<scalar>::updateCoeffs();
178 scalar phi = gSum(-phip*(*this));
180 Info<< patch().boundaryMesh().mesh().name() << ':'
181 << patch().name() << ':'
182 << this->dimensionedInternalField().name() << " :"
183 << " mass flux[Kg/s]:" << phi
189 void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
190 write(Ostream& os) const
192 fvPatchField<scalar>::write(os);
193 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
194 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
195 this->writeEntry("value", os);
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
211 // ************************************************************************* //