externalCoupledTemperatureMixedFvPatchScalarField.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) 2013-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "OFstream.H"
32 
33 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
34 
36 (
37  OFstream& os
38 ) const
39 {
40  os << "# Values: magSf value qDot htc" << endl;
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
48 (
49  const fvPatch& p,
51 )
52 :
54 {}
55 
56 
59 (
61  const fvPatch& p,
63  const fvPatchFieldMapper& mapper
64 )
65 :
67 {}
68 
69 
72 (
73  const fvPatch& p,
75  const dictionary& dict
76 )
77 :
79 {}
80 
81 
84 (
86 )
87 :
89 {}
90 
91 
94 (
97 )
98 :
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
104 
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
113 (
114  OFstream& os
115 ) const
116 {
117  if (log())
118  {
119  Info<< type() << ": " << this->patch().name()
120  << ": writing data to " << os.name()
121  << endl;
122  }
123 
124  const label patchi = patch().index();
125 
126  // heat flux [W/m2]
127  scalarField qDot(this->patch().size(), 0.0);
128 
129  typedef compressible::turbulenceModel cmpTurbModelType;
130 
131  static word turbName
132  (
134  (
136  internalField().group()
137  )
138  );
139 
140  static word thermoName(basicThermo::dictName);
141 
142  if (db().foundObject<cmpTurbModelType>(turbName))
143  {
144  const cmpTurbModelType& turbModel =
145  db().lookupObject<cmpTurbModelType>(turbName);
146 
147  const basicThermo& thermo = turbModel.transport();
148 
149  const fvPatchScalarField& hep = thermo.he().boundaryField()[patchi];
150 
151  qDot = turbModel.alphaEff(patchi)*hep.snGrad();
152  }
153  else if (db().foundObject<basicThermo>(thermoName))
154  {
155  const basicThermo& thermo = db().lookupObject<basicThermo>(thermoName);
156 
157  const fvPatchScalarField& hep = thermo.he().boundaryField()[patchi];
158 
159  qDot = thermo.alpha().boundaryField()[patchi]*hep.snGrad();
160  }
161  else
162  {
164  << "Condition requires either compressible turbulence and/or "
165  << "thermo model to be available" << exit(FatalError);
166  }
167 
168  // patch temperature [K]
169  const scalarField Tp(*this);
170 
171  // near wall cell temperature [K]
172  const scalarField Tc(patchInternalField());
173 
174  // heat transfer coefficient [W/m2/K]
175  const scalarField htc(qDot/(Tp - Tc + ROOTVSMALL));
176 
177  if (Pstream::parRun())
178  {
179  int tag = Pstream::msgType() + 1;
180 
182  magSfs[Pstream::myProcNo()].setSize(this->patch().size());
183  magSfs[Pstream::myProcNo()] = this->patch().magSf();
184  Pstream::gatherList(magSfs, tag);
185 
187  values[Pstream::myProcNo()].setSize(this->patch().size());
188  values[Pstream::myProcNo()] = Tp;
189  Pstream::gatherList(values, tag);
190 
192  qDots[Pstream::myProcNo()].setSize(this->patch().size());
193  qDots[Pstream::myProcNo()] = qDot;
194  Pstream::gatherList(qDots, tag);
195 
197  htcs[Pstream::myProcNo()].setSize(this->patch().size());
198  htcs[Pstream::myProcNo()] = htc;
199  Pstream::gatherList(htcs, tag);
200 
201  if (Pstream::master())
202  {
203  forAll(values, proci)
204  {
205  const Field<scalar>& magSf = magSfs[proci];
206  const Field<scalar>& value = values[proci];
207  const Field<scalar>& qDot = qDots[proci];
208  const Field<scalar>& htc = htcs[proci];
209 
210  forAll(magSf, facei)
211  {
212  os << magSf[facei] << token::SPACE
213  << value[facei] << token::SPACE
214  << qDot[facei] << token::SPACE
215  << htc[facei] << token::SPACE
216  << nl;
217  }
218  }
219 
220  os.flush();
221  }
222  }
223  else
224  {
225  const Field<scalar>& magSf(this->patch().magSf());
226 
227  forAll(patch(), facei)
228  {
229  os << magSf[facei] << token::SPACE
230  << Tp[facei] << token::SPACE
231  << qDot[facei] << token::SPACE
232  << htc[facei] << token::SPACE
233  << nl;
234  }
235 
236  os.flush();
237  }
238 }
239 
240 
242 (
243  const Pstream::commsTypes comms
244 )
245 {
247 }
248 
249 
251 (
252  Ostream& os
253 ) const
254 {
256 }
257 
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 namespace Foam
262 {
264  (
267  );
268 }
269 
270 
271 // ************************************************************************* //
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:339
const char *const group
Group name for atomic constants.
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:136
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:52
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:225
commsTypes
Types of communications.
Definition: UPstream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Output to file stream.
Definition: OFstream.H:81
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:417
const word & name() const
Return name.
Definition: fvPatch.H:149
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
externalCoupledTemperatureMixedFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:411
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:464
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Macros for easy insertion into run-time selection tables.
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
virtual void transferData(OFstream &os) const
Transfer data for external source.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
static const word propertiesName
Default name of the turbulence properties dictionary.
A class for handling words, derived from string.
Definition: word.H:59
static word groupName(Name name, const word &group)
Foam::fvPatchFieldMapper.
virtual void flush()
Flush stream.
Definition: OSstream.C:246
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
This boundary condition provides a temperature interface to an external application. Values are transferred as plain text files, where OpenFOAM data is written as:
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:217
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
label size() const
Return the number of elements in the UList.
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:198
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:179
void setSize(const label)
Reset size of List.
Definition: List.C:295
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:393
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:399
label patchi
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:461
virtual const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: basicThermo.C:490
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void writeHeader(OFstream &os) const
Write header to transfer file.
messageStream Info
volScalarField & p
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
const fileName & name() const
Return the name of the stream.
Definition: OFstream.H:118
const DimensionedField< Type, volMesh > & internalField() const
Return dimensioned internal field reference.
Definition: fvPatchField.H:346
Namespace for OpenFOAM.