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-2018 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 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef regionModel_H
37 #define regionModel_H
38 
39 #include "IOdictionary.H"
40 #include "Switch.H"
41 #include "labelList.H"
42 #include "volFields.H"
43 #include "mappedPatchBase.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 namespace regionModels
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class regionModel Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class regionModel
59 :
60  public IOdictionary
61 {
62 
63 private:
64 
65  // Private Member Functions
66 
67  //- Disallow default bitwise copy construct
68  regionModel(const regionModel&);
69 
70  //- Disallow default bitwise assignment
71  void operator=(const regionModel&);
72 
73  //- Construct region mesh and fields
74  void constructMeshObjects();
75 
76  //- Initialise the region
77  void initialise();
78 
79 
80 protected:
81 
82  // Protected data
83 
84  //- Reference to the primary mesh database
85  const fvMesh& primaryMesh_;
86 
87  //- Reference to the time database
88  const Time& time_;
89 
90  //- Active flag
92 
93  //- Active information output
95 
96  //- Model name
97  const word modelName_;
98 
99  //- Pointer to the region mesh database
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();
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 const Switch& active() const;
200 
201  //- Return the information flag
202  inline const 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
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 // ************************************************************************* //
dictionary dict
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:84
const word modelName_
Model name.
Definition: regionModel.H:96
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:127
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:525
virtual void info()
Provide some feedback.
Definition: regionModel.C:535
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:137
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.
Definition: Switch.H:60
autoPtr< fvMesh > regionMeshPtr_
Pointer to the region mesh database.
Definition: regionModel.H:99
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:105
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
dynamicFvMesh & mesh
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:519
Pre-declare SubField and related Field type.
Definition: Field.H:57
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read()
Read control parameters from dictionary.
Definition: regionModel.C:146
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:278
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:529
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:93
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:191
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:90
PtrList< PtrList< AMIPatchToPatchInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:131
virtual ~regionModel()
Destructor.
Definition: regionModel.C:476
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:102
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
const Time & time_
Reference to the time database.
Definition: regionModel.H:87
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:121
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:482
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:57
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:114
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:118
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:111
const Switch & active() const
Return the active flag.
Definition: regionModelI.H:43
Namespace for OpenFOAM.