MRFZoneList.C
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) 2012-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "MRFZoneList.H"
27 #include "volFields.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const fvMesh& mesh
35 )
36 :
37  PtrList<MRFZone>(),
38  mesh_(mesh)
39 {}
40 
41 
43 (
44  const fvMesh& mesh,
45  const dictionary& dict
46 )
47 :
49 {
50  reset(dict);
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55 
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 
63 {
64  printDictionary print(dict);
65 
66  label count = 0;
68  {
69  if (iter().isDict())
70  {
71  count++;
72  }
73  }
74 
75  if (count)
76  {
77  Info<< indentOrNl << "MRF zone list" << endl;
78  }
79 
80  this->setSize(count);
81  label i = 0;
83  {
84  if (iter().isDict())
85  {
86  const word& name = iter().keyword();
87  const dictionary& modelDict = iter().dict();
88 
89  printDictionary print(modelDict);
90  Info<< indent << "Constructing MRF zone " << name << endl;
91  this->set
92  (
93  i++,
94  new MRFZone(name, mesh_, modelDict)
95  );
96  }
97  }
98 }
99 
100 
102 {
103  bool allOk = true;
104  forAll(*this, i)
105  {
106  MRFZone& pm = this->operator[](i);
107  bool ok = pm.read(dict.subDict(pm.name()));
108  allOk = (allOk && ok);
109  }
110  return allOk;
111 }
112 
113 
115 (
116  const volVectorField& U
117 ) const
118 {
120  (
122  (
123  "MRFZoneList:DDt",
124  U.mesh(),
125  dimensionedVector(U.dimensions()/dimTime, Zero)
126  )
127  );
128  volVectorField& DDt = tDDt.ref();
129 
130  forAll(*this, i)
131  {
132  operator[](i).addCoriolis(U, DDt);
133  }
134 
135  return tDDt;
136 }
137 
138 
140 (
141  const volScalarField& rho,
142  const volVectorField& U
143 ) const
144 {
145  return rho*DDt(U);
146 }
147 
148 
151 {
152  tmp<volVectorField> tcentrifugalAcceleration
153  (
155  (
156  "MRFZoneList:centrifugalAcceleration",
157  mesh_,
159  )
160  );
161  volVectorField& centrifugalAcceleration = tcentrifugalAcceleration.ref();
162 
163  forAll(*this, i)
164  {
165  operator[](i).addCentrifugalAcceleration(centrifugalAcceleration);
166  }
167 
168  return tcentrifugalAcceleration;
169 }
170 
171 
172 
174 {
175  forAll(*this, i)
176  {
177  operator[](i).makeRelative(U);
178  }
179 }
180 
181 
183 {
184  forAll(*this, i)
185  {
186  operator[](i).makeRelative(phi);
187  }
188 }
189 
190 
192 (
193  const tmp<surfaceScalarField>& tphi
194 ) const
195 {
196  if (size())
197  {
199  (
200  New
201  (
202  tphi,
203  "relative(" + tphi().name() + ')',
204  tphi().dimensions(),
205  true
206  )
207  );
208 
209  makeRelative(rphi.ref());
210 
211  tphi.clear();
212 
213  return rphi;
214  }
215  else
216  {
217  return tmp<surfaceScalarField>(tphi, true);
218  }
219 }
220 
221 
224 (
226 ) const
227 {
228  if (size())
229  {
231 
232  forAll(*this, i)
233  {
234  operator[](i).makeRelative(rphi.ref());
235  }
236 
237  tphi.clear();
238 
239  return rphi;
240  }
241  else
242  {
244  }
245 }
246 
247 
250 (
251  const tmp<Field<scalar>>& tphi,
252  const label patchi
253 ) const
254 {
255  if (size())
256  {
257  tmp<Field<scalar>> rphi(New(tphi, true));
258 
259  forAll(*this, i)
260  {
261  operator[](i).makeRelative(rphi.ref(), patchi);
262  }
263 
264  tphi.clear();
265 
266  return rphi;
267  }
268  else
269  {
270  return tmp<Field<scalar>>(tphi, true);
271  }
272 }
273 
274 
276 (
277  const surfaceScalarField& rho,
278  surfaceScalarField& phi
279 ) const
280 {
281  forAll(*this, i)
282  {
283  operator[](i).makeRelative(rho, phi);
284  }
285 }
286 
287 
289 {
290  forAll(*this, i)
291  {
292  operator[](i).makeAbsolute(U);
293  }
294 }
295 
296 
298 {
299  forAll(*this, i)
300  {
301  operator[](i).makeAbsolute(phi);
302  }
303 }
304 
305 
307 (
308  const tmp<surfaceScalarField>& tphi
309 ) const
310 {
311  if (size())
312  {
314  (
315  New
316  (
317  tphi,
318  "absolute(" + tphi().name() + ')',
319  tphi().dimensions(),
320  true
321  )
322  );
323 
324  makeAbsolute(rphi.ref());
325 
326  tphi.clear();
327 
328  return rphi;
329  }
330  else
331  {
332  return tmp<surfaceScalarField>(tphi, true);
333  }
334 }
335 
336 
338 (
339  const surfaceScalarField& rho,
340  surfaceScalarField& phi
341 ) const
342 {
343  forAll(*this, i)
344  {
345  operator[](i).makeAbsolute(rho, phi);
346  }
347 }
348 
349 
351 (
352  const tmp<surfaceScalarField>& tphi,
353  const volScalarField& rho
354 ) const
355 {
356  if (size())
357  {
359  (
360  New
361  (
362  tphi,
363  "absolute(" + tphi().name() + ')',
364  tphi().dimensions(),
365  true
366  )
367  );
368 
370 
371  tphi.clear();
372 
373  return rphi;
374  }
375  else
376  {
377  return tmp<surfaceScalarField>(tphi, true);
378  }
379 }
380 
381 
383 {
384  if (mesh_.topoChanged())
385  {
386  forAll(*this, i)
387  {
388  operator[](i).update();
389  }
390  }
391 }
392 
393 
394 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:492
Generic field type.
Definition: FieldField.H:77
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
List container for MRF zones.
Definition: MRFZoneList.H:55
tmp< surfaceScalarField > relative(const tmp< surfaceScalarField > &phi) const
Return the given absolute flux relative within the MRF region.
Definition: MRFZoneList.C:192
void reset(const dictionary &dict)
Reset the source list.
Definition: MRFZoneList.C:62
MRFZoneList(const fvMesh &mesh)
Construct an empty list.
Definition: MRFZoneList.C:33
tmp< volVectorField > centrifugalAcceleration() const
Return the centrifugal acceleration.
Definition: MRFZoneList.C:150
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &phi) const
Return the given relative flux absolute within the MRF region.
Definition: MRFZoneList.C:307
bool read(const dictionary &dict)
Read dictionary.
Definition: MRFZoneList.C:101
void makeAbsolute(volVectorField &U) const
Make the given relative velocity absolute within the MRF region.
Definition: MRFZoneList.C:288
void makeRelative(volVectorField &U) const
Make the given absolute velocity relative within the MRF region.
Definition: MRFZoneList.C:173
void update()
Update MRFZone faces if the mesh topology changes.
Definition: MRFZoneList.C:382
~MRFZoneList()
Destructor.
Definition: MRFZoneList.C:56
tmp< volVectorField > DDt(const volVectorField &U) const
Return the Coriolis acceleration.
Definition: MRFZoneList.C:115
MRF zone definition based on cell zone and parameters obtained from a control dictionary constructed ...
Definition: MRFZone.H:56
bool read(const dictionary &dict)
Read MRF dictionary.
Definition: MRFZone.C:365
const word & name() const
Return const access to the MRF region name.
Definition: MRFZoneI.H:26
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:778
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Enables the printing of a dictionary and subsequently looked-up defaulted entries.
A class for managing temporary objects.
Definition: tmp.H:55
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:253
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
label patchi
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
tmp< VolField< Type > > DDt(const surfaceScalarField &phi, const VolField< Type > &psi)
Definition: fvcDDt.C:45
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
void makeAbsolute(surfaceScalarField &phi, const volVectorField &U)
Make the given flux absolute.
Definition: fvcMeshPhi.C:128
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:89
static const zero Zero
Definition: zero.H:97
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
const dimensionSet & dimTime
Definition: dimensions.C:142
const dimensionSet & dimAcceleration
Definition: dimensions.C:156
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:243
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
points setSize(newPointi)
dictionary dict