https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
PODMapping Class Reference

Class which provides a Proper Orthogonal Decomposition (POD)-based mapping between full-order and reduced-order spaces. More...

#include <PODMapping.h>

Inheritance diagram for PODMapping:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 PODMapping (const InputParameters &parameters)
 
virtual void buildMapping (const VariableName &vname) override
 Abstract function for building mapping for a given variable. More...
 
void map (const VariableName &vname, const DenseVector< Real > &full_order_vector, std::vector< Real > &reduced_order_vector) const override
 Method used for mapping full-order solutions for a given variable onto a latent space. More...
 
void map (const VariableName &vname, const unsigned int global_sample_i, std::vector< Real > &reduced_order_vector) const override
 Method used for mapping full-order solutions for a given variable onto a latent space. More...
 
void inverse_map (const VariableName &vname, const std::vector< Real > &reduced_order_vector, DenseVector< Real > &full_order_vector) const override
 Method used for mapping reduced-order solutions for a given variable onto the full-order space. More...
 
const std::vector< DenseVector< Real > > & leftBasis (const VariableName &vname)
 Return all of the left basis functions for a given variable. More...
 
const std::vector< DenseVector< Real > > & rightBasis (const VariableName &vname)
 Return all of the right basis functions for a given variable. More...
 
const std::vector< Real > & singularValues (const VariableName &vname)
 Return all of the singular values for a given variable. More...
 
const DenseVector< Real > & leftBasisFunction (const VariableName &vname, const unsigned int base_i)
 Get the base_i-th left basis function for a given variable. More...
 
const DenseVector< Real > & rightBasisFunction (const VariableName &vname, const unsigned int base_i)
 Get the base_i-th right basis function for a given variable. More...
 
virtual const std::vector< VariableName > & getVariableNames ()
 Get the available variable names in this mapping. More...
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
const std::string & modelMetaDataName () const
 Accessor for the name of the model meta data. More...
 
const FileName & getModelDataFileName () const
 Get the associated filename. More...
 
bool hasModelData () const
 Check if we need to load model data (if the filename parameter is used) More...
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
template<typename T , typename... Args>
T & declareModelData (const std::string &data_name, Args &&... args)
 Declare model data for loading from file as well as restart. More...
 
template<typename T , typename... Args>
const T & getModelData (const std::string &data_name, Args &&... args) const
 Retrieve model data from the interface. More...
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

void checkIfReadyToUse (const VariableName &libmesh_dbg_var(vname)) const
 Check if we have a mapping for the variable and if it is ready to be used. More...
 
virtual void addUserObjectDependencyHelper (const UserObject &) const
 

Protected Attributes

const std::vector< dof_id_type_num_modes
 The number of modes which need to be computed. More...
 
const std::vector< Real > & _energy_threshold
 The energy thresholds for truncation of the number of modes, defined by the user. More...
 
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
 Restartable container holding the basis functions for each variable. More...
 
std::map< VariableName, std::vector< DenseVector< Real > > > & _right_basis_functions
 Restartable container holding the basis functions for each variable. More...
 
std::map< VariableName, std::vector< Real > > & _singular_values
 Restartable container holding the singular values. More...
 
const std::string & _extra_slepc_options
 Variable holding additional petsc options for the singular value solve. More...
 
const std::vector< VariableName > & _variable_names
 Storage for the names of the variables this mapping can handle. More...
 
std::map< VariableName, bool > & _mapping_ready_to_use
 Bool to decide if we already have the mapping built or not to make sure it is not computed multiple times unless the user requests it. More...
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const Parallel::Communicator & _communicator
 

Private Attributes

const ParallelSolutionStorage *const _parallel_storage
 Link to the parallel storage which holds the solution fields that are used for the SVD. More...
 
const StochasticTools::POD _pod
 The POD object which can be used to compute the basis functions/vectors. More...
 

Detailed Description

Class which provides a Proper Orthogonal Decomposition (POD)-based mapping between full-order and reduced-order spaces.

Definition at line 23 of file PODMapping.h.

Constructor & Destructor Documentation

◆ PODMapping()

PODMapping::PODMapping ( const InputParameters parameters)

Definition at line 45 of file PODMapping.C.

47  UserObjectInterface(this),
48  _num_modes(isParamValid("num_modes_to_compute")
49  ? getParam<std::vector<dof_id_type>>("num_modes_to_compute")
50  : std::vector<dof_id_type>(_variable_names.size(), 1)),
51  _energy_threshold(getParam<std::vector<Real>>("energy_threshold")),
52  _left_basis_functions(declareModelData<std::map<VariableName, std::vector<DenseVector<Real>>>>(
53  "left_basis_functions")),
54  _right_basis_functions(declareModelData<std::map<VariableName, std::vector<DenseVector<Real>>>>(
55  "right_basis_functions")),
57  declareModelData<std::map<VariableName, std::vector<Real>>>("singular_values")),
58  _extra_slepc_options(getParam<std::string>("extra_slepc_options")),
59  _parallel_storage(isParamValid("solution_storage")
60  ? &getUserObject<ParallelSolutionStorage>("solution_storage")
61  : nullptr),
63 {
64  if (!isParamValid("filename"))
65  {
66  if (_num_modes.size() != _variable_names.size())
67  paramError("num_modes", "The number of modes should be defined for each variable!");
68 
69  for (const auto & mode : _num_modes)
70  if (!mode)
71  paramError("num_modes", "The number of modes should always be a positive integer!");
72 
73  if (_energy_threshold.size())
74  {
75  if (_energy_threshold.size() != _variable_names.size())
76  paramError("energy_threshold",
77  "The energy thresholds should be defined for each variable!");
78 
79  for (const auto & threshold : _energy_threshold)
80  if (threshold < 0 || threshold >= 1)
81  paramError("energy_threshold",
82  "The energy thresholds should always be in the [0,1) range!");
83  }
84 
85 #if PETSC_VERSION_LESS_THAN(3, 14, 0)
86  mooseError("PODMapping is not supported with PETSc version below 3.14!");
87 #else
88  for (const auto & vname : _variable_names)
89  {
90  _singular_values.emplace(vname, std::vector<Real>());
91  _left_basis_functions.emplace(vname, std::vector<DenseVector<Real>>());
92  _right_basis_functions.emplace(vname, std::vector<DenseVector<Real>>());
93  _mapping_ready_to_use.emplace(vname, false);
94  }
95 #endif
96  }
97 }
VariableMappingBase(const InputParameters &parameters)
std::map< VariableName, bool > & _mapping_ready_to_use
Bool to decide if we already have the mapping built or not to make sure it is not computed multiple t...
const Parallel::Communicator & _communicator
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
bool isParamValid(const std::string &name) const
Class which computes a Proper Orthogonal Decomposition (POD) for snapshots stored in ParallelSolution...
Definition: POD.h:25
std::map< VariableName, std::vector< Real > > & _singular_values
Restartable container holding the singular values.
Definition: PODMapping.h:113
const std::string & _extra_slepc_options
Variable holding additional petsc options for the singular value solve.
Definition: PODMapping.h:116
const T & getParam(const std::string &name) const
void paramError(const std::string &param, Args... args) const
T & declareModelData(const std::string &data_name, Args &&... args)
Declare model data for loading from file as well as restart.
const std::vector< dof_id_type > _num_modes
The number of modes which need to be computed.
Definition: PODMapping.h:101
const ParallelSolutionStorage *const _parallel_storage
Link to the parallel storage which holds the solution fields that are used for the SVD...
Definition: PODMapping.h:120
std::map< VariableName, std::vector< DenseVector< Real > > > & _right_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:110
void mooseError(Args &&... args) const
const InputParameters & parameters() const
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.
const StochasticTools::POD _pod
The POD object which can be used to compute the basis functions/vectors.
Definition: PODMapping.h:123
const std::vector< Real > & _energy_threshold
The energy thresholds for truncation of the number of modes, defined by the user. ...
Definition: PODMapping.h:104
UserObjectInterface(const MooseObject *moose_object)

Member Function Documentation

◆ buildMapping()

void PODMapping::buildMapping ( const VariableName &  vname)
overridevirtual

Abstract function for building mapping for a given variable.

Parameters
vnameThe name of the variable

Implements VariableMappingBase.

Definition at line 100 of file PODMapping.C.

Referenced by SingularTripletReporter::execute().

105 {
106 #if !PETSC_VERSION_LESS_THAN(3, 14, 0)
107  if (!_parallel_storage)
108  paramError(
109  "solution_storage",
110  "The parallel storage reporter is not supplied! We cannot build a mapping without data!");
111 
112  if (_mapping_ready_to_use.find(vname) != _mapping_ready_to_use.end() &&
113  !_mapping_ready_to_use[vname])
114  {
115  auto it = std::find(_variable_names.begin(), _variable_names.end(), vname);
116  mooseAssert(it != _variable_names.end(), "Variable " + vname + " is not in PODMapping!");
117  unsigned int var_i = std::distance(_variable_names.begin(), it);
118  // Clear storage containers for the basis functions and singular values.
119  _left_basis_functions[vname].clear();
120  _right_basis_functions[vname].clear();
121  _singular_values[vname].clear();
122  // Find the number of modes that we would want to compute
123  std::size_t num_modes_compute = (std::size_t)_num_modes[var_i];
124  // Find the first element that satisfies the threshold
125  const Real threshold = (_energy_threshold.empty() ? 0.0 : _energy_threshold[var_i]) +
126  std::numeric_limits<Real>::epsilon();
127  // Use POD class to compute for a variable
128  _pod.computePOD(vname,
129  _left_basis_functions[vname],
130  _right_basis_functions[vname],
131  _singular_values[vname],
132  num_modes_compute,
133  threshold);
134  _mapping_ready_to_use[vname] = true;
135  }
136 
137 #endif
138 }
std::map< VariableName, bool > & _mapping_ready_to_use
Bool to decide if we already have the mapping built or not to make sure it is not computed multiple t...
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
void computePOD(const VariableName &vname, std::vector< DenseVector< Real >> &left_basis_functions, std::vector< DenseVector< Real >> &right_basis_functions, std::vector< Real > &singular_values, const dof_id_type num_modes, const Real energy) const
Definition: POD.C:40
std::map< VariableName, std::vector< Real > > & _singular_values
Restartable container holding the singular values.
Definition: PODMapping.h:113
void paramError(const std::string &param, Args... args) const
const std::vector< dof_id_type > _num_modes
The number of modes which need to be computed.
Definition: PODMapping.h:101
const ParallelSolutionStorage *const _parallel_storage
Link to the parallel storage which holds the solution fields that are used for the SVD...
Definition: PODMapping.h:120
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::map< VariableName, std::vector< DenseVector< Real > > > & _right_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:110
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.
const StochasticTools::POD _pod
The POD object which can be used to compute the basis functions/vectors.
Definition: PODMapping.h:123
const std::vector< Real > & _energy_threshold
The energy thresholds for truncation of the number of modes, defined by the user. ...
Definition: PODMapping.h:104

◆ checkIfReadyToUse()

void VariableMappingBase::checkIfReadyToUse ( const VariableName &  libmesh_dbg_varvname) const
protectedinherited

Check if we have a mapping for the variable and if it is ready to be used.

Definition at line 37 of file VariableMappingBase.C.

Referenced by inverse_map(), leftBasis(), leftBasisFunction(), map(), rightBasis(), rightBasisFunction(), and singularValues().

38 {
39  mooseAssert(_mapping_ready_to_use.find(vname) != _mapping_ready_to_use.end() &&
40  _mapping_ready_to_use[vname],
41  "The mapping for variable " + vname + "is not ready to use!");
42 }
std::map< VariableName, bool > & _mapping_ready_to_use
Bool to decide if we already have the mapping built or not to make sure it is not computed multiple t...

◆ declareModelData()

template<typename T , typename... Args>
T & RestartableModelInterface::declareModelData ( const std::string &  data_name,
Args &&...  args 
)
inherited

Declare model data for loading from file as well as restart.

Definition at line 78 of file RestartableModelInterface.h.

79 {
80  return _model_restartable.declareRestartableData<T>(data_name, std::forward<Args>(args)...);
81 }
T & declareRestartableData(const std::string &data_name, Args &&... args)
Declare a piece of data as "restartable" and initialize it.
PublicRestartable _model_restartable
Member for interfacing with the framework&#39;s restartable system.

◆ getModelData()

template<typename T , typename... Args>
const T & RestartableModelInterface::getModelData ( const std::string &  data_name,
Args &&...  args 
) const
inherited

Retrieve model data from the interface.

Definition at line 85 of file RestartableModelInterface.h.

86 {
87  return _model_restartable.getRestartableData<T>(data_name, std::forward<Args>(args)...);
88 }
const T & getRestartableData(const std::string &data_name) const
Declare a piece of data as "restartable" and initialize it Similar to declareRestartableData but retu...
PublicRestartable _model_restartable
Member for interfacing with the framework&#39;s restartable system.

◆ getModelDataFileName()

const FileName & RestartableModelInterface::getModelDataFileName ( ) const
inherited

Get the associated filename.

Definition at line 33 of file RestartableModelInterface.C.

34 {
35  return _model_object.getParam<FileName>("filename");
36 }
const T & getParam(const std::string &name) const
const MooseObject & _model_object
Reference to the MooseObject that uses this interface.

◆ getVariableNames()

virtual const std::vector<VariableName>& VariableMappingBase::getVariableNames ( )
inlinevirtualinherited

Get the available variable names in this mapping.

Definition at line 71 of file VariableMappingBase.h.

Referenced by SingularTripletReporter::initialSetup(), and InverseMapping::initialSetup().

71 { return _variable_names; }
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.

◆ hasModelData()

bool RestartableModelInterface::hasModelData ( ) const
inherited

Check if we need to load model data (if the filename parameter is used)

Definition at line 39 of file RestartableModelInterface.C.

40 {
41  return _model_object.isParamValid("filename");
42 }
bool isParamValid(const std::string &name) const
const MooseObject & _model_object
Reference to the MooseObject that uses this interface.

◆ inverse_map()

void PODMapping::inverse_map ( const VariableName &  vname,
const std::vector< Real > &  reduced_order_vector,
DenseVector< Real > &  full_order_vector 
) const
overridevirtual

Method used for mapping reduced-order solutions for a given variable onto the full-order space.

Parameters
vnameThe name of the variable
reduced_order_vectorThe coordinates in the latent space
full_order_vectorStorage for the reconstructed solution for the given variable

Implements VariableMappingBase.

Definition at line 181 of file PODMapping.C.

184 {
185  mooseAssert(std::find(_variable_names.begin(), _variable_names.end(), vname) !=
186  _variable_names.end(),
187  "Variable " + vname + " is not in PODMapping!");
188 
189  checkIfReadyToUse(vname);
190 
191  if (reduced_order_vector.size() != _left_basis_functions[vname].size())
192  mooseError("The number of supplied reduced-order coefficients (",
193  reduced_order_vector.size(),
194  ") is not the same as the number of basis functions (",
195  _left_basis_functions[vname].size(),
196  ") for variable ",
197  vname,
198  "!");
199  // This zeros the DenseVector too
200  full_order_vector.resize(_left_basis_functions[vname][0].size());
201 
202  for (auto base_i : index_range(reduced_order_vector))
203  for (unsigned int dof_i = 0; dof_i < _left_basis_functions[vname][base_i].size(); ++dof_i)
204  full_order_vector(dof_i) +=
205  reduced_order_vector[base_i] * _left_basis_functions[vname][base_i](dof_i);
206 }
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
void mooseError(Args &&... args) const
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.
auto index_range(const T &sizable)

◆ leftBasis()

const std::vector< DenseVector< Real > > & PODMapping::leftBasis ( const VariableName &  vname)

Return all of the left basis functions for a given variable.

Parameters
vnameThe name of the variable.

Definition at line 241 of file PODMapping.C.

Referenced by SingularTripletReporter::execute().

242 {
243  checkIfReadyToUse(vname);
244  if (_left_basis_functions.find(vname) == _left_basis_functions.end())
245  mooseError("We are trying to access container for variable '",
246  vname,
247  "' but we don't have it in the POD mapping!");
248  return _left_basis_functions[vname];
249 }
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
void mooseError(Args &&... args) const

◆ leftBasisFunction()

const DenseVector< Real > & PODMapping::leftBasisFunction ( const VariableName &  vname,
const unsigned int  base_i 
)

Get the base_i-th left basis function for a given variable.

Parameters
vnameThe name of the variable
base_iThe index of the basis function

Definition at line 209 of file PODMapping.C.

210 {
211  mooseAssert(std::find(_variable_names.begin(), _variable_names.end(), vname) !=
212  _variable_names.end(),
213  "Variable " + vname + " is not in PODMapping!");
214 
215  checkIfReadyToUse(vname);
216 
217  mooseAssert(base_i < _left_basis_functions[vname].size(),
218  "The POD for " + vname + " only has " +
219  std::to_string(_left_basis_functions[vname].size()) + " left modes!");
220 
221  return _left_basis_functions[vname][base_i];
222 }
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.

◆ map() [1/2]

void PODMapping::map ( const VariableName &  vname,
const DenseVector< Real > &  full_order_vector,
std::vector< Real > &  reduced_order_vector 
) const
overridevirtual

Method used for mapping full-order solutions for a given variable onto a latent space.

Parameters
vnameThe name of the variable
full_order_vectorSerialized vector of the solution field for the given variable
reduced_order_vectorStorage space for the coordinates in the latent space

Implements VariableMappingBase.

Definition at line 163 of file PODMapping.C.

166 {
167  checkIfReadyToUse(vname);
168 
169  mooseAssert(_left_basis_functions.find(vname) != _left_basis_functions.end(),
170  "The bases for the requested variable are not available!");
171 
172  const auto & bases = _left_basis_functions[vname];
173 
174  reduced_order_vector.clear();
175  reduced_order_vector.resize(bases.size());
176  for (auto base_i : index_range(bases))
177  reduced_order_vector[base_i] = bases[base_i].dot(full_order_vector);
178 }
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
auto index_range(const T &sizable)

◆ map() [2/2]

void PODMapping::map ( const VariableName &  vname,
const unsigned int  global_sample_i,
std::vector< Real > &  reduced_order_vector 
) const
overridevirtual

Method used for mapping full-order solutions for a given variable onto a latent space.

Parameters
vnameThe name of the variable
global_sample_iThe global index of the sample whose solution should be mapped into the latent space
reduced_order_vectorStorage space for the coordinates in the latent space

Implements VariableMappingBase.

Definition at line 141 of file PODMapping.C.

144 {
145  mooseAssert(_parallel_storage, "We need the parallel solution storage for this operation.");
146  mooseAssert(_left_basis_functions.find(vname) != _left_basis_functions.end(),
147  "The bases for the requested variable are not available!");
148  checkIfReadyToUse(vname);
149 
150  // This takes the 0th snapshot because we only support steady-state simulations
151  // at the moment.
152  const auto & snapshot = _parallel_storage->getGlobalSample(global_sample_i, vname)[0];
153 
154  const auto & bases = _left_basis_functions[vname];
155 
156  reduced_order_vector.clear();
157  reduced_order_vector.resize(bases.size());
158  for (auto base_i : index_range(bases))
159  reduced_order_vector[base_i] = bases[base_i].dot(snapshot);
160 }
std::map< VariableName, std::vector< DenseVector< Real > > > & _left_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:107
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
const ParallelSolutionStorage *const _parallel_storage
Link to the parallel storage which holds the solution fields that are used for the SVD...
Definition: PODMapping.h:120
const std::vector< DenseVector< Real > > & getGlobalSample(unsigned int global_sample_i, const VariableName &variable) const
Get the serialized solution field which is associated with a given global sample index and variable...
auto index_range(const T &sizable)

◆ modelMetaDataName()

const std::string& RestartableModelInterface::modelMetaDataName ( ) const
inlineinherited

Accessor for the name of the model meta data.

Definition at line 47 of file RestartableModelInterface.h.

Referenced by SurrogateTrainerOutput::output(), and MappingOutput::output().

47 { return _model_meta_data_name; }
const std::string _model_meta_data_name
The model meta data name.

◆ rightBasis()

const std::vector< DenseVector< Real > > & PODMapping::rightBasis ( const VariableName &  vname)

Return all of the right basis functions for a given variable.

Parameters
vnameThe name of the variable.

Definition at line 252 of file PODMapping.C.

Referenced by SingularTripletReporter::execute().

253 {
254  checkIfReadyToUse(vname);
255  if (_right_basis_functions.find(vname) == _right_basis_functions.end())
256  mooseError("We are trying to access container for variable '",
257  vname,
258  "' but we don't have it in the POD mapping!");
259  return _right_basis_functions[vname];
260 }
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
std::map< VariableName, std::vector< DenseVector< Real > > > & _right_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:110
void mooseError(Args &&... args) const

◆ rightBasisFunction()

const DenseVector< Real > & PODMapping::rightBasisFunction ( const VariableName &  vname,
const unsigned int  base_i 
)

Get the base_i-th right basis function for a given variable.

Parameters
vnameThe name of the variable
base_iThe index of the basis function

Definition at line 225 of file PODMapping.C.

226 {
227  mooseAssert(std::find(_variable_names.begin(), _variable_names.end(), vname) !=
228  _variable_names.end(),
229  "Variable " + vname + " is not in PODMapping!");
230 
231  checkIfReadyToUse(vname);
232 
233  mooseAssert(base_i < _right_basis_functions[vname].size(),
234  "The POD for " + vname + " only has " +
235  std::to_string(_right_basis_functions[vname].size()) + " right modes!");
236 
237  return _right_basis_functions[vname][base_i];
238 }
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
std::map< VariableName, std::vector< DenseVector< Real > > > & _right_basis_functions
Restartable container holding the basis functions for each variable.
Definition: PODMapping.h:110
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.

◆ singularValues()

const std::vector< Real > & PODMapping::singularValues ( const VariableName &  vname)

Return all of the singular values for a given variable.

Parameters
vnameThe name of the variable.

Definition at line 263 of file PODMapping.C.

Referenced by SingularTripletReporter::execute().

264 {
265  checkIfReadyToUse(vname);
266  if (_singular_values.find(vname) == _singular_values.end())
267  mooseError("We are trying to access container for variable '",
268  vname,
269  "' but we don't have it in the POD mapping!");
270  return _singular_values[vname];
271 }
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
std::map< VariableName, std::vector< Real > > & _singular_values
Restartable container holding the singular values.
Definition: PODMapping.h:113
void mooseError(Args &&... args) const

◆ validParams()

InputParameters PODMapping::validParams ( )
static

Definition at line 18 of file PODMapping.C.

19 {
21  params.addClassDescription("Class which provides a Proper Orthogonal Decomposition-based mapping "
22  "between full-order and reduced-order spaces.");
23  params.addParam<UserObjectName>(
24  "solution_storage", "The name of the storage reporter where the snapshots are located.");
25  params.addParam<std::vector<dof_id_type>>(
26  "num_modes_to_compute",
27  "The number of modes that this object should compute. "
28  "Modes with 0 eigenvalues are filtered out, so the real number of modes "
29  "might be lower than this. This is also used for setting the "
30  "subspace sizes for distributed singular value solves. By default, the subspace used for the "
31  "SVD is twice as big as the number of requested vectors. For more information see the SLEPc "
32  "manual. If not specified, only one mode is computed per variable.");
33  params.addParam<std::vector<Real>>(
34  "energy_threshold",
35  std::vector<Real>(),
36  "The energy threshold for the automatic truncation of the number of modes. In general, the "
37  "lower this number is the more information is retained about the system by keeping more POD "
38  "modes.");
39  params.addParam<std::string>("extra_slepc_options",
40  "",
41  "Additional options for the singular/eigenvalue solvers in SLEPc.");
42  return params;
43 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

Member Data Documentation

◆ _energy_threshold

const std::vector<Real>& PODMapping::_energy_threshold
protected

The energy thresholds for truncation of the number of modes, defined by the user.

Definition at line 104 of file PODMapping.h.

Referenced by buildMapping(), and PODMapping().

◆ _extra_slepc_options

const std::string& PODMapping::_extra_slepc_options
protected

Variable holding additional petsc options for the singular value solve.

Definition at line 116 of file PODMapping.h.

◆ _left_basis_functions

std::map<VariableName, std::vector<DenseVector<Real> > >& PODMapping::_left_basis_functions
protected

Restartable container holding the basis functions for each variable.

Definition at line 107 of file PODMapping.h.

Referenced by buildMapping(), inverse_map(), leftBasis(), leftBasisFunction(), map(), and PODMapping().

◆ _mapping_ready_to_use

std::map<VariableName, bool>& VariableMappingBase::_mapping_ready_to_use
protectedinherited

Bool to decide if we already have the mapping built or not to make sure it is not computed multiple times unless the user requests it.

Definition at line 82 of file VariableMappingBase.h.

Referenced by buildMapping(), VariableMappingBase::checkIfReadyToUse(), and PODMapping().

◆ _num_modes

const std::vector<dof_id_type> PODMapping::_num_modes
protected

The number of modes which need to be computed.

Definition at line 101 of file PODMapping.h.

Referenced by buildMapping(), and PODMapping().

◆ _parallel_storage

const ParallelSolutionStorage* const PODMapping::_parallel_storage
private

Link to the parallel storage which holds the solution fields that are used for the SVD.

Definition at line 120 of file PODMapping.h.

Referenced by buildMapping(), and map().

◆ _pod

const StochasticTools::POD PODMapping::_pod
private

The POD object which can be used to compute the basis functions/vectors.

Definition at line 123 of file PODMapping.h.

Referenced by buildMapping().

◆ _right_basis_functions

std::map<VariableName, std::vector<DenseVector<Real> > >& PODMapping::_right_basis_functions
protected

Restartable container holding the basis functions for each variable.

Definition at line 110 of file PODMapping.h.

Referenced by buildMapping(), PODMapping(), rightBasis(), and rightBasisFunction().

◆ _singular_values

std::map<VariableName, std::vector<Real> >& PODMapping::_singular_values
protected

Restartable container holding the singular values.

Definition at line 113 of file PODMapping.h.

Referenced by buildMapping(), PODMapping(), and singularValues().

◆ _variable_names

const std::vector<VariableName>& VariableMappingBase::_variable_names
protectedinherited

Storage for the names of the variables this mapping can handle.

Definition at line 78 of file VariableMappingBase.h.

Referenced by buildMapping(), VariableMappingBase::getVariableNames(), inverse_map(), leftBasisFunction(), PODMapping(), and rightBasisFunction().


The documentation for this class was generated from the following files: