regionModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 Class
25  Foam::regionModels::regionModel
26 
27 Description
28  Base class for region models
29 
30 SourceFiles
31  regionModelI.H
32  regionModel.C
33  regionModelTemplates.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef regionModel_H
38 #define regionModel_H
39 
40 #include "fvMesh.H"
41 #include "AMIInterpolation.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 namespace regionModels
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class regionModel Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class regionModel
57 :
58  public IOdictionary
59 {
60  // Private Member Functions
61 
62  //- Disallow default bitwise copy construction
63  regionModel(const regionModel&) = delete;
64 
65  //- Disallow default bitwise assignment
66  void operator=(const regionModel&) = delete;
67 
68  //- Construct region mesh and fields
69  void constructMeshObjects();
70 
71  //- Initialise the region
72  void initialise();
73 
74 
75 protected:
76 
77  // Protected data
78 
79  //- Reference to the primary mesh database
80  const fvMesh& primaryMesh_;
81 
82  //- Reference to the time database
83  const Time& time_;
84 
85  //- Active flag
87 
88  //- Active information output
90 
91  //- Model name
92  const word modelName_;
93 
94  //- Pointer to the region mesh database
96 
97  //- Model coefficients dictionary
99 
100  //- Dictionary of output properties
102 
103 
104  // Addressing
105 
106  //- List of patch IDs on the primary region coupled to this region
108 
109  //- List of patch IDs internally coupled with the primary region
111 
112 
113  //- Region name
115 
116  //- Region model function objects
118 
119 
120  // Inter-region AMI interpolation caching
121 
122  //- List of region names this region is coupled to
124 
125  //- List of AMI objects per coupled region
127 
128 
129  // Protected member functions
130 
131  //- Read control parameters from dictionary
132  virtual bool read();
133 
134  //- Read control parameters from dictionary
135  virtual bool read(const dictionary& dict);
136 
137  //- Create or return a new inter-region AMI object
138  virtual const AMIInterpolation& interRegionAMI
139  (
140  const regionModel& nbrRegion,
141  const label regionPatchi,
142  const label nbrPatchi,
143  const bool flip
144  ) const;
145 
146 
147 public:
148 
149  //- Runtime type information
150  TypeName("regionModel");
151 
152 
153  // Constructors
154 
155  //- Construct null
156  regionModel(const fvMesh& mesh, const word& regionType);
157 
158  //- Construct from mesh, region type and name
160  (
161  const fvMesh& mesh,
162  const word& regionType,
163  const word& modelName,
164  bool readFields = true
165  );
166 
167  //- Construct from mesh and name and dict
169  (
170  const fvMesh& mesh,
171  const word& regionType,
172  const word& modelName,
173  const dictionary& dict,
174  bool readFields = true
175  );
176 
177 
178  //- Destructor
179  virtual ~regionModel();
180 
181 
182  // Member Functions
183 
184  // Access
185 
186  //- Return the reference to the primary mesh database
187  inline const fvMesh& primaryMesh() const;
188 
189  //- Return the reference to the time database
190  inline const Time& time() const;
191 
192  //- Return the active flag
193  inline const Switch& active() const;
194 
195  //- Return the information flag
196  inline const Switch& infoOutput() const;
197 
198  //- Return the model name
199  inline const word& modelName() const;
200 
201  //- Return the region mesh database
202  inline const fvMesh& regionMesh() const;
203 
204  //- Return the region mesh database for manipulation
205  inline fvMesh& regionMesh();
206 
207  //- Return the model coefficients dictionary
208  inline const dictionary& coeffs() const;
209 
210  //- Return the solution dictionary
211  inline const dictionary& solution() const;
212 
213  //- Return const access to the output properties dictionary
214  inline const IOdictionary& outputProperties() const;
215 
216  //- Return output properties dictionary
217  inline IOdictionary& outputProperties();
218 
219 
220  // Addressing
221 
222  //- Return true if patchi on the local region is a coupled
223  // patch to the primary region
224  inline bool isCoupledPatch(const label regionPatchi) const;
225 
226  //- Return true if patchi on the primary region is a coupled
227  // patch to the local region
228  inline bool isRegionPatch(const label primaryPatchi) const;
229 
230  //- Return the list of patch IDs on the primary region coupled
231  // to this region
232  inline const labelList& primaryPatchIDs() const;
233 
234  //- Return the list of patch IDs internally coupled with the
235  // primary region
236  inline const labelList& intCoupledPatchIDs() const;
237 
238  //- Return region ID corresponding to primaryPatchID
239  inline label regionPatchID(const label primaryPatchID) const;
240 
241 
242  // Helper
243 
244  //- Return the coupled patch ID paired with coupled patch
245  // regionPatchi
247  (
248  const regionModel& nbrRegion,
249  const label regionPatchi
250  ) const;
251 
252  //- Map patch field from another region model to local patch
253  template<class Type>
255  (
256  const regionModel& nbrRegion,
257  const label regionPatchi,
258  const label nbrPatchi,
259  const Field<Type>& nbrField,
260  const bool flip = false
261  ) const;
262 
263  //- Map patch field from another region model to local patch
264  template<class Type>
266  (
267  const regionModel& nbrRegion,
268  const word& fieldName,
269  const label regionPatchi,
270  const bool flip = false
271  ) const;
272 
273  //- Map patch internal field from another region model to local
274  // patch
275  template<class Type>
277  (
278  const regionModel& nbrRegion,
279  const word& fieldName,
280  const label regionPatchi,
281  const bool flip = false
282  ) const;
283 
284  //- Convert a local region field to the primary region
285  template<class Type>
286  void toPrimary
287  (
288  const label regionPatchi,
289  List<Type>& regionField
290  ) const;
291 
292  //- Convert a local region field to the primary region with op
293  template<class Type, class CombineOp>
294  void toPrimary
295  (
296  const label regionPatchi,
297  List<Type>& regionField,
298  const CombineOp& cop
299  ) const;
300 
301  //- Convert a primary region field to the local region
302  template<class Type>
303  void toRegion
304  (
305  const label regionPatchi,
306  List<Type>& primaryFieldField
307  ) const;
308 
309  //- Return a primary patch field mapped the region internal field
310  template<class Type>
311  void toRegion
312  (
313  Field<Type>& regionField,
314  const label regionPatchi,
315  const fvPatchField<Type>& primaryPatchField
316  ) const;
317 
318  //- Return a primary patch field mapped the local region
319  template<class Type>
320  void toRegion
321  (
322  Field<Type>& rf,
323  const typename GeometricField
324  <
325  Type,
326  fvPatchField,
327  volMesh
328  >::Boundary& pBf
329  ) const;
330 
331 
332  // Evolution
333 
334  //- Main driver routing to evolve the region - calls other evolves
335  virtual void evolve();
336 
337  //- Pre-evolve region
338  virtual void preEvolveRegion();
339 
340  //- Evolve the region
341  virtual void evolveRegion();
342 
343  //- Post-evolve region
344  virtual void postEvolveRegion();
345 
346 
347  // I-O
348 
349  //- Provide some feedback
350  virtual void info();
351 };
352 
353 
354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355 
356 } // End namespace regionModels
357 } // End namespace Foam
358 
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 
361 #include "regionModelI.H"
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #ifdef NoRepository
366  #include "regionModelTemplates.C"
367 #endif
368 
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 
371 #endif
372 
373 // ************************************************************************* //
dictionary dict
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:79
const word modelName_
Model name.
Definition: regionModel.H:91
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
wordList interRegionAMINames_
List of region names this region is coupled to.
Definition: regionModel.H:122
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:520
virtual void info()
Provide some feedback.
Definition: regionModel.C:530
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
bool isRegionPatch(const label primaryPatchi) const
Return true if patchi on the primary region is a coupled.
Definition: regionModelI.H:155
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
autoPtr< fvMesh > regionMeshPtr_
Pointer to the region mesh database.
Definition: regionModel.H:94
Generic GeometricField class.
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:37
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
TypeName("regionModel")
Runtime type information.
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
Definition: regionModel.H:100
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
const word & modelName() const
Return the model name.
Definition: regionModelI.H:55
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
const fvMesh & primaryMesh() const
Return the reference to the primary mesh database.
Definition: regionModelI.H:31
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:53
dynamicFvMesh & mesh
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:514
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read()
Read control parameters from dictionary.
Definition: regionModel.C:141
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:138
label nbrCoupledPatchID(const regionModel &nbrRegion, const label regionPatchi) const
Return the coupled patch ID paired with coupled patch.
Definition: regionModel.C:273
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:524
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
Definition: regionModelI.H:110
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:103
label regionPatchID(const label primaryPatchID) const
Return region ID corresponding to primaryPatchID.
Definition: regionModelI.H:186
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.
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
Switch infoOutput_
Active information output.
Definition: regionModel.H:88
const labelList & primaryPatchIDs() const
Return the list of patch IDs on the primary region coupled.
Definition: regionModelI.H:172
Switch active_
Active flag.
Definition: regionModel.H:85
virtual ~regionModel()
Destructor.
Definition: regionModel.C:471
PtrList< PtrList< AMIInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:125
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:97
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const Time & time_
Reference to the time database.
Definition: regionModel.H:82
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:116
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Definition: regionModel.C:477
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.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
void toRegion(const label regionPatchi, List< Type > &primaryFieldField) const
Convert a primary region field to the local region.
Base class for region models.
Definition: regionModel.H:55
const Switch & infoOutput() const
Return the information flag.
Definition: regionModelI.H:49
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
Definition: regionModel.H:109
A class for managing temporary objects.
Definition: PtrList.H:53
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:179
const dictionary & coeffs() const
Return the model coefficients dictionary.
Definition: regionModelI.H:96
word regionName_
Region name.
Definition: regionModel.H:113
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:106
virtual const AMIInterpolation & 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:186
const Switch & active() const
Return the active flag.
Definition: regionModelI.H:43
Namespace for OpenFOAM.