45 _args = autoPtr<argList>
47 new argList(argc, argv)
50 if (!
_args->checkRootCase())
52 Foam::FatalError.exit();
55 argList& args =
_args();
56#include "createTime.H"
57 Info <<
"Create a dynamic mesh for time = "
58 << runTime.timeName() << nl << endl;
59 meshPtr = autoPtr<dynamicFvMesh> (dynamicFvMesh::New(args, runTime));
60 dynamicFvMesh& mesh = meshPtr();
61 _pimple = autoPtr<pimpleControl>
68 pimpleControl& pimple =
_pimple();
69#include "createFields.H"
71#include "initContinuityErrs.H"
72 turbulence->validate();
98 volVectorField& U =
_U();
99 volScalarField& p = pThermo().p();
100 volScalarField& E = pThermo().he();
101 pimpleControl& pimple =
_pimple();
102 volScalarField
_nut(turbulence->nut());
103 instantList Times = runTime.times();
105 runTime.setTime(Times[1], 1);
114 const volScalarField&
mu = pThermo().mu();
115 volScalarField& mu_field =
const_cast<volScalarField&
>(
mu);
118 for (
int i = 0; i < mu_field.boundaryFieldRef().size(); i++)
120 this->
assignBC(mu_field, i, mu_new);
124fvVectorMatrix CompressibleUnSteadyRhoPimple::getNLTerm(volVectorField& U)
126 surfaceScalarField& phi =
_phi();
127 fvVectorMatrix NLTerm = fvm::div(phi, U);
131fvVectorMatrix CompressibleUnSteadyRhoPimple::getViscTerm(volVectorField& U)
133 volScalarField& rho = _rho();
134 volScalarField nuEff = turbulence->nuEff();
136 fvVectorMatrix viscTerm = - fvc::div((rho * nuEff) * dev2(T(fvc::grad(
137 U)))) - fvm::laplacian(rho * nuEff, U);
141volVectorField CompressibleUnSteadyRhoPimple::getGradP(volScalarField& p)
143 volVectorField gradP = fvc::grad(p);
148fvVectorMatrix CompressibleUnSteadyRhoPimple::getUmatrix(volVectorField& U)
150 volScalarField& rho = _rho();
163 Ueqn_global().relax();
164 fvOptions.constrain(Ueqn_global());
165 return Ueqn_global();
168fvScalarMatrix CompressibleUnSteadyRhoPimple::getFluxTerm()
170 volScalarField& he = pThermo().he();
171 surfaceScalarField& phi =
_phi();
172 fvScalarMatrix fluxTerm = fvm::div(phi, he);
176volScalarField CompressibleUnSteadyRhoPimple::getKinEnTerm(volVectorField& U,
179 surfaceScalarField& phi =
_phi();
180 volScalarField& rho = _rho();
181 volScalarField kinEn = fvc::div(phi, volScalarField(
"Ekp",
182 0.5 * magSqr(U) + p / rho));
186fvScalarMatrix CompressibleUnSteadyRhoPimple::getDiffTerm()
188 volScalarField& he = pThermo().he();
189 fvScalarMatrix diffTerm = fvm::laplacian(turbulence->alphaEff(), he);
193fvScalarMatrix CompressibleUnSteadyRhoPimple::getEmatrix(volVectorField& U,
196 volScalarField& he = pThermo().he();
197 volScalarField& rho = _rho();
199 Eeqn_global.reset(
new fvScalarMatrix(
200 getFluxTerm() + getKinEnTerm(U, p) - getDiffTerm()
204 Eeqn_global().relax();
205 fvOptions.constrain(Eeqn_global());
206 return Eeqn_global();
209surfaceScalarField CompressibleUnSteadyRhoPimple::getPhiHbyA(
210 fvVectorMatrix& Ueqn,
211 volVectorField& U, volScalarField& p)
213 volScalarField& rho = _rho();
214 volScalarField rAU(1.0 /
216 HbyA.reset(
new volVectorField(constrainHbyA(rAU * Ueqn.H(), U,
218 phiHbyA.reset(
new surfaceScalarField(
"phiHbyA",
219 fvc::interpolate(rho)*fvc::flux(HbyA.ref())));
223volScalarField CompressibleUnSteadyRhoPimple::getDivPhiHbyA(
224 fvVectorMatrix& Ueqn,
225 volVectorField& U, volScalarField& p)
227 volScalarField divPhiHbyA = fvc::div(getPhiHbyA(Ueqn, U, p));
231surfaceScalarField CompressibleUnSteadyRhoPimple::getRhorAUf(
232 fvVectorMatrix& Ueqn)
234 volScalarField& rho = _rho();
235 volScalarField rAU(1.0 /
237 rhorAUf.reset(
new surfaceScalarField(
"rhorAUf", fvc::interpolate(rho * rAU)));
241fvScalarMatrix CompressibleUnSteadyRhoPimple::getPoissonTerm(
242 fvVectorMatrix& Ueqn, volScalarField& p)
244 fvScalarMatrix poissonTerm = fvm::laplacian(getRhorAUf(Ueqn), p);
248fvScalarMatrix CompressibleUnSteadyRhoPimple::getPmatrix(fvVectorMatrix& Ueqn,
249 volVectorField& U, volScalarField& p)
251 volScalarField& rho = _rho();
253 volScalarField& psi = _psi();
254 pressureControl& pressureControl = _pressureControl();
255 Peqn_global.reset(
new fvScalarMatrix(
256 getDivPhiHbyA(Ueqn, U, p)
257 - getPoissonTerm(Ueqn, p)
259 fvOptions(psi, p, rho.name())
261 Peqn_global().setReference
263 pressureControl.refCell(),
264 pressureControl.refValue()
266 return Peqn_global();
272 _mesh().objectRegistry::clear();
283 _initialMass.clear();
284 _pressureControl.clear();
287 argList& args =
_args();
288 Info <<
"ReCreate time\n" << Foam::endl;
290 runTime.setTime(0, 1);
291 Foam::fvMesh& mesh =
_mesh();
292 _simple = autoPtr<simpleControl>
299 simpleControl& simple =
_simple();
300 pThermo = autoPtr<fluidThermo>
302 fluidThermo::New(mesh)
304 fluidThermo& thermo = pThermo();
305 thermo.validate(
_args().executable(),
"h",
"e");
306 _p = autoPtr<volScalarField>
308 new volScalarField(thermo.p())
310 volScalarField& p = thermo.p();
311 _rho = autoPtr<volScalarField>
320 IOobject::READ_IF_PRESENT,
326 volScalarField& rho = _rho();
327 _E = autoPtr<volScalarField>
329 new volScalarField(thermo.he())
331 Info <<
"ReReading field U\n" << endl;
332 _U = autoPtr<volVectorField>
347 volVectorField& U =
_U();
348 Info <<
"ReReading/calculating face flux field phi\n" << endl;
349 _phi = autoPtr<surfaceScalarField>
351 new surfaceScalarField
358 IOobject::READ_IF_PRESENT,
361 linearInterpolate(rho * U) & mesh.Sf()
364 surfaceScalarField& phi =
_phi();
365 _pressureControl = autoPtr<pressureControl>
367 new pressureControl(p, rho,
_simple().dict())
369 mesh.setFluxRequired(p.name());
370 Info <<
"ReCreating turbulence model\n" << endl;
371 turbulence = autoPtr<compressible::turbulenceModel>
373 compressible::turbulenceModel::New
381 _initialMass = autoPtr<dimensionedScalar>
383 new dimensionedScalar(fvc::domainIntegrate(rho))
385 _psi = autoPtr<volScalarField>
387 new volScalarField(thermo.psi())
389 _fvOptions = autoPtr<fv::options>(
new fv::options(mesh));
390#include "initContinuityErrs.H"
Header file of the CompressibleUnSteadyPimple class.
CompressibleUnSteadyRhoPimple()
Null constructor.
void changeViscosity(double mu_new)
Function to change the viscosity.
void restart()
set all variables back to the values into the 0 folder
autoPtr< pimpleControl > _pimple
pimpleControl
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.
scalar startTime
Start Time (initial time to start storing the snapshots).
scalar timeStep
Time step of the simulation.
scalar nextWrite
Auxiliary variable to store the next writing instant.
scalar finalTime
Final time (final time of the simulation and consequently of the acquisition of the snapshots).
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.
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.