liquidFilmBase.C
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) 2020-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "liquidFilmBase.H"
29 #include "faMesh.H"
30 #include "gravityMeshObject.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 namespace regionModels
41 {
42 namespace areaSurfaceFilmModels
43 {
44 
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
46 
47 defineTypeNameAndDebug(liquidFilmBase, 0);
48 
50 
51 const Foam::word liquidFilmName("liquidFilm");
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
56 (
57  const word& modelType,
58  const fvMesh& mesh,
59  const dictionary& dict
60 )
61 :
62  regionFaModel(mesh, liquidFilmName, modelType, dict, true),
63 
64  momentumPredictor_
65  (
66  this->solution().subDict("PIMPLE").get<bool>("momentumPredictor")
67  ),
68  nOuterCorr_
69  (
70  this->solution().subDict("PIMPLE").get<label>("nOuterCorr")
71  ),
72  nCorr_(this->solution().subDict("PIMPLE").get<label>("nCorr")),
73  nFilmCorr_
74  (
75  this->solution().subDict("PIMPLE").get<label>("nFilmCorr")
76  ),
77 
78  h0_("h0", dimLength, 1e-7, dict),
79 
80  deltaWet_("deltaWet", dimLength, 1e-4, dict),
81 
82  UName_(dict.get<word>("U")),
83 
84  pName_(dict.getOrDefault<word>("p", word::null)),
85 
86  pRef_(dict.get<scalar>("pRef")),
87 
88  h_
89  (
90  IOobject
91  (
92  "hf_" + regionName_,
93  regionMesh().time().timeName(),
94  regionMesh().thisDb(),
95  IOobject::MUST_READ,
96  IOobject::AUTO_WRITE
97  ),
98  regionMesh()
99  ),
100 
101  Uf_
102  (
103  IOobject
104  (
105  "Uf_" + regionName_,
106  regionMesh().time().timeName(),
107  regionMesh().thisDb(),
108  IOobject::MUST_READ,
109  IOobject::AUTO_WRITE
110  ),
111  regionMesh()
112  ),
113  pf_
114  (
115  IOobject
116  (
117  "pf_" + regionName_,
118  regionMesh().time().timeName(),
119  regionMesh().thisDb(),
120  IOobject::NO_READ,
121  IOobject::AUTO_WRITE
122  ),
123  regionMesh(),
125  ),
126  ppf_
127  (
128  IOobject
129  (
130  "ppf_" + regionName_,
131  regionMesh().time().timeName(),
132  regionMesh().thisDb(),
133  IOobject::NO_READ,
134  IOobject::NO_WRITE
135  ),
136  regionMesh(),
138  ),
139  phif_
140  (
141  IOobject
142  (
143  "phif_" + regionName_,
144  regionMesh().time().timeName(),
145  regionMesh().thisDb(),
146  IOobject::READ_IF_PRESENT,
147  IOobject::AUTO_WRITE
148  ),
149  fac::interpolate(Uf_) & regionMesh().Le()
150  ),
151 
152  phi2s_
153  (
154  IOobject
155  (
156  "phi2s_" + regionName_,
157  regionMesh().time().timeName(),
158  regionMesh().thisDb(),
159  IOobject::READ_IF_PRESENT,
160  IOobject::AUTO_WRITE
161  ),
162  fac::interpolate(h_*Uf_) & regionMesh().Le()
163  ),
164 
165  gn_
166  (
167  IOobject
168  (
169  "gn",
170  regionMesh().time().timeName(),
171  regionMesh().thisDb(),
172  IOobject::NO_READ,
173  IOobject::NO_WRITE
174  ),
175  regionMesh(),
177  ),
178 
179  g_(meshObjects::gravity::New(primaryMesh().time())),
180 
181  massSource_
182  (
183  IOobject
184  (
185  "massSource",
186  primaryMesh().time().timeName(),
187  primaryMesh().thisDb()
188  ),
189  primaryMesh(),
191  ),
192 
193  momentumSource_
194  (
195  IOobject
196  (
197  "momentumSource",
198  primaryMesh().time().timeName(),
199  primaryMesh().thisDb()
200  ),
201  primaryMesh(),
203  ),
204 
205  pnSource_
206  (
207  IOobject
208  (
209  "pnSource",
210  primaryMesh().time().timeName(),
211  primaryMesh().thisDb()
212  ),
213  primaryMesh(),
215  ),
216 
217  energySource_
218  (
219  IOobject
220  (
221  "energySource",
222  primaryMesh().time().timeName(),
223  primaryMesh().thisDb()
224  ),
225  primaryMesh(),
227  ),
228 
229  addedMassTotal_(0),
230 
231  faOptions_(Foam::fa::options::New(primaryMesh()))
232 {
234 
235  gn_ = g_ & ns;
236 
237  if (!faOptions_.optionList::size())
238  {
239  Info << "No finite area options present" << endl;
240  }
241 }
242 
243 
244 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
247 {}
248 
249 
250 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
251 
252 scalar liquidFilmBase::CourantNumber() const
253 {
254  scalar CoNum = 0.0;
255  scalar velMag = 0.0;
256 
257  edgeScalarField SfUfbyDelta
258  (
260  );
261 
262  CoNum =
263  max(SfUfbyDelta/regionMesh().magLe()).value()*time().deltaTValue();
264 
265  velMag = max(mag(phif_)/regionMesh().magLe()).value();
266 
269 
270  Info<< "Max film Courant Number: " << CoNum
271  << " Film velocity magnitude: " << velMag << endl;
272 
273  return CoNum;
274 }
275 
276 
278 {
280  (
281  new areaVectorField
282  (
283  IOobject
284  (
285  "tUw",
286  regionMesh().time().timeName(),
287  regionMesh().thisDb()
288  ),
289  regionMesh(),
291  )
292  );
293  auto& Uw = tUw.ref();
294 
295  if (primaryMesh().moving())
296  {
298 
299  // Set up mapping values per patch
300 
301  PtrMap<vectorField> patchValues(2*patches.size());
302 
303  for (const label patchi : patches)
304  {
305  const auto* wpp = isA<movingWallVelocityFvPatchVectorField>
306  (
307  primaryMesh().boundaryMesh()[patchi]
308  );
309 
310  if (wpp)
311  {
312  patchValues.set(patchi, wpp->Uwall());
313  }
314  }
315 
316  if (patchValues.size())
317  {
318  // Map Up to area
319  tmp<vectorField> UsWall = vsmPtr_->mapToSurface(patchValues);
320 
321  const vectorField& nHat =
323 
324  Uw.primitiveFieldRef() = UsWall() - nHat*(UsWall() & nHat);
325  }
326  }
327 
328  return tUw;
329 }
330 
331 
333 {
335  (
336  new areaVectorField
337  (
338  IOobject
339  (
340  "tUs",
341  regionMesh().time().timeName(),
342  regionMesh().thisDb()
343  ),
344  regionMesh(),
346  )
347  );
348 
349  // Uf quadratic profile
350  tUs.ref() = Foam::sqrt(2.0)*Uf_;
351 
352  return tUs;
353 }
354 
355 
357 {
358  const volVectorField& Uprimary =
360 
362  (
363  new areaVectorField
364  (
365  IOobject
366  (
367  "tUp",
368  regionMesh().time().timeName(),
369  regionMesh().thisDb()
370  ),
371  regionMesh(),
373  )
374  );
375  areaVectorField& Up = tUp.ref();
376 
377 
378  // Set up mapping values per patch
379 
381 
382  PtrMap<vectorField> patchValues(2*patches.size());
383 
384  // U tangential on primary
385  for (const label patchi : patches)
386  {
387  const fvPatchVectorField& Uw = Uprimary.boundaryField()[patchi];
388 
389  patchValues.set(patchi, -Uw.snGrad());
390  }
391 
392 
393  // Map U tang to surface
394  vsmPtr_->mapToSurface(patchValues, Up.primitiveFieldRef());
395 
396  Up.primitiveFieldRef() *= h_.primitiveField();
397 
398  // U tangent on surface
401  Up.primitiveFieldRef() -= nHat*(Up.primitiveField() & nHat);
402 
403  return tUp;
404 }
405 
406 
408 {
410  (
411  new areaScalarField
412  (
413  IOobject
414  (
415  "tpg",
416  regionMesh().time().timeName(),
417  regionMesh().thisDb()
418  ),
419  regionMesh(),
421  )
422  );
423  auto& pfg = tpg.ref();
424 
425  if (!pName_.empty())
426  {
427  vsmPtr_->mapInternalToSurface
428  (
429  primaryMesh().lookupObject<volScalarField>(pName_),
430  pfg.primitiveFieldRef()
431  );
432 
433  //pfg -= pRef_;
434  }
435 
436  return tpg;
437 }
438 
439 
441 {
442  tmp<areaScalarField> talpha
443  (
444  new areaScalarField
445  (
446  IOobject
447  (
448  "talpha",
449  regionMesh().time().timeName(),
450  regionMesh().thisDb()
451  ),
452  regionMesh(),
454  )
455  );
456  auto& alpha = talpha.ref();
457 
459 
460  return talpha;
461 }
462 
463 
465 (
466  const label patchi,
467  const label facei,
468  const scalar massSource,
469  const vector& momentumSource,
470  const scalar pressureSource,
471  const scalar energySource
472 )
473 {
474  massSource_.boundaryFieldRef()[patchi][facei] += massSource;
475  pnSource_.boundaryFieldRef()[patchi][facei] += pressureSource;
476  momentumSource_.boundaryFieldRef()[patchi][facei] += momentumSource;
477 }
478 
481 {
483 }
484 
485 
487 {
488  if (debug && primaryMesh().time().writeTime())
489  {
490  massSource_.write();
491  pnSource_.write();
493  }
494 
498 
500 }
501 
504 {
505  return faOptions_;
506 }
507 
509 const areaVectorField& liquidFilmBase::Uf() const
510 {
511  return Uf_;
512 }
513 
515 const areaScalarField& liquidFilmBase::gn() const
516 {
517  return gn_;
518 }
519 
522 {
523  return g_;
524 }
525 
527 const areaScalarField& liquidFilmBase::h() const
528 {
529  return h_;
530 }
531 
534 {
535  return phif_;
536 }
537 
540 {
541  return phi2s_;
542 }
543 
546 {
547  return h0_;
548 }
549 
552 {
553  return *this;
554 }
555 
557 scalar liquidFilmBase::pRef()
558 {
559  return pRef_;
560 }
561 
562 
564 {
565  return UName_;
566 }
567 
568 
569 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
570 
571 } // End namespace areaSurfaceFilmModels
572 } // End namespace regionModels
573 } // End namespace Foam
574 
575 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
const edgeScalarField & deltaCoeffs() const
Return reference to difference factors array.
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
Calculate the second temporal derivative.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
scalar deltaTValue() const noexcept
Return time step value.
Definition: TimeStateI.H:49
const edgeScalarField & phif() const
Access to momentum flux.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const areaScalarField & h() const
Access const reference h.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Foam::fa::options & faOptions()
Return faOptions.
tmp< areaVectorField > Up() const
Primary region velocity at film hight. Assume the film to be.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
dimensionedScalar h0_
Smallest numerical thickness.
virtual void postEvolveRegion()
Post-evolve region.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
A HashTable of pointers to objects of type <T> with a label key.
Definition: HashTableFwd.H:42
const labelList & whichPolyPatches() const
The polyPatches related to the areaMesh, in sorted order.
Definition: faMeshI.H:135
tmp< areaScalarField > pg() const
Map primary static pressure.
const uniformDimensionedVectorField & g() const
Gravity.
const dimensionSet dimless
Dimensionless.
virtual scalar CourantNumber() const
Courant number evaluation.
defineTypeNameAndDebug(kinematicThinFilm, 0)
liquidFilmBase(const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from type name and mesh and dict.
volScalarField pnSource_
Normal pressure by particles.
word timeName
Definition: getTimeIndex.H:3
const dimensionSet dimAcceleration
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
const dimensionedScalar & h0() const
Return h0.
dynamicFvMesh & mesh
Finite-area options.
Definition: faOptions.H:50
defineRunTimeSelectionTable(liquidFilmBase, dictionary)
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:608
A class for handling words, derived from Foam::string.
Definition: word.H:63
const areaVectorField & Uf() const
Access const reference Uf.
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
bool set(const Key &key, T *ptr)
Assign a new entry, overwrites existing.
const fvMesh & primaryMesh() const noexcept
Return the reference to the primary mesh database.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
const faMesh & regionMesh() const
Return the region mesh database.
const edgeScalarField & phi2s() const
Access continuity flux.
const dimensionSet dimPressure
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: PtrList.H:159
tmp< areaVectorField > Us() const
Film surface film velocity.
scalar CoNum
virtual void preEvolveRegion()
Pre-evolve region.
dimensionedScalar pos0(const dimensionedScalar &ds)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
Base class for area region models.
const dimensionSet dimEnergy
const Foam::word liquidFilmName("liquidFilm")
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const areaScalarField & gn() const
Access const reference gn.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const polyBoundaryMesh & patches
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
dimensionedScalar deltaWet_
Delta wet for sub-models.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const Time & time() const noexcept
Return the reference to the time database.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:92
tmp< areaVectorField > Uw() const
Wall velocity.
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
A class for managing temporary objects.
Definition: HashPtrTable.H:50
tmp< areaScalarField > alpha() const
Wet indicator using h0.
scalar velMag
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
const areaVectorField & faceAreaNormals() const
Return face area normals.
Definition: faMesh.C:964
const regionFaModel & region() const
Access to this region.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
autoPtr< volSurfaceMapping > vsmPtr_
Volume/surface mapping.
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127
const dimensionSet dimVelocity
virtual void addSources(const label patchi, const label facei, const scalar massSource, const vector &momentumSource, const scalar pressureSource, const scalar energySource=0)
Add sources.