SurfaceFilmModel.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) 2011-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 "SurfaceFilmModel.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 #include "meshSearch.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 :
37  g_(owner.g()),
38  ejectedParcelType_(0),
39  massParcelPatch_(0),
40  diameterParcelPatch_(0),
41  deltaFilmPatch_(0),
42  nParcelsTransferred_(0),
43  nParcelsInjected_(0)
44 {}
45 
46 
47 template<class CloudType>
49 (
50  const dictionary& dict,
51  CloudType& owner,
52  const word& type
53 )
54 :
56  g_(owner.g()),
57  ejectedParcelType_
58  (
59  this->typeDict().lookupOrDefault("ejectedParcelType", -1)
60  ),
61  massParcelPatch_(0),
62  diameterParcelPatch_(0),
63  deltaFilmPatch_(),
64  nParcelsTransferred_(0),
65  nParcelsInjected_(0)
66 {}
67 
68 
69 template<class CloudType>
71 (
73 )
74 :
76  g_(sfm.g_),
77  ejectedParcelType_(sfm.ejectedParcelType_),
78  massParcelPatch_(sfm.massParcelPatch_),
79  diameterParcelPatch_(sfm.diameterParcelPatch_),
80  deltaFilmPatch_(sfm.deltaFilmPatch_),
81  nParcelsTransferred_(sfm.nParcelsTransferred_),
82  nParcelsInjected_(sfm.nParcelsInjected_)
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
87 
88 template<class CloudType>
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class CloudType>
96 template<class TrackCloudType>
98 {
99  const meshSearch& searchEngine = meshSearch::New(this->owner().mesh());
100 
101  const labelList& filmPatches = this->filmPatches();
102 
103  forAll(filmPatches, filmi)
104  {
105  const label filmPatchi = filmPatches[filmi];
106 
107  const fvMesh& mesh = this->owner().mesh();
108  const polyBoundaryMesh& pbm = mesh.poly().boundary();
109 
110  const labelList& injectorCellsPatch = pbm[filmPatchi].faceCells();
111 
112  // Get and cache the properties of the droplets ejected from the film
113  cacheFilmFields(filmi);
114 
115  const vectorField& Cf = mesh.C().boundaryField()[filmPatchi];
116  const vectorField& Sf = mesh.Sf().boundaryField()[filmPatchi];
117  const scalarField& magSf = mesh.magSf().boundaryField()[filmPatchi];
118 
119  label nLocateBoundaryHits = 0;
120 
121  if (massParcelPatch_.size())
122  {
123  forAll(injectorCellsPatch, j)
124  {
125  if (massParcelPatch_[j] > 0)
126  {
127  const label celli = injectorCellsPatch[j];
128 
129  const scalar offset = max
130  (
131  diameterParcelPatch_[j],
132  deltaFilmPatch_[j]
133  );
134 
135  const point pos = Cf[j] - 1.1*offset*Sf[j]/magSf[j];
136 
137  // Create a new parcel
138  parcelType* pPtr =
139  new parcelType
140  (
141  searchEngine,
142  pos,
143  celli,
144  nLocateBoundaryHits
145  );
146 
147  // Check/set new parcel thermo properties
148  cloud.setParcelThermoProperties(*pPtr);
149 
150  setParcelProperties(*pPtr, j);
151 
152  if (pPtr->nParticle() > 0.001)
153  {
154  // Check new parcel properties
155  cloud.checkParcelProperties(*pPtr, -1);
156 
157  // Add the new parcel to the cloud
158  cloud.addParticle(pPtr);
159 
160  nParcelsInjected_++;
161  }
162  else
163  {
164  // TODO: cache mass and re-distribute?
165  delete pPtr;
166  }
167  }
168  }
169  }
170 
171  reduce(nLocateBoundaryHits, sumOp<label>());
172  if (nLocateBoundaryHits != 0)
173  {
175  << "Injection by surface film model for cloud "
176  << this->owner().name()
177  << " on patch " << pbm[filmPatchi].name()
178  << " did not accurately locate " << nLocateBoundaryHits
179  << " particles" << endl;
180  }
181  }
182 }
183 
184 
185 template<class CloudType>
187 {
188  label nTrans0 =
189  this->template getModelProperty<label>("nParcelsTransferred");
190 
191  label nInject0 =
192  this->template getModelProperty<label>("nParcelsInjected");
193 
194  label nTransTotal =
195  nTrans0 + returnReduce(nParcelsTransferred_, sumOp<label>());
196 
197  label nInjectTotal =
198  nInject0 + returnReduce(nParcelsInjected_, sumOp<label>());
199 
200  os << " Parcels absorbed into film = " << nTransTotal << nl
201  << " New film detached parcels = " << nInjectTotal << endl;
202 
203  if (this->writeTime())
204  {
205  this->setModelProperty("nParcelsTransferred", nTransTotal);
206  this->setModelProperty("nParcelsInjected", nInjectTotal);
207  nParcelsTransferred_ = 0;
208  nParcelsInjected_ = 0;
209  }
210 }
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #include "SurfaceFilmModelNew.C"
216 
217 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Base class for cloud sub-models.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const word & name() const
Return name.
Definition: IOobject.H:307
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Templated wall surface film model class.
void inject(TrackCloudType &cloud)
Inject parcels into the cloud.
virtual void info(Ostream &os)
Write surface film info to stream.
virtual ~SurfaceFilmModel()
Destructor.
SurfaceFilmModel(CloudType &owner)
Construct null from owner.
CloudType::parcelType parcelType
Convenience typedef to the cloud's parcel type.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const volVectorField & C() const
Return cell centres.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
const polyMesh & poly() const
Return reference to polyMesh.
Definition: fvMesh.H:456
Mesh object that implements searches within the local cells and faces.
Definition: meshSearch.H:59
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Definition: meshSearch.C:61
Foam::polyBoundaryMesh.
const polyBoundaryMesh & boundary() const
Return boundary mesh.
Definition: polyMesh.H:393
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
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)
#define WarningInFunction
Report a warning using Foam::Warning.
dimensionedScalar pos(const dimensionedScalar &ds)
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
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void offset(label &lst, const label o)
static const char nl
Definition: Ostream.H:297
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict
Foam::surfaceFields.