bak_turbulentHeatFluxTemperatureFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10  OpenFOAM is free software: you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17  for more details.
18  You should have received a copy of the GNU General Public License
19  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
20 \*---------------------------------------------------------------------------*/
21 
22 #include "turbulentHeatFluxTemperatureFvPatchScalarField.H"
24 #include "fvPatchFieldMapper.H"
25 #include "volFields.H"
26 //#include "incompressible/turbulenceModel/turbulenceModel.H"
27 #include "turbulenceModel.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  // declare specialization within 'Foam' namespace
34  template<>
35  const char* NamedEnum
36  <
39  2
40  >::names[] =
41  {
42  "power",
43  "flux"
44  };
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 
51 namespace Foam
52 {
53 
54 namespace incompressible
55 {
56 
57 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
58 
59 const NamedEnum
60 <
62  2
64 
65 
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 
70 (
71  const fvPatch& p,
72  const DimensionedField<scalar, volMesh>& iF
73 )
74 :
75  fixedGradientFvPatchScalarField(p, iF),
76  heatSource_(hsPower),
77  q_(p.size(), 0.0),
78  alphaEffName_("undefinedAlphaEff")
79 {
80 Info << "A===:" <<endl;
81 }
82 
83 
84 turbulentHeatFluxTemperatureFvPatchScalarField::
85 turbulentHeatFluxTemperatureFvPatchScalarField
86 (
88  const fvPatch& p,
89  const DimensionedField<scalar, volMesh>& iF,
90  const fvPatchFieldMapper& mapper
91 )
92 :
93  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
94  heatSource_(ptf.heatSource_),
95  q_(ptf.q_, mapper),
96  alphaEffName_(ptf.alphaEffName_)
97 {
98 
99 Info << "B===:" <<endl;
100 }
101 
102 
103 turbulentHeatFluxTemperatureFvPatchScalarField::
104 turbulentHeatFluxTemperatureFvPatchScalarField
105 (
106  const fvPatch& p,
107  const DimensionedField<scalar, volMesh>& iF,
108  const dictionary& dict
109 )
110 :
111  fixedGradientFvPatchScalarField(p, iF),
112  heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
113  q_("q", dict, p.size()),
114  alphaEffName_(dict.lookup("alphaEff"))
115 {
116  Info << "value and gradient is " << endl;
117  if (dict.found("value") && dict.found("gradient"))
118  {
119  Info << "value and gradient is " << endl;
120  fvPatchField<scalar>::operator=(Field<scalar>("value", dict, p.size()));
121  gradient() = Field<scalar>("gradient", dict, p.size());
122  }
123  else
124  {
125  Info << "else value and gradient is " << endl;
126  fvPatchField<scalar>::operator=(patchInternalField());
127  gradient() = 0.0;
128  }
129 }
130 
131 
132 turbulentHeatFluxTemperatureFvPatchScalarField::
133 turbulentHeatFluxTemperatureFvPatchScalarField
134 (
136 )
137 :
138  fixedGradientFvPatchScalarField(thftpsf),
139  heatSource_(thftpsf.heatSource_),
140  q_(thftpsf.q_),
141  alphaEffName_(thftpsf.alphaEffName_)
142 {
143 Info << "C===:" <<endl;
144 }
145 
146 
147 turbulentHeatFluxTemperatureFvPatchScalarField::
148 turbulentHeatFluxTemperatureFvPatchScalarField
149 (
151  const DimensionedField<scalar, volMesh>& iF
152 )
153 :
154  fixedGradientFvPatchScalarField(thftpsf, iF),
155  heatSource_(thftpsf.heatSource_),
156  q_(thftpsf.q_),
157  alphaEffName_(thftpsf.alphaEffName_)
158 {
159 
160 Info << "D===:" <<endl;
161 }
162 
163 
164 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
165 
166 void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap
167 (
168  const fvPatchFieldMapper& m
169 )
170 {
172  q_.autoMap(m);
173 }
174 
175 
176 void turbulentHeatFluxTemperatureFvPatchScalarField::rmap
177 (
178  const fvPatchScalarField& ptf,
179  const labelList& addr
180 )
181 {
182  fixedGradientFvPatchScalarField::rmap(ptf, addr);
183 
185  refCast<const turbulentHeatFluxTemperatureFvPatchScalarField>
186  (
187  ptf
188  );
189 
190  q_.rmap(thftptf.q_, addr);
191 }
192 
193 
194 void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
195 {
196 // Info << "asdf00000000000000" << endl;
197  if (updated())
198  {
199  return;
200  }
201 
202  const scalarField& alphaEffp =
203  patch().lookupPatchField<volScalarField, scalar>(alphaEffName_);
204 
205  // retrieve (constant) specific heat capacity from transport dictionary
206  const IOdictionary& transportProperties =
207  db().lookupObject<IOdictionary>("transportProperties");
208  const scalar rhoCp0(readScalar(transportProperties.lookup("rhoCp0")));
209 
210  Info << "rhoCp0="<< rhoCp0<< endl;
211  switch (heatSource_)
212  {
213  case hsPower:
214  {
215  const scalar Ap = gSum(patch().magSf());
216  gradient() = q_/(Ap*rhoCp0*alphaEffp);
217  Info << "gradient="<< gradient();
218  break;
219  }
220  case hsFlux:
221  {
222  Info << "gradient="<< gradient();
223  gradient() = q_/(rhoCp0*alphaEffp);
224  break;
225  }
226  default:
227  {
229  (
230  "turbulentHeatFluxTemperatureFvPatchScalarField"
231  "("
232  "const fvPatch&, "
233  "const DimensionedField<scalar, volMesh>&, "
234  "const dictionary&"
235  ")"
236  ) << "Unknown heat source type. Valid types are: "
237  << heatSourceTypeNames_ << nl << exit(FatalError);
238  }
239  }
240 
241  fixedGradientFvPatchScalarField::updateCoeffs();
242 }
243 
244 
246 {
248  os.writeKeyword("heatSource") << heatSourceTypeNames_[heatSource_]
249  << token::END_STATEMENT << nl;
250  q_.writeEntry("q", os);
251  os.writeKeyword("alphaEff") << alphaEffName_ << token::END_STATEMENT << nl;
252  writeEntry("value", os);
253 }
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
259 (
262 );
263 
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 } // End namespace incompressible
268 } // End namespace Foam
269 
270 // ************************************************************************* //
Foam::fvPatchScalarField
fvPatchField< scalar > fvPatchScalarField
Definition: fvPatchFieldsFwd.H:38
volFields.H
Foam::fvPatchField< scalar >::operator=
virtual void operator=(const UList< Type > &)
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::Field::autoMap
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:508
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvPatchFieldMapper.H
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::turbulentHeatFluxTemperatureFvPatchScalarField
turbulentHeatFluxTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.C:74
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType
heatSourceType
Enumeration listing the possible hest source input modes.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:123
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames_
static const NamedEnum< heatSourceType, 2 > heatSourceTypeNames_
Heat source type names.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:135
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
turbulentHeatFluxTemperatureFvPatchScalarField
Fixed heat boundary condition to specify temperature gradient. Input heat source either specified in ...
turbulenceModel.H
write
Tcoeff write()
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress