BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / turbulenceModels / compressible / turbulenceModel / derivedFvPatchFields / totalFlowRateAdvectiveDiffusive / totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C
blob25f3389ed00ddac5966c229802c4a5f2360aab34
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
39     const fvPatch& p,
40     const DimensionedField<scalar, volMesh>& iF
43     mixedFvPatchField<scalar>(p, iF),
44     phiName_("phi"),
45     rhoName_("none")
47     refValue() = 0.0;
48     refGrad() = 0.0;
49     valueFraction() = 0.0;
53 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
54 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
56     const fvPatch& p,
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"))
66     refValue() = 1.0;
67     refGrad() = 0.0;
68     valueFraction() = 0.0;
70     if (dict.found("value"))
71     {
72         fvPatchField<scalar>::operator=
73         (
74             Field<scalar>("value", dict, p.size())
75         );
76     }
77     else
78     {
79         fvPatchField<scalar>::operator=(refValue());
80     }
83 Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
84 totalFlowRateAdvectiveDiffusiveFvPatchScalarField
86     const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& ptf,
87     const fvPatch& p,
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()
145     if (this->updated())
146     {
147         return;
148     }
150     const label patchI = patch().index();
152     const compressible::turbulenceModel& turbulence =
153         db().lookupObject<compressible::turbulenceModel>
154         (
155             "turbulenceModel"
156         );
158     const fvsPatchField<scalar>& phip =
159         patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
161     const scalarField alphap = turbulence.alphaEff()().boundaryField()[patchI];
163     refValue() = 1.0;
164     refGrad() = 0.0;
166     valueFraction() =
167         1.0
168         /
169         (
170             1.0 +
171             alphap*patch().deltaCoeffs()*patch().magSf()/max(mag(phip), SMALL)
172         );
174     mixedFvPatchField<scalar>::updateCoeffs();
176     if (debug)
177     {
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
184             << endl;
185     }
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 namespace Foam
203     makePatchTypeField
204     (
205         fvPatchScalarField,
206         totalFlowRateAdvectiveDiffusiveFvPatchScalarField
207     );
211 // ************************************************************************* //