https://mooseframework.inl.gov
MeshMetaDataInterface.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // MOOSE includes
11 #include "MeshMetaDataInterface.h"
12 #include "MooseApp.h"
13 
15  : _meta_data_app(moose_object->getMooseApp()), _meta_data_object(moose_object)
16 {
17 }
18 
20  : _meta_data_app(moose_app), _meta_data_object(nullptr)
21 {
22 }
23 
24 #ifdef MOOSE_KOKKOS_ENABLED
27  : _meta_data_app(object._meta_data_app), _meta_data_object(object._meta_data_object)
28 {
29 }
30 #endif
31 
32 bool
33 MeshMetaDataInterface::hasMeshProperty(const std::string & data_name,
34  const std::string & prefix) const
35 {
36  return _meta_data_app.hasRestartableMetaData(meshPropertyName(data_name, prefix),
38 }
39 
40 std::string
41 MeshMetaDataInterface::meshPropertyName(const std::string & data_name, const std::string & prefix)
42 {
43  return std::string(SYSTEM) + "/" + prefix + "/" + data_name;
44 }
45 
46 std::string
48 {
49  mooseError("This object does not support obtaining a mesh property without a prefix.\n\nThis "
50  "capability is upcoming.");
51 }
52 
54 MeshMetaDataInterface::getMeshPropertyInternal(const std::string & data_name,
55  const std::string & prefix) const
56 {
58  meshPropertyName(data_name, prefix), MooseApp::MESH_META_DATA, 0);
59 }
bool hasRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname) const
Definition: MooseApp.C:2228
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
static const RestartableDataMapName MESH_META_DATA
Definition: MooseApp.h:135
Base class for MOOSE-based applications.
Definition: MooseApp.h:108
static std::string meshPropertyName(const std::string &data_name, const std::string &prefix)
MeshMetaDataInterface(const MooseObject *moose_object)
Interface for all objects reading MeshMetaData.
MooseApp & _meta_data_app
Reference to the application.
RestartableDataValue & getRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname, THREAD_ID tid)
Definition: MooseApp.C:2238
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
static constexpr auto SYSTEM
The system name used when initializing the Restartable interface.
The Interface used to retrieve mesh meta data (attributes) set by the MeshGenerator system...
virtual std::string meshPropertyPrefix(const std::string &data_name) const
The default prefix to use for getting/seeing if mesh properties exist.
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.
Abstract definition of a RestartableData value.