31#ifndef hyperReduction_H
32#define hyperReduction_H
39#include "fvMeshSubset.H"
46template <
typename... SnapshotsLists>
54 std::tuple<typename std::decay_t<SnapshotsLists>::value_type ...>;
55 static constexpr auto n_fields =
sizeof...(SnapshotsLists);
61 template <std::
size_t N>
63 std::tuple_element<N, SnapshotsListTuple>::type;
65 template <std::
size_t N>
82 SnapshotsLists &&...snapshotsLists);
184 Eigen::SparseMatrix<double>
P;
232 void offlineECP(Eigen::MatrixXd& snapshotsModes,
238 void initSeeds(Eigen::VectorXd mp_not_mask, std::set<label> nodePointsSet);
243 void computeLS(Eigen::MatrixXd& J, Eigen::MatrixXd& JWhole, Eigen::VectorXd& b,
253 Eigen::MatrixXd& modesSVD, Eigen::VectorXd& fieldWeights,
254 bool saveModesFlag =
false);
263 Eigen::MatrixXd& modesSVD, Eigen::VectorXd& fieldWeights,
264 Eigen::MatrixXd& modesSVDBoundary, Eigen::VectorXd& fieldWeightsBoundary,
273 void updateNodes(Eigen::SparseMatrix<double>&
P, label& ind_max,
274 Eigen::VectorXd& mp_not_mask);
282 template <
typename SnapshotsList>
283 void stackSnapshots(SnapshotsList sList, Eigen::MatrixXd& snapshotsMatrix,
284 Eigen::VectorXd& fieldWeights);
292 template <
typename SnapshotsList>
294 List<Eigen::MatrixXd>& snapshotsMatrixBoundary,
295 List<Eigen::VectorXd>& fieldWeightsBoundary);
303 template <
typename SnapshotsList>
304 void saveModes(SnapshotsList sList, Eigen::MatrixXd& snapshotsMatrix,
305 unsigned int& rowIndex,
unsigned int& modeIndex, word folder);
313 template <
typename SnapshotsList>
314 void saveModes(SnapshotsList sList, Eigen::MatrixXd& snapshotsMatrix,
315 Eigen::MatrixXd& snapshotsMatrixBoundary,
unsigned int& rowIndex,
316 unsigned int& rowIndexBoundary,
unsigned int& modeIndex, word folder);
324 template <
typename SnapshotsList>
336 template <
typename SnapshotsList>
348 template <
typename SnapshotsList>
360 void evaluatePinv(Eigen::SparseMatrix<double>& Projector,
361 Eigen::MatrixXd&
Modes, Eigen::VectorXd& fieldWeights);
369 void evaluateWPU(Eigen::SparseMatrix<double>& Projector,
370 Eigen::MatrixXd&
Modes, Eigen::VectorXd& fieldWeights,
396 template <
typename FieldType>
399 return autoPtr<FieldType>(
new FieldType(
submesh->interpolate(field)));
408 template <
typename Field>
411 return std::is_same<Field, volScalarField>::value ? 1 : 3;
419 template <
typename LastList>
430 template <
typename List,
typename... RemainingLists>
432 RemainingLists &&...tail)
446 std::sqrt((
A.transpose() *
A).determinant()) / \
447 A.colwise().lpNorm<2>().prod(),
456 template <
typename... FieldsArgs>
459 unsigned int cumulativeSize{0}, ith_field{0};
460 ([ & ](
auto & oFieldsArg)
462 double ith_fieldSize =
fieldDims[ith_field] * oFieldsArg.size();
463 Eigen::VectorXd vec = eFields.segment(cumulativeSize, ith_fieldSize);
465 cumulativeSize += ith_fieldSize;
491 void getSnapMatrix(Eigen::MatrixXd& snapMatrix, Eigen::VectorXd& fieldWeights);
498 void getSnapMatrix(Eigen::MatrixXd& snapMatrix, Eigen::VectorXd& fieldWeights,
499 List<Eigen::MatrixXd>& snapMatrixBoundary,
500 List<Eigen::VectorXd>& fieldWeightsBoundary);
Header file of the EigenFunctions class.
Header file of the Foam2Eigen class.
Header file of the ITHACAPOD class.
Header file of the ITHACAutilities namespace.
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.
Eigen::VectorXi submesh2nodesMask
static constexpr auto n_fields
typename NthFieldListType< N >::value_type NthFieldType
void stackSnapshotsBoundary(SnapshotsList sList, List< Eigen::MatrixXd > &snapshotsMatrixBoundary, List< Eigen::VectorXd > &fieldWeightsBoundary)
TODO.
SnapshotsListTuple snapshotsListTuple
The snapshots matrix containing the nonlinear function or operator.
label n_modes
The maximum number of modes to be considered.
void evaluateWPU(Eigen::SparseMatrix< double > &Projector, Eigen::MatrixXd &Modes, Eigen::VectorXd &fieldWeights, Eigen::VectorXd &quadratureWeights)
Compute the pseudo-inverse of the matrix M restricted with the projector P.
label n_nodes
The maximum number of modes to be considered.
word folderMethod
Folder for the selected HR method.
void stackNames(SnapshotsList sList)
TODO.
List< word > fieldNames
Names of the fields.
void generateSubmesh(label layers, const fvMesh &mesh)
Compute the submesh common to all fields in SnapshotsLists.
autoPtr< FieldType > interpolateField(const FieldType &field)
TODO.
autoPtr< fvMeshSubset > submesh
Submesh of the HyperReduction method.
Eigen::MatrixXd renormalizedBasisMatrix
Renormalized basis of HR.
List< label > n_boundary_cells_list
void offlineGappyDEIM(Eigen::MatrixXd &snapshotsModes, Eigen::VectorXd &normalizingWeights)
Methods implemented: 'GappyDEIM' from "DEIM, Chaturantabut, Saifon, and Danny C. Sorensen....
void updateNodes(Eigen::SparseMatrix< double > &P, label &ind_max, Eigen::VectorXd &mp_not_mask)
TODO.
unsigned int sumFieldsDim
void evaluatePinv(Eigen::SparseMatrix< double > &Projector, Eigen::MatrixXd &Modes, Eigen::VectorXd &fieldWeights)
Compute the pseudo-inverse of the matrix M restricted with the projector P.
Eigen::VectorXd quadratureWeights
Quadrature weights. Ordered in the same order of matrix P.
autoPtr< IOList< labelList > > totalNodePoints
List of label lists of the nodes and corresponding surrounding nodes.
void sumDimensions(double sum, SnapshotsList sList)
TODO.
Eigen::MatrixXd MatrixOnline
Online Matrix.
List< label > global2local(List< label > &points, fvMeshSubset &submesh)
Get local indices in the submesh from indices in the global ones.
Eigen::SparseMatrix< double > submesh2nodes
void stackDimensions(SnapshotsList sList)
TODO.
constexpr unsigned int compute_vectorial_dim(LastList x)
TODO.
void getSnapMatrix(Eigen::MatrixXd &snapMatrix, Eigen::VectorXd &fieldWeights)
TODO.
Eigen::VectorXi initialSeeds
List< label > localNodePoints
Indices of the local node points in the subMesh.
constexpr unsigned int get_field_dim()
TODO.
Eigen::VectorXd normalizingWeights
void offlineECP(Eigen::MatrixXd &snapshotsModes, Eigen::VectorXd &normalizingWeights)
Methods implemented: 'ECP' from "ECP, Hernandez, Joaquin Alberto, Manuel Alejandro Caicedo,...
word problemName
The name of the non-linear function e.g. HR_method/residual.
constexpr unsigned int compute_vectorial_dim(List &&head, RemainingLists &&...tail)
TODO.
void eigen2fields(Eigen::VectorXd &eFields, FieldsArgs &&... oFields)
TODO.
HyperReduction(label n_modes, label n_nodes, Eigen::VectorXi initialSeeds, word problemName, SnapshotsLists &&...snapshotsLists)
Construct HyperReduction class, interpolation-based.
std::tuple< std::decay_t< SnapshotsLists >... > SnapshotsListTuple
Eigen::VectorXd eigenValueseig
Eigen::SparseMatrix< double > P
The P matrix of the HyperReduction method. The nodes are ordered in the order of insertion during the...
typename std::tuple_element< N, SnapshotsListTuple >::type NthFieldListType
unsigned int vectorial_dim
label n_cells
Int Number of Cells;.
void initReshapeMat(Eigen::SparseMatrix< double > &reshapeMat)
TODO.
void initSeeds(Eigen::VectorXd mp_not_mask, std::set< label > nodePointsSet)
TODO.
autoPtr< IOList< label > > nodePoints
Nodes in the case of the a nonlinear function.
static double s_optimality(Eigen::MatrixXd &A)
TODO.
void getModesSVD(SnapshotsListTuple &SnapshotsListTuple, Eigen::MatrixXd &modesSVD, Eigen::VectorXd &fieldWeights, bool saveModesFlag=false)
TODO.
autoPtr< volVectorField > submesh_field
Submeshes.
label n_snapshots
The length of the snapshots lists.
autoPtr< IOList< label > > uniqueNodePoints
List of the unique indices of the nodes that define the submesh.
Eigen::SparseMatrix< double > field2submesh
List< unsigned int > fieldDims
Dimensions of the fields.
void saveModes(SnapshotsList sList, Eigen::MatrixXd &snapshotsMatrix, unsigned int &rowIndex, unsigned int &modeIndex, word folder)
TODO.
word folderProblem
Folder for the HR problem.
std::tuple< typename std::decay_t< SnapshotsLists >::value_type ... > FieldsTuple
void stackSnapshots(SnapshotsList sList, Eigen::MatrixXd &snapshotsMatrix, Eigen::VectorXd &fieldWeights)
TODO.
Eigen::MatrixXd basisMatrix
Orthonormal basis of HR.
label n_cellsSubfields
Int Number of Cells in submeshes;.
void createMasks(bool offlineStage=true)
TODO.
void computeLS(Eigen::MatrixXd &J, Eigen::MatrixXd &JWhole, Eigen::VectorXd &b, Eigen::VectorXd &q)
TODO.
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
Implementation of a container class derived from PtrList.