regionModel.H
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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::regionModels::regionModel
29 
30 Description
31  Base class for region models
32 
33 SourceFiles
34  regionModelI.H
35  regionModel.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef regionModel_H
40 #define regionModel_H
41 
42 #include "IOdictionary.H"
43 #include "Switch.H"
44 #include "labelList.H"
45 #include "volFields.H"
46 #include "mappedPatchBase.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 namespace regionModels
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class regionModel Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class regionModel
62 :
63  public IOdictionary
64 {
65 
66 private:
67 
68  // Private Member Functions
69 
70  //- No copy construct
71  regionModel(const regionModel&) = delete;
72 
73  //- No copy assignment
74  void operator=(const regionModel&) = delete;
75 
76  //- Construct region mesh and fields
77  void constructMeshObjects();
78 
79  //- Initialise the region
80  void initialise();
81 
82 
83 protected:
84 
85  // Protected data
86 
87  //- Reference to the primary mesh database
88  const fvMesh& primaryMesh_;
89 
90  //- Reference to the time database
91  const Time& time_;
92 
93  //- Active flag
95 
96  //- Active information output
98 
99  //- Model name
100  const word modelName_;
101 
102  //- Model coefficients dictionary
104 
105  //- Dictionary of output properties
107 
108 
109  // Addressing
110 
111  //- List of patch IDs on the primary region coupled to this region
113 
114  //- List of patch IDs internally coupled with the primary region
116 
117 
118  //- Region name
120 
121  //- Region model function objects
123 
124 
125  // Inter-region AMI interpolation caching
126 
127  //- List of region names this region is coupled to
129 
130  //- List of AMI objects per coupled region
133 
134 
135  // Protected member functions
136 
137  //- Read control parameters from dictionary
138  virtual bool read();
139 
140  //- Read control parameters from dictionary
141  virtual bool read(const dictionary& dict);
142 
143  //- Create or return a new inter-region AMI object
145  (
146  const regionModel& nbrRegion,
147  const label regionPatchi,
148  const label nbrPatchi,
149  const bool flip
150  ) const;
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("regionModel");
157 
158 
159  // Constructors
160 
161  //- Construct null
162  regionModel(const fvMesh& mesh, const word& regionType);
163 
164  //- Construct from mesh, region type and name
166  (
167  const fvMesh& mesh,
168  const word& regionType,
169  const word& modelName,
170  bool readFields = true
171  );
172 
173  //- Construct from mesh and name and dict
175  (
176  const fvMesh& mesh,
177  const word& regionType,
178  const word& modelName,
179  const dictionary& dict,
180  bool readFields = true
181  );
182 
183 
184  //- Destructor
185  virtual ~regionModel() = default;
186 
187 
188  // Member Functions
189 
190  // Access
191 
192  //- Return the reference to the primary mesh database
193  inline const fvMesh& primaryMesh() const;
194 
195  //- Return the reference to the time database
196  inline const Time& time() const;
197 
198  //- Return the active flag
199  inline Switch active() const;
200 
201  //- Return the information flag
202  inline Switch infoOutput() const;
203 
204  //- Return the model name
205  inline const word& modelName() const;
206 
207  //- Return the region mesh database
208  inline const fvMesh& regionMesh() const;
209 
210  //- Return the region mesh database for manipulation
211  inline fvMesh& regionMesh();
212 
213  //- Return the model coefficients dictionary
214  inline const dictionary& coeffs() const;
215 
216  //- Return the solution dictionary
217  inline const dictionary& solution() const;
218 
219  //- Return const access to the output properties dictionary
220  inline const IOdictionary& outputProperties() const;
221 
222  //- Return output properties dictionary
223  inline IOdictionary& outputProperties();
224 
225 
226  // Addressing
227 
228  //- Return true if patchi on the local region is a coupled
229  // patch to the primary region
230  inline bool isCoupledPatch(const label regionPatchi) const;
231 
232  //- Return true if patchi on the primary region is a coupled
233  // patch to the local region
234  inline bool isRegionPatch(const label primaryPatchi) const;
235 
236  //- Return the list of patch IDs on the primary region coupled
237  // to this region
238  inline const labelList& primaryPatchIDs() const;
239 
240  //- Return the list of patch IDs internally coupled with the
241  // primary region
242  inline const labelList& intCoupledPatchIDs() const;
243 
244  //- Return region ID corresponding to primaryPatchID
245  inline label regionPatchID(const label primaryPatchID) const;
246 
247 
248  // Helper
249 
250  //- Return the coupled patch ID paired with coupled patch
251  // regionPatchi
252  label nbrCoupledPatchID
253  (
254  const regionModel& nbrRegion,
255  const label regionPatchi
256  ) const;
257 
258  //- Map patch field from another region model to local patch
259  template<class Type>
261  (
262  const regionModel& nbrRegion,
263  const label regionPatchi,
264  const label nbrPatchi,
265  const Field<Type>& nbrField,
266  const bool flip = false
267  ) const;
268 
269  //- Map patch field from another region model to local patch
270  template<class Type>
272  (
273  const regionModel& nbrRegion,
274  const word& fieldName,
275  const label regionPatchi,
276  const bool flip = false
277  ) const;
278 
279  //- Map patch internal field from another region model to local
280  // patch
281  template<class Type>
283  (
284  const regionModel& nbrRegion,
285  const word& fieldName,
286  const label regionPatchi,
287  const bool flip = false
288  ) const;
289 
290  //- Convert a local region field to the primary region
291  template<class Type>
292  void toPrimary
293  (
294  const label regionPatchi,
295  List<Type>& regionField
296  ) const;
297 
298  //- Convert a primary region field to the local region
299  template<class Type>
300  void toRegion
301  (
302  const label regionPatchi,
303  List<Type>& primaryFieldField
304  ) const;
305 
306  //- Convert a local region field to the primary region with op
307  template<class Type, class CombineOp>
308  void toPrimary
309  (
310  const label regionPatchi,
311  List<Type>& regionField,
312  const CombineOp& cop
313  ) const;
314 
315  //- Convert a primary region field to the local region with op
316  template<class Type, class CombineOp>
317  void toRegion
318  (
319  const label regionPatchi,
320  List<Type>& primaryFieldField,
321  const CombineOp& cop
322  ) const;
323 
324 
325  // Evolution
326 
327  //- Main driver routing to evolve the region - calls other evolves
328  virtual void evolve();
329 
330  //- Pre-evolve region
331  virtual void preEvolveRegion();
332 
333  //- Evolve the region
334  virtual void evolveRegion();
335 
336  //- Post-evolve region
337  virtual void postEvolveRegion();
338 
339 
340  // I-O
341 
342  //- Provide some feedback
343  virtual void info();
344 };
345 
346 
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348 
349 } // End namespace regionModels
350 } // End namespace Foam
351 
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 
354 #include "regionModelI.H"
355 
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 
358 #ifdef NoRepository
359  #include "regionModelTemplates.C"
360 #endif
361 
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363 
364 #endif
365 
366 // ************************************************************************* //
Foam::regionModels::regionModel::primaryMesh_
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:87
volFields.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
regionModelFunctionObjectList.H
Foam::regionModels::regionModel::interRegionAMINames_
wordList interRegionAMINames_
List of region names this region is coupled to.
Definition: regionModel.H:127
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::regionModels::regionModel::active
Switch active() const
Return the active flag.
Definition: regionModelI.H:46
Foam::regionModels::regionModel::modelName_
const word modelName_
Model name.
Definition: regionModel.H:99
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::regionModels::regionModel::evolveRegion
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:506
Foam::regionModels::regionModel::info
virtual void info()
Provide some feedback.
Definition: regionModel.C:516
Foam::regionModels::regionModel::isRegionPatch
bool isRegionPatch(const label primaryPatchi) const
Return true if patchi on the primary region is a coupled.
Definition: regionModelI.H:151
Foam::regionModels::regionModel::time
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:40
regionModelTemplates.C
Foam::regionModels::regionModel::outputPropertiesPtr_
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
Definition: regionModel.H:105
Foam::regionModels::regionModel::modelName
const word & modelName() const
Return the model name.
Definition: regionModelI.H:58
Foam::regionModels::regionModel
Base class for region models.
Definition: regionModel.H:60
Foam::regionModels::regionModel::primaryMesh
const fvMesh & primaryMesh() const
Return the reference to the primary mesh database.
Definition: regionModelI.H:34
Foam::regionModels::regionModel::toPrimary
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
Definition: regionModelTemplates.C:147
Foam::regionModels::regionModel::TypeName
TypeName("regionModel")
Runtime type information.
Foam::regionModels::regionModel::isCoupledPatch
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:134
labelList.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::regionModels::regionModel::postEvolveRegion
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:510
Foam::regionModels::regionModelFunctionObjectList
List of cloud function objects.
Definition: regionModelFunctionObjectList.H:56
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
Foam::regionModels::regionModel::preEvolveRegion
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:500
Switch.H
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::regionModels::regionModel::read
virtual bool read()
Read control parameters from dictionary.
Definition: regionModel.C:149
Foam::regionModels::regionModel::nbrCoupledPatchID
label nbrCoupledPatchID(const regionModel &nbrRegion, const label regionPatchi) const
Return the coupled patch ID paired with coupled patch.
Definition: regionModel.C:272
Foam::regionModels::regionModel::outputProperties
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
Definition: regionModelI.H:106
Foam::regionModels::regionModel::solution
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:99
Foam::regionModels::regionModel::mapRegionPatchInternalField
tmp< Field< Type > > mapRegionPatchInternalField(const regionModel &nbrRegion, const word &fieldName, const label regionPatchi, const bool flip=false) const
Map patch internal field from another region model to local.
Foam::regionModels::regionModel::regionPatchID
label regionPatchID(const label primaryPatchID) const
Return region ID corresponding to primaryPatchID.
Definition: regionModelI.H:182
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::regionModels::regionModel::active_
Switch active_
Active flag.
Definition: regionModel.H:93
Foam::regionModels::regionModel::infoOutput_
Switch infoOutput_
Active information output.
Definition: regionModel.H:96
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::regionModels::regionModel::interRegionAMI_
PtrList< PtrList< AMIPatchToPatchInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:131
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regionModels::regionModel::interRegionAMI
virtual const AMIPatchToPatchInterpolation & interRegionAMI(const regionModel &nbrRegion, const label regionPatchi, const label nbrPatchi, const bool flip) const
Create or return a new inter-region AMI object.
Definition: regionModel.C:189
Foam::regionModels::regionModel::coeffs_
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:102
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::regionModel::infoOutput
Switch infoOutput() const
Return the information flag.
Definition: regionModelI.H:52
Foam::regionModels::regionModel::primaryPatchIDs
const labelList & primaryPatchIDs() const
Return the list of patch IDs on the primary region coupled.
Definition: regionModelI.H:168
Foam::regionModels::regionModel::~regionModel
virtual ~regionModel()=default
Destructor.
IOdictionary.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::regionModels::regionModel::time_
const Time & time_
Reference to the time database.
Definition: regionModel.H:90
Foam::regionModels::regionModel::functions_
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:121
regionModelI.H
Foam::regionModels::regionModel::evolve
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Definition: regionModel.C:467
Foam::regionModels::regionModel::mapRegionPatchField
tmp< Foam::Field< Type > > mapRegionPatchField(const regionModel &nbrRegion, const label regionPatchi, const label nbrPatchi, const Field< Type > &nbrField, const bool flip=false) const
Map patch field from another region model to local patch.
Foam::List< label >
Foam::AMIInterpolation
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Definition: AMIInterpolation.H:79
Foam::regionModels::regionModel::intCoupledPatchIDs_
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
Definition: regionModel.H:114
Foam::regionModels::regionModel::coeffs
const dictionary & coeffs() const
Return the model coefficients dictionary.
Definition: regionModelI.H:92
Foam::regionModels::regionModel::toRegion
void toRegion(const label regionPatchi, List< Type > &primaryFieldField) const
Convert a primary region field to the local region.
Definition: regionModelTemplates.C:174
Foam::regionModels::regionModel::intCoupledPatchIDs
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:175
Foam::regionModels::regionModel::regionName_
word regionName_
Region name.
Definition: regionModel.H:118
Foam::regionModels::regionModel::primaryPatchIDs_
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:111
mappedPatchBase.H