36#include "viscosityModel.H"
47 _args = autoPtr<argList>
49 new argList(argc, argv)
52 if (!
_args->checkRootCase())
54 Foam::FatalError.exit();
57 argList& args =
_args();
58#include "createTime.H"
59#include "createMesh.H"
60 _simple = autoPtr<simpleControl>
67 simpleControl& simple =
_simple();
68#include "createFields.H"
70#include "initContinuityErrs.H"
72 turbulence->validate();
87 middleExport = para->ITHACAdict->lookupOrDefault<
bool>(
"middleExport",
true);
88 middleStep = para->ITHACAdict->lookupOrDefault<label>(
"middleStep", 20);
99 volVectorField& U =
_U();
100 volScalarField& p = pThermo().p();
101 volScalarField& E = pThermo().he();
102 simpleControl& simple =
_simple();
103 volScalarField
_nut(turbulence->nut());
118 const volScalarField&
mu = pThermo().mu();
119 volScalarField& mu_field =
const_cast<volScalarField&
>(
mu);
122 for (
int i = 0; i < mu_field.boundaryFieldRef().size(); i++)
124 this->
assignBC(mu_field, i, mu_new);
128fvVectorMatrix CompressibleSteadyNS::getNLTerm(volVectorField& U)
130 surfaceScalarField& phi =
_phi();
131 fvVectorMatrix NLTerm = fvm::div(phi, U);
135fvVectorMatrix CompressibleSteadyNS::getViscTerm(volVectorField& U)
137 volScalarField& rho = _rho();
138 volScalarField nuEff = turbulence->nuEff();
140 fvVectorMatrix viscTerm = - fvc::div((rho * nuEff) * dev2(T(fvc::grad(
141 U)))) - fvm::laplacian(rho * nuEff, U);
145volVectorField CompressibleSteadyNS::getGradP(volScalarField& p)
147 volVectorField gradP = fvc::grad(p);
152fvVectorMatrix CompressibleSteadyNS::getUmatrix(volVectorField&
155 volScalarField& rho = _rho();
157 Ueqn_global.reset(
new fvVectorMatrix(getNLTerm(U)
162 Ueqn_global().relax();
163 fvOptions.constrain(Ueqn_global());
164 return Ueqn_global();
167fvScalarMatrix CompressibleSteadyNS::getFluxTerm()
169 volScalarField& he = pThermo().he();
170 surfaceScalarField& phi =
_phi();
171 fvScalarMatrix fluxTerm = fvm::div(phi, he);
175volScalarField CompressibleSteadyNS::getKinEnTerm(volVectorField& U,
178 surfaceScalarField& phi =
_phi();
179 volScalarField& rho = _rho();
180 volScalarField kinEn = fvc::div(phi, volScalarField(
"Ekp",
181 0.5 * magSqr(U) + p / rho));
185fvScalarMatrix CompressibleSteadyNS::getDiffTerm()
187 volScalarField& he = pThermo().he();
188 fvScalarMatrix diffTerm = fvm::laplacian(turbulence->alphaEff(), he);
192fvScalarMatrix CompressibleSteadyNS::getEmatrix(volVectorField& U,
195 volScalarField& he = pThermo().he();
196 volScalarField& rho = _rho();
198 Eeqn_global.reset(
new fvScalarMatrix(
199 getFluxTerm() + getKinEnTerm(U, p) - getDiffTerm()
203 Eeqn_global().relax();
204 fvOptions.constrain(Eeqn_global());
205 return Eeqn_global();
208surfaceScalarField CompressibleSteadyNS::getPhiHbyA(fvVectorMatrix& Ueqn,
209 volVectorField& U, volScalarField& p)
211 volScalarField& rho = _rho();
212 volScalarField rAU(1.0 /
214 HbyA.reset(
new volVectorField(constrainHbyA(rAU * Ueqn.H(), U,
216 phiHbyA.reset(
new surfaceScalarField(
"phiHbyA",
217 fvc::interpolate(rho)*fvc::flux(HbyA())));
221volScalarField CompressibleSteadyNS::getDivPhiHbyA(fvVectorMatrix& Ueqn,
222 volVectorField& U, volScalarField& p)
224 volScalarField divPhiHbyA = fvc::div(getPhiHbyA(Ueqn, U, p));
228surfaceScalarField CompressibleSteadyNS::getRhorAUf(fvVectorMatrix& Ueqn)
230 volScalarField& rho = _rho();
231 volScalarField rAU(1.0 /
233 rhorAUf.reset(
new surfaceScalarField(
"rhorAUf", fvc::interpolate(rho * rAU)));
237fvScalarMatrix CompressibleSteadyNS::getPoissonTerm(fvVectorMatrix& Ueqn,
240 fvScalarMatrix poissonTerm = fvm::laplacian(getRhorAUf(Ueqn), p);
244fvScalarMatrix CompressibleSteadyNS::getPmatrix(fvVectorMatrix& Ueqn,
245 volVectorField& U, volScalarField& p)
247 volScalarField& rho = _rho();
249 volScalarField& psi = _psi();
250 pressureControl& pressureControl = _pressureControl();
251 Peqn_global.reset(
new fvScalarMatrix(
252 getDivPhiHbyA(Ueqn, U, p)
253 - getPoissonTerm(Ueqn, p)
255 fvOptions(psi, p, rho.name())
257 Peqn_global().setReference
259 pressureControl.refCell(),
260 pressureControl.refValue()
262 return Peqn_global();
268 _mesh().objectRegistry::clear();
279 _initialMass.clear();
280 _pressureControl.clear();
283 argList& args =
_args();
284 Info <<
"ReCreate time\n" << Foam::endl;
289 runTime.setTime(0, 1);
303 Foam::fvMesh& mesh =
_mesh();
304 _simple = autoPtr<simpleControl>
311 simpleControl& simple =
_simple();
312 pThermo = autoPtr<fluidThermo>
314 fluidThermo::New(mesh)
316 fluidThermo& thermo = pThermo();
317 thermo.validate(
_args().executable(),
"h",
"e");
318 _p = autoPtr<volScalarField>
320 new volScalarField(thermo.p())
322 volScalarField& p = thermo.p();
323 _rho = autoPtr<volScalarField>
332 IOobject::READ_IF_PRESENT,
338 volScalarField& rho = _rho();
339 _E = autoPtr<volScalarField>
341 new volScalarField(thermo.he())
343 Info <<
"ReReading field U \n" << endl;
344 _U = autoPtr<volVectorField>
359 volVectorField& U =
_U();
360 Info <<
"ReReading/calculating face flux field phi\n" << endl;
361 _phi = autoPtr<surfaceScalarField>
363 new surfaceScalarField
370 IOobject::READ_IF_PRESENT,
373 linearInterpolate(rho * U) & mesh.Sf()
376 surfaceScalarField& phi =
_phi();
377 _pressureControl = autoPtr<pressureControl>
379 new pressureControl(p, rho,
_simple().dict())
381 mesh.setFluxRequired(p.name());
382 Info <<
"ReCreating turbulence model\n" << endl;
383 turbulence = autoPtr<compressible::turbulenceModel>
385 compressible::turbulenceModel::New
393 _initialMass = autoPtr<dimensionedScalar>
395 new dimensionedScalar(fvc::domainIntegrate(rho))
397 _psi = autoPtr<volScalarField>
399 new volScalarField(thermo.psi())
401 _fvOptions = autoPtr<fv::options>(
new fv::options(mesh));
402#include "initContinuityErrs.H"
Header file of the steadyNS class.
CompressibleSteadyNS()
Null constructor.
void changeViscosity(double mu_new)
Function to change the viscosity.
bool middleExport
Export also intermediate fields.
label middleStep
Distancing between intermediate steps (for turbulent case only).
void restart()
set all variables back to the values into the 0 folder
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
autoPtr< volScalarField > _nut
Eddy viscosity field.
label counter
Counter used for the output of the full order solutions.
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
void assignIF(T &s, G &value)
Assign internal field condition.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
IOdictionary * ITHACAdict
dictionary to store input output infos
Eigen::MatrixXd mu
Row matrix of parameters.
autoPtr< argList > _args
argList
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
bool supex
Boolean variable to check the existence of the supremizer modes.
autoPtr< surfaceScalarField > _phi
Flux.
autoPtr< simpleControl > _simple
simpleControl
autoPtr< fv::options > _fvOptions
fvOptions
autoPtr< Time > _runTime
Time.
autoPtr< fvMesh > _mesh
Mesh.
autoPtr< volVectorField > _U
Velocity field.
bool check_pod()
Check if the POD data folder "./ITHACAoutput/POD" exists.
bool check_off()
Check if the offline data folder "./ITHACAoutput/Offline" exists.
bool check_sup()
Check if the supremizer folder exists.