32#include "viscosityModel.H"
33#include "alphatJayatillekeWallFunctionFvPatchScalarField.H"
47#include "setRootCase.H"
50 _piso = autoPtr<pisoControl>
57#pragma GCC diagnostic push
58#pragma GCC diagnostic ignored "-Wunused-variable"
61#pragma GCC diagnostic pop
70 surfaceScalarField&
phi =
_phi();
72#include "initContinuityErrs.H"
74 pisoControl& piso =
_piso();
75 volScalarField
p =
_p();
76 volVectorField
U =
_U();
77 volScalarField
T =
_T();
79 dimensionedScalar
nu =
_nu();
80 dimensionedScalar
Pr =
_Pr();
85 IOMRFZoneList& MRF =
_MRF();
86 instantList Times =
runTime.times();
101#include "CourantNo.H"
104 Info <<
"Time = " <<
runTime.timeName() << nl << endl;
110 while (piso.correct())
122 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
123 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
134 std::ofstream of(
"./ITHACAoutput/Offline/" + name(
counter) +
"/" +
149 scalar diffnow = mag(
nextWrite - atof(timeObject.timeName().c_str()));
150 scalar diffnext = mag(
nextWrite - atof(timeObject.timeName().c_str()) -
151 timeObject.deltaTValue());
153 if ( diffnow < diffnext)
169 volScalarField&
T =
_T();
176 dimensionedScalar&
Pr =
_Pr();
177 dimensionedScalar&
Prt =
_Prt();
179 volScalarField Tlift(
"Tlift" + name(k),
T);
180 instantList Times =
runTime.times();
182 Info <<
"Solving a lifting Problem" << endl;
186 for (label j = 0; j <
T.boundaryField().size(); j++)
192 else if (
T.boundaryField()[BCind].type() ==
"zeroGradient")
197 else if (
T.boundaryField()[BCind].type() ==
"fixedValue")
207 while (
simple.correctNonOrthogonal())
210 alphat.correctBoundaryConditions();
218 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
219 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
223 scalar totalTime =
mesh.time().value();
224 scalar dt =
mesh.time().deltaTValue();
227 Tlift[
i] = (totalTime * Tlift[
i] + dt * Tlift[
i] ) / (totalTime + dt);
235 label NSUPmodes, label Nnutmodes)
241 for (label j = 0; j < Csize; j++)
247 PtrList<volVectorField> Together(0);
253 for (label k = 0; k <
liftfield.size(); k++)
261 for (label k = 0; k <
NUmodes; k++)
263 Together.append(
Umodes[k].clone());
271 Together.append(
supmodes[k].clone());
275 for (label
i = 0;
i < Csize;
i++)
277 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix CT1_matrix" << endl;
281 for (label k = 0; k < Csize; k++)
283 CT1_matrix[
i](j, k) = fvc::domainIntegrate(Together[
i] & fvc::laplacian(
291 "./ITHACAoutput/Matrices/");
293 "./ITHACAoutput/Matrices/");
295 "./ITHACAoutput/Matrices/CT1");
300 label NSUPmodes, label Nnutmodes)
306 for (label j = 0; j < Csize; j++)
312 PtrList<volVectorField> Together(0);
318 for (label k = 0; k <
liftfield.size(); k++)
326 for (label k = 0; k <
NUmodes; k++)
328 Together.append(
Umodes[k].clone());
336 Together.append(
supmodes[k].clone());
340 for (label
i = 0;
i < Csize;
i++)
342 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix CT2_matrix" << endl;
346 for (label k = 0; k < Csize; k++)
348 CT2_matrix[
i](j, k) = fvc::domainIntegrate(Together[
i] & (fvc::div(
349 nuTmodes[j] * dev((fvc::grad(Together[k]))().
T())))).value();
356 "./ITHACAoutput/Matrices/");
358 "./ITHACAoutput/Matrices/");
360 "./ITHACAoutput/Matrices/CT2");
367 Eigen::MatrixXd
BT_matrix(BTsize, BTsize);
370 PtrList<volVectorField> Together(0);
374 for (label k = 0; k <
liftfield.size(); k++)
382 for (label k = 0; k <
NUmodes; k++)
384 Together.append(
Umodes[k].clone());
392 Together.append(
supmodes[k].clone());
397 for (label
i = 0;
i < BTsize;
i++)
399 for (label j = 0; j < BTsize; j++)
401 BT_matrix(
i, j) = fvc::domainIntegrate(Together[
i] & (fvc::div(dev((
T(fvc::grad(
402 Together[j]))))))).value();
408 "./ITHACAoutput/Matrices/");
410 "./ITHACAoutput/Matrices/");
412 "./ITHACAoutput/Matrices/");
417 label NTmodes, label Nnutmodes)
423 for (label j = 0; j < Stsize; j++)
428 PtrList<volScalarField> Together(0);
442 for (label k = 0; k <
NTmodes; k++)
444 Together.append(
Tmodes[k].clone());
448 for (label
i = 0;
i < Stsize;
i++)
450 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix S_matrix" << endl;
454 for (label k = 0; k < Stsize; k++)
456 S_matrix[
i](j, k) = fvc::domainIntegrate(Together[
i] * fvc::laplacian(
464 "./ITHACAoutput/Matrices/");
466 "./ITHACAoutput/Matrices/");
468 "./ITHACAoutput/Matrices/S");
473 label NSUP, label Nnut, label NT)
529 "./ITHACAoutput/Matrices/");
535 SAMPLES[
i] =
new SPLINTER::DataTable(1, 1);
537 for (label j = 0; j < Ncoeff.cols(); j++)
543 SPLINTER::RadialBasisFunctionType::GAUSSIAN);
544 std::cout <<
"Constructing RadialBasisFunction for mode " <<
i + 1 << std::endl;
forAll(example_CG.gList, solutionI)
volScalarField alphaEff("alphaEff", turbulence->nu()/Pr+alphat)
Header file of the unsteadyNSTTurb class.
label Nnutmodes
Number of viscoisty modes used for the projection.
scalar Prt
Scalar to store the turbulent Prandtl number.
Eigen::MatrixXd BT_matrix
Turbulent viscosity term.
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
List< Eigen::MatrixXd > CT1_matrix
Turbulent viscosity term.
bool checkWrite(Time &timeObject)
Function to check if the solution must be exported.
List< Eigen::MatrixXd > S_matrix
Turbulent diffusivity term.
scalar Pr
Scalar to store the Prandtl number.
List< Eigen::MatrixXd > C_total_matrix
Total C Matrix.
void projectSUP(fileName folder, label NU, label NP, label NSUP, label Nnut, label NT)
Project using a supremizer approach.
List< Eigen::MatrixXd > CT2_matrix
Turbulent viscosity term.
Eigen::MatrixXd B_total_matrix
Total B Matrix.
autoPtr< volScalarField > _alphat
Turbulent thermal diffusivity.
List< Eigen::MatrixXd > turbulenceTerm1(label NUmodes, label NSUPmodes, label Nnutmodes)
CT1 added matrix for the turbulence treatement.
List< Eigen::MatrixXd > turbulenceTerm2(label NUmodes, label NSUPmodes, label Nnutmodes)
CT2 added matrix for the turbulence treatement.
std::vector< SPLINTER::RBFSpline * > rbfsplines
Create a SAMPLES for interpolation.
Eigen::MatrixXd BTturbulence(label NUmodes, label NSUPmodes)
BT added matrix for the turbulence treatement.
std::vector< SPLINTER::DataTable * > SAMPLES
Create a Rbf splines for interpolation.
PtrList< volScalarField > nuTmodes
List of POD modes for eddy viscosity.
autoPtr< dimensionedScalar > _Prt
Turbulent Prandtl number.
autoPtr< volScalarField > _nut
Eddy viscosity field.
List< Eigen::MatrixXd > temperatureTurbulenceTerm(label NTmodes, label Nnutmodes)
S added matrix for the thermal turbulence treatement.
autoPtr< dimensionedScalar > _Pr
Prandtl number.
void liftSolveT()
Perform a lift solve for temperature field.
UnsteadyNSTTurb()
Construct Null.
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.
Eigen::MatrixXd mu
Row matrix of parameters.
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.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
autoPtr< fv::options > _fvOptions
fvOptions
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.
autoPtr< singlePhaseTransportModel > _laminarTransport
Laminar transport (used by turbulence model)
label NUmodes
Number of velocity modes used for the projection.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
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.
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.
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.
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.
Eigen::MatrixXd MT_matrix
Mass Matrix T.
autoPtr< fvMesh > _mesh
Mesh.
PtrList< volScalarField > Tmodes
List of pointers used to form the temperature modes.
autoPtr< incompressible::turbulenceModel > turbulence
Turbulence model.
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 ...
List< Eigen::MatrixXd > readMatrix(word folder, word mat_name)
Read a three dimensional matrix from a txt file in Eigen format.
Eigen::VectorXd getCoeffs(GeometricField< Type, PatchField, GeoMesh > &snapshot, PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, label Nmodes, bool consider_volumes)
Projects a snapshot on a basis function and gets the coefficients of the projection.
bool check_folder(word folder)
Checks if a folder exists.
bool check_sup()
Check if the supremizer folder exists.
simpleControl simple(mesh)
singlePhaseTransportModel & laminarTransport