63 Eigen::VectorXd a_o = Eigen::VectorXd::Zero(
Nphi_u);
64 Eigen::VectorXd a_n = a_o;
65 Eigen::MatrixXd b = Eigen::VectorXd::Zero(
Nphi_p);
66 Eigen::MatrixXd x = Eigen::VectorXd::Zero(
Nphi_p);
68 Eigen::VectorXd RHS = Eigen::VectorXd::Zero(
Nphi_p);
93 tmp_sol.col(0).segment(1,
Nphi_u) = a_o;
94 tmp_sol.col(0).tail(b.rows()) = b;
100 std::cout <<
" ################## time = " <<
time <<
101 " ##################" << std::endl;
106 Eigen::MatrixXd cf(1, 1);
110 for (label l = 0; l <
Nphi_p; l++)
114 RHS(l) = (1 /
dt) * M2(l, 0) - cf(0, 0) + M1(l, 0);
121 for (label
i = 0;
i <
N_BC;
i++)
131 Eigen::MatrixXd cc(1, 1);
137 Eigen::MatrixXd boundaryTerm = Eigen::MatrixXd::Zero(
Nphi_u,
N_BC);
139 for (label l = 0; l <
N_BC; l++)
145 for (label l = 0; l <
Nphi_u; l++)
149 a_n(l) = a_o(l) + (M5(l) - cc(0, 0) - M3(l)) *
dt;
151 for (label j = 0; j <
N_BC; j++)
153 a_n(l) += boundaryTerm(l, j) *
dt;
158 tmp_sol.col(0).segment(1,
Nphi_u) = a_n;
159 tmp_sol.col(0).tail(b.rows()) = b;
167 Eigen::VectorXd a_o = Eigen::VectorXd::Zero(
Nphi_u);
168 Eigen::VectorXd a_n = a_o;
169 Eigen::MatrixXd b = Eigen::VectorXd::Zero(
Nphi_p);
170 Eigen::VectorXd c_o = Eigen::VectorXd::Zero(
Nphi_u);
171 Eigen::VectorXd c_n = Eigen::VectorXd::Zero(
Nphi_u);
172 Eigen::MatrixXd x = Eigen::VectorXd::Zero(
Nphi_p);
174 Eigen::VectorXd RHS = Eigen::VectorXd::Zero(
Nphi_p);
201 tmp_sol.col(0).segment(1,
Nphi_u) = a_o;
203 tmp_sol.col(0).tail(
Nphi_u) = c_o;
209 std::cout <<
" ################## time = " <<
time <<
210 " ##################" << std::endl;
216 Eigen::MatrixXd cf(1, 1);
220 for (label l = 0; l <
Nphi_p; l++)
224 RHS(l) = (1 /
dt) * M2(l, 0) - cf(0, 0) + M1(l, 0);
231 for (label l = 0; l <
N_BC; l++)
241 Eigen::MatrixXd cc(1, 1);
247 Eigen::MatrixXd boundaryTerm = Eigen::MatrixXd::Zero(
Nphi_u,
N_BC);
249 for (label l = 0; l <
N_BC; l++)
255 for (label k = 0; k <
Nphi_u; k++)
259 a_n(k) = a_o(k) + (M5(k) - cc(0, 0) - M3(k)) *
dt;
261 for (label l = 0; l <
N_BC; l++)
263 a_n(k) += boundaryTerm(k, l) *
dt;
275 Eigen::MatrixXd M9 = Eigen::VectorXd::Zero(
Nphi_u);
277 for (label k = 0; k <
Nphi_u; k++)
284 Eigen::VectorXd boundaryTermFlux = Eigen::VectorXd::Zero(
Nphi_u);
286 for (label l = 0; l <
N_BC; l++)
293 + boundaryTermFlux));
295 tmp_sol.col(0).segment(1,
Nphi_u) = a_n;
297 tmp_sol.col(0).tail(
Nphi_u) = c_n;
306 "Only the inconsistent flux method and consistent flux method are implemented."
323 List < Eigen::MatrixXd> CoeffU;
324 List < Eigen::MatrixXd> CoeffP;
325 List <double> tValues;
333 if (counter == nextwrite)
335 Eigen::MatrixXd currentUCoeff;
336 Eigen::MatrixXd currentPCoeff;
339 CoeffU.append(currentUCoeff);
340 CoeffP.append(currentPCoeff);
341 nextwrite += exportEveryIndex;
343 tValues.append(timeNow);
Header file of the ReducedUnsteadyNSExplicit class.
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...
void reconstruct(bool exportFields=false, fileName folder="./online_rec")
Method to reconstruct the solutions from an online solve with a supremizer stabilisation technique.
ReducedUnsteadyNSExplicit()
Construct Null.
UnsteadyNSExplicit * problem
Pointer to the FOM problem.
Implementation of a parametrized full order unsteady NS problem and preparation of the the reduced ...
virtual void solveOnline()
Virtual Method to perform and online Solve.
static Eigen::MatrixXd solveLinearSys(List< Eigen::MatrixXd > LinSys, Eigen::MatrixXd x, Eigen::VectorXd &residual, const Eigen::MatrixXd &bc=Eigen::MatrixXd::Zero(0, 0), const std::string solverType="fullPivLu")
Linear system solver for the online problem.
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.
PtrList< volScalarField > pRecFields
Reconstructed pressure fields list.
PtrList< volVectorField > uRecFields
Recontructed velocity fields list.
int N_BC
Number of parametrized boundary conditions.
int Nphi_u
Number of velocity modes.
double exportEvery
A variable for exporting the fields.
scalar finalTime
Scalar to store the final time if the online simulation.
scalar tstart
Scalar to store the initial time if the online simulation.
scalar time
Scalar to store the current time.
double dt
Scalar to store the time increment.
double storeEvery
A variable for storing the reduced coefficients.
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
Eigen::Tensor< double, 3 > C_tensor
Diffusion term.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
Eigen::MatrixXd W_matrix
Mass Matrix New Time Step - Consistent Flux Method.
Eigen::MatrixXd I_matrix
Mass Matrix Old Time Step - Consistent Flux Method.
volVectorModes Umodes
List of pointers used to form the velocity modes.
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
List< Eigen::MatrixXd > LinSysDiff
Projection Peqn onto Pressure modes - Diffusion term.
List< Eigen::MatrixXd > LinSysDiv
Projection Peqn onto Pressure modes - Divergence term.
PtrList< surfaceScalarField > Phifield
List of pointers used to form the flux snapshots matrix.
word fluxMethod
Flux Method.
Eigen::MatrixXd B_matrix
Diffusion term.
List< Eigen::MatrixXd > RD_matrix
Boundary term for diffusion term.
List< Eigen::MatrixXd > SD_matrix
Boundary term for diffusion term - Consistent Flux Method.
Eigen::MatrixXd KF_matrix
Pressure Gradient Term - Consistent Flux Method.
Eigen::MatrixXd K_matrix
Gradient of pressure matrix.
List< Eigen::MatrixXd > LinSysConv
Projection Peqn onto Pressure modes - Convection term.
List< Eigen::MatrixXd > SC_matrix
Boundary term for convection term - Consistent Flux Method.
Eigen::MatrixXd DF_matrix
Diffusion Term - Consistent Flux Method.
Eigen::MatrixXd P_matrix
Div of velocity.
List< Eigen::MatrixXd > RC_matrix
Boundary vector for convection term.
Eigen::MatrixXd BP_matrix
Diffusion term for flux method PPE.
Eigen::Tensor< double, 3 > Cf_tensor
Convection term for flux method.
surfaceScalarModes Phimodes
List of pointers used to form the flux modes.
Eigen::Tensor< double, 3 > Ci_tensor
Convection term - Consistent Flux Method.
volScalarModes Pmodes
List of pointers used to form the pressure modes.
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.
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.
void createSymLink(word folder)
Creates symbolic links to 0, system and constant.