phaseInterface.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) 2021-2022 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::phaseInterface
26 
27 Description
28  Class to represent an interface between phases. Derivations can further
29  specify the configuration of that interface; e.g., representing dispersal,
30  displacement or sidedness.
31 
32 SourceFiles
33  phaseInterface.C
34  phaseInterfaceI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef phaseInterface_H
39 #define phaseInterface_H
40 
41 #include "phaseModel.H"
43 #include "runTimeSelectionTables.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 class phaseInterfaceKey;
51 
52 /*---------------------------------------------------------------------------*\
53  Class phaseInterface Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class phaseInterface
57 {
58 private:
59 
60  // Private Static Data
61 
62  //- List of head separators. This is the first separator in an
63  // interface name, and it delimits the names of phases on either side
64  // of the interface. Other separators are modifiers (e.g.,
65  // displacedBy, inThe, ...).
66  static wordList headSeparators_;
67 
68  //- Map from old-format separators to separators
69  static HashTable<word> oldSeparatorToSeparator_;
70 
71 
72 public:
73 
74  // Public Static Functions
75 
76  //- Get a reference to phase1 after sorting the phases by index
77  static const phaseModel& getPhase1
78  (
79  const phaseModel& phase1,
80  const phaseModel& phase2
81  );
82 
83  //- Get a reference to phase2 after sorting the phases by index
84  static const phaseModel& getPhase2
85  (
86  const phaseModel& phase1,
87  const phaseModel& phase2
88  );
89 
90  //- Add a head separator to the list
91  static bool addHeadSeparator(const word& separator);
92 
93  //- Add a old separator to separator to the table
94  static bool addOldSeparatorToSeparator
95  (
96  const word& oldSeparator,
97  const word& separator
98  );
99 
100  //- Split an interface name and return all its parts
102  (
103  const phaseSystem& fluid,
104  const word& name
105  );
106 
107  //- Split an interface name and return its separators
109  (
110  const phaseSystem& fluid,
111  const word& name
112  );
113 
114  //- Convert a list of separators into a type name
116  (
117  const wordList& separators
118  );
119 
120  //- Convert an interface name into a type name. Essentially just
121  // replaces valid phase names with a "<phase>" placeholder.
122  static word nameToTypeName
123  (
124  const phaseSystem& fluid,
125  const word& name
126  );
127 
128  //- Convert interface name parts to an interface name
129  static word namePartsToName
130  (
131  const phaseSystem& fluid,
132  const wordList& nameParts
133  );
134 
135  //- Convert old-format interface name parts to an interface name. Used
136  // in phaseSystem to provide backwards compatible input.
137  static word oldNamePartsToName
138  (
139  const phaseSystem& fluid,
140  const wordList& oldNameParts
141  );
142 
143  //- Return references to the phases associated with a given name, and a
144  // list of valid separators
146  (
147  const phaseSystem& fluid,
148  const word& name,
149  const wordList& separators
150  );
151 
152 
153 private:
154 
155  // Private Data
156 
157  //- Phase 1
158  const phaseModel& phase1_;
159 
160  //- Phase 2
161  const phaseModel& phase2_;
162 
163  //- Gravitational acceleration
165 
166 
167 public:
168 
169  //- Runtime type information
170  TypeName("phaseInterface");
171 
172 
173  // Declare runtime construction
174 
176  (
177  autoPtr,
179  word,
180  (
181  const phaseSystem& fluid,
182  const word& name
183  ),
184  (fluid, name)
185  );
186 
187 
188  // Constructors
189 
190  //- Construct from phases
192  (
193  const phaseModel& phase1,
194  const phaseModel& phase2
195  );
196 
197  //- Construct from phases
199  (
201  );
202 
203  //- Construct from fluid and name
205  (
206  const phaseSystem& fluid,
207  const word& name
208  );
209 
210  //- Construct from fluid and key
212  (
213  const phaseSystem& fluid,
214  const phaseInterfaceKey& name
215  );
216 
217  //- Clone function
218  virtual autoPtr<phaseInterface> clone() const;
219 
220 
221  //- Destructor
222  virtual ~phaseInterface();
223 
224 
225  // Selectors
226 
227  //- Select given fluid and name
229  (
230  const phaseSystem& fluid,
231  const word& name
232  );
233 
234  //- Select by combining two interfaces
236  (
237  const phaseInterface& interface1,
238  const phaseInterface& interface2
239  );
240 
241  //- Class used for construction of PtrLists of phaseInterfaces
242  class iNew
243  {
244  const phaseSystem& fluid_;
245 
246  public:
248  iNew(const phaseSystem& fluid)
249  :
250  fluid_(fluid)
251  {}
254  {
255  return phaseInterface::New(fluid_, word(is));
256  }
257  };
258 
259 
260  // Static Member Functions
261 
262  //- Return the separator that delimits this interface's name
263  static word separator()
264  {
265  return word::null;
266  }
267 
268 
269  // Member Functions
270 
271  //- Name
272  virtual word name() const;
273 
274  //- Cast to derived type for use in a model
275  template<class ModelType, class Derived>
276  const Derived& modelCast() const
277  {
278  if (!isA<Derived>(*this))
279  {
281  << "Constructing " << ModelType::typeName
282  << " for interface " << name()
283  << " which is not of the required type "
284  << Derived::typeName << exit(FatalError);
285  }
286 
287  return refCast<const Derived>(*this);
288  }
289 
290 
291  // Access
292 
293  //- Return phase 1
294  inline const phaseModel& phase1() const;
295 
296  //- Return phase 2
297  inline const phaseModel& phase2() const;
298 
299  //- Return true if this phaseInterface contains the given phase
300  inline bool contains(const phaseModel& phase) const;
301 
302  //- Return the other phase relative to the given phase
303  // Generates a FatalError if this phaseInterface does not contain
304  // the given phase
305  inline const phaseModel& otherPhase(const phaseModel& phase) const;
306 
307  //- Return the index of the given phase. Generates a FatalError if
308  // this phaseInterface does not contain the given phase
309  inline label index(const phaseModel& phase) const;
310 
311  //- Return the phase system
312  inline const phaseSystem& fluid() const;
313 
314  //- Return the mesh
315  inline const fvMesh& mesh() const;
316 
317  //- Return gravitational acceleration
318  inline const uniformDimensionedVectorField& g() const;
319 
320 
321  // Properties
322 
323  //- Average density
324  tmp<volScalarField> rho() const;
325 
326  //- Relative velocity magnitude
327  tmp<volScalarField> magUr() const;
328 
329  //- Surface tension coefficient
330  tmp<volScalarField> sigma() const;
331 
332 
333  //- STL const_iterator
334  class const_iterator
335  {
336  // Private Data
337 
338  //- Reference to the pair for which this is an iterator
339  const phaseInterface& pair_;
340 
341  //- Current index
342  label index_;
343 
344  //- Construct an iterator with the given index
345  inline const_iterator(const phaseInterface&, const label index);
346 
347  public:
349  friend class phaseInterface;
350 
351  // Constructors
352 
353  //- Construct from pair, moving to its 'begin' position
354  inline explicit const_iterator(const phaseInterface&);
355 
356 
357  // Access
358 
359  //- Return the current index
360  inline label index() const;
361 
362 
363  // Member Operators
364 
365  inline bool operator==(const const_iterator&) const;
366 
367  inline bool operator!=(const const_iterator&) const;
368 
369  inline const phaseModel& operator*() const;
370  inline const phaseModel& operator()() const;
371 
372  inline const phaseModel& otherPhase() const;
373 
374  inline const_iterator& operator++();
375  inline const_iterator operator++(int);
376  };
377 
378 
379  //- const_iterator set to the beginning of the pair
380  inline const_iterator cbegin() const;
381 
382  //- const_iterator set to beyond the end of the pair
383  inline const_iterator cend() const;
384 
385  //- const_iterator set to the beginning of the pair
386  inline const_iterator begin() const;
387 
388  //- const_iterator set to beyond the end of the pair
389  inline const_iterator end() const;
390 };
391 
392 
393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 
395 } // End namespace Foam
396 
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398 
399 #include "phaseInterfaceI.H"
400 
401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402 
403 #endif
404 
405 // ************************************************************************* //
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
const uniformDimensionedVectorField & g() const
Return gravitational acceleration.
static autoPtr< phaseInterface > New(const phaseSystem &fluid, const word &name)
Select given fluid and name.
const fvMesh & mesh() const
Return the mesh.
const_iterator begin() const
const_iterator set to the beginning of the pair
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
tmp< volScalarField > rho() const
Average density.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
phaseInterface(const phaseModel &phase1, const phaseModel &phase2)
Construct from phases.
Word-pair based class used for keying interface models in hash tables.
const_iterator cend() const
const_iterator set to beyond the end of the pair
static word nameToTypeName(const phaseSystem &fluid, const word &name)
Convert an interface name into a type name. Essentially just.
static word separator()
Return the separator that delimits this interface&#39;s name.
virtual word name() const
Name.
const phaseModel & phase1() const
Return phase 1.
static bool addOldSeparatorToSeparator(const word &oldSeparator, const word &separator)
Add a old separator to separator to the table.
autoPtr< phaseInterface > operator()(Istream &is) const
Class to represent an interface between phases. Derivations can further specify the configuration of ...
static bool addHeadSeparator(const word &separator)
Add a head separator to the list.
virtual autoPtr< phaseInterface > clone() const
Clone function.
declareRunTimeSelectionTable(autoPtr, phaseInterface, word,(const phaseSystem &fluid, const word &name),(fluid, name))
iNew(const phaseSystem &fluid)
Class used for construction of PtrLists of phaseInterfaces.
static wordList nameToNameParts(const phaseSystem &fluid, const word &name)
Split an interface name and return all its parts.
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:68
static Tuple2< const phaseModel &, const phaseModel & > identifyPhases(const phaseSystem &fluid, const word &name, const wordList &separators)
Return references to the phases associated with a given name, and a.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
static const word null
An empty word.
Definition: word.H:77
An STL-conforming hash table.
Definition: HashTable.H:61
static word namePartsToName(const phaseSystem &fluid, const wordList &nameParts)
Convert interface name parts to an interface name.
static word oldNamePartsToName(const phaseSystem &fluid, const wordList &oldNameParts)
Convert old-format interface name parts to an interface name. Used.
const phaseModel & phase2() const
Return phase 2.
tmp< volScalarField > magUr() const
Relative velocity magnitude.
const phaseSystem & fluid() const
Return the phase system.
bool contains(const phaseModel &phase) const
Return true if this phaseInterface contains the given phase.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
const Derived & modelCast() const
Cast to derived type for use in a model.
label index(const phaseModel &phase) const
Return the index of the given phase. Generates a FatalError if.
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phase.H:52
phaseSystem::phaseModelList & phases
Definition: createFields.H:12
static const phaseModel & getPhase2(const phaseModel &phase1, const phaseModel &phase2)
Get a reference to phase2 after sorting the phases by index.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
static word separatorsToTypeName(const wordList &separators)
Convert a list of separators into a type name.
tmp< volScalarField > sigma() const
Surface tension coefficient.
Macros to ease declaration of run-time selection tables.
const_iterator cbegin() const
const_iterator set to the beginning of the pair
A class for managing temporary objects.
Definition: PtrList.H:53
bool operator!=(const particle &, const particle &)
Definition: particle.C:1282
virtual ~phaseInterface()
Destructor.
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:53
TypeName("phaseInterface")
Runtime type information.
const_iterator end() const
const_iterator set to beyond the end of the pair
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
static const phaseModel & getPhase1(const phaseModel &phase1, const phaseModel &phase2)
Get a reference to phase1 after sorting the phases by index.
Namespace for OpenFOAM.
static wordList nameToSeparators(const phaseSystem &fluid, const word &name)
Split an interface name and return its separators.