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);
251 word M_str =
"M_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
263 word B_str =
"B_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
275 word C_str =
"C_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
287 word K_str =
"K_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
322 word P_str =
"P_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
340 for (label k = 0; k <
liftfield.size(); k++)
348 for (label k = 0; k <
NUmodes; k++)
374 for (label k = 0; k <
NTmodes; k++)
393 label NTmodes, label NSUPmodes)
400 for (label j = 0; j < Qsizet; j++)
406 for (label
i = 0;
i < Qsizet;
i++)
408 for (label j = 0; j < Qsize; j++)
410 for (label k = 0; k < Qsizet; k++)
428 label NTmodes, label NSUPmodes)
431 Eigen::MatrixXd
Y_matrix(Ysize, Ysize);
432 dimensionedScalar DT =
_DT();
434 for (label
i = 0;
i < Ysize;
i++)
436 for (label j = 0; j < Ysize; j++)
439 dimensionedScalar(
"1", dimless, 1),
L_T_modes[j])).value();
455 for (label
i = 0;
i < Ysize;
i++)
457 for (label j = 0; j < Ysize; j++)
474 surfaceScalarField&
phi =
_phi();
476 volScalarField
p =
_p();
477 volVectorField
U =
_U();
478 dimensionedScalar
nu =
_nu();
479 IOMRFZoneList& MRF =
_MRF();
481 volVectorField Ulift(
"Ulift" + name(k),
U);
482 instantList Times =
runTime.times();
484 pisoControl potentialFlow(
mesh,
"potentialFlow");
485 Info <<
"Solving a lifting Problem" << endl;
486 Vector<double> v1(0, 0, 0);
488 Vector<double>
v0(0, 0, 0);
490 for (label j = 0; j <
U.boundaryField().size(); j++)
496 else if (
U.boundaryField()[BCind].type() ==
"fixedValue")
505 phi = linearInterpolate(Ulift) &
mesh.Sf();
508 Info <<
"Constructing velocity potential field Phi\n" << endl;
516 IOobject::READ_IF_PRESENT,
520 dimensionedScalar(
"Phi", dimLength * dimVelocity, 0),
521 p.boundaryField().types()
523 label PhiRefCell = 0;
524 scalar PhiRefValue = 0;
528 potentialFlow.dict(),
532 mesh.setFluxRequired(Phi.name());
533 runTime.functionObjects().start();
534 MRF.makeRelative(
phi);
537 while (potentialFlow.correctNonOrthogonal())
539 fvScalarMatrix PhiEqn
541 fvm::laplacian(dimensionedScalar(
"1", dimless, 1), Phi)
546 PhiEqn.setReference(PhiRefCell, PhiRefValue);
549 if (potentialFlow.finalNonOrthogonalIter())
551 phi -= PhiEqn.flux();
555 MRF.makeAbsolute(
phi);
556 Info <<
"Continuity error = "
557 << mag(fvc::div(
phi))().weightedAverage(
mesh.V()).value()
559 Ulift = fvc::reconstruct(
phi);
560 Ulift.correctBoundaryConditions();
561 Info <<
"Interpolated velocity error = "
562 << (sqrt(sum(sqr((fvc::interpolate(
U) &
mesh.Sf()) -
phi)))
563 / 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.