MovingPhaseModel.C
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) 2015-2021 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "MovingPhaseModel.H"
30#include "phaseSystem.H"
31#include "phaseCompressibleTurbulenceModel.H"
33#include "slipFvPatchFields.H"
35
36#include "fvmDdt.H"
37#include "fvmDiv.H"
38#include "fvmSup.H"
39#include "fvcDdt.H"
40#include "fvcDiv.H"
41#include "fvcFlux.H"
42#include "surfaceInterpolate.H"
43#include "fvMatrix.H"
44
45// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
46
47template<class BasePhaseModel>
49Foam::MovingPhaseModel<BasePhaseModel>::phi(const volVectorField& U) const
50{
51 word phiName(IOobject::groupName("phi", this->name()));
52
53 IOobject phiHeader
54 (
55 phiName,
56 U.mesh().time().timeName(),
57 U.mesh(),
58 IOobject::NO_READ
59 );
60
61 if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
62 {
63 Info<< "Reading face flux field " << phiName << endl;
64
65 return tmp<surfaceScalarField>
66 (
67 new surfaceScalarField
68 (
69 IOobject
70 (
71 phiName,
72 U.mesh().time().timeName(),
73 U.mesh(),
74 IOobject::MUST_READ,
75 IOobject::AUTO_WRITE
76 ),
77 U.mesh()
78 )
79 );
80 }
81 else
82 {
83 Info<< "Calculating face flux field " << phiName << endl;
84
85 wordList phiTypes
86 (
87 U.boundaryField().size(),
88 calculatedFvPatchScalarField::typeName
89 );
90
91 forAll(U.boundaryField(), i)
92 {
93 if
94 (
95 isA<fixedValueFvPatchVectorField>(U.boundaryField()[i])
96 || isA<slipFvPatchVectorField>(U.boundaryField()[i])
97 || isA<partialSlipFvPatchVectorField>(U.boundaryField()[i])
98 )
99 {
101 }
102 }
103
104 return tmp<surfaceScalarField>
105 (
106 new surfaceScalarField
107 (
108 IOobject
109 (
110 phiName,
111 U.mesh().time().timeName(),
112 U.mesh(),
113 IOobject::NO_READ,
114 IOobject::AUTO_WRITE
115 ),
116 fvc::flux(U),
117 phiTypes
118 )
119 );
120 }
121}
122
123
124// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
125
126template<class BasePhaseModel>
128(
129 const phaseSystem& fluid,
130 const word& phaseName,
131 const label index
132)
133:
134 BasePhaseModel(fluid, phaseName, index),
135 U_
136 (
138 (
139 IOobject::groupName("U", this->name()),
140 fluid.mesh().time().timeName(),
141 fluid.mesh(),
142 IOobject::MUST_READ,
143 IOobject::AUTO_WRITE
144 ),
145 fluid.mesh()
146 ),
147 phi_(phi(U_)),
148 alphaPhi_
149 (
151 (
152 IOobject::groupName("alphaPhi", this->name()),
153 fluid.mesh().time().timeName(),
154 fluid.mesh()
155 ),
156 fluid.mesh(),
157 dimensionedScalar(dimensionSet(0, 3, -1, 0, 0))
158 ),
159 alphaRhoPhi_
160 (
162 (
163 IOobject::groupName("alphaRhoPhi", this->name()),
164 fluid.mesh().time().timeName(),
165 fluid.mesh()
166 ),
167 fluid.mesh(),
168 dimensionedScalar(dimensionSet(1, 0, -1, 0, 0))
169 ),
170 DUDt_(nullptr),
171 DUDtf_(nullptr),
172 divU_(nullptr),
173 turbulence_
174 (
176 (
177 *this,
178 this->thermo().rho(),
179 U_,
180 alphaRhoPhi_,
181 phi_,
182 *this
183 )
184 ),
185 continuityErrorFlow_
186 (
188 (
189 IOobject::groupName("continuityErrorFlow", this->name()),
190 fluid.mesh().time().timeName(),
191 fluid.mesh()
192 ),
193 fluid.mesh(),
195 ),
196 continuityErrorSources_
197 (
199 (
200 IOobject::groupName("continuityErrorSources", this->name()),
201 fluid.mesh().time().timeName(),
202 fluid.mesh()
203 ),
204 fluid.mesh(),
206 ),
207 K_(nullptr)
208{
210
212}
213
214
215// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
216
217template<class BasePhaseModel>
219{
220 BasePhaseModel::correct();
221
222 this->fluid().MRF().correctBoundaryVelocity(U_);
223
224 volScalarField& rho = this->thermoRef().rho();
225
226 continuityErrorFlow_ = fvc::ddt(*this, rho) + fvc::div(alphaRhoPhi_);
227
228 continuityErrorSources_ = - (this->fluid().fvOptions()(*this, rho)&rho);
229}
230
231
232template<class BasePhaseModel>
234{
235 BasePhaseModel::correctKinematics();
236
237 if (DUDt_.valid())
238 {
239 DUDt_.clear();
240 DUDt();
241 }
242
243 if (DUDtf_.valid())
244 {
245 DUDtf_.clear();
246 DUDtf();
247 }
248
249 if (K_.valid())
250 {
251 K_.ref() = 0.5*magSqr(this->U());
252 }
253}
254
255
256template<class BasePhaseModel>
258{
259 BasePhaseModel::correctTurbulence();
260
261 turbulence_->correct();
262}
263
264
265template<class BasePhaseModel>
267{
268 BasePhaseModel::correctEnergyTransport();
269
270 turbulence_->correctEnergyTransport();
271}
272
273
274template<class BasePhaseModel>
276{
277 return false;
278}
279
280
281template<class BasePhaseModel>
284{
285 const volScalarField& alpha = *this;
286 const volScalarField& rho = this->thermo().rho();
287
288 return
289 (
290 fvm::ddt(alpha, rho, U_)
291 + fvm::div(alphaRhoPhi_, U_)
292 + fvm::SuSp(- this->continuityError(), U_)
293 + this->fluid().MRF().DDt(alpha*rho, U_)
294 + turbulence_->divDevRhoReff(U_)
295 );
296}
297
298
299template<class BasePhaseModel>
302{
303 // As the "normal" U-eqn but without the ddt terms
304
305 const volScalarField& alpha = *this;
306 const volScalarField& rho = this->thermo().rho();
307
308 return
309 (
310 fvm::div(alphaRhoPhi_, U_)
311 - fvm::Sp(fvc::div(alphaRhoPhi_), U_)
312 + fvm::SuSp(- this->continuityErrorSources(), U_)
313 + this->fluid().MRF().DDt(alpha*rho, U_)
314 + turbulence_->divDevRhoReff(U_)
315 );
316}
317
318
319template<class BasePhaseModel>
322{
323 return U_;
324}
325
326
327template<class BasePhaseModel>
330{
331 return U_;
332}
333
334
335template<class BasePhaseModel>
338{
339 return phi_;
340}
341
342
343template<class BasePhaseModel>
346{
347 return phi_;
348}
349
350
351template<class BasePhaseModel>
354{
355 return alphaPhi_;
356}
357
358
359template<class BasePhaseModel>
362{
363 return alphaPhi_;
364}
365
366
367template<class BasePhaseModel>
370{
371 return alphaRhoPhi_;
372}
373
374
375template<class BasePhaseModel>
378{
379 return alphaRhoPhi_;
380}
381
382
383template<class BasePhaseModel>
386{
387 if (!DUDt_.valid())
388 {
389 DUDt_ = fvc::ddt(U_) + fvc::div(phi_, U_) - fvc::div(phi_)*U_;
390 }
391
392 return tmp<volVectorField>(DUDt_());
393}
394
395
396template<class BasePhaseModel>
399{
400 if (!DUDtf_.valid())
401 {
402 DUDtf_ = byDt(phi_ - phi_.oldTime());
403 }
404
405 return tmp<surfaceScalarField>(DUDtf_());
406}
407
408
409template<class BasePhaseModel>
412{
413 return continuityErrorFlow_ + continuityErrorSources_;
414}
415
416
417template<class BasePhaseModel>
420{
421 return continuityErrorFlow_;
422}
423
424
425template<class BasePhaseModel>
428{
429 return continuityErrorSources_;
430}
431
432
433template<class BasePhaseModel>
436{
437 if (!K_.valid())
438 {
440 (
441 IOobject::groupName("K", this->name()),
442 0.5*magSqr(this->U())
443 );
444 }
445
446 return tmp<volScalarField>(K_());
447}
448
449
450template<class BasePhaseModel>
453{
454 return divU_.valid() ? tmp<volScalarField>(divU_()) : tmp<volScalarField>();
455}
456
457
458template<class BasePhaseModel>
460{
461 divU_ = divU;
462}
463
464
465template<class BasePhaseModel>
468{
469 return turbulence_->mut();
470}
471
472
473template<class BasePhaseModel>
476{
477 return turbulence_->muEff();
478}
479
480
481template<class BasePhaseModel>
484{
485 return turbulence_->nut();
486}
487
488
489template<class BasePhaseModel>
492{
493 return turbulence_->nuEff();
494}
495
496
497template<class BasePhaseModel>
500{
501 return turbulence_->kappaEff();
502}
503
504
505template<class BasePhaseModel>
508{
509 return turbulence_->kappaEff(patchi);
510}
511
512
513template<class BasePhaseModel>
516{
517 return turbulence_->alphaEff();
518}
519
520
521template<class BasePhaseModel>
524{
525 return turbulence_->alphaEff(patchi);
526}
527
528
529template<class BasePhaseModel>
532{
533 return turbulence_->k();
534}
535
536
537template<class BasePhaseModel>
540{
541 return turbulence_->pPrime();
542}
543
544
545// ************************************************************************* //
surfaceScalarField & phi
IOMRFZoneList & MRF
twoPhaseSystem & fluid
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
void correctBoundaryVelocity(volVectorField &U) const
Correct the boundary velocity for the rotation of the MRF region.
Definition: MRFZoneList.C:401
Class which represents a moving fluid phase. Holds the velocity, fluxes and turbulence model....
virtual void correctKinematics()
Correct the kinematics.
virtual tmp< volScalarField > continuityErrorSources() const
Return the continuity error due to any sources.
virtual void correctEnergyTransport()
Correct the energy transport e.g. alphat.
virtual tmp< fvVectorMatrix > UEqn()
Return the momentum equation.
virtual tmp< surfaceScalarField > DUDtf() const
Return the substantive acceleration on the faces.
virtual tmp< volScalarField > muEff() const
Return the effective dynamic viscosity.
virtual void correct()
Correct the phase properties other than the thermo and turbulence.
virtual tmp< volScalarField > k() const
Return the turbulent kinetic energy.
virtual tmp< volVectorField > U() const
Access const reference to U.
virtual tmp< volScalarField > mut() const
Return the turbulent dynamic viscosity.
virtual surfaceScalarField & alphaRhoPhiRef()
Access the mass flux of the phase.
virtual void correctTurbulence()
Correct the turbulence.
virtual surfaceScalarField & phiRef()
Access the volumetric flux.
virtual tmp< volScalarField > alphaEff() const
Return the effective thermal diffusivity.
virtual tmp< surfaceScalarField > alphaPhi() const
Constant access the volumetric flux of the phase.
virtual tmp< volScalarField > K() const
Return the phase kinetic energy.
virtual tmp< volScalarField > pPrime() const
Return the phase-pressure'.
virtual tmp< volScalarField > continuityErrorFlow() const
Return the continuity error due to the flow field.
virtual tmp< volScalarField > nuEff() const
Return the effective kinematic viscosity.
virtual tmp< volScalarField > divU() const
Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
virtual surfaceScalarField & alphaPhiRef()
Access the volumetric flux of the phase.
virtual tmp< surfaceScalarField > alphaRhoPhi() const
Return the mass flux of the phase.
virtual tmp< surfaceScalarField > phi() const
Constant access the volumetric flux.
virtual tmp< fvVectorMatrix > UfEqn()
Return the momentum equation for the face-based algorithm.
virtual tmp< volScalarField > nut() const
Return the turbulent kinematic viscosity.
virtual volVectorField & URef()
Access the velocity.
virtual tmp< volVectorField > DUDt() const
Return the substantive acceleration.
virtual tmp< volScalarField > kappaEff() const
Return the effective thermal conductivity.
virtual bool stationary() const
Return whether the phase is stationary.
virtual tmp< volScalarField > continuityError() const
Return the continuity error.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:76
const IOMRFZoneList & MRF() const
Return MRF zones.
Definition: phaseSystemI.H:137
fv::options & fvOptions() const
Access the fvOptions.
Definition: phaseSystemI.H:143
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
U
Definition: pEqn.H:72
dynamicFvMesh & mesh
Calculate the first temporal derivative.
Calculate the divergence of the given field.
Calculate the face-flux of the given field.
Calculate the matrix for the first temporal derivative.
Calculate the matrix for the divergence of the given field and flux.
Calculate the finiteVolume matrix for implicit and explicit sources.
zeroField divU
Definition: alphaSuSp.H:3
word timeName
Definition: getTimeIndex.H:3
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:49
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:47
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:48
zeroField SuSp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
List< word > wordList
A List of words.
Definition: fileName.H:63
tmp< volScalarField > byDt(const volScalarField &vf)
Definition: phaseSystem.C:442
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
const dimensionSet dimDensity
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
volScalarField & alpha
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
static const char *const typeName
The type name used in ensight case files.