32#include "simpleControl.H"
33#include "simpleControl.H"
34#include "fvMeshSubset.H"
39#include "hyperReduction.templates.H"
45 static volScalarField evaluate_expression(volScalarField& S, Eigen::MatrixXd mu)
47 volScalarField yPos = S.mesh().C().component(vector::Y).ref();
48 volScalarField xPos = S.mesh().C().component(vector::X).ref();
50 for (
auto i = 0; i < S.size(); i++)
52 S[i] = std::exp(- 2 * std::pow(xPos[i] - mu(0) - 1,
53 2) - 2 * std::pow(yPos[i] - mu(1) - 0.5, 2));
62 auto f = evaluate_expression(subField(), mu);
73 Eigen::VectorXd theta;
74 PtrList<volScalarField> fields;
75 autoPtr<volScalarField> subField;
78int main(
int argc,
char* argv[])
81#include "setRootCase.H"
82 Foam::Time runTime(Foam::Time::controlDictName, args);
87 Foam::fvMesh::defaultRegion,
90 Foam::IOobject::MUST_READ
94 int NDEIM = para->ITHACAdict->lookupOrDefault<
int>(
"NDEIM", 15);
95 simpleControl simple(mesh);
96#include "createFields.H"
98 PtrList<volScalarField> Sp;
111 dimensionedScalar(
"zero", dimensionSet(0, 0, -1, 1, 0, 0, 0), 0)
121 for (
int i = 0; i < 100; i++)
123 DEIM_function::evaluate_expression(S, pars.row(i));
124 Sp.append((S).clone());
128 Eigen::MatrixXd snapshotsModes;
139 Eigen::VectorXi initSeeds(0);
142 c.offlineGappyDEIM(snapshotsModes, normalizingWeights);
147 c.generateSubmesh(2, mesh);
148 c.subField = c.interpolateField<volScalarField>(Sp[0]);
150 Eigen::MatrixXd par_new(2, 1);
154 Eigen::VectorXd aprfield = c.MatrixOnline * c.onlineCoeffs(par_new);
159 DEIM_function::evaluate_expression(S, par_new);
Header file of the Foam2Eigen class.
Header file of the ITHACAPOD class.
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...
Header file of the ITHACAutilities namespace.
HyperReduction(label n_modes, label n_nodes, Eigen::VectorXi initialSeeds, word problemName, SnapshotsLists &&...snapshotsLists)
Construct HyperReduction class, interpolation-based.
static GeometricField< scalar, PatchField, GeoMesh > Eigen2field(GeometricField< scalar, PatchField, GeoMesh > &field, Eigen::VectorXd &eigen_vector, bool correctBC=true)
Convert a vector in Eigen format into an OpenFOAM scalar GeometricField.
static Eigen::MatrixXd PtrList2Eigen(PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, label Nfields=-1)
Convert a PtrList of snapshots to Eigen matrix (only internal field).
List< label > localNodePoints
HyperReduction(label n_modes, label n_nodes, Eigen::VectorXi initialSeeds, word problemName, SnapshotsLists &&...snapshotsLists)
Construct HyperReduction class, interpolation-based.
autoPtr< IOList< label > > nodePoints
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
std::tuple< List< Eigen::SparseMatrix< double > >, List< Eigen::VectorXd > > DEIMmodes(List< Eigen::SparseMatrix< double > > &A, List< Eigen::VectorXd > &b, label nmodesA, label nmodesB, word MatrixName)
Get the DEIM modes for a generic non a parametrized matrix coming from a differential operator functi...
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
double errorL2Rel(GeometricField< T, fvPatchField, volMesh > &field1, GeometricField< T, fvPatchField, volMesh > &field2, List< label > *labels)
Computes the relative error between two geometric Fields in L2 norm.
Eigen::VectorXd getMassMatrixFV(GeometricField< Type, PatchField, GeoMesh > &snapshot)
Gets a vector containing the volumes of each cell of the mesh.
Eigen::MatrixXd rand(label rows, label cols, double min, double max)
Generates random matrix with random values in an interval.