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");
162 example.inletIndex.resize(2, 2);
163 example.inletIndex(0, 0) = 0;
164 example.inletIndex(0, 1) = 0;
165 example.inletIndex(1, 0) = 0;
166 example.inletIndex(1, 1) = 1;
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",
178 example.offlineSolve();
182 example.computeLift(example.Ufield, example.liftfield, example.Uomfield);
189 example.supex, 0, NmodesProject);
192 example.supex, 0, NmodesProject);
195 example.supex, 0, NmodesProject);
198 if (stabilization ==
"supremizer")
200 example.solvesupremizer(
"modes");
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")
237 pod_rbf.solveOnlineSUP(velNow);
239 else if (stabilization ==
"PPE")
241 pod_rbf.solveOnlinePPE(velNow);
244 rbfCoeff.col(k) = pod_rbf.rbfCoeff;
245 Eigen::MatrixXd tmp_sol(pod_rbf.y.rows() + 1, 1);
247 tmp_sol.col(0).tail(pod_rbf.y.rows()) = pod_rbf.y;
248 pod_rbf.online_solution.append(tmp_sol);
253 "./ITHACAoutput/Matrices/");
255 "./ITHACAoutput/Matrices/");
258 "./ITHACAoutput/red_coeff");
260 "./ITHACAoutput/red_coeff");
262 "./ITHACAoutput/red_coeff");
263 pod_rbf.rbfCoeffMat = rbfCoeff;
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;
281 pod_normal.solveOnline_sup(vel_now);
282 Eigen::MatrixXd tmp_sol(pod_normal.y.rows() + 1, 1);
284 tmp_sol.col(0).tail(pod_normal.y.rows()) = pod_normal.y;
285 pod_normal.online_solution.append(tmp_sol);
290 "./ITHACAoutput/red_coeffnew");
292 "./ITHACAoutput/red_coeffnew");
294 "./ITHACAoutput/red_coeffnew");
296 pod_normal.reconstruct(
true,
"./ITHACAoutput/Lam_Rec/");
308 pod_rbf.nutRecFields);
310 "./ITHACAoutput/ErrorsFrob/");
312 "./ITHACAoutput/ErrorsFrob/");
314 "./ITHACAoutput/ErrorsFrob/");
320 pod_rbf.nutRecFields);
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.
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.
Class where it is implemented a reduced problem for the steady Navier-stokes problem.
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.
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.
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
autoPtr< Time > _runTime
Time.
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)
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.
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.