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())
124 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
125 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
136 std::ofstream of(
"./ITHACAoutput/Offline/" + name(
counter) +
"/" +
151 scalar diffnow = mag(
nextWrite - atof(timeObject.timeName().c_str()));
152 scalar diffnext = mag(
nextWrite - atof(timeObject.timeName().c_str()) -
153 timeObject.deltaTValue());
155 if ( diffnow < diffnext)
171 volScalarField&
T =
_T();
178 dimensionedScalar&
Pr =
_Pr();
179 dimensionedScalar&
Prt =
_Prt();
181 volScalarField Tlift(
"Tlift" + name(k),
T);
182 instantList Times =
runTime.times();
184 Info <<
"Solving a lifting Problem" << endl;
188 for (label j = 0; j <
T.boundaryField().size(); j++)
194 else if (
T.boundaryField()[BCind].type() ==
"zeroGradient")
199 else if (
T.boundaryField()[BCind].type() ==
"fixedValue")
209 while (
simple.correctNonOrthogonal())
212 alphat.correctBoundaryConditions();
220 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
221 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
225 scalar totalTime =
mesh.time().value();
226 scalar dt =
mesh.time().deltaTValue();
229 Tlift[
i] = (totalTime * Tlift[
i] + dt * Tlift[
i] ) / (totalTime + dt);
244 for (label j = 0; j < Csize; j++)
250 PtrList<volVectorField> Together(0);
256 for (label k = 0; k <
liftfield.size(); k++)
264 for (label k = 0; k <
NUmodes; k++)
266 Together.append(
Umodes[k].clone());
274 Together.append(
supmodes[k].clone());
278 for (label
i = 0;
i < Csize;
i++)
280 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix CT1_matrix" << endl;
284 for (label k = 0; k < Csize; k++)
286 CT1_matrix[
i](j, k) = fvc::domainIntegrate(Together[
i] & fvc::laplacian(
294 "./ITHACAoutput/Matrices/");
296 "./ITHACAoutput/Matrices/");
298 "./ITHACAoutput/Matrices/CT1");
309 for (label j = 0; j < Csize; j++)
315 PtrList<volVectorField> Together(0);
321 for (label k = 0; k <
liftfield.size(); k++)
329 for (label k = 0; k <
NUmodes; k++)
331 Together.append(
Umodes[k].clone());
339 Together.append(
supmodes[k].clone());
343 for (label
i = 0;
i < Csize;
i++)
345 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix CT2_matrix" << endl;
349 for (label k = 0; k < Csize; k++)
351 CT2_matrix[
i](j, k) = fvc::domainIntegrate(Together[
i] & (fvc::div(
352 nuTmodes[j] * dev((fvc::grad(Together[k]))().
T())))).value();
359 "./ITHACAoutput/Matrices/");
361 "./ITHACAoutput/Matrices/");
363 "./ITHACAoutput/Matrices/CT2");
370 Eigen::MatrixXd
BT_matrix(BTsize, BTsize);
373 PtrList<volVectorField> Together(0);
377 for (label k = 0; k <
liftfield.size(); k++)
385 for (label k = 0; k <
NUmodes; k++)
387 Together.append(
Umodes[k].clone());
395 Together.append(
supmodes[k].clone());
400 for (label
i = 0;
i < BTsize;
i++)
402 for (label j = 0; j < BTsize; j++)
404 BT_matrix(
i, j) = fvc::domainIntegrate(Together[
i] & (fvc::div(dev((
T(fvc::grad(
405 Together[j]))))))).value();
411 "./ITHACAoutput/Matrices/");
413 "./ITHACAoutput/Matrices/");
415 "./ITHACAoutput/Matrices/");
426 for (label j = 0; j < Stsize; j++)
431 PtrList<volScalarField> Together(0);
445 for (label k = 0; k <
NTmodes; k++)
447 Together.append(
Tmodes[k].clone());
451 for (label
i = 0;
i < Stsize;
i++)
453 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix S_matrix" << endl;
457 for (label k = 0; k < Stsize; k++)
459 S_matrix[
i](j, k) = fvc::domainIntegrate(Together[
i] * fvc::laplacian(
467 "./ITHACAoutput/Matrices/");
469 "./ITHACAoutput/Matrices/");
471 "./ITHACAoutput/Matrices/S");
476 label NSUP, label Nnut, label NT)
532 "./ITHACAoutput/Matrices/");
538 SAMPLES[
i] =
new SPLINTER::DataTable(1, 1);
540 for (label j = 0; j < Ncoeff.cols(); j++)
546 SPLINTER::RadialBasisFunctionType::GAUSSIAN);
547 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