111 Eigen::VectorXd& fvec)
const
113 Eigen::VectorXd a_dot(
Nphi_u);
114 Eigen::VectorXd a_tmp(
Nphi_u);
115 Eigen::VectorXd b_tmp(
Nphi_p);
120 Eigen::MatrixXd cc(1, 1);
135 fvec(
i) = - M5(
i) + M1(
i) - cc(0, 0) - M2(
i);
139 for (
int j = 0; j <
Nphi_p; j++)
145 for (
int j = 0; j <
N_BC; j++)
147 fvec(j) = x(j) -
BC(j);
155 Eigen::MatrixXd& fjac)
const
157 Eigen::NumericalDiff<newton_unsteadyNSTTurb_sup> numDiff(*
this);
164 Eigen::VectorXd& fvect)
const
167 Eigen::VectorXd c_dot(
Nphi_t);
168 Eigen::VectorXd c_tmp(
Nphi_t);
172 Eigen::MatrixXd qq(1, 1);
173 Eigen::MatrixXd st(1, 1);
183 fvect(
i) = -M8(
i) + M6(
i) - qq(0, 0) + st(0, 0) /
Prt;
186 for (
int j = 0; j <
N_BC_t; j++)
188 fvect(j) = t(j) -
BC_t(j);
194 Eigen::MatrixXd& fjact)
const
196 Eigen::NumericalDiff<newton_unsteadyNSTTurb_sup_t> numDiff(*
this);
197 numDiff.df(t, fjact);
204 Eigen::MatrixXd& temp_now,
int startSnap)
213 for (
int j = 0; j < T_IC.boundaryField().size(); j++)
232 for (
int j = 0; j <
N_BC; j++)
237 for (
int j = 0; j <
N_BC_t; j++)
239 z(j) = temp_now(j, 0);
254 for (
int j = 0; j <
N_BC; j++)
259 for (
int j = 0; j <
N_BC_t; j++)
275 tmp_sol.col(0).tail(
y.rows()) =
y;
277 Eigen::MatrixXd tmp_solt(
Nphi_t + 1, 1);
279 tmp_solt.col(0).tail(
z.rows()) =
z;
282 Eigen::HybridNonLinearSolver<newton_unsteadyNSTTurb_sup> hnls(
284 Eigen::HybridNonLinearSolver<newton_unsteadyNSTTurb_sup_t> hnlst(
295 std::vector<double> tv;
299 for (
int i = 1;
i < tv.size();
i++)
316 nutREC.append((nut_rec).clone());
318 Eigen::VectorXd res(
y);
319 Eigen::VectorXd rest(
z);
324 for (
int j = 0; j <
N_BC; j++)
332 for (
int j = 0; j <
N_BC_t; j++)
334 z(j) = temp_now(j, 0);
342 " ##################" << std::endl;
343 Info <<
"Time = " <<
time << endl;
344 std::cout <<
"Solving for the parameter: " <<
vel_now << std::endl;
346 if (res.norm() < 1e-5)
348 std::cout << green <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
349 hnls.iter <<
" iterations " << def << std::endl << std::endl;
353 std::cout << red <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
354 hnls.iter <<
" iterations " << def << std::endl << std::endl;
359 tmp_sol.col(0).tail(
y.rows()) =
y;
371 tmp_solt.col(0).tail(
z.rows()) =
z;
387 "./ITHACAoutput/red_coeff");
389 "./ITHACAoutput/red_coeff");
391 "./ITHACAoutput/red_coeff_t");
393 "./ITHACAoutput/red_coeff_t");
403 system(
"ln -s ../../constant " + folder +
"/constant");
404 system(
"ln -s ../../0 " + folder +
"/0");
405 system(
"ln -s ../../system " + folder +
"/system");
412 if (counter == nextwrite)
414 volVectorField U_rec(
"U_rec",
Umodes[0] * 0);
416 for (
int j = 0; j <
Nphi_u; j++)
422 volScalarField P_rec(
"P_rec",
Pmodes[0] * 0);
424 for (
int j = 0; j <
Nphi_p; j++)
431 nextwrite += printevery;
433 UREC.append((U_rec).clone());
434 PREC.append((P_rec).clone());
444 system(
"ln -s ../../constant " + folder +
"/constant");
445 system(
"ln -s ../../0 " + folder +
"/0");
446 system(
"ln -s ../../system " + folder +
"/system");
453 if (counter == nextwrite)
457 for (
int j = 0; j <
Nphi_t; j++)
463 nextwrite += printevery;
Header file of the reducedUnsteadyNSTTurb class.
Class to change color to the output stream.
ReducedUnsteadyNSTTurb()
Construct Null.
void solveOnlineSup(Eigen::MatrixXd &vel_now, Eigen::MatrixXd &temp_now, int startSnap=0)
Method to perform an online solve using a supremizer stabilisation method.
double time
Scalar to store the current time.
newton_unsteadyNSTTurb_sup_t newton_object_sup_t
Functor object to call the non linear solver sup. approach for temperature field.
double dt
Scalar to store the time increment.
newton_unsteadyNSTTurb_sup newton_object_sup
Functor object to call the non linear solver sup. approach.
scalar Prt
Scalar to store the turbulent Prandtl number.
int Nphi_nut
Number of nut field modes.
UnsteadyNSTTurb * problem
Pointer to the FOM problem.
void reconstructSup(fileName folder="./ITHACAOutput/online_rec", int printevery=1)
Method to reconstruct a solution for velocity and pressure from an online solve with a supremizer sta...
PtrList< volScalarField > nutREC
Reconstructed eddy viscosity field.
double finalTime
Scalar to store the final time if the online simulation.
void reconstructSupt(fileName folder="./ITHACAOutput/online_rec", int printevery=1)
Method to reconstruct a solution for temperature from an online solve with a supremizer stabilisation...
scalar Pr
Scalar to store the Prandtl number.
double tstart
Scalar to store the final time if the online simulation.
Implementation of a parametrized full order unsteady NST problem weakly coupled with the energy equa...
List< Eigen::MatrixXd > S_matrix
Turbulent diffusivity term.
List< Eigen::MatrixXd > C_total_matrix
Total C Matrix.
List< Eigen::MatrixXd > CT2_matrix
Turbulent viscosity term.
Eigen::MatrixXd B_total_matrix
Total B Matrix.
std::vector< SPLINTER::RBFSpline * > rbfsplines
Create a SAMPLES for interpolation.
PtrList< volScalarField > nuTmodes
List of POD modes for eddy viscosity.
PtrList< volScalarField > PREC
Reconstructed pressure field.
Eigen::VectorXd y
Vector to store the solution during the Newton procedure.
PtrList< volScalarField > Pmodes
List of pointers to store the modes for pressure.
List< Eigen::MatrixXd > online_solution
List of Eigen matrices to store the online solution.
int Nphi_p
Number of pressure modes.
scalar nu
Reduced viscosity in case of parametrized viscosity.
int count_online_solve
Counter to count the online solutions.
Eigen::MatrixXd vel_now
Online inlet velocity vector.
PtrList< volScalarField > Psnapshots
List of pointers to store the snapshots for pressure.
PtrList< volVectorField > Usnapshots
List of pointers to store the snapshots for velocity.
PtrList< volVectorField > Umodes
List of pointers to store the modes for velocity.
int N_BC
Number of parametrized boundary conditions.
PtrList< volVectorField > UREC
Recontructed velocity field.
int Nphi_u
Number of velocity modes.
PtrList< volScalarField > TREC
Reconstructed temperature field.
int N_BC_t
Number of parametrized boundary conditions related to temperature field.
PtrList< volScalarField > Tmodes
List of pointers to store the modes for temperature.
PtrList< volScalarField > T_rec
Reconstructed temperature field.
List< Eigen::MatrixXd > online_solutiont
List of Eigen matrices to store the online solution for temperature equation.
int Nphi_t
Number of temperature modes.
Eigen::VectorXd z
Vector to store the temperature solution during the Newton procedure.
PtrList< volScalarField > Tsnapshots
List of pointers to store the snapshots for temperature.
Eigen::MatrixXi inletIndexT
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
label NPmodes
Number of pressure modes used for the projection.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
volVectorModes Umodes
List of pointers used to form the velocity modes.
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
label NUmodes
Number of velocity modes used for the projection.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
Eigen::MatrixXd B_matrix
Diffusion term.
label NSUPmodes
Number of supremizer modes used for the projection.
Eigen::MatrixXd K_matrix
Gradient of pressure matrix.
List< Eigen::MatrixXd > C_matrix
Non linear term.
Eigen::MatrixXd P_matrix
Div of velocity.
Eigen::MatrixXd M_matrix
Mass Matrix.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
Eigen::MatrixXd Y_matrix
Gradient of pressure matrix.
PtrList< volScalarField > Tfield
List of pointers used to form the temperature snapshots matrix.
List< Eigen::MatrixXd > Q_matrix
Non linear term.
PtrList< volScalarField > liftfieldT
List of pointers used to form the list of the temperature lifting functions.
label NTmodes
Number of temperature modes used for the projection.
Eigen::MatrixXd MT_matrix
Mass Matrix T.
PtrList< volScalarField > Tmodes
List of pointers used to form the temperature modes.
void exportFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &field, word folder, word fieldname)
Function to export a scalar of vector field.
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
void exportMatrix(Eigen::Matrix< T, -1, dim > &matrix, word Name, word type, word folder)
Export the reduced matrices in numpy (type=python), matlab (type=matlab) and txt (type=eigen) format ...
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.
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec) const
UnsteadyNSTTurb * problem
int df(const Eigen::VectorXd &x, Eigen::MatrixXd &fjac) const
int df(const Eigen::VectorXd &x, Eigen::MatrixXd &fjac) const
UnsteadyNSTTurb * problem
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec) const