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-2022 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  }
104  return false;
105 }
106 
107 
108 // * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
109 
111 {
112  return vsmPtr_();
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
119 (
120  const fvMesh& mesh,
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, dict.get<word>("region")),
132  mesh.time().constant(),
133  mesh.time(),
134  IOobject::NO_READ,
135  IOobject::NO_WRITE
136  )
137  ),
138  primaryMesh_(mesh),
139  time_(mesh.time()),
140  active_(dict.get<Switch>("active")),
141  infoOutput_(false),
142  modelName_(modelName),
143  regionMeshPtr_(nullptr),
144  coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")),
145  outputPropertiesPtr_(nullptr),
146  vsmPtr_(nullptr),
147  regionName_(dict.get<word>("region"))
148 {
149  constructMeshObjects();
150  initialise();
151 
152  if (readFields)
153  {
154  init(dict);
155  }
156 }
157 
158 
159 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
160 
162 {
163  if (active_)
164  {
165  Info<< "\nEvolving " << modelName_ << " for region "
166  << regionMesh().name() << endl;
167 
168  preEvolveRegion();
169 
170  evolveRegion();
171 
172  postEvolveRegion();
173 
174  // Provide some feedback
175  if (infoOutput_)
176  {
177  Info<< incrIndent;
178  info();
179  Info<< endl << decrIndent;
180  }
181  }
182 }
183 
184 
186 {}
187 
188 
190 {}
191 
192 
194 {}
195 
196 
198 {
199  return 0;
200 }
201 
202 
203 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const volSurfaceMapping & vsm() const
Return mapping between surface and volume fields.
virtual void postEvolveRegion()
Post-evolve region.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
Ignore writing from objectRegistry::writeObject()
Volume to surface and surface to volume mapping.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
autoPtr< faMesh > regionMeshPtr_
Pointer to the region mesh database.
dynamicFvMesh & mesh
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
A class for handling words, derived from Foam::string.
Definition: word.H:63
regionFaModel(const fvMesh &mesh, const word &regionType, const word &modelName, const dictionary &dict, bool readFields=true)
Construct from mesh and name and dict.
Reading is optional [identical to LAZY_READ].
virtual scalar CourantNumber() const
Courant number of the region.
virtual void preEvolveRegion()
Pre-evolve region.
int debug
Static debugging option.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:511
const fvMesh & primaryMesh_
Reference to the primary mesh database.
static const word regionFaModelName
Default name regionFaModel.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void evolveRegion()
Evolve the region.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:502
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
defineTypeNameAndDebug(KirchhoffShell, 0)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Namespace for OpenFOAM.