1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | 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 "nusseltFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 nusseltFvPatchScalarField::nusseltFvPatchScalarField
42 const DimensionedField<scalar, volMesh>& iF
45 mixedFvPatchScalarField(p, iF),
52 valueFraction() = 0.0;
56 nusseltFvPatchScalarField::nusseltFvPatchScalarField
59 const DimensionedField<scalar, volMesh>& iF,
60 const dictionary& dict
63 mixedFvPatchScalarField(p, iF),
64 DTName_(dict.lookup("DT")),
65 Tinf_(readScalar(dict.lookup("Tinf"))),
66 alpha_("alpha", dict, p.size())
68 if (dict.found("value"))
70 fvPatchField<scalar>::operator=
72 scalarField("value", dict, p.size())
77 fvPatchField<scalar>::operator=(patchInternalField());
82 valueFraction() = 0.0;
88 "nusseltFvPatchScalarField::nusseltFvPatchScalarField\n"
91 " const DimensionedField<scalar, volMesh>&,\n"
92 " const dictionary&\n"
95 ) << "unphysical Tinf specified (Tinf = 0 or negative)"
99 if (min(alpha_) < -SMALL)
103 "nusseltFvPatchScalarField::nusseltFvPatchScalarField\n"
106 " const DimensionedField<scalar, volMesh>&,\n"
107 " const dictionary&\n"
110 ) << "unphysical alpha specified (alpha = 0 or negative)" << endl
116 nusseltFvPatchScalarField::nusseltFvPatchScalarField
118 const nusseltFvPatchScalarField& ptf,
120 const DimensionedField<scalar, volMesh>& iF,
121 const fvPatchFieldMapper& mapper
124 mixedFvPatchScalarField(ptf, p, iF, mapper),
125 DTName_(ptf.DTName_),
131 nusseltFvPatchScalarField::nusseltFvPatchScalarField
133 const nusseltFvPatchScalarField& ptf
136 mixedFvPatchScalarField(ptf),
137 DTName_(ptf.DTName_),
143 nusseltFvPatchScalarField::nusseltFvPatchScalarField
145 const nusseltFvPatchScalarField& ptpsf,
146 const DimensionedField<scalar, volMesh>& iF
149 mixedFvPatchScalarField(ptpsf, iF),
150 DTName_(ptpsf.DTName_),
156 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
159 void nusseltFvPatchScalarField::autoMap
161 const fvPatchFieldMapper& m
164 mixedFvPatchScalarField::autoMap(m);
169 // Reverse-map the given fvPatchField onto this fvPatchField
170 void nusseltFvPatchScalarField::rmap
172 const fvPatchField<scalar>& ptf,
173 const labelList& addr
176 mixedFvPatchField<scalar>::rmap(ptf, addr);
178 const nusseltFvPatchScalarField& npsf =
179 refCast<const nusseltFvPatchScalarField>(ptf);
181 alpha_.rmap(npsf.alpha_, addr);
185 // Update the coefficients associated with the patch field
186 void nusseltFvPatchScalarField::updateCoeffs()
193 scalarField Tinternal = patchInternalField();
195 // Lookup temperature diffusivity of the patch
196 const fvPatchField<scalar>& DT =
197 this->patch().lookupPatchField<volScalarField, scalar>(DTName_);
200 scalarField tempFlux = alpha_*(Tinternal - Tinf_);
206 Tinternal - tempFlux/(DT*patch().deltaCoeffs()),
212 Tinternal - tempFlux/(DT*patch().deltaCoeffs()),
216 refGrad() = -tempFlux;
217 valueFraction() = pos(tempFlux);
219 mixedFvPatchScalarField::updateCoeffs();
224 void nusseltFvPatchScalarField::write(Ostream& os) const
226 fvPatchScalarField::write(os);
227 os.writeKeyword("DT") << DTName_ << token::END_STATEMENT << nl;
228 os.writeKeyword("Tinf") << Tinf_ << token::END_STATEMENT << endl;
229 alpha_.writeEntry("alpha", os);
230 writeEntry("value", os);
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 makePatchTypeField(fvPatchScalarField, nusseltFvPatchScalarField);
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 } // End namespace Foam
242 // ************************************************************************* //