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 "radiationCoupledBase.H"
27 #include "volFields.H"
28 #include "basicSolidThermo.H"
30 #include "directMappedPatchBase.H"
31 #include "fvPatchFieldMapper.H"
33 // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
38 const char* Foam::NamedEnum
40 Foam::radiationCoupledBase::emissivityMethodType,
50 const Foam::NamedEnum<Foam::radiationCoupledBase::emissivityMethodType, 2>
51 Foam::radiationCoupledBase::emissivityMethodTypeNames_;
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 Foam::radiationCoupledBase::radiationCoupledBase
59 const word& calculationType,
60 const scalarField& emissivity
64 method_(emissivityMethodTypeNames_[calculationType]),
65 emissivity_(emissivity)
69 Foam::radiationCoupledBase::radiationCoupledBase
72 const dictionary& dict
76 method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
82 if (!isA<directMappedPatchBase>(patch_.patch()))
86 "radiationCoupledBase::radiationCoupledBase\n"
88 " const fvPatch& p,\n"
89 " const dictionary& dict\n"
92 ) << "\n patch type '" << patch_.type()
93 << "' not type '" << directMappedPatchBase::typeName << "'"
94 << "\n for patch " << patch_.name()
95 << exit(FatalIOError);
98 emissivity_ = scalarField(patch_.size(), 0.0);
104 if(!dict.found("emissivity"))
108 "radiationCoupledBase::radiationCoupledBase\n"
110 " const fvPatch& p,\n"
111 " const dictionary& dict\n"
114 ) << "\n emissivity key does not exist for patch "
116 << exit(FatalIOError);
120 emissivity_ = scalarField("emissivity", dict, patch_.size());
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 Foam::scalarField Foam::radiationCoupledBase::emissivity() const
136 // Get the coupling information from the directMappedPatchBase
137 const directMappedPatchBase& mpp =
138 refCast<const directMappedPatchBase>
143 const polyMesh& nbrMesh = mpp.sampleMesh();
145 // Force recalculation of mapping and schedule
146 const mapDistribute& distMap = mpp.map();
148 const fvPatch& nbrPatch = refCast<const fvMesh>
151 ).boundary()[mpp.samplePolyPatch().index()];
153 if (nbrMesh.foundObject<volScalarField>("emissivity"))
155 tmp<scalarField> temissivity
159 nbrPatch.lookupPatchField<volScalarField, scalar>
166 scalarField emissivity(temissivity);
167 // Use direct map mapping to exchange data
168 distMap.distribute(emissivity);
169 //Pout << emissivity << endl;
174 return scalarField(0);
182 // return local value
190 "radiationCoupledBase::emissivity(const scalarField&)"
192 << "Unimplemented method " << method_ << endl
193 << "Please set 'emissivity' to one of "
194 << emissivityMethodTypeNames_.toc()
195 << " and 'emissivityName' to the name of the volScalar"
200 return scalarField(0);
204 void Foam::radiationCoupledBase::write(Ostream& os) const
206 os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_]
207 << token::END_STATEMENT << nl;
208 emissivity_.writeEntry("emissivity", os);
212 // ************************************************************************* //