33#include "viscosityModel.H"
38SteadyNSTurbIntrusive::SteadyNSTurbIntrusive() {}
40SteadyNSTurbIntrusive::SteadyNSTurbIntrusive(
int argc,
char* argv[])
42 _args = autoPtr<argList>
44 new argList(argc, argv)
47 if (!
_args->checkRootCase())
49 Foam::FatalError.exit();
52 argList& args =
_args();
53#include "createTime.H"
54#include "createMesh.H"
55 _simple = autoPtr<simpleControl>
62 simpleControl& simple =
_simple();
63#include "createFields.H"
64#include "createFvOptions.H"
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");
101 fvMesh& mesh =
_mesh();
102 volScalarField& p =
_p();
103 volVectorField& U =
_U();
104 surfaceScalarField& phi =
_phi();
106 simpleControl& simple =
_simple();
107 IOMRFZoneList& MRF =
_MRF();
109#include "NLsolveSteadyNSTurbIntrusive.H"
122 for (label i = 0; i < mu_now.size(); i++)
136 "./ITHACAoutput/Offline");
143 ct1Tensor.resize(nModes, nModes, nModes);
145 for (label i = 0; i < nModes; i++)
147 for (label j = 0; j < nModes; j++)
149 for (label k = 0; k < nModes; k++)
157 if (Pstream::parRun())
159 reduce(
ct1Tensor, sumOp<Eigen::Tensor<double, 3 >> ());
164 "ct1_" + name(nModes) +
"_t");
171 ct2Tensor.resize(nModes, nModes, nModes);
173 for (label i = 0; i < nModes; i++)
175 for (label j = 0; j < nModes; j++)
177 for (label k = 0; k < nModes; k++)
185 if (Pstream::parRun())
187 reduce(
ct2Tensor, sumOp<Eigen::Tensor<double, 3 >> ());
192 "ct2_" + name(nModes) +
"_t");
198 Eigen::MatrixXd
btMatrix(nModes, nModes);
202 for (label i = 0; i < nModes; i++)
204 for (label j = 0; j < nModes; j++)
206 btMatrix(i, j) = fvc::domainIntegrate(
Umodes[i] & (fvc::div(dev((T(
214 "bt_" + name(nModes) +
"_t");
224 word bStr =
"b_" + name(nModes);
235 word btStr =
"bt_" + name(nModes);
246 word kStr =
"k_" + name(nModes);
257 word cStr =
"c_" + name(nModes) +
"_t";
268 word ct1Str =
"ct1_" + name(nModes) +
"_t";
279 word ct2Str =
"ct2_" + name(nModes) +
"_t";
313 if (para->exportPython)
318 "./ITHACAoutput/Matrices/");
320 "./ITHACAoutput/Matrices/");
322 "./ITHACAoutput/Matrices/");
324 "./ITHACAoutput/Matrices/");
327 if (para->exportMatlab)
332 "./ITHACAoutput/Matrices/");
334 "./ITHACAoutput/Matrices/");
336 "./ITHACAoutput/Matrices/");
338 "./ITHACAoutput/Matrices/");
347 "./ITHACAoutput/Matrices/c");
349 "./ITHACAoutput/Matrices/ct1");
351 "./ITHACAoutput/Matrices/ct2");
362 bMatrix.resize(nModes, nModes);
365 for (label i = 0; i < nModes; i++)
367 for (label j = 0; j < nModes; j++)
369 bMatrix(i, j) = fvc::domainIntegrate(
Umodes[i] & fvc::laplacian(
370 dimensionedScalar(
"1", dimless, 1),
Umodes[j])).value();
374 if (Pstream::parRun())
376 reduce(
bMatrix, sumOp<Eigen::MatrixXd>());
380 "b_" + name(nModes));
389 for (label i = 0; i < nModes; i++)
391 for (label j = 0; j < nModes; j++)
393 for (label k = 0; k < nModes; k++)
402 if (Pstream::parRun())
404 reduce(
convTensor, sumOp<Eigen::Tensor<double, 3 >> ());
409 "c_" + name(nModes) +
"_t");
415 Eigen::MatrixXd
kMatrix(nModes, nModes);
418 for (label i = 0; i < nModes; i++)
420 for (label j = 0; j < nModes; j++)
427 if (Pstream::parRun())
429 reduce(
kMatrix, sumOp<Eigen::MatrixXd>());
433 "k_" + name(nModes));
451 for (label i = 0; i < nModes; i++)
453 bcVelVec[k](i, 0) = gSum(
Umodes[i].boundaryField()[BCind].component(
459 "./ITHACAoutput/Matrices/bcVelVec");
466 List < Eigen::MatrixXd >
bcVelMat(BCUsize);
478 for (label i = 0; i < nModes; i++)
480 for (label j = 0; j < nModes; j++)
482 bcVelMat[k](i, j) = gSum(
Umodes[i].boundaryField()[BCind].component(
484 Umodes[j].boundaryField()[BCind].component(BCcomp));
490 "./ITHACAoutput/Matrices/bcVelMat");
Header file of the SteadyNSTurbIntrusive class.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
Eigen::MatrixXd diffusiveTerm(label nModes)
Diffusive Term.
Eigen::MatrixXd bTotalMatrix
Total B Matrix.
PtrList< volScalarField > nutModes
List of POD modes for eddy viscosity.
Eigen::MatrixXd btTurbulence(label nModes)
bt added matrix for the turbulence treatement
Eigen::Tensor< double, 3 > turbulenceTensor2(label nModes)
Method to compute one of the turbulence eddy viscosity tensors.
Eigen::Tensor< double, 3 > convTensor
Convective tensor.
PtrList< volScalarField > nutFields
List of snapshots for the solution for eddy viscosity.
List< Eigen::MatrixXd > bcVelocityVec(label nModes)
Boundary integral modes on boundary used by the penaly method.
Eigen::Tensor< double, 3 > cTotalTensor
Total Turbulent tensor.
Eigen::Tensor< double, 3 > convectiveTerm(label nModes)
The method for computing the convective term tensor.
autoPtr< volScalarField > _nut
Eddy viscosity field.
Eigen::MatrixXd kMatrix
Pressure Gradient matrix.
Eigen::MatrixXd btMatrix
Turbulent viscosity matrix.
List< Eigen::MatrixXd > bcVelocityMat(label nModes)
Boundary integral modes on boundary used by the penaly method.
Eigen::Tensor< double, 3 > turbulenceTensor1(label nModes)
Method to compute one of the turbulence eddy viscosity tensors.
Eigen::MatrixXd pressureGradientTerm(label nModes)
The method for computing the pressure gradient term with number of modes of pressure being equal to t...
label nModesOnline
Number of modes used in the online stage.
Eigen::MatrixXd bMatrix
Diffusive matrix.
Eigen::Tensor< double, 3 > ct2Tensor
Turbulent viscosity tensor.
Eigen::Tensor< double, 3 > ct1Tensor
Turbulent viscosity tensor.
void project()
General projection operation.
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
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
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.
bool supex
Boolean variable to check the existence of the supremizer modes.
autoPtr< surfaceScalarField > _phi
Flux.
autoPtr< simpleControl > _simple
simpleControl
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
autoPtr< fv::options > _fvOptions
fvOptions
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.
scalar tolerance
Tolerance for the residual of the stationary problems, there is the same tolerance for velocity and p...
autoPtr< fvMesh > _mesh
Mesh.
autoPtr< singlePhaseTransportModel > _laminarTransport
Laminar transport (used by turbulence model).
autoPtr< IOMRFZoneList > _MRF
MRF variable.
autoPtr< incompressible::turbulenceModel > turbulence
Turbulence model.
List< Eigen::MatrixXd > bcVelMat
Boundary term for penalty method - matrix.
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.
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.
Header file of the steadyNS class.