www.mooseframework.org
MeshMetaDataInterface.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #pragma once
11 
12 #include "MooseObject.h"
13 #include "MooseError.h"
14 #include "InputParameters.h"
15 #include "RestartableData.h"
16 
17 #include <string>
18 
19 class MooseApp;
20 class MeshGenerator;
21 
29 {
30 public:
32  static constexpr auto FILE_SUFFIX = "_mesh";
33 
35  static constexpr auto SYSTEM = "MeshMetaData";
36 
38  static constexpr auto NAME = "<empty>";
39 
40 protected:
46  MeshMetaDataInterface(const MooseObject * moose_object);
47 
52  MeshMetaDataInterface(MooseApp & moose_app);
53 
58  template <typename T>
59  const T & getMeshProperty(const std::string & data_name, const std::string & prefix);
60 
61 private:
63  RestartableDataValue & registerMetaDataOnApp(const std::string & name,
64  std::unique_ptr<RestartableDataValue> data);
65 
68 };
69 
70 template <typename T>
71 const T &
72 MeshMetaDataInterface::getMeshProperty(const std::string & data_name, const std::string & prefix)
73 
74 {
75  std::string full_name = std::string(SYSTEM) + "/" + prefix + "/" + data_name;
76  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, nullptr);
77 
78  // Here we will create the RestartableData even though we may not use this instance.
79  // If it's already in use, the App will return a reference to the existing instance and we'll
80  // return that one instead. We might refactor this to have the app create the RestartableData
81  // at a later date.
82  auto & restartable_data_ref =
83  static_cast<RestartableData<T> &>(registerMetaDataOnApp(full_name, std::move(data_ptr)));
84 
85  return restartable_data_ref.get();
86 }
MeshGenerator
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:32
RestartableData.h
MeshMetaDataInterface::_meta_data_app
MooseApp & _meta_data_app
Reference to the application.
Definition: MeshMetaDataInterface.h:67
MeshMetaDataInterface::registerMetaDataOnApp
RestartableDataValue & registerMetaDataOnApp(const std::string &name, std::unique_ptr< RestartableDataValue > data)
Helper function for actually registering the restartable data.
Definition: MeshMetaDataInterface.C:23
MeshMetaDataInterface::MeshMetaDataInterface
MeshMetaDataInterface(const MooseObject *moose_object)
Interface for all objects reading MeshMetaData.
Definition: MeshMetaDataInterface.C:15
MooseObject
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:50
MeshMetaDataInterface::FILE_SUFFIX
static constexpr auto FILE_SUFFIX
The suffix appended when writing the restartable data file.
Definition: MeshMetaDataInterface.h:32
RestartableDataValue
Abstract definition of a RestartableData value.
Definition: RestartableData.h:26
MeshMetaDataInterface::SYSTEM
static constexpr auto SYSTEM
The system name used when initializing the Restartable interface.
Definition: MeshMetaDataInterface.h:35
MeshMetaDataInterface::getMeshProperty
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.
Definition: MeshMetaDataInterface.h:72
InputParameters.h
MooseObject.h
MooseError.h
MooseApp
Base class for MOOSE-based applications.
Definition: MooseApp.h:61
RestartableData
Concrete definition of a parameter value for a specified type.
Definition: RestartableData.h:76
MeshMetaDataInterface::NAME
static constexpr auto NAME
The data name used when initializing the Restartable interface for non-MeshGenerator objects.
Definition: MeshMetaDataInterface.h:38
RestartableData::get
T & get()
Definition: RestartableData.h:92
MeshMetaDataInterface
The Interface used to retrieve mesh meta data (attributes) set by the MeshGenerator system.
Definition: MeshMetaDataInterface.h:28