12#include "libmesh/utility.h"
16#include "libmesh/parallel.h"
38 virtual void execute()
override;
48 const std::shared_ptr<DenseVector<Real>> & snapshot);
53 std::vector<DenseVector<Real>> & residual);
72 const DenseVector<Real> &
getBasisVector(
unsigned int var_i,
unsigned int base_i)
const;
75 const DenseVector<Real> &
getBasisVector(
unsigned int glob_i)
const;
120 std::vector<std::vector<DenseVector<Real>>> &
_base;
143 ReplicatedMesh & mesh,
144 std::unordered_map<
unsigned int, std::vector<std::shared_ptr<DenseVector<Real>>>> &
146 std::unordered_map<
unsigned int, std::vector<std::shared_ptr<DenseVector<Real>>>> &
150 std::tuple<
unsigned int,
unsigned int, std::shared_ptr<DenseVector<Real>>>> & vectors);
StochasticTools::DistributedData< std::shared_ptr< DenseVector< Real > > > DistributedSnapshots
const InputParameters & parameters() const
void computeCorrelationMatrix()
Computes the correlation matrices using the snapshots.
unsigned int getSnapsSize(unsigned int var_i) const
Getting the snapshot size across all of the processors for a given variable with index var_i.
virtual void initialSetup() override
void receiveObjects(ReplicatedMesh &mesh, std::unordered_map< unsigned int, std::vector< std::shared_ptr< DenseVector< Real > > > > &received_vectors, std::unordered_map< unsigned int, std::vector< std::shared_ptr< DenseVector< Real > > > > &local_vectors, processor_id_type, const std::vector< std::tuple< unsigned int, unsigned int, std::shared_ptr< DenseVector< Real > > > > &vectors)
Function that manipulates the received objects and computes the correlation matrices on the fly.
unsigned int getSumBaseSize() const
Getting the overall base size, which is the sum of the individual bases.
virtual void finalize() override
std::vector< DenseMatrix< Real > > _eigenvectors
The eigenvectors of the correalation matrix for each variable.
unsigned int determineNumberOfModes(Real error, const std::vector< Real > &inp_vec) const
Computes the number of bases necessary for a given error indicator.
const std::vector< std::string > & getTagTypes() const
void printEigenvalues()
Prints the eigenvalues of the correlation matrix for each variable.
virtual void initialize() override
void computeBasisVectors()
Generates the basis vectors using the snapshots together with the eigen-decomposition of the correlat...
std::vector< DistributedSnapshots > _snapshots
Distributed container for snapshots per variable.
void computeEigenDecomposition()
Computes the eigen-decomposition of the stored correlation matrices.
void initReducedOperators()
Initializing the reduced operators.
const std::vector< std::string > & getVarNames() const
std::vector< DenseVector< Real > > _eigenvalues
The eigenvalues of the correalation matrix for each variable.
std::vector< std::string > & _tag_names
Names of the tags that should be used to fetch residuals from the MultiApp.
unsigned int getBaseSize(unsigned int var_i) const
Getting the base size for variable with index v_ind.
bool _empty_operators
Flag describing if the reduced operators are empty or not.
bool _base_completed
Switch that tells if the object has already computed the necessary basis vectors.
std::vector< std::string > & _tag_types
list of bools describing which tag is indepedent of the solution.
void addSnapshot(unsigned int var_i, unsigned int glob_i, const std::shared_ptr< DenseVector< Real > > &snapshot)
Adding a snapshot for a variable.
const std::vector< std::string > & getTagNames() const
std::vector< std::vector< DenseVector< Real > > > & _base
The reduced basis for the variables.
std::vector< DenseMatrix< Real > > _corr_mx
The correlation matrices for the variables.
static InputParameters validParams()
virtual void execute() override
const DenseVector< Real > & getBasisVector(unsigned int var_i, unsigned int base_i) const
Getting a basis vector for a given variable.
std::vector< std::string > & _var_names
Vector containing the names of the variables we want to use for constructing the surrogates.
void addToReducedOperator(unsigned int base_i, unsigned int tag_i, std::vector< DenseVector< Real > > &residual)
Adding the contribution of a residual to the reduced operators.
std::vector< Real > _error_res
Energy limits that define how many basis functions will be kept for each variable.
std::vector< DenseMatrix< Real > > & _red_operators
The reduced operators that should be transferred to the surrogate.
unsigned int getVariableIndex(unsigned int glob_i) const
Getting appropriate variable index for a global base index.
This is the base trainer class whose main functionality is the API for declaring model data.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...