33#include "viscosityModel.H"
42 _args = autoPtr<argList>
44 new argList(argc, argv)
47 if (!
_args->checkRootCase())
49 Foam::FatalError.exit();
52 argList& args =
_args();
55 _simple = autoPtr<simpleControl>
66#pragma GCC diagnostic push
67#pragma GCC diagnostic ignored "-Wunused-variable"
68#include "initContinuityErrs.H"
69#pragma GCC diagnostic pop
87 "The BC method must be set to lift or penalty in ITHACAdict");
103 volScalarField&
p =
_p();
104 volVectorField&
U =
_U();
105 surfaceScalarField&
phi =
_phi();
108 IOMRFZoneList& MRF =
_MRF();
123 for (label
i = 0;
i < mu_now.size();
i++)
137 "./ITHACAoutput/Offline");
148 for (label j = 0; j < cSize; j++)
154 for (label
i = 0;
i < cSize;
i++)
156 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix ct1Matrix" << endl;
160 for (label k = 0; k < cSize; k++)
170 "./ITHACAoutput/Matrices/");
172 "./ITHACAoutput/Matrices/");
174 "./ITHACAoutput/Matrices/ct1");
185 for (label
i = 0;
i < cSize;
i++)
189 for (label k = 0; k < cSize; k++)
213 List<tmp<volVectorField>> lapRow(cSize);
214 for (label k = 0; k < cSize; ++k)
219 for (label
i = 0;
i < cSize; ++
i)
221 for (label k = 0; k < cSize; ++k)
223 const volVectorField& lapField = lapRow[k]();
230 if (Pstream::master())
246 for (label j = 0; j < cSize; j++)
252 for (label
i = 0;
i < cSize;
i++)
254 Info <<
"Filling layer number " <<
i + 1 <<
" in the matrix ct2Matrix" << endl;
258 for (label k = 0; k < cSize; k++)
268 "./ITHACAoutput/Matrices/");
270 "./ITHACAoutput/Matrices/");
272 "./ITHACAoutput/Matrices/ct2");
283 for (label
i = 0;
i < cSize;
i++)
287 for (label k = 0; k < cSize; k++)
311 List<tmp<volVectorField>> divRow(cSize);
312 for (label k = 0; k < cSize; ++k)
317 for (label
i = 0;
i < cSize; ++
i)
319 for (label k = 0; k < cSize; ++k)
321 const volVectorField& divRowField = divRow[k]();
328 if (Pstream::master())
348 for (label k = 0; k < cSize; k++)
375 List<tmp<volVectorField>> PmodesGrad(
NPmodes);
378 PmodesGrad[
i] = fvc::grad(
Pmodes[
i]);
384 List<tmp<volVectorField>> lapRow(cSize);
385 for (label k = 0; k < cSize; ++k)
392 const volVectorField& gradPi = PmodesGrad[
i]();
393 for (label k = 0; k < cSize; ++k)
395 const volVectorField& lapRowField = lapRow[k]();
396 ct1PPETensor(
i, j, k) = fvc::domainIntegrate(gradPi & lapRowField).value();
402 if (Pstream::master())
422 for (label k = 0; k < cSize; k++)
448 List<tmp<volVectorField>> PmodesGrad(
NPmodes);
451 PmodesGrad[
i] = fvc::grad(
Pmodes[
i]);
457 List<tmp<volVectorField>> divLow(cSize);
458 for (label k = 0; k < cSize; ++k)
465 const volVectorField& gradPi = PmodesGrad[
i]();
466 for (label k = 0; k < cSize; ++k)
468 const volVectorField& divLowField = divLow[k]();
469 ct2PPETensor(
i, j, k) = fvc::domainIntegrate(gradPi & divLowField).value();
475 if (Pstream::master())
487 Eigen::MatrixXd
btMatrix(btSize, btSize);
491 for (label
i = 0;
i < btSize;
i++)
493 for (label j = 0; j < btSize; j++)
518 for (label k = 0; k <
liftfield.size(); k++)
526 for (label k = 0; k <
NUmodes; k++)
534 word bStr =
"B_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
546 word btStr =
"bt_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
558 word kStr =
"K_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
570 word pStr =
"P_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
582 word mStr =
"M_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
594 word D_str =
"D_" + name(
NPmodes);
605 word bc3_str =
"BC3_" + name(
liftfield.size()) +
"_" + name(
617 word bc4_str =
"BC4_" + name(
liftfield.size()) +
"_" + name(
629 word C_str =
"C_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
641 word ct1Str =
"ct1_" + name(
liftfield.size()) +
"_" + name(
654 word ct2Str =
"ct2_" + name(
liftfield.size()) +
"_" + name(
667 word G_str =
"G_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
691 for (label k = 0; k <
liftfield.size(); k++)
699 for (label k = 0; k <
NUmodes; k++)
735 if (
para->exportPython)
742 "./ITHACAoutput/Matrices/");
744 "./ITHACAoutput/Matrices/");
746 "./ITHACAoutput/Matrices/");
750 "./ITHACAoutput/Matrices/");
752 "./ITHACAoutput/Matrices/");
754 "./ITHACAoutput/Matrices/");
756 "./ITHACAoutput/Matrices/");
759 if (
para->exportMatlab)
766 "./ITHACAoutput/Matrices/");
768 "./ITHACAoutput/Matrices/");
770 "./ITHACAoutput/Matrices/");
773 "./ITHACAoutput/Matrices/");
775 "./ITHACAoutput/Matrices/");
777 "./ITHACAoutput/Matrices/");
779 "./ITHACAoutput/Matrices/");
789 "./ITHACAoutput/Matrices/");
791 "./ITHACAoutput/Matrices/");
796 "./ITHACAoutput/Matrices/ct1");
798 "./ITHACAoutput/Matrices/ct2");
800 "./ITHACAoutput/Matrices/ct1PPE");
802 "./ITHACAoutput/Matrices/ct2PPE");
815 "./ITHACAoutput/Matrices/");
817 "./ITHACAoutput/Matrices/");
819 "./ITHACAoutput/Matrices/");
825 Eigen::MatrixXd weights;
829 word weightName =
"wRBF_N" + name(
i + 1) +
"_" + name(
liftfield.size()) +
"_"
834 samples[
i] =
new SPLINTER::DataTable(1, 1);
836 for (label j = 0; j <
coeffL2.cols(); j++)
844 SPLINTER::RadialBasisFunctionType::GAUSSIAN, weights);
845 std::cout <<
"Constructing RadialBasisFunction for mode " <<
i + 1 << std::endl;
849 samples[
i] =
new SPLINTER::DataTable(1, 1);
851 for (label j = 0; j <
coeffL2.cols(); j++)
857 SPLINTER::RadialBasisFunctionType::GAUSSIAN);
859 "./ITHACAoutput/weightsPPE/", weightName);
860 std::cout <<
"Constructing RadialBasisFunction for mode " <<
i + 1 << std::endl;
876 for (label k = 0; k <
liftfield.size(); k++)
884 for (label k = 0; k <
NUmodes; k++)
900 word bStr =
"B_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
912 word btStr =
"bt_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
924 word kStr =
"K_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
936 word pStr =
"P_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
948 word mStr =
"M_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
960 word C_str =
"C_" + name(
liftfield.size()) +
"_" + name(
NUmodes) +
"_" + name(
972 word ct1Str =
"ct1_" + name(
liftfield.size()) +
"_" + name(
985 word ct2Str =
"ct2_" + name(
liftfield.size()) +
"_" + name(
1010 for (label k = 0; k <
liftfield.size(); k++)
1018 for (label k = 0; k <
NUmodes; k++)
1049 if (
para->exportPython)
1056 "./ITHACAoutput/Matrices/");
1059 "./ITHACAoutput/Matrices/");
1061 "./ITHACAoutput/Matrices/");
1064 if (
para->exportMatlab)
1071 "./ITHACAoutput/Matrices/");
1074 "./ITHACAoutput/Matrices/");
1076 "./ITHACAoutput/Matrices/");
1079 if (
para->exportTxt)
1088 "./ITHACAoutput/Matrices/ct1");
1090 "./ITHACAoutput/Matrices/ct2");
1101 "./ITHACAoutput/Matrices/");
1103 "./ITHACAoutput/Matrices/");
1105 "./ITHACAoutput/Matrices/");
1111 Eigen::MatrixXd weights;
1115 word weightName =
"wRBF_N" + name(
i + 1) +
"_" + name(
liftfield.size()) +
"_"
1120 samples[
i] =
new SPLINTER::DataTable(1, 1);
1122 for (label j = 0; j <
coeffL2.cols(); j++)
1130 SPLINTER::RadialBasisFunctionType::GAUSSIAN, weights);
1131 std::cout <<
"Constructing RadialBasisFunction for mode " <<
i + 1 << std::endl;
1135 samples[
i] =
new SPLINTER::DataTable(1, 1);
1137 for (label j = 0; j <
coeffL2.cols(); j++)
1143 SPLINTER::RadialBasisFunctionType::GAUSSIAN);
1145 "./ITHACAoutput/weightsSUP/", weightName);
1147 "wRBF_" + name(
i),
"eigen",
1148 "./ITHACAoutput/weightsSUP/"
1150 std::cout <<
"Constructing RadialBasisFunction for mode " <<
i + 1 << std::endl;
#define M_Assert(Expr, Msg)
Header file of the SteadyNSTurb class.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
Eigen::MatrixXd coeffL2
The matrix of L2 projection coefficients for the eddy viscosity.
Eigen::MatrixXd btMatrix
Turbulent viscosity matrix.
Eigen::Tensor< double, 3 > cTotalPPETensor
Turbulent total viscosity tensor in the PPE equation.
label nNutModes
Number of viscoisty modes used for the projection.
Eigen::MatrixXd bTotalMatrix
Total B Matrix.
std::vector< SPLINTER::RBFSpline * > rbfSplines
Create a RBF splines for interpolation.
Eigen::Tensor< double, 3 > turbulenceTensor2_cache(label NUmodes, label NSUPmodes, label nNutModes)
Method to compute one of the turbulence eddy viscosity tensors using the cached procedure.
Eigen::MatrixXd btTurbulence(label NUmodes, label NSUPmodes)
bt added matrix for the turbulence treatement
autoPtr< volScalarField > _nut
Eddy viscosity field.
std::vector< SPLINTER::DataTable * > samples
Create a samples for interpolation.
List< Eigen::MatrixXd > turbulenceTerm1(label NUmodes, label NSUPmodes, label nNutModes)
ct1 added matrix for the turbulence treatement
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
Eigen::Tensor< double, 3 > turbulenceTensor1_cache(label NUmodes, label NSUPmodes, label nNutModes)
ct1 tensor for the turbulence treatement using the cached procedure
List< Eigen::MatrixXd > ct2Matrix
Turbulent viscosity tensor.
Eigen::Tensor< double, 3 > ct1PPETensor
Turbulent viscosity tensor in the PPE equation.
Eigen::Tensor< double, 3 > turbulencePPETensor2_cache(label NUmodes, label NSUPmodes, label NPmodes, label nNutModes)
ct2PPE added tensor for the turbulence treatement in the PPE method using the cached procedure
Eigen::Tensor< double, 3 > turbulencePPETensor1_cache(label NUmodes, label NSUPmodes, label NPmodes, label nNutModes)
ct1PPE added tensor for the turbulence treatement in the PPE method using the cached procedure
Eigen::Tensor< double, 3 > ct1Tensor
List< Eigen::MatrixXd > ct1Matrix
Turbulent viscosity tensor.
List< Eigen::MatrixXd > turbulenceTerm2(label NUmodes, label NSUPmodes, label nNutModes)
Method to compute one of the turbulence eddy viscosity tensors.
void projectSUP(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes)
Project using a supremizer approach.
Eigen::Tensor< double, 3 > ct2PPETensor
Turbulent viscosity tensor in the PPE equation.
Eigen::Tensor< double, 3 > turbulencePPETensor1(label NUmodes, label NSUPmodes, label NPmodes, label nNutModes)
ct1PPE added tensor for the turbulence treatement in the PPE method
Eigen::Tensor< double, 3 > cTotalTensor
Eigen::Tensor< double, 3 > turbulencePPETensor2(label NUmodes, label NSUPmodes, label NPmodes, label nNutModes)
ct2PPE added tensor for the turbulence treatement in the PPE method
Eigen::Tensor< double, 3 > turbulenceTensor1(label NUmodes, label NSUPmodes, label nNutModes)
ct1 tensor for the turbulence treatement
Eigen::Tensor< double, 3 > ct2Tensor
Eigen::Tensor< double, 3 > turbulenceTensor2(label NUmodes, label NSUPmodes, label nNutModes)
Method to compute one of the turbulence eddy viscosity tensors.
void projectPPE(fileName folder, label NUmodes, label NPmodes, label NSUPmodes, label nNutModes)
Project using a PPE approach.
word viscCoeff
The way to compute the eddy viscosity snapshots.
volScalarModes nutModes
List of POD modes for eddy viscosity.
void writeMu(List< scalar > mu_now)
Write out a list of scalar corresponding to the parameters used in the truthSolve.
Eigen::MatrixXd mu_samples
Matrix of parameters to be used for PODI, where each row corresponds to a sample point....
label counter
Counter used for the output of the full order solutions.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
IOdictionary * ITHACAdict
dictionary to store input output infos
Eigen::MatrixXd mu
Row matrix of parameters.
autoPtr< argList > _args
argList
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
List< Eigen::MatrixXd > bcVelVec
Boundary term for penalty method - vector.
scalar maxIter
Number of maximum iterations to be done for the computation of the truth solution.
label NPmodes
Number of pressure modes used for the projection.
bool supex
Boolean variable to check the existence of the supremizer modes.
Eigen::MatrixXd diffusive_term(label NUmodes, label NPmodes, label NSUPmodes)
Diffusive Term.
autoPtr< surfaceScalarField > _phi
Flux.
Eigen::MatrixXd BC4_matrix
PPE BC4.
Eigen::MatrixXd BC3_matrix
PPE BC3.
Eigen::Tensor< double, 3 > C_tensor
Diffusion term.
autoPtr< simpleControl > _simple
simpleControl
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
volVectorModes supmodes
List of pointers used to form the supremizer modes.
List< Eigen::MatrixXd > bcVelocityVec(label NUmodes, label NSUPmodes)
Boundary integral modes on boundary used by the penaly method.
autoPtr< fv::options > _fvOptions
fvOptions
Eigen::MatrixXd pressure_BC4(label NPmodes, label NUmodes)
Term N° 4 given by the additional boundary condition using a PPE approach for time-dependent BCs.
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.
Eigen::MatrixXd divergence_term(label NUmodes, label NPmodes, label NSUPmodes)
Divergence Term (supremizer approach)
scalar tolerance
Tolerance for the residual of the stationary problems, there is the same tolerance for velocity and p...
Eigen::MatrixXd mass_term(label NUmodes, label NPmodes, label NSUPmodes)
Mass Term.
autoPtr< fvMesh > _mesh
Mesh.
autoPtr< singlePhaseTransportModel > _laminarTransport
Laminar transport (used by turbulence model)
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 pressure_BC3(label NPmodes, label NUmodes)
Term N° 3 given by the additional boundary condition using a PPE approach.
Eigen::MatrixXd B_matrix
Diffusion term.
Eigen::MatrixXd D_matrix
Laplacian term PPE.
autoPtr< IOMRFZoneList > _MRF
MRF variable.
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.
Eigen::Tensor< double, 3 > convective_term_tens(label NUmodes, label NPmodes, label NSUPmodes)
Export convective term as a tensor.
autoPtr< incompressible::turbulenceModel > turbulence
Turbulence model.
Eigen::Tensor< double, 3 > divMomentum(label NUmodes, label NPmodes)
Divergence of convective term (PPE approach)
Eigen::MatrixXd pressure_gradient_term(label NUmodes, label NPmodes, label NSUPmodes)
Gradient of pressure.
List< Eigen::MatrixXd > bcVelMat
Boundary term for penalty method - matrix.
Eigen::MatrixXd P_matrix
Div of velocity.
Eigen::MatrixXd M_matrix
Mass Matrix.
Eigen::MatrixXd laplacian_pressure(label NPmodes)
Laplacian of pressure term (PPE approach)
List< Eigen::MatrixXd > bcVelocityMat(label NUmodes, label NSUPmodes)
Boundary integral modes on boundary used by the penaly method.
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.
void ReadDenseMatrix(MatrixType &Matrix, word folder, word MatrixName)
Read a dense matrix from a binary format file.
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 SaveDenseMatrix(MatrixType &Matrix, word folder, word MatrixName)
Save a dense matrix to a binary format file.
void ReadDenseTensor(TensorType &Tensor, word folder, word MatrixName)
Read a dense tensor from file.
void exportTensor(Eigen::Tensor< T, 3 > tensor, word Name, word type, word folder)
Export the reduced tensor in numpy (tipo=python), matlab (tipo=matlab) and txt (tipo=eigen) format.
void SaveDenseTensor(TensorType &Tensor, word folder, word MatrixName)
Save a dense tensor to file.
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.
bool check_pod()
Check if the POD data folder "./ITHACAoutput/POD" exists.
bool check_off()
Check if the offline data folder "./ITHACAoutput/Offline" exists.
bool check_folder(word folder)
Checks if a folder exists.
bool check_file(std::string fileName)
Function that returns true if a file exists.
bool check_sup()
Check if the supremizer folder exists.
simpleControl simple(mesh)
singlePhaseTransportModel & laminarTransport
Header file of the steadyNS class.