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 "MarshakRadiationMixedFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
32 #include "radiationModel.H"
33 #include "radiationConstants.H"
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
40 const DimensionedField<scalar, volMesh>& iF
43 mixedFvPatchScalarField(p, iF),
49 valueFraction() = 0.0;
53 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
55 const MarshakRadiationFvPatchScalarField& ptf,
57 const DimensionedField<scalar, volMesh>& iF,
58 const fvPatchFieldMapper& mapper
61 mixedFvPatchScalarField(ptf, p, iF, mapper),
63 emissivity_(ptf.emissivity_)
67 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
70 const DimensionedField<scalar, volMesh>& iF,
71 const dictionary& dict
74 mixedFvPatchScalarField(p, iF),
75 TName_(dict.lookup("T")),
76 emissivity_(readScalar(dict.lookup("emissivity")))
78 if (dict.found("value"))
80 refValue() = scalarField("value", dict, p.size());
82 fvPatchScalarField::operator=
92 // No value given. Restart as fixedValue b.c.
94 // Bugfix: Do not initialize from temperautre because it is unavailable
95 // when running, e.g. decomposePar and loading radiation as
96 // shared library. Initialize to zero instead.
103 fvPatchScalarField::operator=(refValue());
108 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
110 const MarshakRadiationFvPatchScalarField& ptf
113 mixedFvPatchScalarField(ptf),
115 emissivity_(ptf.emissivity_)
119 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
121 const MarshakRadiationFvPatchScalarField& ptf,
122 const DimensionedField<scalar, volMesh>& iF
125 mixedFvPatchScalarField(ptf, iF),
127 emissivity_(ptf.emissivity_)
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 void Foam::MarshakRadiationFvPatchScalarField::autoMap
135 const fvPatchFieldMapper& m
138 scalarField::autoMap(m);
142 void Foam::MarshakRadiationFvPatchScalarField::rmap
144 const fvPatchScalarField& ptf,
145 const labelList& addr
148 mixedFvPatchScalarField::rmap(ptf, addr);
152 void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs()
160 const scalarField& Tp =
161 lookupPatchField<volScalarField, scalar>(TName_);
163 // Re-calc reference value
164 refValue() = 4.0*radiation::sigmaSB.value()*pow4(Tp);
166 // Diffusion coefficient - created by radiation model's ::updateCoeffs()
167 const scalarField& gamma =
168 lookupPatchField<volScalarField, scalar>("gammaRad");
170 const scalar Ep = emissivity_/(2.0*(2.0 - emissivity_));
172 // Set value fraction
173 valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
175 mixedFvPatchScalarField::updateCoeffs();
179 void Foam::MarshakRadiationFvPatchScalarField::write(Ostream& os) const
181 fvPatchScalarField::write(os);
182 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
183 os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
184 writeEntry("value", os);
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 MarshakRadiationFvPatchScalarField
200 // ************************************************************************* //