Loading...
Searching...
No Matches
26MovingAirfoil Directory Reference

Directory containing the header and source files for the reducedSteadyNS class.

More...

Files

 
CompressibleUnSteadyPimpleTutorial.C
 
HyperRedSolvers.H
 
HyperReducedCompressibleUnSteadyNS.C
 Source file of the HyperReducedCompressibleUnSteadyNS class.
 
HyperReducedCompressibleUnSteadyNS.H
 Header file of the reducedSteadyNS class.
 
ReducedEEqn.H
 
ReducedpEqn.H
 
ReducedUEqn.H

Detailed Description

Directory containing the header and source files for the reducedSteadyNS class.

Introduction

This tutorial covers a compressible, unsteady Reynolds-averaged Navier–Stokes (RANS) simulation of flow past a moving airfoil. The focus is on computing a reduced-order model and applying hyper-reduction to the resulting modes.

A detailed look into the code

Let's have a look at the code of tutorial 26.

Header files

Important headers used by this example include:

#include "ITHACAPOD.H"
#include "ITHACAstream.H"
#include "Foam2Eigen.H"
#include "DEIM.H"
Header file of the CompressibleUnSteadyPimple class.
Header file of the Foam2Eigen class.
Header file of the reducedSteadyNS class.
Header file of the ITHACAPOD class.
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...

The code makes use of DEIM for hyper-reduction and includes Eigen, chrono and other utilities.

Implementation

The tutorial26 class derives from the compressible rhoPimple solver and holds references to the velocity U, pressure p and energy E fields. The offlineSolve method either reads precomputed snapshots or runs the full-order simulation to generate them:

{
public:
tutorial26(int argc, char* argv[])
U(_U()),
p(_p()),
E(_E())
{}
volVectorField& U;
volScalarField& p;
volScalarField& E;
void offlineSolve(word folder = "./ITHACAoutput/Offline/")
{
if (offline)
{
}
else
{
truthSolve(folder);
}
}
};
Implementation of a parametrized full order Compressible UnSteady Pimple and preparation of the the...
PtrList< volScalarField > Efield
List of pointers used to store the energy solutions.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
Definition steadyNS.H:86
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
Definition steadyNS.H:89
void offlineSolve(word folder="./ITHACAoutput/Offline/")
Hyper-reduced object.
volScalarField & E
Energy field.
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.

The main

The main function sets simulation parameters (time interval, time step, modes to output) from the ITHACAdict dictionary:

std::clock_t startOff;
double durationOff;
// Read some parameters from file
example._runTime());
// Read the par file where the parameters are stored
int NmodesUout = readInt(para->ITHACAdict->lookup("NmodesUout"));
int NmodesPout = readInt(para->ITHACAdict->lookup("NmodesPout"));
int NmodesEout = readInt(para->ITHACAdict->lookup("NmodesEout"));
int NmodesUproj = readInt(para->ITHACAdict->lookup("NmodesUproj"));
int NmodesPproj = readInt(para->ITHACAdict->lookup("NmodesPproj"));
int NmodesEproj = readInt(para->ITHACAdict->lookup("NmodesEproj"));
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.

Then, it access the time parameters:

example.startTime = 0;
example.finalTime = 0.15;
example.timeStep = 2e-06;
example.writeEvery = 4e-04;

executes the offline stage:

example.offlineSolve();

and computes POD modes for velocity, pressure and energy (if not already saved):

if (example.podex == 0 )
{
ITHACAPOD::getModes(example.Ufield, example.Umodes, example._U().name(),
example.podex, 0, 0, NmodesUout);
ITHACAPOD::getModes(example.Pfield, example.Pmodes, example._p().name(),
example.podex, 0, 0, NmodesPout);
ITHACAPOD::getModes(example.Efield, example.Emodes, example.E().name(),
example.podex, 0, 0, NmodesEout);
}
else
{
ITHACAstream::read_fields(example.Umodes, example._U(), "./ITHACAoutput/POD/");
ITHACAstream::read_fields(example.Pmodes, example._p(), "./ITHACAoutput/POD/");
ITHACAstream::read_fields(example.Emodes, example._E(), "./ITHACAoutput/POD/");
}
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.
Definition ITHACAPOD.C:93

It then constructs a HyperReducedCompressibleUnSteadyNS object and solves the hyper-reduced system using specified projection dimensions:

HyperReducedCompressibleUnSteadyNS hyperreduced(example);
// Info << hyperreduced.Umodes.size() << endl;
// Info << hyperreduced.Pmodes.size() << endl;
// Info << hyperreduced.Emodes.size() << endl;
hyperreduced.startTime = example.startTime;
hyperreduced.finalTime = example.finalTime;
hyperreduced.timeStep = example.timeStep;
hyperreduced.writeEvery = example.writeEvery;
hyperreduced.SolveHyperReducedSys(NmodesUproj, NmodesPproj, NmodesEproj);
Class where it is implemented a reduced problem for the UnSteady RhoPimple problem.

Hyper-reduction

Hyper-reduction is performed on the compressible fields to accelerate online simulations. The class HyperReducedCompressibleUnSteadyNS handles both the offline assembly and the online solve. Users may specify the numbers of projection modes NmodesUproj, NmodesPproj and NmodesEproj through the dictionary.

The plain code

The plain code is available here.