https://mooseframework.inl.gov
MFEMExecutedObject.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 #ifdef MOOSE_MFEM_ENABLED
11 
12 #include "MFEMExecutedObject.h"
13 
16 {
18  params += SetupInterface::validParams();
19  params.registerSystemAttributeName("MFEMExecutedObject");
20  params.addPrivateParam<std::vector<std::string>>("_mfem_dependency_param_names", {});
21  params.set<ExecFlagEnum>("execute_on", true) = EXEC_TIMESTEP_END;
22  params.addClassDescription("Base class for executed MFEM objects.");
23  return params;
24 }
25 
28 {
29 }
30 
31 std::optional<std::string>
33 {
34  return std::nullopt;
35 }
36 
37 std::optional<std::string>
39 {
40  return std::nullopt;
41 }
42 
43 std::optional<std::string>
45 {
46  return std::nullopt;
47 }
48 
49 const std::set<std::string> &
51 {
52  if (_requested_items)
53  return *_requested_items;
54 
55  _requested_items.emplace();
56 
57  for (const auto & param : getParam<std::vector<std::string>>("_mfem_dependency_param_names"))
58  {
59  if (const auto * name = queryParam<VariableName>(param))
61  if (const auto * names = queryParam<std::vector<VariableName>>(param))
62  for (const auto & name : *names)
64  if (const auto * name = queryParam<PostprocessorName>(param))
66  if (const auto * names = queryParam<std::vector<PostprocessorName>>(param))
67  for (const auto & name : *names)
69  if (const auto * name = queryParam<VectorPostprocessorName>(param))
71  if (const auto * names = queryParam<std::vector<VectorPostprocessorName>>(param))
72  for (const auto & name : *names)
74  }
75 
76  return *_requested_items;
77 }
78 
79 const std::set<std::string> &
81 {
82  if (_supplied_items)
83  return *_supplied_items;
84 
85  _supplied_items.emplace();
86 
87  if (const auto name = suppliedVariableName())
89  if (const auto name = suppliedPostprocessorName())
91  if (const auto name = suppliedVectorPostprocessorName())
93 
94  return *_supplied_items;
95 }
96 
97 std::string
99 {
100  return "variable:" + name;
101 }
102 
103 std::string
105 {
106  return "postprocessor:" + name;
107 }
108 
109 std::string
111 {
112  return "vector_postprocessor:" + name;
113 }
114 
115 void
116 MFEMExecutedObject::appendDependencyParam(InputParameters & params, const std::string & param_name)
117 {
118  auto & param_names = params.set<std::vector<std::string>>("_mfem_dependency_param_names");
119  param_names.push_back(param_name);
120 }
121 
122 #endif
virtual std::optional< std::string > suppliedPostprocessorName() const
Return the postprocessor name supplied by this object, or std::nullopt if none.
Thin base for MFEM objects backed directly by MooseObject instead of UserObject.
Definition: MFEMObject.h:25
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:416
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
static std::string vectorPostprocessorDependencyKey(const std::string &name)
Build the dependency key used for a supplied/requested vector postprocessor.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
static void appendDependencyParam(InputParameters &params, const std::string &param_name)
Record one dependency-bearing parameter in the private parameter metadata.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
static std::string variableDependencyKey(const std::string &name)
Build the dependency key used for a supplied/requested variable.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::optional< std::set< std::string > > _requested_items
Lazily constructed requested dependency keys for this object&#39;s registered dependencies.
static std::string postprocessorDependencyKey(const std::string &name)
Build the dependency key used for a supplied/requested postprocessor.
static InputParameters validParams()
Declare the common parameters used by MFEM executed objects.
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:36
std::optional< std::set< std::string > > _supplied_items
Lazily constructed supplied dependency keys for this object&#39;s supplied resources. ...
virtual std::optional< std::string > suppliedVectorPostprocessorName() const
Return the vector postprocessor name supplied by this object, or std::nullopt if none.
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
virtual std::optional< std::string > suppliedVariableName() const
Return the variable name supplied by this object, or std::nullopt if none.
MFEMExecutedObject(const InputParameters &parameters)
Construct an executed MFEM object and materialize its dependency metadata.
static InputParameters validParams()
const T * queryParam(const std::string &name) const
Query a parameter for the object.
Definition: MooseBase.h:423
static InputParameters validParams()
Declare the common parameters required by MFEM MooseObject-backed classes.
Definition: MFEMObject.C:17
Interface for sorting dependent vectors of objects.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.