48 for (
int k = 0; k <
Nphi_u; k++)
58 Eigen::VectorXd& fvec)
const
60 Eigen::VectorXd aTmp(
Nphi_u);
63 Eigen::MatrixXd cc(1, 1);
69 Eigen::MatrixXd penaltyU = Eigen::MatrixXd::Zero(
Nphi_u,
N_BC);
74 for (
int l = 0; l <
N_BC; l++)
85 fvec(
i) = m1(
i) - cc(0, 0) - m2(
i);
89 fvec(
i) += ((penaltyU *
tauU)(
i, 0));
95 for (
int j = 0; j <
N_BC; j++)
97 fvec(j) = x(j) -
bc(j);
105 Eigen::MatrixXd& fjac)
const
107 Eigen::NumericalDiff<newtonSteadyNSTurbIntrusive> numDiff(*
this);
133 for (
int j = 0; j <
N_BC; j++)
142 Eigen::HybridNonLinearSolver<newtonSteadyNSTurbIntrusive> hnls(
newtonObject);
146 for (
int j = 0; j <
N_BC; j++)
153 Eigen::VectorXd res(
y);
156 " ##################" << std::endl;
157 std::cout <<
"Solving for the parameter: " <<
vel_now << std::endl;
159 if (res.norm() < 1e-5)
161 std::cout << green <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
162 hnls.iter <<
" iterations " << def << std::endl << std::endl;
166 std::cout << red <<
"|F(x)| = " << res.norm() <<
" - Minimun reached in " <<
167 hnls.iter <<
" iterations " << def << std::endl << std::endl;
184 if (counter == nextWrite)
186 volVectorField uRec(
"uRec",
Umodes[0] * 0);
190 for (
int j = 0; j <
Nphi_u; j++)
199 nextWrite += printEvery;
200 UREC.append(uRec.clone());
201 PREC.append(pRec.clone());
202 nutRec.append(nutTemp.clone());
213 &&
"Imposed boundary conditions dimensions do not match given values matrix dimensions");
214 Eigen::MatrixXd vel_scal;
215 vel_scal.resize(vel.rows(), vel.cols());
224 vel_scal(k, 0) = vel(k, 0) / u_lf;
235 system(
"ln -s ../../constant " + folder +
"/constant");
236 system(
"ln -s ../../0 " + folder +
"/0");
237 system(
"ln -s ../../system " + folder +
"/system");
241 IOdictionary FORCESdict
257 for (
int j = 0; j <
Nphi_u; j++)
262 for (
int j = 0; j <
Nphi_u; j++)
Header file of the ReducedSteadyNSTurbIntrusive class.
Class to change color to the output stream.
PtrList< volScalarField > nutRec
Reconstructed eddy viscosity field.
void reconstructLiftAndDrag(SteadyNSTurbIntrusive &problem, fileName folder)
Method to compute the reduced order forces for same number of modes of velocity and pressure.
ReducedSteadyNSTurbIntrusive()
Construct Null.
Eigen::MatrixXd setOnlineVelocity(Eigen::MatrixXd vel)
Sets the online velocity.
newtonSteadyNSTurbIntrusive newtonObject
Newton Object to solve the nonlinear problem.
SteadyNSTurbIntrusive * problem
Pointer to the FOM problem.
void reconstruct(fileName folder="./ITHACAOutput/online_rec", int printEvery=1)
Method to reconstruct the solutions from an online solve with a supremizer stabilisation technique.
Implementation of a parametrized full order steady turbulent Navier Stokes problem and preparation ...
Eigen::MatrixXd bTotalMatrix
Total B Matrix.
PtrList< volScalarField > nutModes
List of POD modes for eddy viscosity.
Eigen::Tensor< double, 3 > cTotalTensor
Total Turbulent tensor.
Eigen::MatrixXd kMatrix
Pressure Gradient matrix.
Eigen::MatrixXd bMatrix
Diffusive matrix.
virtual void solveOnline()
Virtual Method to perform and online Solve.
PtrList< volScalarField > PREC
Reconstructed pressure field.
Eigen::VectorXd y
Vector to store the solution during the Newton procedure.
ITHACAparameters * para
parameters to be read from the ITHACAdict file
Eigen::MatrixXd fTau
Reduced matrix for tangent forces.
List< Eigen::MatrixXd > online_solution
List of Eigen matrices to store the online solution.
scalar nu
Reduced viscosity in case of parametrized viscosity.
Eigen::MatrixXd tauU
Penalty Factor.
int count_online_solve
Counter to count the online solutions.
Eigen::MatrixXd vel_now
Online inlet velocity vector.
Eigen::MatrixXd fN
Reduced matrix for normal forces.
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.
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
List< Eigen::MatrixXd > bcVelVec
Boundary term for penalty method - vector.
Eigen::MatrixXd nMatrix
Pressure forces.
Eigen::MatrixXd tauMatrix
Viscous forces.
volVectorModes Umodes
List of pointers used to form the velocity modes.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
List< Eigen::MatrixXd > bcVelMat
Boundary term for penalty method - matrix.
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 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 ...
void createSymLink(word folder)
Creates symbolic links to 0, system and constant.
Structure to implement a newton object for a stationary NS problem.
SteadyNSTurbIntrusive * problem
int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec) const
int df(const Eigen::VectorXd &x, Eigen::MatrixXd &fjac) const