dsmcFields.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 
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 
26 #include "dsmcFields.H"
27 #include "volFields.H"
28 #include "dictionary.H"
29 #include "dsmcCloud.H"
30 
31 #include "constants.H"
32 
33 using namespace Foam::constant;
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 defineTypeNameAndDebug(dsmcFields, 0);
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 (
47  const word& name,
48  const objectRegistry& obr,
49  const dictionary& dict,
50  const bool loadFromFiles
51 )
52 :
53  name_(name),
54  obr_(obr),
55  active_(true),
56  log_(true)
57 {
58  // Check if the available mesh is an fvMesh, otherwise deactivate
59  if (!isA<fvMesh>(obr_))
60  {
61  active_ = false;
63  << "No fvMesh available, deactivating " << name_ << nl
64  << endl;
65  }
66 
67  read(dict);
68 }
69 
70 
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 {
81  if (active_)
82  {
83  log_.readIfPresent("log", dict);
84  }
85 }
86 
87 
89 {
90  // Do nothing - only valid on write
91 }
92 
93 
95 {
96  // Do nothing - only valid on write
97 }
98 
99 
101 {
102  // Do nothing - only valid on write
103 }
104 
105 
107 {
108  if (active_)
109  {
110  word rhoNMeanName = "rhoNMean";
111  word rhoMMeanName = "rhoMMean";
112  word momentumMeanName = "momentumMean";
113  word linearKEMeanName = "linearKEMean";
114  word internalEMeanName = "internalEMean";
115  word iDofMeanName = "iDofMean";
116  word fDMeanName = "fDMean";
117 
118  const volScalarField& rhoNMean =
119  obr_.lookupObject<volScalarField>(rhoNMeanName);
120 
121  const volScalarField& rhoMMean =
122  obr_.lookupObject<volScalarField>(rhoMMeanName);
123 
124  const volVectorField& momentumMean =
125  obr_.lookupObject<volVectorField>(momentumMeanName);
126 
127  const volScalarField& linearKEMean =
128  obr_.lookupObject<volScalarField>(linearKEMeanName);
129 
130  const volScalarField& internalEMean =
131  obr_.lookupObject<volScalarField>(internalEMeanName);
132 
133  const volScalarField& iDofMean =
134  obr_.lookupObject<volScalarField>(iDofMeanName);
135 
136  const volVectorField& fDMean =
137  obr_.lookupObject<volVectorField>(fDMeanName);
138 
139  if (min(mag(rhoNMean)).value() > VSMALL)
140  {
141  if (log_) Info<< type() << " " << name_ << " output:" << endl;
142 
143  if (log_) Info<< " Calculating UMean field" << endl;
145  (
146  IOobject
147  (
148  "UMean",
149  obr_.time().timeName(),
150  obr_,
152  ),
153  momentumMean/rhoMMean
154  );
155 
156  if (log_) Info<< " Calculating translationalT field" << endl;
157  volScalarField translationalT
158  (
159  IOobject
160  (
161  "translationalT",
162  obr_.time().timeName(),
163  obr_,
165  ),
166 
167  2.0/(3.0*physicoChemical::k.value()*rhoNMean)
168  *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
169  );
170 
171  if (log_) Info<< " Calculating internalT field" << endl;
172  volScalarField internalT
173  (
174  IOobject
175  (
176  "internalT",
177  obr_.time().timeName(),
178  obr_,
180  ),
181  (2.0/physicoChemical::k.value())*(internalEMean/iDofMean)
182  );
183 
184  if (log_) Info<< " Calculating overallT field" << endl;
185  volScalarField overallT
186  (
187  IOobject
188  (
189  "overallT",
190  obr_.time().timeName(),
191  obr_,
193  ),
194  2.0/(physicoChemical::k.value()*(3.0*rhoNMean + iDofMean))
195  *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
196  );
197 
198  if (log_) Info<< " Calculating pressure field" << endl;
200  (
201  IOobject
202  (
203  "p",
204  obr_.time().timeName(),
205  obr_,
207  ),
208  physicoChemical::k.value()*rhoNMean*translationalT
209  );
210 
211  const fvMesh& mesh = fDMean.mesh();
212 
213  forAll(mesh.boundaryMesh(), i)
214  {
215  const polyPatch& patch = mesh.boundaryMesh()[i];
216 
217  if (isA<wallPolyPatch>(patch))
218  {
219  p.boundaryField()[i] =
220  fDMean.boundaryField()[i]
221  & (patch.faceAreas()/mag(patch.faceAreas()));
222  }
223  }
224 
225  if (log_)
226  {
227  Info<< " mag(UMean) max/min: "
228  << max(mag(UMean)).value() << " "
229  << min(mag(UMean)).value() << endl;
230 
231  Info<< " translationalT max/min: "
232  << max(translationalT).value() << " "
233  << min(translationalT).value() << endl;
234 
235  Info<< " internalT max/min: "
236  << max(internalT).value() << " "
237  << min(internalT).value() << endl;
238 
239  Info<< " overallT max/min: "
240  << max(overallT).value() << " "
241  << min(overallT).value() << endl;
242 
243  Info<< " p max/min: "
244  << max(p).value() << " "
245  << min(p).value() << endl;
246  }
247 
248  UMean.write();
249 
250  translationalT.write();
251 
252  internalT.write();
253 
254  overallT.write();
255 
256  p.write();
257 
258  if (log_) Info<< " " << type() << " written" << nl << endl;
259  }
260  else
261  {
262  if (log_) Info
263  << "Small value (" << min(mag(rhoNMean))
264  << ") found in rhoNMean field. "
265  << "Not calculating " << type() << " to avoid division by zero."
266  << endl;
267  }
268  }
269 }
270 
271 
272 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dsmcFields::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: dsmcFields.C:94
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::constant::physicoChemical::k
const dimensionedScalar k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::constant
Collection of constants.
Definition: atomicConstants.C:37
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
dsmcCloud.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:261
dsmcFields.H
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::dsmcFields::read
virtual void read(const dictionary &)
Read the dsmcFields data.
Definition: dsmcFields.C:79
Foam::dsmcFields::~dsmcFields
virtual ~dsmcFields()
Destructor.
Definition: dsmcFields.C:73
Foam::dsmcFields::dsmcFields
dsmcFields(const dsmcFields &)
Disallow default bitwise copy construct.
Foam::dsmcFields::execute
virtual void execute()
Execute, currently does nothing.
Definition: dsmcFields.C:88
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
constants.H
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::dsmcFields::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: dsmcFields.C:100
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:314
dictionary.H
Foam::dsmcFields::write
virtual void write()
Calculate the dsmcFields and write.
Definition: dsmcFields.C:106
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
UMean
volVectorField UMean(UMeanHeader, mesh)
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47