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-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 \*---------------------------------------------------------------------------*/
25 
26 #include "SidedInterfacialModel.H"
27 #include "phaseSystem.H"
28 #include "sidedPhaseInterface.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class ModelType>
34 (
35  const dictionary& dict,
36  const phaseInterface& interface
37 )
38 :
39  regIOobject
40  (
41  IOobject
42  (
43  IOobject::groupName(typeName, interface.name()),
44  interface.mesh().time().timeName(),
45  interface.mesh()
46  )
47  ),
48  interface_(interface)
49 {
50  // Construct the models
51  PtrList<phaseInterface> interfaces;
52  PtrList<ModelType> models;
53  interface.fluid().generateInterfacialModels<ModelType, sidedPhaseInterface>
54  (
55  dict,
56  interface,
57  interfaces,
58  models
59  );
60 
61  // Unpack the interface and model lists to populate the models used for
62  // either side of the interface
63  forAll(interfaces, i)
64  {
65  const sidedPhaseInterface& interface =
66  refCast<const sidedPhaseInterface>(interfaces[i]);
67 
68  if (interface_.index(interface.phase()) == 0)
69  {
70  modelInPhase1_.set(models.set(i, nullptr).ptr());
71  }
72  else
73  {
74  modelInPhase2_.set(models.set(i, nullptr).ptr());
75  }
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
82 template<class ModelType>
84 {}
85 
86 
87 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
88 
89 template<class ModelType>
92 {
93  return interface_;
94 }
95 
96 
97 template<class ModelType>
99 (
100  const phaseModel& phase
101 ) const
102 {
103  return
104  interface_.index(phase) == 0
105  ? modelInPhase1_.valid()
106  : modelInPhase2_.valid();
107 }
108 
109 
110 template<class ModelType>
112 (
113  const phaseModel& phase
114 ) const
115 {
116  if (!haveModelInThe(phase))
117  {
119  << "There is no " << type() << " active for the "
120  << phase.name() << " side of the "
121  << interface_.name() << " interface"
122  << exit(FatalError);
123  }
124 
125  return
126  interface_.index(phase) == 0
127  ? modelInPhase1_()
128  : modelInPhase2_();
129 }
130 
131 
132 template<class ModelType>
134 (
135  const phaseModel& phase
136 )
137 {
138  if (!haveModelInThe(phase))
139  {
141  << "There is no " << type() << " active for the "
142  << phase.name() << " side of the "
143  << interface_.name() << " interface"
144  << exit(FatalError);
145  }
146 
147  return
148  interface_.index(phase) == 0
149  ? modelInPhase1_()
150  : modelInPhase2_();
151 }
152 
153 
154 template<class ModelType>
156 {
157  return os.good();
158 }
159 
160 
161 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
SidedInterfacialModel(const dictionary &dict, const phaseInterface &interface)
Construct from a dictionary and an interface.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
const dictionary & dict() const
Return populationBalanceCoeffs dictionary.
fvMesh & mesh
Class to represent an interface between phases. Derivations can further specify the configuration of ...
word timeName
Definition: getTimeIndex.H:3
bool writeData(Ostream &os) const
Dummy write for regIOobject.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
bool haveModelInThe(const phaseModel &phase) const
Does a model exist in the given phase?
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
const phaseInterface & interface() const
Access the interface.
~SidedInterfacialModel()
Destructor.
const ModelType & modelInThe(const phaseModel &phase) const
Access the model within the given phase.