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 | Copyright (C) 2011-2016 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::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  //- Construct region mesh and dictionary
77  void constructMeshObjects(const dictionary& dict);
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  //- Pointer to the region mesh database
104 
105  //- Model coefficients dictionary
107 
108  //- Dictionary of output properties
110 
111 
112  // Addressing
113 
114  //- List of patch IDs on the primary region coupled to this region
116 
117  //- List of patch IDs internally coupled with the primary region
119 
120 
121  //- Region name
123 
124  //- Region model function objects
126 
127 
128  // Inter-region AMI interpolation caching
129 
130  //- List of region names this region is coupled to
132 
133  //- List of AMI objects per coupled region
136 
137 
138  // Protected member functions
139 
140  //- Read control parameters from dictionary
141  virtual bool read();
142 
143  //- Read control parameters from dictionary
144  virtual bool read(const dictionary& dict);
145 
146  //- Create or return a new inter-region AMI object
148  (
149  const regionModel& nbrRegion,
150  const label regionPatchi,
151  const label nbrPatchi,
152  const bool flip
153  ) const;
154 
155 
156 public:
157 
158  //- Runtime type information
159  TypeName("regionModel");
160 
161 
162  // Constructors
163 
164  //- Construct null
165  regionModel(const fvMesh& mesh, const word& regionType);
166 
167  //- Construct from mesh, region type and name
169  (
170  const fvMesh& mesh,
171  const word& regionType,
172  const word& modelName,
173  bool readFields = true
174  );
175 
176  //- Construct from mesh and name and dict
178  (
179  const fvMesh& mesh,
180  const word& regionType,
181  const word& modelName,
182  const dictionary& dict,
183  bool readFields = true
184  );
185 
186 
187  //- Destructor
188  virtual ~regionModel();
189 
190 
191  // Member Functions
192 
193  // Access
194 
195  //- Return the reference to the primary mesh database
196  inline const fvMesh& primaryMesh() const;
197 
198  //- Return the reference to the time database
199  inline const Time& time() const;
200 
201  //- Return the active flag
202  inline const Switch& active() const;
203 
204  //- Return the information flag
205  inline const Switch& infoOutput() const;
206 
207  //- Return the model name
208  inline const word& modelName() const;
209 
210  //- Return the region mesh database
211  inline const fvMesh& regionMesh() const;
212 
213  //- Return the region mesh database for manipulation
214  inline fvMesh& regionMesh();
215 
216  //- Return the model coefficients dictionary
217  inline const dictionary& coeffs() const;
218 
219  //- Return the solution dictionary
220  inline const dictionary& solution() const;
221 
222  //- Return const access to the output properties dictionary
223  inline const IOdictionary& outputProperties() const;
224 
225  //- Return output properties dictionary
226  inline IOdictionary& outputProperties();
227 
228 
229  // Addressing
230 
231  //- Return true if patchi on the local region is a coupled
232  // patch to the primary region
233  inline bool isCoupledPatch(const label regionPatchi) const;
234 
235  //- Return true if patchi on the primary region is a coupled
236  // patch to the local region
237  inline bool isRegionPatch(const label primaryPatchi) const;
238 
239  //- Return the list of patch IDs on the primary region coupled
240  // to this region
241  inline const labelList& primaryPatchIDs() const;
242 
243  //- Return the list of patch IDs internally coupled with the
244  // primary region
245  inline const labelList& intCoupledPatchIDs() const;
246 
247  //- Return region ID corresponding to primaryPatchID
248  inline label regionPatchID(const label primaryPatchID) const;
249 
250 
251  // Helper
252 
253  //- Return the coupled patch ID paired with coupled patch
254  // regionPatchi
256  (
257  const regionModel& nbrRegion,
258  const label regionPatchi
259  ) const;
260 
261  //- Map patch field from another region model to local patch
262  template<class Type>
264  (
265  const regionModel& nbrRegion,
266  const label regionPatchi,
267  const label nbrPatchi,
268  const Field<Type>& nbrField,
269  const bool flip = false
270  ) const;
271 
272  //- Map patch field from another region model to local patch
273  template<class Type>
275  (
276  const regionModel& nbrRegion,
277  const word& fieldName,
278  const label regionPatchi,
279  const bool flip = false
280  ) const;
281 
282  //- Map patch internal field from another region model to local
283  // patch
284  template<class Type>
286  (
287  const regionModel& nbrRegion,
288  const word& fieldName,
289  const label regionPatchi,
290  const bool flip = false
291  ) const;
292 
293  //- Convert a local region field to the primary region
294  template<class Type>
295  void toPrimary
296  (
297  const label regionPatchi,
298  List<Type>& regionField
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  //- Convert a local region field to the primary region with op
310  template<class Type, class CombineOp>
311  void toPrimary
312  (
313  const label regionPatchi,
314  List<Type>& regionField,
315  const CombineOp& cop
316  ) const;
317 
318  //- Convert a primary region field to the local region with op
319  template<class Type, class CombineOp>
320  void toRegion
321  (
322  const label regionPatchi,
323  List<Type>& primaryFieldField,
324  const CombineOp& cop
325  ) const;
326 
327 
328  // Evolution
329 
330  //- Main driver routing to evolve the region - calls other evolves
331  virtual void evolve();
332 
333  //- Pre-evolve region
334  virtual void preEvolveRegion();
335 
336  //- Evolve the region
337  virtual void evolveRegion();
338 
339  //- Post-evolve region
340  virtual void postEvolveRegion();
341 
342 
343  // I-O
344 
345  //- Provide some feedback
346  virtual void info();
347 };
348 
349 
350 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
351 
352 } // End namespace regionModels
353 } // End namespace Foam
354 
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 
357 #include "regionModelI.H"
358 
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 
361 #ifdef NoRepository
362  #include "regionModelTemplates.C"
363 #endif
364 
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
366 
367 #endif
368 
369 // ************************************************************************* //
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:103
dictionary dict
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:87
const word modelName_
Model name.
Definition: regionModel.H:99
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
bool isRegionPatch(const label primaryPatchi) const
Return true if patchi on the primary region is a coupled.
Definition: regionModelI.H:155
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:37
wordList interRegionAMINames_
List of region names this region is coupled to.
Definition: regionModel.H:130
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:549
virtual void info()
Provide some feedback.
Definition: regionModel.C:561
const Switch & active() const
Return the active flag.
Definition: regionModelI.H:43
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
label regionPatchID(const label primaryPatchID) const
Return region ID corresponding to primaryPatchID.
Definition: regionModelI.H:186
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:138
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:102
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
TypeName("regionModel")
Runtime type information.
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
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
Definition: regionModel.H:108
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
const dictionary & coeffs() const
Return the model coefficients dictionary.
Definition: regionModelI.H:96
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.
dynamicFvMesh & mesh
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:543
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:171
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:555
const word & modelName() const
Return the model name.
Definition: regionModelI.H:55
label nbrCoupledPatchID(const regionModel &nbrRegion, const label regionPatchi) const
Return the coupled patch ID paired with coupled patch.
Definition: regionModel.C:303
Switch infoOutput_
Active information output.
Definition: regionModel.H:96
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
Definition: regionModelI.H:110
void toRegion(const label regionPatchi, List< Type > &primaryFieldField) const
Convert a primary region field to the local region.
Switch active_
Active flag.
Definition: regionModel.H:93
const labelList & primaryPatchIDs() const
Return the list of patch IDs on the primary region coupled.
Definition: regionModelI.H:172
PtrList< PtrList< AMIPatchToPatchInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:134
virtual ~regionModel()
Destructor.
Definition: regionModel.C:501
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:105
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.
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:62
const Time & time_
Reference to the time database.
Definition: regionModel.H:90
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:124
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:507
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:216
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:179
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
Definition: regionModel.H:117
A class for managing temporary objects.
Definition: PtrList.H:54
const fvMesh & primaryMesh() const
Return the reference to the primary mesh database.
Definition: regionModelI.H:31
word regionName_
Region name.
Definition: regionModel.H:121
const Switch & infoOutput() const
Return the information flag.
Definition: regionModelI.H:49
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:114
Namespace for OpenFOAM.