TwoResistanceHeatTransferPhaseSystem.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) 2015-2018 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 
27 
28 #include "BlendedInterfacialModel.H"
29 #include "heatTransferModel.H"
30 
31 #include "HashPtrTable.H"
32 
33 #include "fvcDiv.H"
34 #include "fvmSup.H"
35 #include "fvMatrix.H"
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 template<class BasePhaseSystem>
43 (
44  const fvMesh& mesh
45 )
46 :
47  BasePhaseSystem(mesh)
48 {
49  this->generatePairsAndSubModels
50  (
51  "heatTransfer",
52  heatTransferModels_,
53  false
54  );
55 
56  // Check that models have been specified on both sides of the interfaces
58  (
59  heatTransferModelTable,
60  heatTransferModels_,
61  heatTransferModelIter
62  )
63  {
64  const phasePair& pair = this->phasePairs_[heatTransferModelIter.key()];
65 
66  if (!heatTransferModels_[pair].first().valid())
67  {
69  << "A heat transfer model for the " << pair.phase1().name()
70  << " side of the " << pair << " pair is not specified"
71  << exit(FatalError);
72  }
73  if (!heatTransferModels_[pair].second().valid())
74  {
76  << "A heat transfer model for the " << pair.phase2().name()
77  << " side of the " << pair << " pair is not specified"
78  << exit(FatalError);
79  }
80  }
81 
82  // Calculate initial Tf-s as if there is no mass transfer
84  (
85  heatTransferModelTable,
86  heatTransferModels_,
87  heatTransferModelIter
88  )
89  {
90  const phasePair& pair = this->phasePairs_[heatTransferModelIter.key()];
91 
92  const phaseModel& phase1 = pair.phase1();
93  const phaseModel& phase2 = pair.phase2();
94 
95  const volScalarField& T1(phase1.thermo().T());
96  const volScalarField& T2(phase2.thermo().T());
97 
98  volScalarField H1(heatTransferModels_[pair].first()->K());
99  volScalarField H2(heatTransferModels_[pair].second()->K());
100  dimensionedScalar HSmall("small", heatTransferModel::dimK, small);
101 
102  Tf_.insert
103  (
104  pair,
105  new volScalarField
106  (
107  IOobject
108  (
109  IOobject::groupName("Tf", pair.name()),
110  this->mesh().time().timeName(),
111  this->mesh(),
114  ),
115  (H1*T1 + H2*T2)/max(H1 + H2, HSmall)
116  )
117  );
118  }
119 }
120 
121 
122 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
123 
124 template<class BasePhaseSystem>
127 {}
128 
129 
130 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
131 
132 template<class BasePhaseSystem>
135 heatTransfer() const
136 {
137  autoPtr<phaseSystem::heatTransferTable> eqnsPtr
138  (
140  );
141 
142  phaseSystem::heatTransferTable& eqns = eqnsPtr();
143 
144  forAll(this->phaseModels_, phasei)
145  {
146  const phaseModel& phase = this->phaseModels_[phasei];
147 
148  eqns.insert
149  (
150  phase.name(),
151  new fvScalarMatrix(phase.thermo().he(), dimEnergy/dimTime)
152  );
153  }
154 
155  // Heat transfer with the interface
157  (
158  heatTransferModelTable,
159  heatTransferModels_,
160  heatTransferModelIter
161  )
162  {
163  const phasePair& pair
164  (
165  this->phasePairs_[heatTransferModelIter.key()]
166  );
167 
168  const volScalarField& Tf(*Tf_[pair]);
169 
170  const Pair<tmp<volScalarField>> Ks
171  (
172  heatTransferModelIter().first()->K(),
173  heatTransferModelIter().second()->K()
174  );
175 
176  const volScalarField KEff
177  (
178  Ks.first()()*Ks.second()()
179  /max
180  (
181  Ks.first()() + Ks.second()(),
183  )
184  );
185 
186  forAllConstIter(phasePair, pair, iter)
187  {
188  const phaseModel& phase = iter();
189 
190  const volScalarField& he(phase.thermo().he());
191  const volScalarField Cpv(phase.thermo().Cpv());
192 
193  *eqns[phase.name()] +=
194  Ks[iter.index()]*(Tf - phase.thermo().T())
195  + KEff/Cpv*he - fvm::Sp(KEff/Cpv, he);
196  }
197  }
198 
199  // Source term due to mass transfer
201  (
203  this->phasePairs_,
204  phasePairIter
205  )
206  {
207  const phasePair& pair(phasePairIter());
208 
209  if (pair.ordered())
210  {
211  continue;
212  }
213 
214  const phaseModel& phase1 = pair.phase1();
215  const phaseModel& phase2 = pair.phase2();
216 
217  const volScalarField& he1(phase1.thermo().he());
218  const volScalarField& he2(phase2.thermo().he());
219 
220  const volScalarField K1(phase1.K());
221  const volScalarField K2(phase2.K());
222 
223  const volScalarField dmdt(this->dmdt(pair));
224  const volScalarField dmdt21(posPart(dmdt));
225  const volScalarField dmdt12(negPart(dmdt));
226 
227  *eqns[phase1.name()] += - fvm::Sp(dmdt21, he1) + dmdt21*(K2 - K1);
228 
229  *eqns[phase2.name()] -= - fvm::Sp(dmdt12, he2) + dmdt12*(K1 - K2);
230 
231  if (this->heatTransferModels_.found(phasePairIter.key()))
232  {
233  const volScalarField& Tf(*Tf_[pair]);
234 
235  *eqns[phase1.name()] +=
236  dmdt21*phase1.thermo().he(phase1.thermo().p(), Tf);
237 
238  *eqns[phase2.name()] -=
239  dmdt12*phase2.thermo().he(phase2.thermo().p(), Tf);
240  }
241  else
242  {
243  *eqns[phase1.name()] += dmdt21*he2;
244 
245  *eqns[phase2.name()] -= dmdt12*he1;
246  }
247  }
248 
249  return eqnsPtr;
250 }
251 
252 
253 template<class BasePhaseSystem>
256 {
258 
260 }
261 
262 
263 template<class BasePhaseSystem>
266 {
268  (
269  heatTransferModelTable,
270  heatTransferModels_,
271  heatTransferModelIter
272  )
273  {
274  const phasePair& pair
275  (
276  this->phasePairs_[heatTransferModelIter.key()]
277  );
278 
279  const phaseModel& phase1 = pair.phase1();
280  const phaseModel& phase2 = pair.phase2();
281 
282  const volScalarField& p(phase1.thermo().p());
283 
284  const volScalarField& T1(phase1.thermo().T());
285  const volScalarField& T2(phase2.thermo().T());
286 
287  volScalarField& Tf(*this->Tf_[pair]);
288 
289  const volScalarField L
290  (
291  phase1.thermo().he(p, Tf) - phase2.thermo().he(p, Tf)
292  );
293 
294  const volScalarField dmdt(this->dmdt(pair));
295 
296  volScalarField H1
297  (
298  this->heatTransferModels_[pair].first()->K()
299  );
300 
301  volScalarField H2
302  (
303  this->heatTransferModels_[pair].second()->K()
304  );
305 
306  // Limit the H[12] to avoid /0
307  H1.max(small);
308  H2.max(small);
309 
310  Tf = (H1*T1 + H2*T2 + dmdt*L)/(H1 + H2);
311 
312  Info<< "Tf." << pair.name()
313  << ": min = " << min(Tf.primitiveField())
314  << ", mean = " << average(Tf.primitiveField())
315  << ", max = " << max(Tf.primitiveField())
316  << endl;
317  }
318 }
319 
320 
321 template<class BasePhaseSystem>
323 {
324  if (BasePhaseSystem::read())
325  {
326  bool readOK = true;
327 
328  // Models ...
329 
330  return readOK;
331  }
332  else
333  {
334  return false;
335  }
336 }
337 
338 
339 // ************************************************************************* //
volScalarField & he
Definition: YEEqn.H:51
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
label phasei
Definition: pEqn.H:27
#define K1
Definition: SHA1.C:167
HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash > phasePairTable
Definition: phaseSystem.H:87
error FatalError
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
#define K2
Definition: SHA1.C:168
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
virtual tmp< volScalarField > dmdt(const phasePairKey &key) const
Return the mass transfer rate for a pair.
HashPtrTable< fvScalarMatrix > heatTransferTable
Definition: phaseSystem.H:77
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
CGAL::Exact_predicates_exact_constructions_kernel K
dimensionedScalar posPart(const dimensionedScalar &ds)
static const dimensionSet dimK
Coefficient dimensions.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
virtual void correctInterfaceThermo()
Correct the interface thermodynamics.
dynamicFvMesh & mesh
static word groupName(Name name, const word &group)
virtual void correctInterfaceThermo()
Correct the interface thermodynamics.
virtual void correctThermo()
Correct the thermodynamics.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
virtual void correctThermo()
Correct the thermodynamics.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
Calculate the divergence of the given field.
volScalarField & he2
Definition: EEqns.H:3
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const dimensionSet dimEnergy
virtual autoPtr< phaseSystem::heatTransferTable > heatTransfer() const
Return the heat transfer matrices.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
virtual ~TwoResistanceHeatTransferPhaseSystem()
Destructor.
messageStream Info
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
Calculate the matrix for implicit and explicit sources.
dimensionedScalar negPart(const dimensionedScalar &ds)
TwoResistanceHeatTransferPhaseSystem(const fvMesh &)
Construct from fvMesh.
virtual bool read()
Read base phaseProperties dictionary.