BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / radiationModels / derivedFvPatchFields / radiationCoupledBase / radiationCoupledBase.C
blobd3045f092391984eea35ff552fd0efc1ab9817fc
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 "radiationCoupledBase.H"
27 #include "volFields.H"
28 #include "basicSolidThermo.H"
30 #include "directMappedPatchBase.H"
31 #include "fvPatchFieldMapper.H"
33 // * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * * //
35 namespace Foam
37     template<>
38     const char* Foam::NamedEnum
39     <
40         Foam::radiationCoupledBase::emissivityMethodType,
41         2
42     >::names[] =
43     {
44         "solidThermo",
45         "lookup"
46     };
50 const Foam::NamedEnum<Foam::radiationCoupledBase::emissivityMethodType, 2>
51     Foam::radiationCoupledBase::emissivityMethodTypeNames_;
54 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
56 Foam::radiationCoupledBase::radiationCoupledBase
58     const fvPatch& patch,
59     const word& calculationType,
60     const scalarField& emissivity
63     patch_(patch),
64     method_(emissivityMethodTypeNames_[calculationType]),
65     emissivity_(emissivity)
69 Foam::radiationCoupledBase::radiationCoupledBase
71     const fvPatch& patch,
72     const dictionary& dict
75     patch_(patch),
76     method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
78     switch (method_)
79     {
80         case SOLIDTHERMO:
81         {
82             if (!isA<directMappedPatchBase>(patch_.patch()))
83             {
84                 FatalIOErrorIn
85                 (
86                     "radiationCoupledBase::radiationCoupledBase\n"
87                     "(\n"
88                     "    const fvPatch& p,\n"
89                     "    const dictionary& dict\n"
90                     ")\n",
91                     dict
92                 )   << "\n    patch type '" << patch_.type()
93                     << "' not type '" << directMappedPatchBase::typeName << "'"
94                     << "\n    for patch " << patch_.name()
95                     << exit(FatalIOError);
96             }
98             emissivity_ = scalarField(patch_.size(), 0.0);
99         }
100         break;
102         case LOOKUP:
103         {
104             if(!dict.found("emissivity"))
105             {
106                 FatalIOErrorIn
107                 (
108                     "radiationCoupledBase::radiationCoupledBase\n"
109                     "(\n"
110                     "    const fvPatch& p,\n"
111                     "    const dictionary& dict\n"
112                     ")\n",
113                     dict
114                 )   << "\n    emissivity key does not exist for patch "
115                     << patch_.name()
116                     << exit(FatalIOError);
117             }
118             else
119             {
120                 emissivity_ = scalarField("emissivity", dict, patch_.size());
121             }
122         }
123         break;
124     }
128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
130 Foam::scalarField Foam::radiationCoupledBase::emissivity() const
132     switch (method_)
133     {
134         case SOLIDTHERMO:
135         {
136             // Get the coupling information from the directMappedPatchBase
137             const directMappedPatchBase& mpp =
138                 refCast<const directMappedPatchBase>
139                 (
140                     patch_.patch()
141                 );
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>
149             (
150                 nbrMesh
151             ).boundary()[mpp.samplePolyPatch().index()];
153             if (nbrMesh.foundObject<volScalarField>("emissivity"))
154             {
155                 tmp<scalarField> temissivity
156                 (
157                     new scalarField
158                     (
159                         nbrPatch.lookupPatchField<volScalarField, scalar>
160                         (
161                             "emissivity"
162                         )
163                     )
164                 );
166                 scalarField emissivity(temissivity);
167                 // Use direct map mapping to exchange data
168                 distMap.distribute(emissivity);
169                 //Pout << emissivity << endl;
170                 return emissivity;
171             }
172             else
173             {
174                 return scalarField(0);
175             }
177         }
178         break;
180         case LOOKUP:
181         {
182             // return local value
183             return emissivity_;
184         }
186         default:
187         {
188             FatalErrorIn
189             (
190                 "radiationCoupledBase::emissivity(const scalarField&)"
191             )
192                 << "Unimplemented method " << method_ << endl
193                 << "Please set 'emissivity' to one of "
194                 << emissivityMethodTypeNames_.toc()
195                 << " and 'emissivityName' to the name of the volScalar"
196                 << exit(FatalError);
197         }
198         break;
199     }
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 // ************************************************************************* //