https://mooseframework.inl.gov
MFEMExecutedObject.h
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 #pragma once
13 
14 #include "MFEMObject.h"
15 #include "SetupInterface.h"
17 
18 #include <optional>
19 #include <set>
20 
25  public SetupInterface,
27 {
28 public:
33 
38 
42  virtual void initialize() {}
46  virtual void execute() {}
50  virtual void finalize() {}
51 
55  virtual std::optional<std::string> suppliedVariableName() const;
59  virtual std::optional<std::string> suppliedPostprocessorName() const;
63  virtual std::optional<std::string> suppliedVectorPostprocessorName() const;
64 
65  virtual const std::set<std::string> & getRequestedItems() override;
66  virtual const std::set<std::string> & getSuppliedItems() override;
67 
71  template <typename T>
72  static void addDependencyParam(InputParameters & params,
73  const std::string & param_name,
74  const std::string & doc_string);
75 
79  template <typename T>
80  static void addRequiredDependencyParam(InputParameters & params,
81  const std::string & param_name,
82  const std::string & doc_string);
83 
84 protected:
88  static std::string variableDependencyKey(const std::string & name);
92  static std::string postprocessorDependencyKey(const std::string & name);
96  static std::string vectorPostprocessorDependencyKey(const std::string & name);
97 
101  static void appendDependencyParam(InputParameters & params, const std::string & param_name);
102 
103 private:
105  std::optional<std::set<std::string>> _requested_items;
107  std::optional<std::set<std::string>> _supplied_items;
108 };
109 
110 template <typename T>
111 void
113  const std::string & param_name,
114  const std::string & doc_string)
115 {
116  params.addParam<T>(param_name, doc_string);
117  appendDependencyParam(params, param_name);
118 }
119 
120 template <typename T>
121 void
123  const std::string & param_name,
124  const std::string & doc_string)
125 {
126  params.addRequiredParam<T>(param_name, doc_string);
127  appendDependencyParam(params, param_name);
128 }
129 
130 #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
static void addRequiredDependencyParam(InputParameters &params, const std::string &param_name, const std::string &doc_string)
Add a required dependency-bearing parameter and register it with the MFEM scheduler.
Base class for MFEM objects that participate in execution ordering but are not UserObjects.
static std::string vectorPostprocessorDependencyKey(const std::string &name)
Build the dependency key used for a supplied/requested vector postprocessor.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
static void appendDependencyParam(InputParameters &params, const std::string &param_name)
Record one dependency-bearing parameter in the private parameter metadata.
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...
virtual void execute()
Perform the main work for this object.
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.
std::optional< std::set< std::string > > _supplied_items
Lazily constructed supplied dependency keys for this object&#39;s supplied resources. ...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual void initialize()
Perform any pre-execution setup for this object.
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.
virtual void finalize()
Perform any post-execution finalization for this object.
static void addDependencyParam(InputParameters &params, const std::string &param_name, const std::string &doc_string)
Add an optional dependency-bearing parameter and register it with the MFEM scheduler.
Interface for sorting dependent vectors of objects.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
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.