36#include "simpleControl.H"
43#include <Eigen/SparseLU>
74 Vector<double> inl(0, 0, 0);
75 List<scalar> mu_now(2);
87 Vector<double>
Uinl(0, 0, 0);
102 Vector<double>
Uinl(0, 0, 0);
105 for (label
i = 0;
i <
mu.rows();
i++)
118 Vector<double> inl(0, 0, 0);
119 List<scalar> mu_now(2);
120 Vector<double>
Uinl(0, 0, 0);
123 for (label
i = 0;
i < par.rows();
i++)
136 volScalarField&
p =
_p();
137 volVectorField&
U =
_U();
138 surfaceScalarField&
phi =
_phi();
141 IOMRFZoneList& MRF =
_MRF();
155int main(
int argc,
char* argv[])
160 word par_offline(
"./par_offline");
161 word par_new(
"./par_online");
173 int NmodesU =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 5);
174 int NmodesP =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 5);
175 int NmodesSUP =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 5);
176 int NmodesNUT =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 5);
177 int NmodesProject =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 5);
178 word stabilization =
para->ITHACAdict->lookupOrDefault<word>(
"Stabilization",
192 example.
supex, 0, NmodesProject);
195 example.
supex, 0, NmodesProject);
198 example.
supex, 0, NmodesProject);
201 if (stabilization ==
"supremizer")
208 if (stabilization ==
"supremizer")
210 example.
projectSUP(
"./Matrices", NmodesU, NmodesP, NmodesSUP,
213 else if (stabilization ==
"PPE")
215 example.
projectPPE(
"./Matrices", NmodesU, NmodesP, NmodesSUP,
224 pod_rbf.
tauU.resize(2, 1);
226 Eigen::MatrixXd rbfCoeff;
227 rbfCoeff.resize(NmodesNUT, par_online.rows());
230 for (label k = 0; k < par_online.rows(); k++)
232 Eigen::MatrixXd velNow(2, 1);
233 velNow(0, 0) = par_online(k, 0);
234 velNow(1, 0) = par_online(k, 1);
235 pod_rbf.
tauU(0, 0) = 0;
236 pod_rbf.
tauU(1, 0) = 0;
238 if (stabilization ==
"supremizer")
242 else if (stabilization ==
"PPE")
248 Eigen::MatrixXd tmp_sol(pod_rbf.
y.rows() + 1, 1);
250 tmp_sol.col(0).tail(pod_rbf.
y.rows()) = pod_rbf.
y;
256 "./ITHACAoutput/Matrices/");
258 "./ITHACAoutput/Matrices/");
261 "./ITHACAoutput/red_coeff");
263 "./ITHACAoutput/red_coeff");
265 "./ITHACAoutput/red_coeff");
268 pod_rbf.
reconstruct(
true,
"./ITHACAoutput/Reconstruction/");
273 pod_normal.
nu = 1e-3;
274 pod_normal.
tauU.resize(2, 1);
277 for (label k = 0; k < par_online.rows(); k++)
279 Eigen::MatrixXd vel_now(2, 1);
280 vel_now(0, 0) = par_online(k, 0);
281 vel_now(1, 0) = par_online(k, 1);
282 pod_normal.
tauU(0, 0) = 0;
283 pod_normal.
tauU(1, 0) = 0;
285 Eigen::MatrixXd tmp_sol(pod_normal.
y.rows() + 1, 1);
287 tmp_sol.col(0).tail(pod_normal.
y.rows()) = pod_normal.
y;
293 "./ITHACAoutput/red_coeffnew");
295 "./ITHACAoutput/red_coeffnew");
297 "./ITHACAoutput/red_coeffnew");
299 pod_normal.
reconstruct(
true,
"./ITHACAoutput/Lam_Rec/");
313 "./ITHACAoutput/ErrorsFrob/");
315 "./ITHACAoutput/ErrorsFrob/");
317 "./ITHACAoutput/ErrorsFrob/");
325 "./ITHACAoutput/ErrorsL2/");
327 "./ITHACAoutput/ErrorsL2/");
329 "./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 ReducedSteadyNSTurb class.
Header file of the reducedSteadyNS class.
Header file of the SteadyNSTurb 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 steady turbulent Navier-stokes problem.
PtrList< volScalarField > nutRecFields
Reconstructed eddy viscosity fields list.
void solveOnlinePPE(Eigen::MatrixXd velNow)
Method to perform an online solve using a PPE stabilisation method.
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="./ITHACAoutput/online_rec", int printevery=1)
Method to reconstruct the solutions from an online solve.
Eigen::VectorXd rbfCoeff
Vector of eddy viscosity RBF interoplated coefficients.
autoPtr< volScalarField > _nut
Eddy viscosity field.
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes)
Project using a supremizer approach.
void projectPPE(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes)
Project using a PPE approach.
volScalarModes nutModes
List of POD modes for eddy viscosity.
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.
PtrList< volScalarField > pRecFields
Reconstructed pressure fields list.
PtrList< volVectorField > uRecFields
Recontructed velocity fields list.
void reconstruct(bool exportFields=false, fileName folder="./ITHACAoutput/online_rec", int printevery=1)
Method to reconstruct the solutions from an online solve.
label counter
Counter used for the output of the full order solutions.
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
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::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.
bool supex
Boolean variable to check the existence of the supremizer modes.
autoPtr< surfaceScalarField > _phi
Flux.
autoPtr< simpleControl > _simple
simpleControl
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
autoPtr< fv::options > _fvOptions
fvOptions
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.
autoPtr< singlePhaseTransportModel > _laminarTransport
Laminar transport (used by turbulence model)
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< IOMRFZoneList > _MRF
MRF variable.
autoPtr< incompressible::turbulenceModel > turbulence
Turbulence model.
autoPtr< volVectorField > Uinl
Initial dummy field with all Dirichlet boundary conditions.
autoPtr< volVectorField > _U
Velocity field.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
autoPtr< volScalarField > _p
Pressure field.
Class where the tutorial number 6 is implemented.
volVectorField & U
[tutorial06]
tutorial06(int argc, char *argv[])
void truthSolve(fileName folder)
void offlineSolve()
Perform an Offline solve.
void offlineSolve(Eigen::MatrixXd par, fileName folder)
Perform an Offline solve for a special set of parameter samples called par.
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 exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
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.
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.
Header file of the reductionProblem class.
simpleControl simple(mesh)
singlePhaseTransportModel & laminarTransport
Header file of the steadyNS class.