31#include "UnsteadyNSTurb.H"
47#include <Eigen/SparseLU>
52class tutorial21:
public UnsteadyNSTurb
55 explicit tutorial21(
int argc,
char* argv[])
57 UnsteadyNSTurb(argc, argv),
68 void offlineSolve(std::string offlinepath)
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);
113 example.setParameters();
115 example.mu_range(0, 0) = 1.0;
116 example.mu_range(0, 1) = 1.1;
118 example.genEquiPar();
120 example.inletIndex.resize(1, 2);
121 example.inletIndex(0, 0) = 0;
122 example.inletIndex(0, 1) = 0;
124 example.startTime = 0;
125 example.finalTime = 5;
126 example.timeStep = 0.001;
127 example.writeEvery = 0.1;
129 example.offlineSolve(
"./ITHACAoutput/Offline/");
133 example.velRBF = mu_mat.col(1);
135 example.solvesupremizer();
141 example.computeLift(example.Ufield, example.liftfield, example.Uomfield);
148 example.supex, 0, NmodesProject);
151 example.supex, 0, NmodesProject);
154 example.supex, 0, NmodesProject);
156 example.solvesupremizer(
"modes");
158 example.projectSUP(
"./Matrices", NmodesU, NmodesP, NmodesSUP,
165 pod_rbf.tauU.resize(1, 1);
167 pod_rbf.finalTime = 10.1;
169 pod_rbf.storeEvery = 0.005;
170 pod_rbf.exportEvery = 0.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;
181 pod_rbf.solveOnlineSUP(velNow);
182 rbfCoeff.col(k) = pod_rbf.rbfCoeffMat.col(k);
183 Eigen::MatrixXd tmp_sol(pod_rbf.y.rows() + 1, 1);
185 tmp_sol.col(0).tail(pod_rbf.y.rows()) = pod_rbf.y;
186 pod_rbf.online_solution.append(tmp_sol);
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/");
206 example2.Pnumber = 1;
208 example2.Tnumber = 2;
210 example2.setParameters();
212 example2.mu_range(0, 0) = 1.05;
213 example2.mu_range(0, 1) = 1.05;
215 example2.genEquiPar();
217 example2.inletIndex.resize(1, 2);
218 example2.inletIndex(0, 0) = 0;
219 example2.inletIndex(0, 1) = 0;
221 example2.startTime = 0;
222 example2.finalTime = 5;
223 example2.timeStep = 0.001;
224 example2.writeEvery = 0.1;
225 example2.offlineSolve(
"./ITHACAoutput/Offline_check/");
231 pod_rbf.nutRecFields);
233 "./ITHACAoutput/ErrorsFrob/");
235 "./ITHACAoutput/ErrorsFrob/");
237 "./ITHACAoutput/ErrorsFrob/");
243 pod_rbf.nutRecFields);
245 "./ITHACAoutput/ErrorsL2/");
247 "./ITHACAoutput/ErrorsL2/");
249 "./ITHACAoutput/ErrorsL2/");
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.
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
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.
autoPtr< volScalarField > _nut
Eddy viscosity field.
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
Eigen::MatrixXd mu
Row matrix of parameters.
void truthSolve()
Perform a TruthSolve.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
autoPtr< volVectorField > _U
Velocity field.
autoPtr< volScalarField > _p
Pressure field.
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.