regionFaModel.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "regionFaModel.H"
29 #include "faMesh.H"
30 #include "Time.H"
31 #include "mappedWallPolyPatch.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace regionModels
39 {
40  defineTypeNameAndDebug(regionFaModel, 0);
41 }
42 }
43 
44 const Foam::word
46 
47 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 
49 void Foam::regionModels::regionFaModel::constructMeshObjects()
50 {
51  regionMeshPtr_.reset
52  (
53  new faMesh(primaryMesh_)
54  );
55 }
56 
57 
58 void Foam::regionModels::regionFaModel::initialise()
59 {
60  if (debug)
61  {
62  Pout<< "regionFaModel::initialise()" << endl;
63  }
64 
65  vsmPtr_.reset(new volSurfaceMapping(regionMeshPtr_()));
66 
67  if (!outputPropertiesPtr_)
68  {
69  const fileName uniformPath(word("uniform")/regionFaModelName);
70 
71  outputPropertiesPtr_.reset
72  (
73  new IOdictionary
74  (
75  IOobject
76  (
77  regionName_ + "OutputProperties",
78  time_.timeName(),
79  uniformPath/regionName_,
80  primaryMesh_,
83  )
84  )
85  );
86  }
87 }
88 
89 
90 bool Foam::regionModels::regionFaModel::init(const dictionary& dict)
91 {
92  if (active_)
93  {
94  if (const dictionary* dictptr = dict.findDict(modelName_ + "Coeffs"))
95  {
96  coeffs_ <<= *dictptr;
97  }
98 
99  infoOutput_.readIfPresent("infoOutput", dict);
100 
101  return true;
102  }
103 
104  return false;
105 }
106 
107 
108 // * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
109 
111 {
112  return vsmPtr_();
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
119 (
120  const fvPatch& patch,
121  const word& regionType,
122  const word& modelName,
123  const dictionary& dict,
124  bool readFields
125 )
126 :
128  (
129  IOobject
130  (
131  IOobject::groupName(regionFaModelName, patch.name()),
132  patch.boundaryMesh().mesh().time().constant(),
133  patch.boundaryMesh().mesh().time(),
136  )
137  ),
138  primaryMesh_(patch.boundaryMesh().mesh()),
139  patch_(patch),
140  time_(patch.boundaryMesh().mesh().time()),
141  active_(dict.get<Switch>("active")),
142  infoOutput_(false),
143  modelName_(modelName),
144  regionMeshPtr_(nullptr),
145  coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")),
146  outputPropertiesPtr_(nullptr),
147  vsmPtr_(nullptr),
148  patchID_(patch.index()),
149  regionName_(dict.lookup("region"))
150 {
151  constructMeshObjects();
152  initialise();
153 
154  if (readFields)
155  {
156  init(dict);
157  }
158 }
159 
160 
161 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
162 
164 {
165  if (active_)
166  {
167  Info<< "\nEvolving " << modelName_ << " for region "
168  << regionMesh().name() << endl;
169 
170  preEvolveRegion();
171 
172  evolveRegion();
173 
174  postEvolveRegion();
175 
176  // Provide some feedback
177  if (infoOutput_)
178  {
179  Info<< incrIndent;
180  info();
181  Info<< endl << decrIndent;
182  }
183  }
184 }
185 
186 
188 {}
189 
190 
192 {}
193 
194 
196 {}
197 
198 
200 {
201  return 0;
202 }
203 
204 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::regionModels::regionFaModel::regionFaModelName
static const word regionFaModelName
Default name regionFaModel.
Definition: regionFaModel.H:181
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
mappedWallPolyPatch.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::regionModels::defineTypeNameAndDebug
defineTypeNameAndDebug(KirchhoffShell, 0)
Foam::regionModels::regionFaModel::regionMeshPtr_
autoPtr< faMesh > regionMeshPtr_
Pointer to the region mesh database.
Definition: regionFaModel.H:152
Foam::regionModels::regionFaModel::CourantNumber
virtual scalar CourantNumber() const
Courant number of the region.
Definition: regionFaModel.C:199
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
faMesh.H
Foam::regionModels::regionFaModel::regionFaModel
regionFaModel(const fvPatch &patch, const word &regionType, const word &modelName, const dictionary &dict, bool readFields=true)
Construct from mesh and name and dict.
Definition: regionFaModel.C:119
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::regionModels::regionFaModel::vsm
const volSurfaceMapping & vsm() const
Return mapping between surface and volume fields.
Definition: regionFaModel.C:110
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:346
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
init
mesh init(true)
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:187
Foam::regionModels::regionFaModel::postEvolveRegion
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionFaModel.C:195
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:353
Foam::regionModels::regionFaModel::preEvolveRegion
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionFaModel.C:187
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::regionModels::regionFaModel::evolveRegion
virtual void evolveRegion()
Evolve the region.
Definition: regionFaModel.C:191
Time.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::volSurfaceMapping
Volume to surface and surface to volume mapping.
Definition: volSurfaceMapping.H:57
regionFaModel.H
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Foam::regionModels::regionFaModel::evolve
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Definition: regionFaModel.C:163
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::regionModels::regionFaModel::primaryMesh_
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionFaModel.H:134
zeroGradientFvPatchFields.H