47#include <Eigen/SparseLU>
70 Vector<double> inl(1, 0, 0);
71 List<scalar> mu_now(1);
82 for (label
i = 0;
i <
mu.cols();
i++)
96int main(
int argc,
char* argv[])
103 int NmodesU = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 10);
104 int NmodesP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 10);
105 int NmodesSUP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 10);
106 int NmodesNUT = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 10);
107 int NmodesProject = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 10);
133 example.
velRBF = mu_mat.col(1);
148 example.
supex, 0, NmodesProject);
151 example.
supex, 0, NmodesProject);
154 example.
supex, 0, NmodesProject);
158 example.
projectSUP(
"./Matrices", NmodesU, NmodesP, NmodesSUP,
165 pod_rbf.
tauU.resize(1, 1);
172 Eigen::MatrixXd rbfCoeff;
173 rbfCoeff.resize(NmodesNUT + 1, 1);
176 for (label k = 0; k < 1; k++)
178 Eigen::MatrixXd velNow(1, 1);
180 pod_rbf.
tauU(0, 0) = 0;
183 Eigen::MatrixXd tmp_sol(pod_rbf.
y.rows() + 1, 1);
185 tmp_sol.col(0).tail(pod_rbf.
y.rows()) = pod_rbf.
y;
191 "./ITHACAoutput/Matrices/");
193 "./ITHACAoutput/Matrices/");
196 "./ITHACAoutput/red_coeff");
198 "./ITHACAoutput/red_coeff");
200 "./ITHACAoutput/red_coeff");
202 pod_rbf.
reconstruct(
true,
"./ITHACAoutput/Reconstruction/");
233 "./ITHACAoutput/ErrorsFrob/");
235 "./ITHACAoutput/ErrorsFrob/");
237 "./ITHACAoutput/ErrorsFrob/");
245 "./ITHACAoutput/ErrorsL2/");
247 "./ITHACAoutput/ErrorsL2/");
249 "./ITHACAoutput/ErrorsL2/");
int main(int argc, char *argv[])
Header file of the EigenFunctions class.
Header file of the Foam2Eigen class.
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 ITHACAutilities namespace.
Header file of the ReducedUnsteadyNSTurb class.
Header file of the reducedUnsteadyNS class.
Header file of the UnsteadyNSTurb 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.
PtrList< volScalarField > nutRecFields
Reconstructed eddy viscosity fields list.
Eigen::MatrixXd rbfCoeffMat
The matrix of the eddy viscosity RBF interoplated coefficients.
void solveOnlineSUP(Eigen::MatrixXd velNow)
Method to perform an online solve using a supremizer stabilisation method.
void reconstruct(bool exportFields=false, fileName folder="./online_rec")
Method to reconstruct the solutions from an online solve with any of the two techniques SUP or the PP...
Implementation of a parametrized full order unsteady NS problem and preparation of the the reduced ...
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes, bool rbfInterp=true)
Project using a supremizer approach.
autoPtr< volScalarField > _nut
Eddy viscosity field.
volScalarModes nutModes
List of POD modes for eddy viscosity.
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
Eigen::MatrixXd velRBF
Velocity coefficients for RBF interpolation.
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)
Eigen::VectorXd y
Vector to store the solution during the Newton procedure.
List< Eigen::MatrixXd > online_solution
List of Eigen matrices to store the online solution.
scalar nu
Reduced viscosity in case of parametrized viscosity.
Eigen::MatrixXd tauU
Penalty Factor.
PtrList< volScalarField > pRecFields
Reconstructed pressure fields list.
PtrList< volVectorField > uRecFields
Recontructed velocity fields list.
double exportEvery
A variable for exporting the fields.
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.
double storeEvery
A variable for storing the reduced coefficients.
label Pnumber
Number of parameters.
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
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.
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.
bool supex
Boolean variable to check the existence of the supremizer modes.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
void solvesupremizer(word type="snapshots")
solve the supremizer either with the use of the pressure snaphots or the pressure 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.
autoPtr< fvMesh > _mesh
Mesh.
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.
void liftSolve()
Perform a lift solve.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
autoPtr< volScalarField > _p
Pressure field.
void offlineSolve(std::string offlinepath)
tutorial21(int argc, char *argv[])
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 exportFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &field, word folder, word fieldname)
Function to export a scalar of vector 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.
void normalizeFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &fields)
Normalize list of Geometric fields.
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.
double errorFrobRel(GeometricField< Type, PatchField, GeoMesh > &field1, GeometricField< Type, PatchField, GeoMesh > &field2, List< label > *labels)
Computes the relative error between two Fields in the Frobenius norm.
bool check_folder(word folder)
Checks if a folder exists.
Header file of the reductionProblem class.
Header file of the steadyNS class.
Header file of the unsteadyNS class.