55 List<scalar> mu_now(1);
64 for (label k = 0; k < par_BC.rows(); k++)
66 for (label j = 0; j < par_BC.cols(); j++)
68 for (label
i = 0;
i <
mu.cols();
i++)
91 label
i = para_set_BC;
93 for (label j = 0; j < par_BC.cols(); j++)
122 volScalarField
T =
_T();
125 dimensionedScalar&
Pr =
_Pr();
126 dimensionedScalar&
Prt =
_Prt();
128 volScalarField Tlift(
"Tlift" + name(k),
T);
129 instantList Times =
runTime.times();
131 Info <<
"Solving a lifting Problem" << endl;
135 for (label j = 0; j <
T.boundaryField().size(); j++)
143 else if (
T.boundaryField()[BCind].type() ==
"fixedValue")
152 while (
simple.correctNonOrthogonal())
155 alphat.correctBoundaryConditions();
162 Info <<
"ExecutionTime = " <<
runTime.elapsedCpuTime() <<
" s"
163 <<
" ClockTime = " <<
runTime.elapsedClockTime() <<
" s"
177int main(
int argc,
char* argv[])
182 word par_offline_BC(
"./par_offline_BC");
185 word par_online_BC(
"./par_online_BC");
190 int NmodesUproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesUproj", 5);
191 int NmodesPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPproj", 5);
192 int NmodesTproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesTproj", 5);
193 int NmodesSUPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPproj", 5);
194 int NmodesOut = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesOut", 15);
228 Eigen::MatrixXd List_of_modes(NmodesOut - 5, 1);
230 for (
int i = 0;
i < List_of_modes.rows();
i++)
232 List_of_modes(
i, 0) =
i + 1;
237 "./ITHACAoutput/l2error");
239 PtrList<volScalarField> TLmodes;
241 for (label k = 0; k < example.
liftfieldT.size(); k++)
243 TLmodes.append((example.
liftfieldT[k]).clone());
246 for (label k = 0; k < List_of_modes.size(); k++)
248 TLmodes.append((example.
Tmodes[k]).clone());
252 Eigen::MatrixXd L2errorProjMatrixU(example.
Ufield.size(), List_of_modes.rows());
253 Eigen::MatrixXd L2errorProjMatrixT(example.
Tfield.size(), List_of_modes.rows());
256 for (
int i = 0;
i < List_of_modes.rows();
i++)
260 List_of_modes(
i, 0) + example.
liftfield.size() + NmodesSUPproj);
264 example.
Umodes, coeffU, List_of_modes(
i, 0));
266 TLmodes, coeffT, List_of_modes(
i, 0) + example.
liftfieldT.size());
271 L2errorProjMatrixU.col(
i) = L2errorProjU;
272 L2errorProjMatrixT.col(
i) = L2errorProjT;
277 "./ITHACAoutput/l2error");
279 "./ITHACAoutput/l2error");
281 example.
projectSUP(
"./Matrices", NmodesUproj, NmodesPproj, NmodesTproj,
284 example.
Tmodes.resize(NmodesTproj);
285 example.
Umodes.resize(NmodesUproj);
289 reduced.
nu = 0.00001;
295 Eigen::MatrixXd vel_now_BC(0, 0);
298 for (label k = 0; k < (par_on_BC.rows()); k++)
300 Eigen::MatrixXd temp_now_BC(2, 1);
301 temp_now_BC(0, 0) = par_on_BC(k, 0);
302 temp_now_BC(1, 0) = par_on_BC(k, 1);
323 "./ITHACAoutput/HFonline2");
340 "./ITHACAoutput/HFonline3");
355 "./ITHACAoutput/l2error");
357 "./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.
Implementation of a parametrized full order unsteady Boussinesq problem and preparation of the the ...
autoPtr< volScalarField > _p_rgh
Shifted Pressure field.
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< 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.
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.
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.
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)
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.
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< 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.
autoPtr< volVectorField > _U
Velocity field.
autoPtr< volScalarField > _p
Pressure field.
void onlineSolveRead(fileName folder)
tutorial10(int argc, char *argv[])
void onlineSolveFull(Eigen::MatrixXd par_BC, label para_set_BC, fileName folder)
void offlineSolve(Eigen::MatrixXd par_BC)
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)