44 _args = autoPtr<argList>
46 new argList(argc, argv)
49 if (!
_args->checkRootCase())
51 Foam::FatalError.exit();
54 argList& args =
_args();
58 _piso = autoPtr<pisoControl>
79 surfaceScalarField&
phi =
_phi();
81#include "initContinuityErrs.H"
82 pisoControl& piso =
_piso();
83 volScalarField&
p =
_p();
84 volVectorField&
U =
_U();
85 volScalarField&
T =
_T();
86 dimensionedScalar DT =
_DT();
87 dimensionedScalar
nu =
_nu();
88 instantList Times =
runTime.times();
101 Info <<
"Time = " <<
runTime.timeName() << nl << endl;
102#include "CourantNo.H"
108 - fvm::laplacian(
nu,
U)
111 if (piso.momentumPredictor())
117 while (piso.correct())
130 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
131 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
142 std::ofstream of(
"./ITHACAoutput/Offline/" + name(
counter) +
"/" +
156 scalar diffnow = mag(
nextWrite - atof(timeObject.timeName().c_str()));
157 scalar diffnext = mag(
nextWrite - atof(timeObject.timeName().c_str()) -
158 timeObject.deltaTValue());
160 if ( diffnow < diffnext)
177 volScalarField
T =
_T();
178 volScalarField
p =
_p();
179 volVectorField
U =
_U();
180 dimensionedScalar DT =
_DT();
182 volScalarField Tlift(
"Tlift" + name(k),
T);
183 volVectorField Ulift(
"Ulift" + name(k),
U);
184 pisoControl potentialFlow(
mesh,
"potentialFlow");
185 instantList Times =
runTime.times();
188 dimensionedScalar
nu =
_nu();
193 for (label j = 0; j <
T.boundaryField().size(); j++)
199 else if (
T.boundaryField()[BCind].type() ==
"zeroGradient")
204 else if (
T.boundaryField()[BCind].type() ==
"fixedValue")
214 while (
simple.correctNonOrthogonal())
219 - fvm::laplacian(DT, Tlift)
222 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
223 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
227 scalar totalTime =
mesh.time().value();
228 scalar dt =
mesh.time().deltaTValue();
231 Tlift[
i] = (totalTime * Tlift[
i] + dt * Tlift[
i] ) / (totalTime + dt);
252 word M_str =
"M_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
264 word B_str =
"B_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
276 word C_str =
"C_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
288 word K_str =
"K_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
323 word P_str =
"P_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
341 for (label k = 0; k <
liftfield.size(); k++)
349 for (label k = 0; k <
NUmodes; k++)
375 for (label k = 0; k <
NTmodes; k++)
401 for (label j = 0; j < Qsizet; j++)
407 for (label
i = 0;
i < Qsizet;
i++)
409 for (label j = 0; j < Qsize; j++)
411 for (label k = 0; k < Qsizet; k++)
432 Eigen::MatrixXd
Y_matrix(Ysize, Ysize);
433 dimensionedScalar DT =
_DT();
435 for (label
i = 0;
i < Ysize;
i++)
437 for (label j = 0; j < Ysize; j++)
440 dimensionedScalar(
"1", dimless, 1),
L_T_modes[j])).value();
457 for (label
i = 0;
i < Ysize;
i++)
459 for (label j = 0; j < Ysize; j++)
477 surfaceScalarField&
phi =
_phi();
479 volScalarField
p =
_p();
480 volVectorField
U =
_U();
481 dimensionedScalar
nu =
_nu();
482 IOMRFZoneList& MRF =
_MRF();
484 volVectorField Ulift(
"Ulift" + name(k),
U);
485 instantList Times =
runTime.times();
487 pisoControl potentialFlow(
mesh,
"potentialFlow");
488 Info <<
"Solving a lifting Problem" << endl;
489 Vector<double> v1(0, 0, 0);
491 Vector<double>
v0(0, 0, 0);
493 for (label j = 0; j <
U.boundaryField().size(); j++)
499 else if (
U.boundaryField()[BCind].type() ==
"fixedValue")
508 phi = linearInterpolate(Ulift) &
mesh.Sf();
511 Info <<
"Constructing velocity potential field Phi\n" << endl;
519 IOobject::READ_IF_PRESENT,
523 dimensionedScalar(
"Phi", dimLength * dimVelocity, 0),
524 p.boundaryField().types()
526 label PhiRefCell = 0;
527 scalar PhiRefValue = 0;
531 potentialFlow.dict(),
535 mesh.setFluxRequired(Phi.name());
536 runTime.functionObjects().start();
537 MRF.makeRelative(
phi);
540 while (potentialFlow.correctNonOrthogonal())
542 fvScalarMatrix PhiEqn
544 fvm::laplacian(dimensionedScalar(
"1", dimless, 1), Phi)
549 PhiEqn.setReference(PhiRefCell, PhiRefValue);
552 if (potentialFlow.finalNonOrthogonalIter())
554 phi -= PhiEqn.flux();
558 MRF.makeAbsolute(
phi);
559 Info <<
"Continuity error = "
560 << mag(fvc::div(
phi))().weightedAverage(
mesh.V()).value()
562 Ulift = fvc::reconstruct(
phi);
563 Ulift.correctBoundaryConditions();
564 Info <<
"Interpolated velocity error = "
565 << (sqrt(sum(sqr((fvc::interpolate(
U) &
mesh.Sf()) -
phi)))
566 / sum(
mesh.magSf())).value()
forAll(example_CG.gList, solutionI)
Eigen::MatrixXi inletIndexT
void writeMu(List< scalar > mu_now)
Write out a list of scalar corresponding to the parameters used in the truthSolve.
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.
autoPtr< argList > _args
argList
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
label NPmodes
Number of pressure modes used for the projection.
bool supex
Boolean variable to check the existence of the supremizer modes.
Eigen::MatrixXd diffusive_term(label NUmodes, label NPmodes, label NSUPmodes)
Diffusive Term.
autoPtr< surfaceScalarField > _phi
Flux.
Eigen::Tensor< double, 3 > C_tensor
Diffusion term.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
volVectorModes Umodes
List of pointers used to form the velocity modes.
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
Eigen::MatrixXd divergence_term(label NUmodes, label NPmodes, label NSUPmodes)
Divergence Term (supremizer approach)
Eigen::MatrixXd mass_term(label NUmodes, label NPmodes, label NSUPmodes)
Mass Term.
label NUmodes
Number of velocity modes used for the projection.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
volVectorModes L_U_SUPmodes
List of pointers containing the total number of lift, supremizer and velocity modes.
Eigen::MatrixXd B_matrix
Diffusion term.
autoPtr< IOMRFZoneList > _MRF
MRF variable.
label NSUPmodes
Number of supremizer modes used for the projection.
Eigen::MatrixXd K_matrix
Gradient of pressure matrix.
List< Eigen::MatrixXd > C_matrix
Non linear term.
Eigen::Tensor< double, 3 > convective_term_tens(label NUmodes, label NPmodes, label NSUPmodes)
Export convective term as a tensor.
List< Eigen::MatrixXd > convective_term(label NUmodes, label NPmodes, label NSUPmodes)
Convective Term.
Eigen::MatrixXd pressure_gradient_term(label NUmodes, label NPmodes, label NSUPmodes)
Gradient of pressure.
Eigen::MatrixXd P_matrix
Div of velocity.
Eigen::MatrixXd M_matrix
Mass Matrix.
autoPtr< volVectorField > _U
Velocity field.
autoPtr< volScalarField > _p
Pressure field.
Eigen::MatrixXd Y_matrix
Gradient of pressure matrix.
PtrList< volScalarField > Tfield
List of pointers used to form the temperature snapshots matrix.
List< Eigen::MatrixXd > convective_term_temperature(label NUmodes, label NTmodes, label NSUPmodes)
Convective Term for Temperature.
unsteadyNST()
Constructors.
List< Eigen::MatrixXd > Q_matrix
Non linear term.
PtrList< volScalarField > liftfieldT
List of pointers used to form the list of the temperature lifting functions.
scalar timeStep
Time step of the simulation.
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NTmodes, label NSUPmodes)
Specific variable for the unstationary case.
bool checkWrite(Time &timeObject)
Function to check if the solution must be exported.
autoPtr< Time > _runTime
Time.
label NTmodes
Number of temperature modes used for the projection.
scalar finalTime
Final time (final time of the simulation and consequently of the acquisition of the snapshots)
Eigen::MatrixXd diffusive_term_temperature(label NUmodes, label NTmodes, label NSUPmodes)
Diffusive Term for Temperature.
autoPtr< dimensionedScalar > _nu
dimensionedScalar nu;
Eigen::MatrixXd mass_term_temperature(label NUmodes, label NTmodes, label NSUPmodes)
Mass Term for Temperature.
scalar nextWrite
Auxiliary variable to store the next writing instant.
scalar startTime
Start Time (initial time to start storing the snapshots)
autoPtr< volScalarField > _T
Temperature field.
autoPtr< pisoControl > _piso
pisoControl
scalar writeEvery
Time step of the writing procedure.
void liftSolve()
Perform a lift solve for velocity field.
Eigen::MatrixXd MT_matrix
Mass Matrix T.
autoPtr< dimensionedScalar > _DT
dimensionedScalar DT;
autoPtr< fvMesh > _mesh
Mesh.
PtrList< volScalarField > Tmodes
List of pointers used to form the temperature modes.
PtrList< volScalarField > L_T_modes
List of pointers containing the lift for temperature and the temperature field.
void liftSolveT()
Perform a lift solve for temperature field.
void ReadDenseMatrix(MatrixType &Matrix, word folder, word MatrixName)
Read a dense matrix from a binary format file.
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
void exportMatrix(Eigen::Matrix< T, -1, dim > &matrix, word Name, word type, word folder)
Export the reduced matrices in numpy (type=python), matlab (type=matlab) and txt (type=eigen) format ...
void SaveDenseMatrix(MatrixType &Matrix, word folder, word MatrixName)
Save a dense matrix to a binary format file.
void ReadDenseTensor(TensorType &Tensor, word folder, word MatrixName)
Read a dense tensor from file.
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_folder(word folder)
Checks if a folder exists.
bool check_file(std::string fileName)
Function that returns true if a file exists.
bool check_sup()
Check if the supremizer folder exists.
simpleControl simple(mesh)
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue)
Header file of the unsteadyNST class.