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-2022 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.lookupOrDefault<word>("p", word::null)),
85 
86  pRef_(dict.get<scalar>("pRef")),
87 
88  h_
89  (
90  IOobject
91  (
92  "hf_" + regionName_,
93  primaryMesh().time().timeName(),
94  primaryMesh(),
95  IOobject::MUST_READ,
96  IOobject::AUTO_WRITE
97  ),
98  regionMesh()
99  ),
100 
101  Uf_
102  (
103  IOobject
104  (
105  "Uf_" + regionName_,
106  primaryMesh().time().timeName(),
107  primaryMesh(),
108  IOobject::MUST_READ,
109  IOobject::AUTO_WRITE
110  ),
111  regionMesh()
112  ),
113  pf_
114  (
115  IOobject
116  (
117  "pf_" + regionName_,
118  primaryMesh().time().timeName(),
119  primaryMesh(),
120  IOobject::NO_READ,
121  IOobject::AUTO_WRITE
122  ),
123  regionMesh(),
125  ),
126  ppf_
127  (
128  IOobject
129  (
130  "ppf_" + regionName_,
131  primaryMesh().time().timeName(),
132  primaryMesh(),
133  IOobject::NO_READ,
134  IOobject::NO_WRITE
135  ),
136  regionMesh(),
138  ),
139  phif_
140  (
141  IOobject
142  (
143  "phif_" + regionName_,
144  primaryMesh().time().timeName(),
145  primaryMesh(),
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  primaryMesh().time().timeName(),
158  primaryMesh(),
159  IOobject::READ_IF_PRESENT,
160  IOobject::AUTO_WRITE
161  ),
162  fac::interpolate(h_*Uf_) & regionMesh().Le()
163  ),
164 
165 
166  gn_
167  (
168  IOobject
169  (
170  "gn",
171  primaryMesh().time().timeName(),
172  primaryMesh(),
173  IOobject::NO_READ,
174  IOobject::NO_WRITE
175  ),
176  regionMesh(),
178  ),
179 
180  g_(meshObjects::gravity::New(primaryMesh().time())),
181 
182  massSource_
183  (
184  IOobject
185  (
186  "massSource",
187  primaryMesh().time().timeName(),
188  primaryMesh()
189  ),
190  primaryMesh(),
192  ),
193 
194  momentumSource_
195  (
196  IOobject
197  (
198  "momentumSource",
199  primaryMesh().time().timeName(),
200  primaryMesh()
201  ),
202  primaryMesh(),
204  ),
205 
206  pnSource_
207  (
208  IOobject
209  (
210  "pnSource",
211  primaryMesh().time().timeName(),
212  primaryMesh()
213  ),
214  primaryMesh(),
216  ),
217 
218  energySource_
219  (
220  IOobject
221  (
222  "energySource",
223  primaryMesh().time().timeName(),
224  primaryMesh()
225  ),
226  primaryMesh(),
228  ),
229 
230  addedMassTotal_(0),
231 
232  faOptions_(Foam::fa::options::New(primaryMesh()))
233 {
235 
236  gn_ = g_ & ns;
237 
238  if (!faOptions_.optionList::size())
239  {
240  Info << "No finite area options present" << endl;
241  }
242 }
243 
244 
245 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
248 {}
249 
250 
251 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
252 
253 scalar liquidFilmBase::CourantNumber() const
254 {
255  scalar CoNum = 0.0;
256  scalar velMag = 0.0;
257 
258  edgeScalarField SfUfbyDelta
259  (
261  );
262 
263  CoNum =
264  max(SfUfbyDelta/regionMesh().magLe()).value()*time().deltaT().value();
265 
266  velMag = max(mag(phif_)/regionMesh().magLe()).value();
267 
270 
271  Info<< "Max film Courant Number: " << CoNum
272  << " Film velocity magnitude: " << velMag << endl;
273 
274  return CoNum;
275 }
276 
277 
279 {
281  (
282  new areaVectorField
283  (
284  IOobject
285  (
286  "tUw",
287  primaryMesh().time().timeName(),
288  primaryMesh()
289  ),
290  regionMesh(),
292  )
293  );
294  auto& Uw = tUw.ref();
295 
296  if (primaryMesh().moving())
297  {
299 
300  // Set up mapping values per patch
301 
302  PtrMap<vectorField> patchValues(2*patches.size());
303 
304  for (const label patchi : patches)
305  {
306  const auto* wpp = isA<movingWallVelocityFvPatchVectorField>
307  (
308  primaryMesh().boundaryMesh()[patchi]
309  );
310 
311  if (wpp)
312  {
313  patchValues.set(patchi, wpp->Uwall());
314  }
315  }
316 
317  if (patchValues.size())
318  {
319  // Map Up to area
320  tmp<vectorField> UsWall = vsmPtr_->mapToSurface(patchValues);
321 
322  const vectorField& nHat =
324 
325  Uw.primitiveFieldRef() = UsWall() - nHat*(UsWall() & nHat);
326  }
327  }
328 
329  return tUw;
330 }
331 
332 
334 {
336  (
337  new areaVectorField
338  (
339  IOobject
340  (
341  "tUs",
342  primaryMesh().time().timeName(),
343  primaryMesh()
344  ),
345  regionMesh(),
347  )
348  );
349 
350  // Uf quadratic profile
351  tUs.ref() = Foam::sqrt(2.0)*Uf_;
352 
353  return tUs;
354 }
355 
356 
358 {
359  const volVectorField& Uprimary =
361 
363  (
364  new areaVectorField
365  (
366  IOobject
367  (
368  "tUp",
369  primaryMesh().time().timeName(),
370  primaryMesh()
371  ),
372  regionMesh(),
374  )
375  );
376  areaVectorField& Up = tUp.ref();
377 
378 
379  // Set up mapping values per patch
380 
382 
383  PtrMap<vectorField> patchValues(2*patches.size());
384 
385  // U tangential on primary
386  for (const label patchi : patches)
387  {
388  const fvPatchVectorField& Uw = Uprimary.boundaryField()[patchi];
389 
390  patchValues.set(patchi, -Uw.snGrad());
391  }
392 
393 
394  // Map U tang to surface
395  vsmPtr_->mapToSurface(patchValues, Up.primitiveFieldRef());
396 
397  Up.primitiveFieldRef() *= h_.primitiveField();
398 
399  // U tangent on surface
402  Up.primitiveFieldRef() -= nHat*(Up.primitiveField() & nHat);
403 
404  return tUp;
405 }
406 
407 
409 {
411  (
412  new areaScalarField
413  (
414  IOobject
415  (
416  "tpg",
417  primaryMesh().time().timeName(),
418  primaryMesh()
419  ),
420  regionMesh(),
422  )
423  );
424  auto& pfg = tpg.ref();
425 
426  if (!pName_.empty())
427  {
428  vsmPtr_->mapInternalToSurface
429  (
430  primaryMesh().lookupObject<volScalarField>(pName_),
431  pfg.primitiveFieldRef()
432  );
433 
434  //pfg -= pRef_;
435  }
436 
437  return tpg;
438 }
439 
440 
442 {
443  tmp<areaScalarField> talpha
444  (
445  new areaScalarField
446  (
447  IOobject
448  (
449  "talpha",
450  primaryMesh().time().timeName(),
451  primaryMesh()
452  ),
453  regionMesh(),
455  )
456  );
457  auto& alpha = talpha.ref();
458 
460 
461  return talpha;
462 }
463 
464 
466 (
467  const label patchi,
468  const label facei,
469  const scalar massSource,
470  const vector& momentumSource,
471  const scalar pressureSource,
472  const scalar energySource
473 )
474 {
475  massSource_.boundaryFieldRef()[patchi][facei] += massSource;
476  pnSource_.boundaryFieldRef()[patchi][facei] += pressureSource;
477  momentumSource_.boundaryFieldRef()[patchi][facei] += momentumSource;
478 }
479 
482 {
484 }
485 
486 
488 {
489  if (debug && primaryMesh().time().writeTime())
490  {
491  massSource_.write();
492  pnSource_.write();
494  }
495 
499 
501 }
502 
505 {
506  return faOptions_;
507 }
508 
510 const areaVectorField& liquidFilmBase::Uf() const
511 {
512  return Uf_;
513 }
514 
516 const areaScalarField& liquidFilmBase::gn() const
517 {
518  return gn_;
519 }
520 
523 {
524  return g_;
525 }
526 
528 const areaScalarField& liquidFilmBase::h() const
529 {
530  return h_;
531 }
532 
535 {
536  return phif_;
537 }
538 
541 {
542  return phi2s_;
543 }
544 
547 {
548  return h0_;
549 }
550 
553 {
554  return *this;
555 }
556 
558 scalar liquidFilmBase::pRef()
559 {
560  return pRef_;
561 }
562 
563 
565 {
566  return UName_;
567 }
568 
569 
570 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
571 
572 } // End namespace areaSurfaceFilmModels
573 } // End namespace regionModels
574 } // End namespace Foam
575 
576 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
const Type & value() const noexcept
Return const reference to value.
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.
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:120
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:244
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:487
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:147
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:584
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:113
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:79
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:59
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:171
const areaVectorField & faceAreaNormals() const
Return face area normals.
Definition: faMesh.C:908
const regionFaModel & region() const
Access to this region.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
dimensionedScalar deltaT() const
Return time step.
Definition: TimeStateI.H:48
autoPtr< volSurfaceMapping > vsmPtr_
Volume/surface mapping.
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:133
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.