phaseSystemTemplates.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
29 
30 template<class modelType>
32 (
33  const dictTable& modelDicts,
34  HashTable
35  <
39  >& models
40 )
41 {
42  forAllConstIters(modelDicts, iter)
43  {
44  const phasePairKey& key = iter.key();
45 
46  models.insert
47  (
48  key,
50  (
51  iter.val(),
52  phasePairs_[key]
53  )
54  );
55  }
56 }
57 
58 
59 template<class modelType>
61 (
62  const dictTable& modelDicts,
63  const fvMesh& mesh,
64  HashTable
65  <
69  >& models
70 )
71 {
72  forAllConstIters(modelDicts, iter)
73  {
74  const phasePairKey& key = iter.key();
75 
76  models.insert
77  (
78  key,
80  (
81  iter.val(),
82  mesh
83  )
84  );
85  }
86 }
87 
88 
89 template<class modelType>
91 (
92  const word& modelName,
93  HashTable
94  <
98  >& models
99 )
100 {
101  dictTable modelDicts(lookup(modelName));
102 
103  generatePairs(modelDicts);
104 
105  createSubModels(modelDicts, models);
106 }
107 
108 
109 template<class modelType>
111 (
112  const word& modelName,
113  const fvMesh& mesh,
114  HashTable
115  <
117  phasePairKey,
119  >& models
120 )
121 {
122  dictTable modelDicts(lookup(modelName));
123 
124  generatePairs(modelDicts);
125 
126  createSubModels(modelDicts, mesh, models);
127 }
128 
129 
130 template<class modelType>
132 (
133  const word& modelName,
134  HashTable
135  <
137  phasePairKey,
139  >& models
140 )
141 {
142  typedef
144  modelTypeTable;
145 
146  for (const word& phaseName : phaseNames_)
147  {
148  modelTypeTable tempModels;
149  generatePairsAndSubModels
150  (
151  IOobject::groupName(modelName, phaseName),
152  tempModels
153  );
154 
155  forAllConstIters(tempModels, tempModelIter)
156  {
157  const phasePairKey& key = tempModelIter.key();
158 
159  if (!models.found(key))
160  {
161  models.insert
162  (
163  key,
165  );
166  }
167 
168  models[key].insert
169  (
170  phaseName,
171  *tempModelIter
172  );
173  }
174  }
175 }
176 
177 
178 template <class modelType>
179 const modelType& Foam::phaseSystem::lookupSubModel(const phasePair& key) const
180 {
181  return
182  mesh().lookupObject<modelType>
183  (
184  IOobject::groupName(modelType::typeName, key.name())
185  );
186 }
187 
188 
189 template <class modelType>
190 const modelType& Foam::phaseSystem::lookupSubModel
191 (
192  const phaseModel& from,
193  const phaseModel& to
194 ) const
195 {
196  return lookupSubModel<modelType>(orderedPhasePair(from, to));
197 }
198 
199 
200 // ************************************************************************* //
Foam::phaseModel
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:54
Foam::phasePair
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:53
Foam::phasePairKey::hasher
Hashing functor for phasePairKey.
Definition: phasePairKey.H:122
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::phaseSystem::createSubModels
void createSubModels(const dictTable &modelDicts, HashTable< autoPtr< modelType >, phasePairKey, phasePairKey::hash > &models)
Generate pairs and sub-model tables using pair keys.
Definition: phaseSystemTemplates.H:32
Foam::phaseSystem::lookupSubModel
const modelType & lookupSubModel(const phasePair &key) const
Access a sub model between a phase pair.
Definition: phaseSystemTemplates.H:179
Foam::phaseSystem::generatePairsAndSubModels
void generatePairsAndSubModels(const word &modelName, HashTable< autoPtr< modelType >, phasePairKey, phasePairKey::hash > &models)
Generate pairs and sub-model tables.
Definition: phaseSystemTemplates.H:91
Foam::orderedPhasePair
Definition: orderedPhasePair.H:49
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
Foam::phasePairKey
An ordered or unorder pair of phase names. Typically specified as follows.
Definition: phasePairKey.H:65
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:63
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::phaseSystem::mesh
const fvMesh & mesh() const
Return mesh.
Definition: phaseSystem.C:990
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr< modelType >
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.