BlendedInterfacialModel.H
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) 2014-2025 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::BlendedInterfacialModel
26 
27 Description
28  Wrapper class for interfacial models for which multiple instances of the
29  model are used for different configurations of the interface; e.g.,
30  bubbles, droplets, segregated flow, displaced by another phase, ... The
31  values generated by these multiple models are then "blended" to create a
32  single effective coefficient or source.
33 
34 SourceFiles
35  BlendedInterfacialModel.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef BlendedInterfacialModel_H
40 #define BlendedInterfacialModel_H
41 
42 #include "blendingMethod.H"
43 #include "HashPtrTable.H"
44 #include "hashedWordList.H"
47 #include "TypeSet.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class BlendedInterfacialModel Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class ModelType>
60 :
61  public regIOobject
62 {
63  // Private Data
64 
65  //- The interface
66  const phaseInterface interface_;
67 
68  //- Blending method
69  autoPtr<blendingMethod> blending_;
70 
71  //- Model for general configurations
72  autoPtr<ModelType> modelGeneral_;
73 
74  //- Model for phase 1 dispersed in phase 2
75  autoPtr<ModelType> model1DispersedIn2_;
76 
77  //- Model for phase 2 dispersed in phase 1
78  autoPtr<ModelType> model2DispersedIn1_;
79 
80  //- Model for phase 1 segregated with phase 2
81  autoPtr<ModelType> model1SegregatedWith2_;
82 
83  //- Models for general configurations displaced by a third phase
84  PtrList<ModelType> modelsGeneralDisplaced_;
85 
86  //- Models for phase 1 dispersed in phase 2 displaced by a third phase
87  PtrList<ModelType> models1DispersedIn2Displaced_;
88 
89  //- Models for phase 2 dispersed in phase 1 displaced by a third phase
90  PtrList<ModelType> models2DispersedIn1Displaced_;
91 
92  //- Models for phase 1 segregated with phase 2 displaced by a third
93  // phase
94  PtrList<ModelType> models1SegregatedWith2Displaced_;
95 
96  //- Time index of last check
97  mutable label checkTimeIndex_;
98 
99 
100  // Private Member Functions
101 
102  //- Check compatibility of the available models and the blending method
103  void check() const;
104 
105  //- Calculate the blending coefficients
106  template<class GeoMesh>
107  void calculateBlendingCoeffs
108  (
109  const UPtrList<const volScalarField>& alphas,
118  ) const;
119 
120  //- Write out a set or surface that visualises the various models'
121  // utilisation of the blending space
122  void postProcessBlendingCoefficients(const word& format) const;
123 
124 
125 protected:
126 
127  // Protected Member Functions
128 
129  //- Return a blended field
130  template<class Type, class GeoMesh, class ... Args>
132  (
134  (ModelType::*method)(Args ...) const,
135  const word& name,
136  const dimensionSet& dims,
137  Args ... args
138  ) const;
139 
140  //- Return a table of blended fields
141  template<class Type, class GeoMesh, class ... Args>
143  (
145  (ModelType::*method)(Args ...) const,
146  const word& name,
147  const dimensionSet& dims,
148  Args ... args
149  ) const;
150 
151  //- Return a bool combined (or) from all models
152  template<class ... Args>
153  bool evaluate
154  (
155  bool (ModelType::*method)(Args ...) const,
156  Args ... args
157  ) const;
158 
159  //- Return a hashed word list combined from all models
160  template<class ... Args>
162  (
163  const hashedWordList& (ModelType::*method)(Args ...) const,
164  Args ... args
165  ) const;
166 
167 
168 public:
169 
170  //- Public Type Definitions
171 
172  //- The underlying model type
173  typedef ModelType modelType;
174 
175  //- Required phase interface types
177 
178  //- Allowed phase interface types
179  typedef TypeSet
180  <
185 
186 
187  //- Runtime type information
188  TypeName("BlendedInterfacialModel");
189 
190 
191  // Constructors
192 
193  //- Construct from a dictionary, an interface and a blending dictionary
194  template<class ... Args>
196  (
197  const dictionary& dict,
198  const phaseInterface& interface,
199  const dictionary& blendingDict,
200  const Args& ... args
201  );
202 
203  //- Disallow default bitwise copy construction
205  (
207  ) = delete;
208 
209 
210  //- Destructor
212 
213 
214  // Member Functions
215 
216  //- Access the interface
217  const phaseInterface& interface() const;
218 
219  //- Dummy write for regIOobject
220  bool writeData(Ostream& os) const;
221 
222 
223  // Member Operators
224 
225  //- Disallow default bitwise assignment
226  void operator=(const BlendedInterfacialModel<ModelType>&) = delete;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #define defineBlendedInterfacialModelTypeNameAndDebug(ModelType, DebugSwitch) \
233  \
234  defineTemplateTypeNameAndDebugWithName \
235  ( \
236  BlendedInterfacialModel<ModelType>, \
237  ( \
238  word(BlendedInterfacialModel<ModelType>::typeName_()) + "<" \
239  + ModelType::typeName + ">" \
240  ).c_str(), \
241  DebugSwitch \
242  );
243 
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 } // End namespace Foam
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #ifdef NoRepository
252  #include "BlendedInterfacialModel.C"
253 #endif
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #endif
258 
259 // ************************************************************************* //
Wrapper class for interfacial models for which multiple instances of the model are used for different...
BlendedInterfacialModel(const dictionary &dict, const phaseInterface &interface, const dictionary &blendingDict, const Args &... args)
Construct from a dictionary, an interface and a blending dictionary.
TypeSet requiredPhaseInterfaces
Required phase interface types.
void operator=(const BlendedInterfacialModel< ModelType > &)=delete
Disallow default bitwise assignment.
const phaseInterface & interface() const
Access the interface.
bool writeData(Ostream &os) const
Dummy write for regIOobject.
TypeSet< dispersedPhaseInterface, segregatedPhaseInterface, displacedPhaseInterface > allowedPhaseInterfaces
Allowed phase interface types.
TypeName("BlendedInterfacialModel")
Runtime type information.
ModelType modelType
Public Type Definitions.
tmp< GeometricField< Type, GeoMesh > > evaluate(tmp< GeometricField< Type, GeoMesh >>(ModelType::*method)(Args ...) const, const word &name, const dimensionSet &dims, Args ... args) const
Return a blended field.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:47
Generic GeometricField class.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
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
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Dimension set for the base types.
Definition: dimensionSet.H:125
Class to represent a interface between phases where one phase is considered dispersed within the othe...
Class to represent an interface between phases which has been displaced to some extent by a third pha...
A wordList with hashed indices for faster lookup by name.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
Class to represent a interface between phases where the two phases are considered to be segregated; t...
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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
const dictionary & blendingDict(const phaseSystem &fluid, const dictionary &dict)
word format(conversionProperties.lookup("format"))
dictionary dict
Foam::argList args(argc, argv)
Template meta-programming for operations involving sets of types.
Definition: TypeSet.H:47