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-2024 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.YRef();
51  const volScalarField& alpha = phase;
52  const volScalarField& rho = phase.rho();
53 
54  forAll(Y, i)
55  {
56  if (phase.solveSpecie(i))
57  {
58  fvScalarMatrix YiEqn
59  (
60  phase.YiEqn(Y[i])
61  ==
62  *specieTransfer[Y[i].name()]
63  + fvModels().source(alpha, rho, Y[i])
64  );
65 
66  YiEqn.relax();
67 
68  fvConstraints().constrain(YiEqn);
69 
70  YiEqn.solve("Yi");
71 
73  }
74  else
75  {
76  Y[i].correctBoundaryConditions();
77  }
78  }
79  }
80 
82 }
83 
84 
85 void Foam::solvers::multiphaseEuler::energyPredictor()
86 {
87  autoPtr<phaseSystem::heatTransferTable>
88  heatTransferPtr(fluid.heatTransfer());
89 
90  phaseSystem::heatTransferTable& heatTransfer = heatTransferPtr();
91 
92  forAll(fluid.anisothermalPhases(), anisothermalPhasei)
93  {
94  phaseModel& phase = fluid_.anisothermalPhases()[anisothermalPhasei];
95 
96  const volScalarField& alpha = phase;
97  const volScalarField& rho = phase.rho();
98 
100  (
101  phase.heEqn()
102  ==
103  *heatTransfer[phase.name()]
104  + fvModels().source(alpha, rho, phase.thermo().he())
105  );
106 
107  EEqn.relax();
109  EEqn.solve();
110  fvConstraints().constrain(phase.thermo().he());
111  }
112 
113  fluid_.correctThermo();
114  fluid_.correctContinuityError();
115 }
116 
117 
118 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
119 
121 {
122  if (pimple.thermophysics())
123  {
124  for (int Ecorr=0; Ecorr<nEnergyCorrectors; Ecorr++)
125  {
126  fluid_.predictThermophysicalTransport();
127  compositionPredictor();
128  energyPredictor();
129 
130  forAll(fluid.anisothermalPhases(), anisothermalPhasei)
131  {
132  const phaseModel& phase =
133  fluid.anisothermalPhases()[anisothermalPhasei];
134 
135  Info<< phase.name() << " min/max T "
136  << min(phase.thermo().T()).value()
137  << " - "
138  << max(phase.thermo().T()).value()
139  << endl;
140  }
141  }
142  }
143 }
144 
145 
146 // ************************************************************************* //
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:145
virtual autoPtr< specieTransferTable > specieTransfer() const =0
Return the specie transfer matrices.
virtual void correctReactions()
Correct the reactions.
Definition: phaseSystem.C:622
virtual void correctSpecies()
Correct the species mass fractions.
Definition: phaseSystem.C:631
const phaseModelPartialList & multicomponentPhases() const
Return the models for phases that have multiple species.
Definition: phaseSystemI.H:158
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:96
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:107
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.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
messageStream Info
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
PtrList< volScalarField > & Y