SidedInterfacialModel.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) 2014-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 "SidedInterfacialModel.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class ModelType>
32 template<class ... Args>
34 (
35  const UPtrList<const dictionary>& subDicts,
36  const phaseInterface& interface,
37  const Args& ... args
38 )
39 :
41  (
42  IOobject
43  (
44  IOobject::groupName(typeName, interface.name()),
45  interface.mesh().time().name(),
46  interface.mesh()
47  )
48  ),
49  interface_(interface)
50 {
51  // Construct the models
52  PtrList<phaseInterface> interfaces;
53  PtrList<ModelType> models;
55  <
56  ModelType,
58  >
59  (
60  interfaces,
61  models,
62  interface.fluid(),
63  subDicts,
64  wordHashSet(),
65  interface,
66  args ...
67  );
68 
69  // Unpack the interface and model lists to populate the models used for
70  // either side of the interface
71  forAll(interfaces, i)
72  {
73  const sidedPhaseInterface& interface =
74  refCast<const sidedPhaseInterface>(interfaces[i]);
75 
76  if (interface_.index(interface.phase()) == 0)
77  {
78  modelInPhase1_.set(models.set(i, nullptr).ptr());
79  }
80  else
81  {
82  modelInPhase2_.set(models.set(i, nullptr).ptr());
83  }
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 
90 template<class ModelType>
92 {}
93 
94 
95 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
96 
97 template<class ModelType>
100 {
101  return interface_;
102 }
103 
104 
105 template<class ModelType>
107 (
108  const phaseModel& phase
109 ) const
110 {
111  return
112  interface_.index(phase) == 0
113  ? modelInPhase1_.valid()
114  : modelInPhase2_.valid();
115 }
116 
117 
118 template<class ModelType>
120 (
121  const phaseModel& phase
122 ) const
123 {
124  if (!haveModelInThe(phase))
125  {
127  << "There is no " << type() << " active for the "
128  << phase.name() << " side of the "
129  << interface_.name() << " interface"
130  << exit(FatalError);
131  }
132 
133  return
134  interface_.index(phase) == 0
135  ? modelInPhase1_()
136  : modelInPhase2_();
137 }
138 
139 
140 template<class ModelType>
142 (
143  const phaseModel& phase
144 )
145 {
146  if (!haveModelInThe(phase))
147  {
149  << "There is no " << type() << " active for the "
150  << phase.name() << " side of the "
151  << interface_.name() << " interface"
152  << exit(FatalError);
153  }
154 
155  return
156  interface_.index(phase) == 0
157  ? modelInPhase1_()
158  : modelInPhase2_();
159 }
160 
161 
162 template<class ModelType>
164 {
165  return os.good();
166 }
167 
168 
169 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
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: PtrList.H:75
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
const phaseInterface & interface() const
Access the interface.
bool writeData(Ostream &os) const
Dummy write for regIOobject.
SidedInterfacialModel(const UPtrList< const dictionary > &subDicts, const phaseInterface &interface, const Args &... args)
Construct from a dictionary and an interface.
bool haveModelInThe(const phaseModel &phase) const
Does a model exist in the given phase?
const ModelType & modelInThe(const phaseModel &phase) const
Access the model within the given phase.
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
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
Class to represent an interface between phases. Derivations can further specify the configuration of ...
const phaseSystem & fluid() const
Return the phase system.
label index(const phaseModel &phase) const
Return the index of the given phase. Generates a FatalError if.
const word & name() const
Return the name of this phase.
Definition: phaseModel.C:92
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
Class to represent a certain side of an interface between phases.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const dimensionSet time
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:141
void generateInterfacialModels(PtrList< phaseInterface > &interfaces, PtrList< ModelType > &models, const phaseSystem &fluid, const UPtrList< const dictionary > &subDicts, const wordHashSet &ignoreKeys, const phaseInterface &interface, const Args &... args)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
HashSet wordHashSet
A HashSet with word keys.
Definition: HashSet.H:210
error FatalError
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Foam::argList args(argc, argv)