Introduction to POD with Interpolation
In this tutorial the POD is applied on the backstep steady test case with parametrized viscosity.
A detailed look into the code
In this section are explained the main steps necessary to construct the tutorial N°5.
The necessary header files
First of all let's have a look to the header files that need to be included and what they are responsible for.
Some of the header files of ITHACA-FV necessary for this tutorial are: <steadyNS.H> for the full order steady NS problem, <ITHACAPOD.H> for the POD decomposition, <ITHACAstream.H> for some ITHACA input-output operations, and also <bspline.h> and <rbfspline.h> to perform the RBF interpolation in the reduced space.
#include "forces.H"
#include "IOmanip.H"
#include "bspline.h"
#include "rbfspline.h"
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 steadyNS class.
Implementation of the tutorial05 class
We can define the tutorial05 class as a child of the <steadyNS> class. The constructor is defined with members that are the fields need to be manipulated during the resolution of the full order problem using simpleFoam. Such fields are also initialized with the same initial conditions in the solver.
{
public:
:
steadyNS(argc, argv), U(_U()), p(_p()) {}
Implementation of a parametrized full order steady NS problem and preparation of the the reduced ma...
tutorial05(int argc, char *argv[])
Constructor.
Inside the tutorial05 class we define the offlineSolve method according to the specific parametrized problem that needs to be solved. If the offline solve has been previously performed, then the method just reads the existing snapshots from the Offline directory. Otherwise it loops over all the parameters, changes the system viscosity with the iterable parameter, and then performs the offline solve.
void offlineSolve()
{
Vector<double> inl(1, 0, 0);
List<scalar> mu_now(1);
if (offline)
{
mu_samples =
}
else
{
Vector<double> Uinl(0, 0, 0);
for (label i = 0; i < mu.cols(); i++)
{
mu_now[0] = mu(0, i);
change_viscosity(mu(0, i));
assignIF(U, inl);
truthSolve(mu_now);
}
}
}
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.
Definition of the main function
In this section we show the definition of the main function. First we construct the object "example" of type tutorial05:
Then we parse the ITHACAdict file to determine the number of modes to be written out and also the ones to be used for projection of the velocity and the pressure fields:
example._runTime());
int NmodesUout = para->ITHACAdict->lookupOrDefault<int>("NmodesUout", 15);
int NmodesPout = para->ITHACAdict->lookupOrDefault<int>("NmodesPout", 15);
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.
We note that a default value can be assigned in case the parser did not find the corresponding string in the ITHACAdict file.
Then, the parameters for which we collect the snapshots are read from a text file (previously stored) and the offline solver is performed for these parameters.
word filename("./par");
example.offlineSolve();
Then, the velocity and pressure modes are collected:
example.offlineSolve();
example.podex, 0, 0,
NmodesUout);
example.podex, 0, 0,
NmodesPout);
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.
The plain code is available here.