71 Eigen::VectorXd& fvec)
const
73 Eigen::VectorXd aTmp(
Nphi_u);
74 Eigen::VectorXd bTmp(
Nphi_p);
78 Eigen::MatrixXd cc(1, 1);
86 Eigen::MatrixXd penaltyU = Eigen::MatrixXd::Zero(
Nphi_u,
N_BC);
91 for (
int l = 0; l <
N_BC; l++)
101 i) * aTmp -
gNut.transpose() *
103 fvec(
i) = m1(
i) - cc(0, 0) - m2(
i);
107 fvec(
i) += ((penaltyU *
tauU)(
i, 0));
111 for (
int j = 0; j <
Nphi_p; j++)
119 for (
int j = 0; j <
N_BC; j++)
121 fvec(j) = x(j) -
bc(j);
129 Eigen::VectorXd& fvec)
const
131 Eigen::VectorXd aTmp(
Nphi_u);
132 Eigen::VectorXd bTmp(
Nphi_p);
136 Eigen::MatrixXd cc(1, 1);
137 Eigen::MatrixXd gg(1, 1);
138 Eigen::MatrixXd bb(1, 1);
148 Eigen::MatrixXd penaltyU = Eigen::MatrixXd::Zero(
Nphi_u,
N_BC);
153 for (
int l = 0; l <
N_BC; l++)
163 i) * aTmp -
gNut.transpose() *
165 fvec(
i) = m1(
i) - cc(0, 0) - m2(
i);
169 fvec(
i) += ((penaltyU *
tauU)(
i, 0));
173 for (
int j = 0; j <
Nphi_p; j++)
179 fvec(k) = m3(j, 0) + gg(0, 0) - m7(j, 0);
184 for (
int j = 0; j <
N_BC; j++)
186 fvec(j) = x(j) -
bc(j);
195 Eigen::MatrixXd& fjac)
const
197 Eigen::NumericalDiff<newtonSteadyNSTurbSUP> numDiff(*
this);
203 Eigen::MatrixXd& fjac)
const
205 Eigen::NumericalDiff<newtonSteadyNSTurbPPE> numDiff(*
this);
229 for (
int j = 0; j <
N_BC; j++)
238 Eigen::HybridNonLinearSolver<newtonSteadyNSTurbSUP> hnls(
newtonObjectSUP);
242 for (
int j = 0; j <
N_BC; j++)
264 Info <<
"The way to compute the eddy viscosity coefficients has to be either L2 or RBF"
271 Eigen::VectorXd res(
y);
274 " ##################" << std::endl;
275 std::cout <<
"Solving for the parameter: " <<
vel_now << std::endl;
277 if (res.norm() < 1e-5)
279 std::cout << green <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
280 hnls.iter <<
" iterations " << def << std::endl << std::endl;
284 std::cout << red <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
285 hnls.iter <<
" iterations " << def << std::endl << std::endl;
308 for (
int j = 0; j <
N_BC; j++)
317 Eigen::HybridNonLinearSolver<newtonSteadyNSTurbPPE> hnls(
newtonObjectPPE);
321 for (
int j = 0; j <
N_BC; j++)
343 Info <<
"The way to compute the eddy viscosity coefficients has to be either L2 or RBF"
350 Eigen::VectorXd res(
y);
353 " ##################" << std::endl;
354 std::cout <<
"Solving for the parameter: " <<
vel_now << std::endl;
356 if (res.norm() < 1e-5)
358 std::cout << green <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
359 hnls.iter <<
" iterations " << def << std::endl << std::endl;
363 std::cout << red <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
364 hnls.iter <<
" iterations " << def << std::endl << std::endl;
381 List <Eigen::MatrixXd> CoeffU;
382 List <Eigen::MatrixXd> CoeffP;
383 List <Eigen::MatrixXd> CoeffNut;
390 if (counter == nextWrite)
392 Eigen::MatrixXd currentUCoeff;
393 Eigen::MatrixXd currentPCoeff;
394 Eigen::MatrixXd currentNutCoeff;
398 CoeffU.append(currentUCoeff);
399 CoeffP.append(currentPCoeff);
400 CoeffNut.append(currentNutCoeff);
401 nextWrite += printevery;
407 volVectorField uRec(
"uRec",
Umodes[0]);
428 &&
"Imposed boundary conditions dimensions do not match given values matrix dimensions");
429 Eigen::MatrixXd vel_scal;
430 vel_scal.resize(vel.rows(), vel.cols());
439 vel_scal(k, 0) = vel(k, 0) / u_lf;
Header file of the ReducedSteadyNSTurb class.
Class to change color to the output stream.
GeometricField< Type, PatchField, GeoMesh > reconstruct(GeometricField< Type, PatchField, GeoMesh > &inputField, Eigen::MatrixXd Coeff, word Name)
Function to reconstruct the solution starting from the coefficients, in this case the field is passed...
PtrList< volScalarField > nutRecFields
Reconstructed eddy viscosity fields list.
newtonSteadyNSTurbSUP newtonObjectSUP
Newton Object to solve the nonlinear problem sup approach.
newtonSteadyNSTurbPPE newtonObjectPPE
Newton Object to solve the nonlinear problem PPE approach.
void solveOnlinePPE(Eigen::MatrixXd velNow)
Method to perform an online solve using a PPE stabilisation method.
ReducedSteadyNSTurb()
Construct Null.
int nphiNut
Number of viscosity modes.
Eigen::MatrixXd rbfCoeffMat
The matrix of the eddy viscosity RBF interoplated coefficients.
void solveOnlineSUP(Eigen::MatrixXd velNow)
Method to perform an online solve using a supremizer stabilisation method.
SteadyNSTurb * problem
Pointer to the FOM problem.
void reconstruct(bool exportFields=false, fileName folder="./ITHACAoutput/online_rec", int printevery=1)
Method to reconstruct the solutions from an online solve.
Eigen::VectorXd rbfCoeff
Vector of eddy viscosity RBF interoplated coefficients.
Eigen::MatrixXd setOnlineVelocity(Eigen::MatrixXd vel)
Sets the online velocity.
Implementation of a parametrized full order steady turbulent Navier Stokes problem and preparation ...
Eigen::MatrixXd bTotalMatrix
Total B Matrix.
std::vector< SPLINTER::RBFSpline * > rbfSplines
Create a RBF splines for interpolation.
Eigen::Tensor< double, 3 > cTotalTensor
word viscCoeff
The way to compute the eddy viscosity snapshots.
Eigen::VectorXd nutCoeff
The vector of L2 projection coefficients for the eddy viscosity snapshot.
volScalarModes nutModes
List of POD modes for eddy viscosity.
Eigen::VectorXd y
Vector to store the solution during the Newton procedure.
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.
Eigen::MatrixXd tauU
Penalty Factor.
PtrList< volScalarField > pRecFields
Reconstructed pressure fields list.
int count_online_solve
Counter to count the online solutions.
Eigen::MatrixXd vel_now
Online inlet velocity vector.
PtrList< volVectorField > Umodes
List of pointers to store the modes for velocity.
PtrList< volVectorField > uRecFields
Recontructed velocity fields list.
int N_BC
Number of parametrized boundary conditions.
int Nphi_u
Number of velocity modes.
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
List< Eigen::MatrixXd > bcVelVec
Boundary term for penalty method - vector.
Eigen::MatrixXd BC3_matrix
PPE BC3.
Eigen::Tensor< double, 3 > C_tensor
Diffusion term.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
volVectorModes Umodes
List of pointers used to form the velocity modes.
label NUmodes
Number of velocity modes used for the projection.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
volVectorModes L_U_SUPmodes
List of pointers containing the total number of lift, supremizer and velocity modes.
Eigen::MatrixXd B_matrix
Diffusion term.
Eigen::MatrixXd D_matrix
Laplacian term PPE.
label NSUPmodes
Number of supremizer modes used for the projection.
Eigen::Tensor< double, 3 > gTensor
Divergence of momentum PPE.
Eigen::MatrixXd K_matrix
Gradient of pressure matrix.
List< Eigen::MatrixXd > bcVelMat
Boundary term for penalty method - matrix.
Eigen::MatrixXd P_matrix
Div of velocity.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
word bcMethod
Boundary Method.
Matrix< VectorType, Dynamic, Dynamic > SliceFromTensor(Eigen::Tensor< VectorType, 3 > &tensor, label dim, label index1)
void exportFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &field, word folder, word fieldname)
Function to export a scalar of vector field.
void createSymLink(word folder)
Creates symbolic links to 0, system and constant.
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec) const
int df(const Eigen::VectorXd &x, Eigen::MatrixXd &fjac) const
Structure to implement a newton object for a stationary NS problem.
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec) const
int df(const Eigen::VectorXd &x, Eigen::MatrixXd &fjac) const