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

This is an abstract base class for objects that provide mapping between a full-order and a latent space. More...

#include <VariableMappingBase.h>

Inheritance diagram for VariableMappingBase:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 VariableMappingBase (const InputParameters &parameters)
 
virtual ~VariableMappingBase ()
 
virtual void buildMapping (const VariableName &vname)=0
 Abstract function for building mapping for a given variable. More...
 
virtual void map (const VariableName &vname, const DenseVector< Real > &full_order_vector, std::vector< Real > &reduced_order_vector) const =0
 Map a full-order solution vector (in DenseVector format) for a given variable into a reduced-order vector (in a standard vector format) More...
 
virtual void map (const VariableName &vname, const unsigned int global_sample_i, std::vector< Real > &reduced_order_vector) const =0
 Map a full-order solution vector with a given global sample number for a given variable into a reduced-order vector (in a standard vector format) More...
 
virtual void inverse_map (const VariableName &vname, const std::vector< Real > &reduced_order_vector, DenseVector< Real > &full_order_vector) const =0
 Map a reduced-order vector (from the latent space) back to a full-order solution vector (in DenseVector format) 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...
 
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...
 

Protected Attributes

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
 

Detailed Description

This is an abstract base class for objects that provide mapping between a full-order and a latent space.

Definition at line 23 of file VariableMappingBase.h.

Constructor & Destructor Documentation

◆ VariableMappingBase()

VariableMappingBase::VariableMappingBase ( const InputParameters parameters)

Definition at line 25 of file VariableMappingBase.C.

27  RestartableModelInterface(*this, /*read_only=*/false, _type + "_" + name()),
28  _variable_names(isParamValid("filename")
29  ? getModelData<std::vector<VariableName>>("variables")
30  : declareModelData<std::vector<VariableName>>(
31  "variables", getParam<std::vector<VariableName>>("variables"))),
32  _mapping_ready_to_use(declareModelData<std::map<VariableName, bool>>("mapping_ready_to_use"))
33 {
34 }
MooseObject(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...
virtual const std::string & name() const
bool isParamValid(const std::string &name) const
const T & getModelData(const std::string &data_name, Args &&... args) const
Retrieve model data from the interface.
const std::string _type
const T & getParam(const std::string &name) const
T & declareModelData(const std::string &data_name, Args &&... args)
Declare model data for loading from file as well as restart.
RestartableModelInterface(const MooseObject &object, const bool read_only, const std::string &meta_data_name)
const InputParameters & parameters() const
const std::vector< VariableName > & _variable_names
Storage for the names of the variables this mapping can handle.

◆ ~VariableMappingBase()

virtual VariableMappingBase::~VariableMappingBase ( )
inlinevirtual

Definition at line 29 of file VariableMappingBase.h.

29 {}

Member Function Documentation

◆ buildMapping()

virtual void VariableMappingBase::buildMapping ( const VariableName &  vname)
pure virtual

Abstract function for building mapping for a given variable.

Parameters
vnameThe name of the variable

Implemented in PODMapping.

Referenced by MappingReporter::mapParallelStorageData().

◆ checkIfReadyToUse()

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

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 PODMapping::inverse_map(), PODMapping::leftBasis(), PODMapping::leftBasisFunction(), PODMapping::map(), PODMapping::rightBasis(), PODMapping::rightBasisFunction(), and PODMapping::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 ( )
inlinevirtual

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()

virtual void VariableMappingBase::inverse_map ( const VariableName &  vname,
const std::vector< Real > &  reduced_order_vector,
DenseVector< Real > &  full_order_vector 
) const
pure virtual

Map a reduced-order vector (from the latent space) back to a full-order solution vector (in DenseVector format) for a given variable.

Parameters
vnameThe name of the variable
reduced_order_vectorThe reduced-order vector
full_order_vectorThe full order vector to fill

Implemented in PODMapping.

Referenced by InverseMapping::execute().

◆ map() [1/2]

virtual void VariableMappingBase::map ( const VariableName &  vname,
const DenseVector< Real > &  full_order_vector,
std::vector< Real > &  reduced_order_vector 
) const
pure virtual

Map a full-order solution vector (in DenseVector format) for a given variable into a reduced-order vector (in a standard vector format)

Parameters
vnameThe name of the variable
full_order_vectorThe full-order vector
reduced_order_vectorThe reduced-order vector to fill

Implemented in PODMapping.

Referenced by MappingReporter::mapParallelStorageData(), and MappingReporter::mapVariableData().

◆ map() [2/2]

virtual void VariableMappingBase::map ( const VariableName &  vname,
const unsigned int  global_sample_i,
std::vector< Real > &  reduced_order_vector 
) const
pure virtual

Map a full-order solution vector with a given global sample number for a given variable into a reduced-order vector (in a standard vector format)

Parameters
vnameThe name of the variable
global_sample_iThe global sample index
reduced_order_vectorThe reduced-order vector to fill

Implemented in PODMapping.

◆ 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.

◆ validParams()

InputParameters VariableMappingBase::validParams ( )
static

Definition at line 13 of file VariableMappingBase.C.

Referenced by PODMapping::validParams().

14 {
17  params.addClassDescription("Base class for mapping objects.");
18  params.registerBase("VariableMappingBase");
19  params.registerSystemAttributeName("VariableMappingBase");
20  params.addParam<std::vector<VariableName>>("variables",
21  "The names of the variables which need a mapping.");
22  return params;
23 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void registerSystemAttributeName(const std::string &value)
void registerBase(const std::string &value)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

Member Data Documentation

◆ _mapping_ready_to_use

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

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 PODMapping::buildMapping(), checkIfReadyToUse(), and PODMapping::PODMapping().

◆ _variable_names

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

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

Definition at line 78 of file VariableMappingBase.h.

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


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