54 List<scalar> mu_now(1);
55 volVectorField
U0 =
U;
56 volScalarField P0 =
p;
78 surfaceScalarField&
phi =
_phi();
80 volScalarField
p =
_p();
81 volVectorField
U =
_U();
82 IOMRFZoneList& MRF =
_MRF();
84 volVectorField Ulift(
"Ulift" + name(k),
U);
85 instantList Times =
runTime.times();
87 pisoControl potentialFlow(
mesh,
"potentialFlow");
88 Info <<
"Solving a lifting Problem" << endl;
89 Vector<double> v1(0, 0, 0);
92 Vector<double>
v0(0, 0, 0);
94 for (label j = 0; j <
U.boundaryField().size(); j++)
100 else if (
U.boundaryField()[BCind].type() ==
"fixedValue")
109 phi = linearInterpolate(Ulift) &
mesh.Sf();
112 Info <<
"Constructing velocity potential field Phi\n" << endl;
120 IOobject::READ_IF_PRESENT,
124 dimensionedScalar(
"Phi", dimLength * dimVelocity, 0),
125 p.boundaryField().types()
127 label PhiRefCell = 0;
128 scalar PhiRefValue = 0;
132 potentialFlow.dict(),
136 mesh.setFluxRequired(Phi.name());
137 runTime.functionObjects().start();
138 MRF.makeRelative(
phi);
141 while (potentialFlow.correctNonOrthogonal())
143 fvScalarMatrix PhiEqn
145 fvm::laplacian(dimensionedScalar(
"1", dimless, 1), Phi)
149 PhiEqn.setReference(PhiRefCell, PhiRefValue);
152 if (potentialFlow.finalNonOrthogonalIter())
154 phi -= PhiEqn.flux();
158 MRF.makeAbsolute(
phi);
159 Info <<
"Continuity error = "
160 << mag(fvc::div(
phi))().weightedAverage(
mesh.V()).value()
162 Ulift = fvc::reconstruct(
phi);
163 Ulift.correctBoundaryConditions();
164 Info <<
"Interpolated velocity error = "
165 << (sqrt(sum(sqr((fvc::interpolate(
U) &
mesh.Sf()) -
phi)))
166 / sum(
mesh.magSf())).value()
180 dimensionedVector(
"zero",
U.dimensions(), vector::zero)
182 volVectorField Uliftx(
"Uliftx" + name(k), Uzero);
183 Uliftx.replace(0, Ulift.component(0));
186 volVectorField Ulifty(
"Ulifty" + name(k), Uzero);
187 Ulifty.replace(1, Ulift.component(1));
198int main(
int argc,
char* argv[])
203 word par_offline_BC(
"./timeBCoff");
206 Eigen::MatrixXd timeBCoff3D = Eigen::MatrixXd::Zero(6, timeBCoff2D.cols());
207 timeBCoff3D.row(0) = timeBCoff2D.row(0);
208 timeBCoff3D.row(1) = timeBCoff2D.row(1);
209 timeBCoff3D.row(3) = timeBCoff2D.row(2);
210 timeBCoff3D.row(4) = timeBCoff2D.row(3);
212 Eigen::MatrixXd par_on_BC;
213 word par_online_BC(
"./timeBCon");
218 int NmodesUout = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesUout", 15);
219 int NmodesPout = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPout", 15);
220 int NmodesSUPout = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPout", 15);
221 int NmodesUproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesUproj", 10);
222 int NmodesPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesPproj", 10);
223 int NmodesSUPproj = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPproj", 10);
224 int NmodesOut = para->
ITHACAdict->lookupOrDefault<
int>(
"NmodesOut", 20);
280 else if (example.
bcMethod ==
"penalty")
292 example.
projectPPE(
"./Matrices", NmodesUproj, NmodesPproj, NmodesSUPproj);
302 Eigen::MatrixXd vel_now = par_on_BC;
311 reduced.
tauIter = Eigen::MatrixXd::Zero(4, 1);
312 reduced.
tauIter << 1e-6, 1e-6, 1e-6, 1e-6;
319 reduced.
reconstruct(
false,
"./ITHACAoutput/Reconstruction/");
int main(int argc, char *argv[])
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 reducedUnsteadyNS 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.
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)
scalar nu
Reduced viscosity in case of parametrized viscosity.
Eigen::MatrixXd tauU
Penalty Factor.
Class where it is implemented a reduced problem for the unsteady Navier-stokes problem.
double exportEvery
A variable for exporting the fields.
scalar tolerancePenalty
Tolerance for the residual of the boundary values, there is the same tolerance for velocity and tempe...
scalar finalTime
Scalar to store the final time if the online simulation.
int timeStepPenalty
Number of timesteps calculated for the iterative penalty method.
void solveOnline_PPE(Eigen::MatrixXd vel_now, int startSnap=0)
Method to perform an online solve using a PPE stabilisation method.
scalar tstart
Scalar to store the initial time if the online simulation.
void reconstruct(bool exportFields=false, fileName folder="./online_rec")
Method to reconstruct the solutions from an online solve with a supremizer stabilisation technique.
Eigen::MatrixXd tauIter
Penalty Factor determined with iterative solver.
scalar maxIterPenalty
Maximum number of iterations to be done for the computation of the penalty factor.
double dt
Scalar to store the time increment.
Eigen::MatrixXd penalty_PPE(Eigen::MatrixXd &vel_now, Eigen::MatrixXd &tauIter, int startSnap=0)
Method to determine the penalty factors iteratively.
double storeEvery
A variable for storing the reduced coefficients.
Eigen::MatrixXi inletPatch
Matrix that contains informations about the inlet boundaries without specifing the direction Rows = N...
label Pnumber
Number of parameters.
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
void assignIF(T &s, G &value)
Assign internal field condition.
label Tnumber
Dimension of the training set (used only when gerating parameters without input)
void computeLift(T &Lfield, T &liftfield, T &omfield)
Homogenize the snapshot matrix, it works with PtrList of volVectorField and volScalarField.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
Eigen::MatrixXd mu
Row matrix of parameters.
Eigen::MatrixXd mu_range
Range of the parameter spaces.
void setParameters()
Set Parameters Problems.
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.
void genEquiPar()
Generate Equidistributed Numbers.
void projectPPE(fileName folder, label NUmodes, label NPmodes, label NSUPmodes=0)
Project using the Poisson Equation for pressure.
autoPtr< surfaceScalarField > _phi
Flux.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
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.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
PtrList< volVectorField > Uomfield
List of pointers used to form the homogeneous velocity snapshots.
autoPtr< IOMRFZoneList > _MRF
MRF variable.
autoPtr< volVectorField > _U
Velocity field.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
word bcMethod
Boundary Method.
autoPtr< volScalarField > _p
Pressure field.
tutorial17(int argc, char *argv[])
void liftSolve(Eigen::MatrixXd BCs)
Implementation of a parametrized full order unsteady NS problem and preparation of the the reduced ...
Eigen::MatrixXd timeBCoff
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.
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.
void normalizeFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &fields)
Normalize list of Geometric fields.
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue)
Header file of the unsteadyNS class.