Forward compatibility: flex
[foam-extend-3.2.git] / src / thermophysicalModels / radiation / derivedFvPatchFields / MarshakRadiation / MarshakRadiationMixedFvPatchScalarField.C
blob6dbcaa43743ea91fcb338e08b0fe47483999a5d2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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"
31 #include "fvc.H"
32 #include "radiationModel.H"
33 #include "radiationConstants.H"
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
39     const fvPatch& p,
40     const DimensionedField<scalar, volMesh>& iF
43     mixedFvPatchScalarField(p, iF),
44     TName_("undefined"),
45     emissivity_(0.0)
47     refValue() = 0.0;
48     refGrad() = 0.0;
49     valueFraction() = 0.0;
53 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
55     const MarshakRadiationFvPatchScalarField& ptf,
56     const fvPatch& p,
57     const DimensionedField<scalar, volMesh>& iF,
58     const fvPatchFieldMapper& mapper
61     mixedFvPatchScalarField(ptf, p, iF, mapper),
62     TName_(ptf.TName_),
63     emissivity_(ptf.emissivity_)
67 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
69     const fvPatch& p,
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"))
79     {
80         refValue() = scalarField("value", dict, p.size());
82         fvPatchScalarField::operator=
83         (
84             refValue()
85         );
87         refGrad() = 0;
88         valueFraction() = 1;
89     }
90     else
91     {
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.
97         // 26 Mar 2014 - DC
98         refValue() = 0;
100         refGrad() = 0;
101         valueFraction() = 0;
103         fvPatchScalarField::operator=(refValue());
104     }
108 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
110     const MarshakRadiationFvPatchScalarField& ptf
113     mixedFvPatchScalarField(ptf),
114     TName_(ptf.TName_),
115     emissivity_(ptf.emissivity_)
119 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
121     const MarshakRadiationFvPatchScalarField& ptf,
122     const DimensionedField<scalar, volMesh>& iF
125     mixedFvPatchScalarField(ptf, iF),
126     TName_(ptf.TName_),
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()
154     if (this->updated())
155     {
156         return;
157     }
159     // Temperature field
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 namespace Foam
192     makePatchTypeField
193     (
194         fvPatchScalarField,
195         MarshakRadiationFvPatchScalarField
196     );
200 // ************************************************************************* //