54 Vector<double> inl(0, 0, 0);
55 List<scalar> mu_now(1);
67 Vector<double>
Uinl(0, 0, 0);
69 for (label
i = 0;
i <
mu.cols();
i++)
83int main(
int argc,
char* argv[])
87 argList::addOption(
"stage",
"offline",
"Perform offline stage");
88 argList::addOption(
"stage",
"online",
"Perform online stage");
90 HashTable<string> validParOptions;
101 Pstream::addValidParOptions(validParOptions);
105 if (example.
_args().get(
"stage").match(
"offline"))
111 else if (example.
_args().get(
"stage").match(
"online"))
120 Info <<
"Pass '-stage offline', '-stage online'" << endl;
127 Info <<
"Pass 'offline' or 'online' as first arguments."
133 int argc_proc = argc - 1;
134 char* argv_proc[argc_proc];
135 argv_proc[0] = argv[0];
139 std::copy(argv + 2, argv + argc, argv_proc + 1);
146 if (std::strcmp(argv[1],
"offline") == 0)
151 else if (std::strcmp(argv[1],
"online") == 0)
160 Info <<
"Pass offline, online" << endl;
172 int NmodesUout = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesUout", 15);
173 int NmodesPout = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPout", 15);
174 int NmodesSUPout = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPout", 15);
175 int NmodesUproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesUproj", 10);
176 int NmodesPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPproj", 10);
178 para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPproj", 10);
180 word filename(
"./parOffline");
199 example.
podex, 0, 0, NmodesUout);
204 example.
podex, 0, 0, NmodesUout);
210 example.
podex, 0, 0, NmodesPout);
212 example.
podex, example.
supex, 1, NmodesSUPout);
214 example.
projectSUP(
"./Matrices", NmodesUproj, NmodesPproj, NmodesSUPproj);
222 word filename(
"./parOnline");
225 Eigen::MatrixXd vel_now(1, 1);
228 reduced.
tauU = Eigen::MatrixXd::Zero(1, 1);
229 reduced.
tauU(0, 0) = 1e-1;
232 for (label k = 0; k < example.
mu.size(); k++)
234 Info <<
"Evaluation of the reduced order model on the test set" << endl;
235 Info <<
"Inlet Ux = " << vel_now(0, 0) <<
" nu = " << example.
mu(0, k)
238 reduced.
nu = example.
mu(0, k);
240 Eigen::MatrixXd tmp_sol(reduced.
y.rows() + 1, 1);
242 tmp_sol.col(0).tail(reduced.
y.rows()) = reduced.
y;
248 "./ITHACAoutput/red_coeff");
250 "./ITHACAoutput/red_coeff");
252 "./ITHACAoutput/red_coeff");
254 reduced.
reconstruct(
true,
"./ITHACAoutput/Reconstruction/");
256 if (Pstream::parRun())
258 bool endedOnline =
true;
259 reduce(endedOnline, sumOp<label>());
int main(int argc, char *argv[])
void offline_stage(tutorial03 &example)
void online_stage(tutorial03 &example)
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 reducedSteadyNS 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 steady Navier-stokes problem.
Eigen::VectorXd y
Vector to store the solution during the Newton procedure.
void solveOnline_sup(Eigen::MatrixXd vel_now)
Method to perform an online solve using a supremizer stabilisation method.
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.
void reconstruct(bool exportFields=false, fileName folder="./ITHACAoutput/online_rec", int printevery=1)
Method to reconstruct the solutions from an online solve.
Eigen::MatrixXd mu_samples
Matrix of parameters to be used for PODI, where each row corresponds to a sample point....
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.
autoPtr< argList > _args
argList
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.
Implementation of a parametrized full order steady NS problem and preparation of the the reduced ma...
void change_viscosity(double mu)
Function to change the viscosity.
void restart()
set U and P back to the values into the 0 folder
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.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
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.
PtrList< volVectorField > supfield
List of pointers used to form the supremizer snapshots matrix.
autoPtr< volVectorField > Uinl
Initial dummy field with all Dirichlet boundary conditions.
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NSUPmodes)
Project using a supremizer approach.
autoPtr< volVectorField > _U
Velocity field.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
word bcMethod
Boundary Method.
autoPtr< volScalarField > _p
Pressure field.
void offlineSolve()
Perform an Offline solve.
volScalarField & p
Pressure field.
volVectorField & U
Velocity field.
tutorial03(int argc, char *argv[])
Constructor.
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.
void normalizeFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &fields)
Normalize list of Geometric fields.
Header file of the steadyNS class.