34#include "dynamicFvMesh.H"
36#include "ReducedFsi.H"
40#include "pointConstraints.H"
41#include "mathematicalConstants.H"
48 tutorial22(
int argc,
char* argv[])
75 for (label i = 0; i <
mu.rows(); i++)
80 Info <<
"Current mu = " <<
mu(i, 0) << endl;
84 word param_name =
"damping";
94 word localFolder = folder +
"../" +
"/DataFromFoam_" + name(i + 1);
101 centerofmassy.clear();
119int main(
int argc,
char* argv[])
130 std::ifstream exFileOff(
"./parsOff_mat.txt");
137 int NmodesUout = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesUout", 40);
138 int NmodesPout = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesPout", 40);
139 int NmodesDout = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesDout", 40);
140 int NmodesUproj = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesUproj", 15);
141 int NmodesPproj = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesPproj", 5);
142 int NmodesDproj = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesDproj", 1);
148 example.offlineSolve();
177 if (example.podex == 0 )
180 example.podex, 0, 0, NmodesUout);
184 example.podex, 0, 0, NmodesPout);
186 example._pointDisplacement().name(),
187 example.podex, 0, 0, NmodesDout);
192 "./ITHACAoutput/POD/");
194 "./ITHACAoutput/POD/");
196 "./ITHACAoutput/POD/");
199 example.loadCentreOfMassY();
206 Eigen::MatrixXd parsOn;
207 std::ifstream exFileOn(
"./parsOn_mat.txt");
215 word test_folder =
"./ITHACAoutput/TestingOff/";
221 testkOff.mu = parsOn;
223 testkOff.offline =
false;
225 for (label k = 0; k < parsOn.rows(); k++)
229 word param_name =
"damping";
230 testkOff.updateStiffnessAndRebuildSolver(parsOn(k, 0), param_name);
231 testkOff.startTime = 0;
232 testkOff.finalTime = 30;
233 testkOff.timeStep = 0.003;
234 testkOff.writeEvery = 1e-01;
235 testkOff.truthSolve(k, test_folder);
236 word localFolder = test_folder +
"/DataFromFoam_" + name(k + 1);
237 testkOff.prepareFoamData(localFolder);
239 testkOff.Ufield.clear();
240 testkOff.Pfield.clear();
241 testkOff.Dfield.clear();
242 testkOff.fomforcex.clear();
243 testkOff.fomforcey.clear();
245 testkOff.centerofmassy.clear();
252 testkOff.offline =
true;
277 word folder =
"./ITHACAoutput/Online/";
282 for (label i = 0; i < parsOn.rows(); i++)
287 word param_name =
"damping";
288 example.updateStiffnessAndRebuildSolver(parsOn(i, 0), param_name);
289 reduced.startTime = 0;
290 reduced.finalTime = 30;
291 reduced.timeStep = 0.003;
292 reduced.writeEvery = 1e-1;
294 reduced.solveOnline_Pimple(NmodesUproj,
298 word localFolder = folder + name(i + 1);
300 for (
int k = 0; k < reduced.UredFields.size(); ++k)
309 name(k + 1) +
"/polyMesh/");
312 word DataRom = folder +
"../" +
"/DataFromRom_" + name(i + 1);
313 reduced.prepareRomData(DataRom);
316 reduced.UredFields.clear();
317 reduced.PredFields.clear();
318 reduced.Dfield.clear();
319 reduced.romforcey.clear();
320 reduced.romforcex.clear();
321 reduced.centerofmassy.clear();
330 "======================= errL2U completed================================" <<
334 cnpy::save(errL2U,
"./ITHACAoutput/DataFromRom/errL2U_" + name(
335 NmodesUproj) +
"_" + name(NmodesPproj) +
".npy");
336 cnpy::save(errL2P,
"./ITHACAoutput/DataFromRom/errL2P_" + name(
337 NmodesUproj) +
"_" + name(NmodesPproj) +
".npy");
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 reducedProblem 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.
double e
RBF functions radius.
scalar startTime
Start Time (initial time to start storing the snapshots).
scalar writeEvery
Time step of the writing procedure.
scalar timeStep
Time step of the simulation.
scalar finalTime
Final time (final time of the simulation and consequently of the acquisition of the snapshots).
Implementation of a parametrized full order unsteady NS problem and preparation of the the reduced ...
void updateStiffnessAndRebuildSolver(scalar &newMu, word param_name="stiffness")
autoPtr< pointVectorField > _pointDisplacement
pointDisplacement field
List< scalar > fomforcey
List to save lift and drag forces.
void prepareFoamData(const word &outputPath)
Prepare data such forces and centre of mass.
PtrList< pointVectorField > Dfield
List of pointers used to form the displacement snapshots matrix.
void restart()
method to set all fields back to values in 0 folder
fsiBasic()
Construct Null.
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.
autoPtr< volVectorField > _U
Velocity field.
void offlineSolve(word folder="./ITHACAoutput/Offline/")
Initial coordinates of the grid points.
volVectorField & U
Velocity field.
volScalarField & p
Pressure field.
Header file of the fsiBasic class.
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 writePoints(pointField points, fileName folder, fileName subfolder)
Write points of a mesh to a file.
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 readMiddleFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, GeometricField< Type, PatchField, GeoMesh > &field, fileName casename)
Funtion to read a list of volVectorField from name of the field including all the intermediate snapsh...
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.
Eigen::VectorXd getCoeffs(GeometricField< Type, PatchField, GeoMesh > &snapshot, PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, label Nmodes, bool consider_volumes)
Projects a snapshot on a basis function and gets the coefficients of the projection.
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.
bool check_folder(word folder)
Checks if a folder exists.
void createSymLink(word folder)
Creates symbolic links to 0, system and constant.