55 List<scalar> mu_now(1);
66 for (label k = 0; k < par_BC.rows(); k++)
68 for (label j = 0; j < par_BC.cols(); j++)
70 for (label
i = 0;
i <
mu.cols();
i++)
92 label
i = para_set_BC;
94 for (label j = 0; j < par_BC.cols(); j++)
123 volScalarField&
T =
_T();
124 volVectorField&
U =
_U();
125 surfaceScalarField&
phi =
_phi();
126 phi = linearInterpolate(
U) &
mesh.Sf();
133 dimensionedScalar&
Pr =
_Pr();
134 dimensionedScalar&
Prt =
_Prt();
136 volScalarField Tlift(
"Tlift" + name(k),
T);
137 instantList Times =
runTime.times();
139 Info <<
"Solving a lifting Problem" << endl;
143 alphat.correctBoundaryConditions();
146 for (label j = 0; j <
T.boundaryField().size(); j++)
153 else if (
T.boundaryField()[BCind].type() ==
"fixedValue")
163 while (
simple.correctNonOrthogonal())
171 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
172 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
187int main(
int argc,
char* argv[])
192 word par_offline_BC(
"./par_offline_BC");
194 word par_online_BC(
"./par_online_BC");
200 word stabilization = para->
ITHACAdict->lookupOrDefault<word>(
"Stabilization",
202 int NmodesUproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesUproj", 5);
203 int NmodesPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPproj", 5);
204 int NmodesPrghproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPrghproj",
206 int NmodesTproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesTproj", 5);
207 int NmodesSUPproj = 0;
209 if (stabilization ==
"supremizer")
211 NmodesSUPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPproj", 5);
214 int NmodesOut = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesOut", 15);
250 example.
podex, 0, 0, NmodesOut,
false);
253 example.
podex, 0, 0, NmodesOut,
false);
256 example.
podex, 0, 0, NmodesOut,
false);
259 example.
podex, 0, 0, NmodesOut,
false);
262 if (stabilization ==
"supremizer")
268 Eigen::MatrixXd List_of_modes(NmodesOut - 5, 1);
270 for (
int i = 0;
i < List_of_modes.rows();
i++)
272 List_of_modes(
i, 0) =
i + 1;
277 "./ITHACAoutput/l2error");
279 PtrList<volScalarField> TLmodes;
281 for (label k = 0; k < example.
liftfieldT.size(); k++)
283 TLmodes.append((example.
liftfieldT[k]).clone());
286 for (label k = 0; k < List_of_modes.size(); k++)
288 TLmodes.append((example.
Tmodes[k]).clone());
292 PtrList<volVectorField> ULmodes;
294 for (label k = 0; k < example.
liftfield.size(); k++)
296 ULmodes.append((example.
liftfield[k]).clone());
299 for (label k = 0; k < List_of_modes.size(); k++)
301 ULmodes.append((example.
Umodes[k]).clone());
304 if (stabilization ==
"supremizer")
306 for (label k = 0; k < NmodesSUPproj; k++)
308 ULmodes.append((example.
supmodes[k]).clone());
313 Eigen::MatrixXd L2errorProjMatrixU(example.
Ufield.size(), List_of_modes.rows());
314 Eigen::MatrixXd L2errorProjMatrixT(example.
Tfield.size(), List_of_modes.rows());
317 for (
int i = 0;
i < List_of_modes.rows();
i++)
320 List_of_modes(
i, 0) + example.
liftfield.size() + NmodesSUPproj);
324 ULmodes, coeffU, List_of_modes(
i,
325 0) + example.
liftfield.size() + NmodesSUPproj);
327 TLmodes, coeffT, List_of_modes(
i, 0) + example.
liftfieldT.size());
332 L2errorProjMatrixU.col(
i) = L2errorProjU;
333 L2errorProjMatrixT.col(
i) = L2errorProjT;
338 "./ITHACAoutput/l2error");
340 "./ITHACAoutput/l2error");
343 if (stabilization ==
"supremizer")
345 example.
projectSUP(
"./Matrices", NmodesUproj, NmodesPrghproj, NmodesTproj,
348 else if (stabilization ==
"PPE")
350 example.
projectPPE(
"./Matrices", NmodesUproj, NmodesPrghproj, NmodesTproj,
359 example.
Tmodes.resize(NmodesTproj);
360 example.
Umodes.resize(NmodesUproj);
361 example.
Pmodes.resize(NmodesPproj);
362 example.
Prghmodes.resize(NmodesPrghproj);
366 reduced.
nu = 0.00001;
372 Eigen::MatrixXd vel_now_BC(1, 1);
373 vel_now_BC(0, 0) = 0.0157;
376 for (label k = 0; k < par_on_BC.rows(); k++)
378 Eigen::MatrixXd temp_now_BC(3, 1);
379 temp_now_BC(0, 0) = par_on_BC(k, 0);
380 temp_now_BC(1, 0) = par_on_BC(k, 1);
381 temp_now_BC(2, 0) = par_on_BC(k, 2);
384 if (stabilization ==
"supremizer")
389 else if (stabilization ==
"PPE")
414 "./ITHACAoutput/high_fidelity_online2");
427 "./ITHACAoutput/l2error");
429 "./ITHACAoutput/l2error");
int main(int argc, char *argv[])
Header file of the ITHACAPOD class.
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...
Header file of the ReducedUnsteadyBB class.
volScalarField alphaEff("alphaEff", turbulence->nu()/Pr+alphat)
Header file of the UnsteadyBB class.
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
IOdictionary * ITHACAdict
Dictionary for input objects from file.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
Class where it is implemented a reduced problem for the unsteady Navier-stokes problem.
void reconstruct_sup(fileName folder="./ITHACAOutput/online_rec", int printevery=1)
Method to reconstruct a solution from an online solve with a supremizer stabilisation technique.
scalar Pr
DimensionedScalar Pr;.
Eigen::MatrixXd solveOnline_sup(Eigen::MatrixXd &temp_now_BC, Eigen::MatrixXd &vel_now_BC, int NParaSet=0, int startSnap=0)
Method to perform an online solve using a supremizer stabilisation method.
PtrList< volScalarField > TREC
Reconstructed temperature field.
Eigen::MatrixXd solveOnline_PPE(Eigen::MatrixXd &temp_now_BC, Eigen::MatrixXd &vel_now_BC, int NParaSet=0, int startSnap=0)
Method to perform an online solve using a PPE stabilisation method.
Implementation of a parametrized full order unsteady Boussinesq problem and preparation of the the ...
autoPtr< volScalarField > _p_rgh
Shifted Pressure field.
void solvesupremizer(word type="snapshots")
solve the supremizer either with the use of the pressure snaphots or the pressure modes
PtrList< volScalarField > Prghmodes
List of pointers used to form the shifted pressure modes.
autoPtr< volScalarField > _T
Temperature field.
autoPtr< dimensionedScalar > _Prt
dimensionedScalar Prt;
autoPtr< dimensionedScalar > _Pr
dimensionedScalar Pr;
PtrList< volScalarField > Tomfield
List of pointers used to form the homogeneous velocity snapshots.
PtrList< volScalarField > Prghfield
List of pointers used to form the shifted pressure snapshots matrix.
PtrList< volVectorField > Ufield_on
List of pointers used to form the temperature snapshots matrix.
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NTmodes, label NSUPmodes)
Project using a supremizer approach.
void liftSolve()
Perform a lift solve for velocity field.
autoPtr< fvMesh > _mesh
Mesh.
PtrList< volScalarField > Tmodes
List of pointers used to form the temperature modes.
autoPtr< volScalarField > _alphat
dimensionedScalar alphat;
PtrList< volScalarField > Tfield_on
List of pointers used to form the temperature snapshots matrix.
PtrList< volScalarField > liftfieldT
List of pointers used to form the list of lifting functions.
PtrList< volScalarField > Tfield
List of pointers used to form the temperature snapshots matrix.
void projectPPE(fileName folder, label NUmodes, label NPrghmodes, label NTmodes, label NSUPmodes)
Project using a PPE approach.
scalar startTime
Start Time (initial time to start storing the snapshots)
scalar writeEvery
Time step of the writing procedure.
scalar timeStep
Time step of the simulation.
scalar finalTime
Final time (final time of the simulation and consequently of the acquisition of the snapshots)
scalar nu
Reduced viscosity in case of parametrized viscosity.
PtrList< volVectorField > UREC
Recontructed velocity field.
void reconstruct_PPE(fileName folder="./ITHACAoutput/online_rec", int printevery=1)
Method to reconstruct a solution from an online solve with a PPE stabilisation technique.
scalar finalTime
Scalar to store the final time if the online simulation.
scalar tstart
Scalar to store the initial time if the online simulation.
double dt
Scalar to store the time increment.
Eigen::MatrixXi inletIndexT
label Pnumber
Number of parameters.
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.
label Tnumber
Dimension of the training set (used only when gerating parameters without input)
void computeLift(T &Lfield, T &liftfield, T &omfield)
Homogenize the snapshot matrix, it works with PtrList of volVectorField and volScalarField.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
void computeLiftT(T &Lfield, T &liftfield, T &omfield)
Virtual function to compute the lifting function.
Eigen::MatrixXd mu
Row matrix of parameters.
Eigen::MatrixXd mu_range
Range of the parameter spaces.
void setParameters()
Set Parameters Problems.
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.
void genEquiPar()
Generate Equidistributed Numbers.
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< Time > _runTime
Time.
volVectorModes Umodes
List of pointers used to form the velocity modes.
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
PtrList< volVectorField > Uomfield
List of pointers used to form the homogeneous velocity snapshots.
autoPtr< volVectorField > _U
Velocity field.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
autoPtr< volScalarField > _p
Pressure field.
void onlineSolveFull(Eigen::MatrixXd par_BC, label para_set_BC, fileName folder)
void onlineSolveRead(fileName folder)
void offlineSolve(Eigen::MatrixXd par_BC)
tutorial11(int argc, char *argv[])
autoPtr< incompressible::turbulenceModel > turbulence
Turbulence model.
void getModes(PtrList< GeometricField< Type, PatchField, GeoMesh > > &snapshots, PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, word fieldName, bool podex, bool supex, bool sup, label nmodes, bool correctBC)
Computes the bases or reads them for a field.
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.
void read_fields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, word Name, fileName casename, int first_snap, int n_snap)
Function to read a list of fields from the name of the field and casename.
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.
PtrList< GeometricField< Type, PatchField, GeoMesh > > reconstructFromCoeff(PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, Eigen::MatrixXd &coeff_matrix, label Nmodes)
Exact reconstruction using a certain number of modes for a list of fields and the projection coeffici...
double errorL2Rel(GeometricField< T, fvPatchField, volMesh > &field1, GeometricField< T, fvPatchField, volMesh > &field2, List< label > *labels)
Computes the relative error between two geometric Fields in L2 norm.
bool check_folder(word folder)
Checks if a folder exists.
void createSymLink(word folder)
Creates symbolic links to 0, system and constant.
simpleControl simple(mesh)