https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | List of all members
MeshMetaDataInterface Class Reference

The Interface used to retrieve mesh meta data (attributes) set by the MeshGenerator system. More...

#include <MeshMetaDataInterface.h>

Inheritance diagram for MeshMetaDataInterface:
[legend]

Static Public Attributes

static constexpr auto SYSTEM = "MeshMetaData"
 The system name used when initializing the Restartable interface.
 
static constexpr auto NAME = "<empty>"
 The data name used when initializing the Restartable interface for non-MeshGenerator objects.
 

Protected Member Functions

 MeshMetaDataInterface (const MooseObject *moose_object)
 Interface for all objects reading MeshMetaData.
 
 MeshMetaDataInterface (MooseApp &moose_app)
 This class constructor is used for non-Moose-based objects like interfaces.
 
 MeshMetaDataInterface (const MeshMetaDataInterface &object, const Moose::Kokkos::FunctorCopy &key)
 Special constructor used for Kokkos functor copy during parallel dispatch.
 
template<typename T >
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 Method for retrieving a property with the given type and name exists in the mesh meta-data store.
 
template<typename T >
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
template<typename T >
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
template<typename T >
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Private Member Functions

virtual std::string meshPropertyPrefix (const std::string &data_name) const
 The default prefix to use for getting/seeing if mesh properties exist.
 
const RestartableDataValuegetMeshPropertyInternal (const std::string &data_name, const std::string &prefix) const
 Helper for getting a mesh property.
 
template<typename... Args>
void mooseErrorInternal (Args &&... args) const
 Helper for forwarding a mooseError to an object's mooseError if it is available (said error will provide more context: object name and type)
 

Private Attributes

MooseApp_meta_data_app
 Reference to the application.
 
const MooseObject *const _meta_data_object
 The MooseObject (if any); used for better error handling.
 

Detailed Description

The Interface used to retrieve mesh meta data (attributes) set by the MeshGenerator system.

MOOSE objects should avoid retrieving and casting MeshGenerator objects since they are not re-created during a recover operation. This data is read from files early during the simulation setup an d can be used to make decisions about how to setup the rest of the problem.

Definition at line 26 of file MeshMetaDataInterface.h.

Constructor & Destructor Documentation

◆ MeshMetaDataInterface() [1/3]

MeshMetaDataInterface::MeshMetaDataInterface ( const MooseObject moose_object)
protected

Interface for all objects reading MeshMetaData.

The name of the object gets a bogus prefix, which is not intended to be used for storing data. Instead this value is overridden during retrieval.

Definition at line 14 of file MeshMetaDataInterface.C.

15 : _meta_data_app(moose_object->getMooseApp()), _meta_data_object(moose_object)
16{
17}
MooseApp & _meta_data_app
Reference to the application.
const MooseObject *const _meta_data_object
The MooseObject (if any); used for better error handling.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition MooseBase.h:87

◆ MeshMetaDataInterface() [2/3]

MeshMetaDataInterface::MeshMetaDataInterface ( MooseApp moose_app)
protected

This class constructor is used for non-Moose-based objects like interfaces.

A name for the storage as well as a system name must be passed in along with the thread ID explicitly.

Definition at line 19 of file MeshMetaDataInterface.C.

20 : _meta_data_app(moose_app), _meta_data_object(nullptr)
21{
22}

◆ MeshMetaDataInterface() [3/3]

MeshMetaDataInterface::MeshMetaDataInterface ( const MeshMetaDataInterface object,
const Moose::Kokkos::FunctorCopy key 
)
protected

Special constructor used for Kokkos functor copy during parallel dispatch.

Definition at line 25 of file MeshMetaDataInterface.C.

Member Function Documentation

◆ getMeshProperty() [1/2]

template<typename T >
const T & MeshMetaDataInterface::getMeshProperty ( const std::string &  data_name)
inlineprotected

Definition at line 64 of file MeshMetaDataInterface.h.

65 {
66 return getMeshProperty<T>(data_name, meshPropertyPrefix(data_name));
67 }
virtual std::string meshPropertyPrefix(const std::string &data_name) const
The default prefix to use for getting/seeing if mesh properties exist.

◆ getMeshProperty() [2/2]

template<typename T >
const T & MeshMetaDataInterface::getMeshProperty ( const std::string &  data_name,
const std::string &  prefix 
)
protected

Method for retrieving a property with the given type and name exists in the mesh meta-data store.

This method will throw an error if the property does not exist.

Definition at line 142 of file MeshMetaDataInterface.h.

144{
145 if (!hasMeshProperty(data_name, prefix))
146 mooseErrorInternal("Failed to get mesh property '", prefix, "/", data_name, "'");
147
148 auto value = &getMeshPropertyInternal(data_name, prefix);
149 mooseAssert(value->declared(), "Value has not been declared");
150 const RestartableData<T> * T_value = dynamic_cast<const RestartableData<T> *>(value);
151 if (!T_value)
152 mooseErrorInternal("While retrieving mesh property '",
153 prefix,
154 "/",
155 data_name,
156 "' with type '",
157 MooseUtils::prettyCppType<T>(),
158 "',\nthe property exists with different type '",
159 value->type(),
160 "'");
161 return T_value->get();
162}
bool hasMeshProperty(const std::string &data_name, const std::string &prefix) const
const RestartableDataValue & getMeshPropertyInternal(const std::string &data_name, const std::string &prefix) const
Helper for getting a mesh property.
void mooseErrorInternal(Args &&... args) const
Helper for forwarding a mooseError to an object's mooseError if it is available (said error will prov...
Concrete definition of a parameter value for a specified type.
const T & get() const
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ getMeshPropertyInternal()

const RestartableDataValue & MeshMetaDataInterface::getMeshPropertyInternal ( const std::string &  data_name,
const std::string &  prefix 
) const
private

Helper for getting a mesh property.

Definition at line 54 of file MeshMetaDataInterface.C.

56{
58 meshPropertyName(data_name, prefix), MooseApp::MESH_META_DATA, 0);
59}
static std::string meshPropertyName(const std::string &data_name, const std::string &prefix)
RestartableDataValue & getRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname, THREAD_ID tid)
Definition MooseApp.C:2511
static const RestartableDataMapName MESH_META_DATA
Definition MooseApp.h:136

Referenced by getMeshProperty(), and hasMeshProperty().

◆ hasMeshProperty() [1/4]

bool MeshMetaDataInterface::hasMeshProperty ( const std::string &  data_name) const
inlineprotected
Returns
Whether or not a mesh meta-data exists with the default prefix.

Definition at line 82 of file MeshMetaDataInterface.h.

83 {
84 return hasMeshProperty(data_name, meshPropertyPrefix(data_name));
85 }

◆ hasMeshProperty() [2/4]

template<typename T >
bool MeshMetaDataInterface::hasMeshProperty ( const std::string &  data_name) const
inlineprotected
Returns
Whether or not a mesh meta-data exists with the default prefix and the given type.

Definition at line 90 of file MeshMetaDataInterface.h.

91 {
92 return hasMeshProperty<T>(data_name, meshPropertyPrefix(data_name));
93 }

◆ hasMeshProperty() [3/4]

bool MeshMetaDataInterface::hasMeshProperty ( const std::string &  data_name,
const std::string &  prefix 
) const
protected
Returns
Whether or not a mesh meta-data exists.

Definition at line 33 of file MeshMetaDataInterface.C.

35{
38}
bool hasRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname) const
Definition MooseApp.C:2501

Referenced by MeshGenerator::declareMeshProperty(), getMeshProperty(), hasMeshProperty(), hasMeshProperty(), and MeshGenerator::setMeshProperty().

◆ hasMeshProperty() [4/4]

template<typename T >
bool MeshMetaDataInterface::hasMeshProperty ( const std::string &  data_name,
const std::string &  prefix 
) const
protected
Returns
Whether or not a mesh meta-data exists with the given type.

Definition at line 166 of file MeshMetaDataInterface.h.

168{
169 if (!hasMeshProperty(data_name, prefix))
170 return false;
171 const auto & value = getMeshPropertyInternal(data_name, prefix);
172 return dynamic_cast<const RestartableData<T> *>(&value) != nullptr;
173}

◆ meshPropertyName() [1/2]

std::string MeshMetaDataInterface::meshPropertyName ( const std::string &  data_name) const
inlineprotected
Returns
The default mesh property name for mesh property data

Definition at line 103 of file MeshMetaDataInterface.h.

104 {
105 return meshPropertyName(data_name, meshPropertyPrefix(data_name));
106 }

◆ meshPropertyName() [2/2]

std::string MeshMetaDataInterface::meshPropertyName ( const std::string &  data_name,
const std::string &  prefix 
)
staticprotected
Returns
The full name for mesh property data.

Definition at line 41 of file MeshMetaDataInterface.C.

42{
43 return std::string(SYSTEM) + "/" + prefix + "/" + data_name;
44}
static constexpr auto SYSTEM
The system name used when initializing the Restartable interface.

Referenced by MeshGenerator::declareMeshProperty(), getMeshPropertyInternal(), hasMeshProperty(), meshPropertyName(), and MeshGenerator::setMeshPropertyHelper().

◆ meshPropertyPrefix()

std::string MeshMetaDataInterface::meshPropertyPrefix ( const std::string &  data_name) const
privatevirtual

The default prefix to use for getting/seeing if mesh properties exist.

For now, this is not supported except in MeshGenerators. In the future, we will automate looking for mesh properties.

Reimplemented in MeshGenerator.

Definition at line 47 of file MeshMetaDataInterface.C.

48{
49 mooseError("This object does not support obtaining a mesh property without a prefix.\n\nThis "
50 "capability is upcoming.");
51}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311

Referenced by getMeshProperty(), hasMeshProperty(), and meshPropertyName().

◆ mooseErrorInternal()

template<typename... Args>
void MeshMetaDataInterface::mooseErrorInternal ( Args &&...  args) const
inlineprivate

Helper for forwarding a mooseError to an object's mooseError if it is available (said error will provide more context: object name and type)

Definition at line 132 of file MeshMetaDataInterface.h.

133 {
135 _meta_data_object->mooseError(std::forward<Args>(args)...);
136 mooseError(std::forward<Args>(args)...);
137 }
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271

Referenced by getMeshProperty().

Member Data Documentation

◆ _meta_data_app

MooseApp& MeshMetaDataInterface::_meta_data_app
private

Reference to the application.

Definition at line 122 of file MeshMetaDataInterface.h.

Referenced by getMeshPropertyInternal(), and hasMeshProperty().

◆ _meta_data_object

const MooseObject* const MeshMetaDataInterface::_meta_data_object
private

The MooseObject (if any); used for better error handling.

Definition at line 125 of file MeshMetaDataInterface.h.

Referenced by mooseErrorInternal().

◆ NAME

constexpr auto MeshMetaDataInterface::NAME = "<empty>"
staticconstexpr

The data name used when initializing the Restartable interface for non-MeshGenerator objects.

Definition at line 33 of file MeshMetaDataInterface.h.

◆ SYSTEM

constexpr auto MeshMetaDataInterface::SYSTEM = "MeshMetaData"
staticconstexpr

The system name used when initializing the Restartable interface.

Definition at line 30 of file MeshMetaDataInterface.h.

Referenced by meshPropertyName().


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