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);
113 int prodDim = c.dimension(0);
114 Eigen::MatrixXd prod;
115 prod.resize(prodDim, 1);
117 for (
int i = 0;
i < prodDim;
i++)
119 prod(
i, 0) =
g.transpose() *
135int main(
int argc,
char* argv[])
139 std::cout <<
"Pass 'supremizer' or 'poisson' as first arguments."
145 int argc_proc = argc - 1;
146 char* argv_proc[argc_proc];
147 argv_proc[0] = argv[0];
151 std::copy(argv + 2, argv + argc, argv_proc + 1);
157 if (std::strcmp(argv[1],
"supremizer") == 0)
162 else if (std::strcmp(argv[1],
"poisson") == 0)
168 std::cout <<
"Pass supremizer, poisson" << std::endl;
177 word filename(
"./par");
185 int NmodesU =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 5);
186 int NmodesP =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 5);
187 int NmodesSUP =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 5);
188 int NmodesNUT =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 5);
189 int NmodesProject =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 5);
190 int NmodesMatrixRec =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesMatrixRec",
192 double penaltyFactor =
193 para->ITHACAdict->lookupOrDefault<
double>(
"penaltyFactor", 5);
194 double U_BC =
para->ITHACAdict->lookupOrDefault<
double>(
"U_BC", 0.001);
195 double romStartTime =
para->ITHACAdict->lookupOrDefault<
double>(
"romStartTime",
197 double romEndTime =
para->ITHACAdict->lookupOrDefault<
double>(
"romEndTime", 3);
198 double romTimeStep =
para->ITHACAdict->lookupOrDefault<
double>(
"romTimeStep",
200 double e =
para->ITHACAdict->lookupOrDefault<
double>(
"RBFradius", 1);
208 example.
podex, 0, 0, NmodesProject);
210 example.
podex, 0, 0, NmodesProject);
212 example.
podex, 0, 0, NmodesProject);
215 example.
supex, 1, NmodesProject);
216 example.
projectSUP(
"./Matrices", NmodesU, NmodesP, NmodesSUP, NmodesNUT);
223 cnpy::save(coeefs,
"./ITHACAoutput/Matrices/coeefs.npy");
224 cnpy::save(coeefsNut,
"./ITHACAoutput/Matrices/coeefsNut.npy");
225 cnpy::save(coeefsP,
"./ITHACAoutput/Matrices/coeefsP.npy");
231 word filename(
"./par");
239 int NmodesU =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesU", 5);
240 int NmodesP =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesP", 5);
241 int NmodesSUP =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesSUP", 5);
242 int NmodesNUT =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesNUT", 5);
243 int NmodesProject =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesProject", 5);
244 int NmodesMatrixRec =
para->ITHACAdict->lookupOrDefault<
int>(
"NmodesMatrixRec",
246 double penaltyFactor =
247 para->ITHACAdict->lookupOrDefault<
double>(
"penaltyFactor", 5);
248 double U_BC =
para->ITHACAdict->lookupOrDefault<
double>(
"U_BC", 0.001);
249 double romStartTime =
para->ITHACAdict->lookupOrDefault<
double>(
"romStartTime",
251 double romEndTime =
para->ITHACAdict->lookupOrDefault<
double>(
"romEndTime", 3);
252 double romTimeStep =
para->ITHACAdict->lookupOrDefault<
double>(
"romTimeStep",
254 double e =
para->ITHACAdict->lookupOrDefault<
double>(
"RBFradius", 1);
264 example.
podex, 0, 0, NmodesProject);
266 example.
podex, 0, 0, NmodesProject);
269 example.
supex, 1, NmodesProject);
270 example.
projectPPE(
"./Matrices", NmodesU, NmodesP, NmodesSUP, NmodesNUT);
277 cnpy::save(coeefs,
"./ITHACAoutput/Matrices/coeefs.npy");
278 cnpy::save(coeefsNut,
"./ITHACAoutput/Matrices/coeefsNut.npy");
279 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...
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes, bool rbfInterp=true)
Project using a supremizer approach.
UnsteadyNSTurb()
Construct Null.
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.