36#include "simpleControl.H"
43#include <Eigen/SparseLU>
73 Vector<double> inl(0, 0, 0);
74 List<scalar> mu_now(2);
86 Vector<double>
Uinl(0, 0, 0);
101 Vector<double>
Uinl(0, 0, 0);
104 for (label
i = 0;
i <
mu.rows();
i++)
116 Vector<double> inl(0, 0, 0);
117 List<scalar> mu_now(2);
118 Vector<double>
Uinl(0, 0, 0);
121 for (label
i = 0;
i < par.rows();
i++)
133 volScalarField&
p =
_p();
134 volVectorField&
U =
_U();
135 surfaceScalarField&
phi =
_phi();
138 IOMRFZoneList& MRF =
_MRF();
152int main(
int argc,
char* argv[])
157 word par_offline(
"./par_offline");
158 word par_new(
"./par_online");
170 int NmodesU = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 5);
171 int NmodesP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 5);
172 int NmodesSUP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 5);
173 int NmodesNUT = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 5);
174 int NmodesProject = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 5);
175 word stabilization = para->
ITHACAdict->lookupOrDefault<word>(
"Stabilization",
189 example.
supex, 0, NmodesProject);
192 example.
supex, 0, NmodesProject);
195 example.
supex, 0, NmodesProject);
198 if (stabilization ==
"supremizer")
205 if (stabilization ==
"supremizer")
207 example.
projectSUP(
"./Matrices", NmodesU, NmodesP, NmodesSUP,
210 else if (stabilization ==
"PPE")
212 example.
projectPPE(
"./Matrices", NmodesU, NmodesP, NmodesSUP,
221 pod_rbf.
tauU.resize(2, 1);
223 Eigen::MatrixXd rbfCoeff;
224 rbfCoeff.resize(NmodesNUT, par_online.rows());
227 for (label k = 0; k < par_online.rows(); k++)
229 Eigen::MatrixXd velNow(2, 1);
230 velNow(0, 0) = par_online(k, 0);
231 velNow(1, 0) = par_online(k, 1);
232 pod_rbf.
tauU(0, 0) = 0;
233 pod_rbf.
tauU(1, 0) = 0;
235 if (stabilization ==
"supremizer")
239 else if (stabilization ==
"PPE")
245 Eigen::MatrixXd tmp_sol(pod_rbf.
y.rows() + 1, 1);
247 tmp_sol.col(0).tail(pod_rbf.
y.rows()) = pod_rbf.
y;
253 "./ITHACAoutput/Matrices/");
255 "./ITHACAoutput/Matrices/");
258 "./ITHACAoutput/red_coeff");
260 "./ITHACAoutput/red_coeff");
262 "./ITHACAoutput/red_coeff");
265 pod_rbf.
reconstruct(
true,
"./ITHACAoutput/Reconstruction/");
270 pod_normal.
nu = 1e-3;
271 pod_normal.
tauU.resize(2, 1);
274 for (label k = 0; k < par_online.rows(); k++)
276 Eigen::MatrixXd vel_now(2, 1);
277 vel_now(0, 0) = par_online(k, 0);
278 vel_now(1, 0) = par_online(k, 1);
279 pod_normal.
tauU(0, 0) = 0;
280 pod_normal.
tauU(1, 0) = 0;
282 Eigen::MatrixXd tmp_sol(pod_normal.
y.rows() + 1, 1);
284 tmp_sol.col(0).tail(pod_normal.
y.rows()) = pod_normal.
y;
290 "./ITHACAoutput/red_coeffnew");
292 "./ITHACAoutput/red_coeffnew");
294 "./ITHACAoutput/red_coeffnew");
296 pod_normal.
reconstruct(
true,
"./ITHACAoutput/Lam_Rec/");
310 "./ITHACAoutput/ErrorsFrob/");
312 "./ITHACAoutput/ErrorsFrob/");
314 "./ITHACAoutput/ErrorsFrob/");
322 "./ITHACAoutput/ErrorsL2/");
324 "./ITHACAoutput/ErrorsL2/");
326 "./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...
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 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.
Implementation of a parametrized full order steady turbulent Navier Stokes problem and preparation ...
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.