47#include "forceCoeffs.H"
50#include "simpleControl.H"
58#include <Eigen/SparseLU>
94 Vector<double> inl(0, 0, 0);
95 List<scalar> mu_now(1);
112 int prodDim = c.dimension(0);
113 Eigen::MatrixXd prod;
114 prod.resize(prodDim, 1);
116 for (
int i = 0;
i < prodDim;
i++)
118 prod(
i, 0) =
g.transpose() *
134int main(
int argc,
char* argv[])
138 std::cout <<
"Pass 'supremizer' or 'poisson' as first arguments."
144 int argc_proc = argc - 1;
145 char* argv_proc[argc_proc];
146 argv_proc[0] = argv[0];
150 std::copy(argv + 2, argv + argc, argv_proc + 1);
156 if (std::strcmp(argv[1],
"supremizer") == 0)
161 else if (std::strcmp(argv[1],
"poisson") == 0)
167 std::cout <<
"Pass supremizer, poisson" << std::endl;
176 word filename(
"./par");
184 int NmodesU = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 5);
185 int NmodesP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 5);
186 int NmodesSUP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 5);
187 int NmodesNUT = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 5);
188 int NmodesProject = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 5);
189 int NmodesMatrixRec = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesMatrixRec",
191 double penaltyFactor =
192 para->
ITHACAdict->lookupOrDefault<
double>(
"penaltyFactor", 5);
193 double U_BC = para->
ITHACAdict->lookupOrDefault<
double>(
"U_BC", 0.001);
194 double romStartTime = para->
ITHACAdict->lookupOrDefault<
double>(
"romStartTime",
196 double romEndTime = para->
ITHACAdict->lookupOrDefault<
double>(
"romEndTime", 3);
197 double romTimeStep = para->
ITHACAdict->lookupOrDefault<
double>(
"romTimeStep",
199 double e = para->
ITHACAdict->lookupOrDefault<
double>(
"RBFradius", 1);
207 example.
podex, 0, 0, NmodesProject);
209 example.
podex, 0, 0, NmodesProject);
211 example.
podex, 0, 0, NmodesProject);
214 example.
supex, 1, NmodesProject);
215 example.
projectSUP(
"./Matrices", NmodesU, NmodesP, NmodesSUP, NmodesNUT);
222 cnpy::save(coeefs,
"./ITHACAoutput/Matrices/coeefs.npy");
223 cnpy::save(coeefsNut,
"./ITHACAoutput/Matrices/coeefsNut.npy");
224 cnpy::save(coeefsP,
"./ITHACAoutput/Matrices/coeefsP.npy");
230 word filename(
"./par");
238 int NmodesU = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 5);
239 int NmodesP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 5);
240 int NmodesSUP = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 5);
241 int NmodesNUT = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 5);
242 int NmodesProject = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 5);
243 int NmodesMatrixRec = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesMatrixRec",
245 double penaltyFactor =
246 para->
ITHACAdict->lookupOrDefault<
double>(
"penaltyFactor", 5);
247 double U_BC = para->
ITHACAdict->lookupOrDefault<
double>(
"U_BC", 0.001);
248 double romStartTime = para->
ITHACAdict->lookupOrDefault<
double>(
"romStartTime",
250 double romEndTime = para->
ITHACAdict->lookupOrDefault<
double>(
"romEndTime", 3);
251 double romTimeStep = para->
ITHACAdict->lookupOrDefault<
double>(
"romTimeStep",
253 double e = para->
ITHACAdict->lookupOrDefault<
double>(
"RBFradius", 1);
263 example.
podex, 0, 0, NmodesProject);
265 example.
podex, 0, 0, NmodesProject);
268 example.
supex, 1, NmodesProject);
269 example.
projectPPE(
"./Matrices", NmodesU, NmodesP, NmodesSUP, NmodesNUT);
276 cnpy::save(coeefs,
"./ITHACAoutput/Matrices/coeefs.npy");
277 cnpy::save(coeefsNut,
"./ITHACAoutput/Matrices/coeefsNut.npy");
278 cnpy::save(coeefsP,
"./ITHACAoutput/Matrices/coeefsP.npy");
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 reducedSteadyNS class.
Header file of the ReducedUnsteadyNSTurb class.
Header file of the reducedUnsteadyNS class.
Header file of the UnsteadyNSTurb 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.
Implementation of a parametrized full order unsteady NS problem and preparation of the the reduced ...
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes, bool rbfInterp=true)
Project using a supremizer approach.
autoPtr< volScalarField > _nut
Eddy viscosity field.
volScalarModes nutModes
List of POD modes for eddy viscosity.
double e
RBF functions radius.
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
void projectPPE(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes, bool rbfInterp=true)
Project using the Poisson Equation for pressure.
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)
Eigen::MatrixXi inletIndexT
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
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.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
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.
volVectorModes L_U_SUPmodes
List of pointers containing the total number of lift, supremizer and velocity modes.
PtrList< volVectorField > supfield
List of pointers used to form the supremizer snapshots matrix.
autoPtr< volVectorField > _U
Velocity field.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
autoPtr< volScalarField > _p
Pressure field.
void offlineSolve(std::string offlinepath)
tutorial22(int argc, char *argv[])
Eigen::MatrixXd vectorTensorMult(Eigen::VectorXd g, Eigen::Tensor< double, 3 > c, Eigen::VectorXd a)
Matrix< VectorType, Dynamic, Dynamic > SliceFromTensor(Eigen::Tensor< VectorType, 3 > &tensor, label dim, label index1)
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 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.
bool check_folder(word folder)
Checks if a folder exists.
void save(const Eigen::Matrix< T, -1, dim > &mat, const std::string fname)
void supremizer_approach(tutorial22 &example)
int main(int argc, char *argv[])
void poisson_approach(tutorial22 &example)
Header file of the reductionProblem class.
Header file of the steadyNS class.