thermophysicalPredictor.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) 2022-2023 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 "multiphaseEuler.H"
27 #include "fvcDdt.H"
28 #include "fvcDiv.H"
29 #include "fvcSup.H"
30 #include "fvmDdt.H"
31 #include "fvmDiv.H"
32 #include "fvmSup.H"
33 
34 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
35 
36 void Foam::solvers::multiphaseEuler::compositionPredictor()
37 {
38  autoPtr<phaseSystem::specieTransferTable>
39  specieTransferPtr(fluid.specieTransfer());
40 
42  specieTransfer(specieTransferPtr());
43 
45 
46  forAll(fluid.multicomponentPhases(), multicomponentPhasei)
47  {
48  phaseModel& phase = fluid_.multicomponentPhases()[multicomponentPhasei];
49 
50  UPtrList<volScalarField>& Y = phase.YActiveRef();
51  const volScalarField& alpha = phase;
52  const volScalarField& rho = phase.rho();
53 
54  forAll(Y, i)
55  {
56  fvScalarMatrix YiEqn
57  (
58  phase.YiEqn(Y[i])
59  ==
60  *specieTransfer[Y[i].name()]
61  + fvModels().source(alpha, rho, Y[i])
62  );
63 
64  YiEqn.relax();
65  fvConstraints().constrain(YiEqn);
66  YiEqn.solve("Yi");
68  }
69  }
70 
72 }
73 
74 
75 void Foam::solvers::multiphaseEuler::energyPredictor()
76 {
77  autoPtr<phaseSystem::heatTransferTable>
78  heatTransferPtr(fluid.heatTransfer());
79 
80  phaseSystem::heatTransferTable& heatTransfer = heatTransferPtr();
81 
82  forAll(fluid.anisothermalPhases(), anisothermalPhasei)
83  {
84  phaseModel& phase = fluid_.anisothermalPhases()[anisothermalPhasei];
85 
86  const volScalarField& alpha = phase;
87  const volScalarField& rho = phase.rho();
88  const tmp<volVectorField> tU(phase.U());
89  const volVectorField& U(tU());
90 
92  (
93  phase.heEqn()
94  ==
95  *heatTransfer[phase.name()]
96  + alpha*rho*(U&buoyancy.g)
97  + fvModels().source(alpha, rho, phase.thermo().he())
98  );
99 
100  EEqn.relax();
102  EEqn.solve();
103  fvConstraints().constrain(phase.thermo().he());
104  }
105 
106  fluid_.correctThermo();
107  fluid_.correctContinuityError();
108 }
109 
110 
111 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
112 
114 {
115  if (pimple.thermophysics())
116  {
117  for (int Ecorr=0; Ecorr<nEnergyCorrectors; Ecorr++)
118  {
119  fluid_.predictThermophysicalTransport();
120  compositionPredictor();
121  energyPredictor();
122 
123  forAll(fluid.anisothermalPhases(), anisothermalPhasei)
124  {
125  const phaseModel& phase =
126  fluid.anisothermalPhases()[anisothermalPhasei];
127 
128  Info<< phase.name() << " min/max T "
129  << min(phase.thermo().T()).value()
130  << " - "
131  << max(phase.thermo().T()).value()
132  << endl;
133  }
134  }
135  }
136 }
137 
138 
139 // ************************************************************************* //
fvScalarMatrix EEqn(fvm::div(phi, he)+(he.name()=="e" ? fvc::div(phi, volScalarField("Ekp", 0.5 *magSqr(U)+p/rho)) :fvc::div(phi, volScalarField("K", 0.5 *magSqr(U))))+thermophysicalTransport->divq(he)==fvModels.source(rho, he))
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual const volScalarField & T() const =0
Temperature [K].
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
virtual const rhoThermo & thermo() const =0
Return the thermophysical model.
const word & name() const
Return the name of this phase.
Definition: phaseModel.C:109
virtual autoPtr< specieTransferTable > specieTransfer() const =0
Return the specie transfer matrices.
virtual void correctReactions()
Correct the reactions.
Definition: phaseSystem.C:630
virtual void correctSpecies()
Correct the species mass fractions.
Definition: phaseSystem.C:639
const phaseModelPartialList & multicomponentPhases() const
Return the models for phases that have multiple species.
Definition: phaseSystemI.H:97
HashPtrTable< fvScalarMatrix > specieTransferTable
Definition: phaseSystem.H:82
HashPtrTable< fvScalarMatrix > heatTransferTable
Definition: phaseSystem.H:80
Foam::fvModels & fvModels() const
Return the fvModels that are created on demand.
Definition: solver.C:85
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:96
Solver module for steady or transient turbulent flow of compressible fluids with heat-transfer for HV...
Definition: fluid.H:70
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
const phaseSystem & fluid
Reference to the multiphase fluid.
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(mesh)
Calculate the first temporal derivative.
Calculate the divergence of the given field.
Calculate the field for explicit evaluation of implicit and explicit sources.
Calculate the matrix for the first temporal derivative.
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for implicit and explicit sources.
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
VolField< vector > volVectorField
Definition: volFieldsFwd.H:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
messageStream Info
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
PtrList< volScalarField > & Y