27#include "neml2/base/OptionSet.h"
28#include "neml2/base/Factory.h"
32#include "neml2/base/Registry.h"
84 const std::string &
name()
const {
return _input_options.name(); }
86 std::string
type()
const {
return _input_options.type(); }
88 const std::string &
path()
const {
return _input_options.path(); }
90 const std::string &
doc()
const {
return _input_options.doc(); }
99 template <
typename T = NEML2Object>
100 const T *
host()
const;
103 template <
typename T = NEML2Object>
107 template <
typename T>
113 std::shared_ptr<T>
get_object(
const std::string & section,
const std::string &
name);
115 template <
class T = EquationSystem>
116 std::shared_ptr<T>
get_es(
const std::string &
name);
118 template <
class T = Solver>
121 template <
class T = Data>
124 template <
class T = Model>
127 template <
class T = Driver>
130 template <
class T = WorkScheduler>
184 const std::shared_ptr<Settings> _settings;
194 auto host_ptr =
dynamic_cast<const T *
>(_host ? _host :
this);
196 throw NEMLException(
"Internal error: Failed to retrieve host of object " +
name());
204 auto host_ptr =
dynamic_cast<T *
>(_host ? _host :
this);
206 throw NEMLException(
"Internal error: Failed to retrieve host of object " +
name());
214 auto obj_name = _input_options.contains(
name) ? _input_options.get<std::string>(
name) :
name;
217 throw NEMLException(
"Internal error: factory is nullptr for object " + this->
name());
219 if (!_factory->has_object(section, obj_name))
221 if (_input_options.contains(
name))
223 path() +
" failed to get an object via option '" +
name +
"' under section " + section +
224 ". Currently, " +
path() +
"/" +
name +
" = '" + obj_name +
225 "'. Check to make sure the object name is specified correctly in the input file.");
228 "' under section " + section +
".");
233 return _factory->get_object<T>(section, obj_name, extra_opts,
false);
The Driver drives the execution of a NEML2 Model.
Definition Driver.h:44
Base class for manufacturable objects under the EquationSystems section.
Definition EquationSystem.h:33
The base class for all constitutive models.
Definition Model.h:82
NEML2Object(const NEML2Object &)=delete
std::shared_ptr< T > get_driver(const std::string &name)
Get a driver from the factory.
Definition NEML2Object.h:266
VariableName residual_name(const VariableName &var) const
Helper method to wrap a variable name into its residual form.
const T & resolve_tensor(const std::string &name)
Resolve a TensorName to a Tensor.
const std::string & name() const
A readonly reference to the object's name.
Definition NEML2Object.h:84
const T * host() const
Get a readonly pointer to the host.
Definition NEML2Object.h:192
std::shared_ptr< T > get_data(const std::string &name)
Get a data from the factory.
Definition NEML2Object.h:252
Factory * factory() const
Get the factory that created this object.
Definition NEML2Object.h:93
virtual void setup()
Setup this object.
Definition NEML2Object.h:81
const OptionSet & input_options() const
Definition NEML2Object.h:70
std::shared_ptr< T > get_es(const std::string &name)
Get an equation system from the factory.
Definition NEML2Object.h:238
std::shared_ptr< T > get_object(const std::string §ion, const std::string &name)
Definition NEML2Object.h:212
NEML2Object(NEML2Object &&)=delete
NEML2Object & operator=(const NEML2Object &)=delete
const std::string & doc() const
A readonly reference to the object's docstring.
Definition NEML2Object.h:90
NEML2Object & operator=(NEML2Object &&)=delete
std::string type() const
The object's type.
Definition NEML2Object.h:86
std::shared_ptr< T > get_model(const std::string &name)
Get a model from the factory.
Definition NEML2Object.h:259
std::shared_ptr< T > get_scheduler(const std::string &name)
Get a scheduler from the factory.
Definition NEML2Object.h:273
VariableName history_name(const VariableName &var, std::size_t nstep) const
Helper method to wrap a variable name into its history form.
const std::string & path() const
A readonly reference to the object's path.
Definition NEML2Object.h:88
const Settings & settings() const
Settings.
Definition NEML2Object.h:96
NEML2Object(const OptionSet &options)
Construct a new NEML2Object object.
VariableName rate_name(const VariableName &var) const
Helper method to wrap a variable name into its rate form.
static OptionSet expected_options()
virtual ~NEML2Object()=default
std::shared_ptr< T > get_solver(const std::string &name)
Get a solver from the factory.
Definition NEML2Object.h:245
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:54
void add_private(const std::string &name, const T &default_value)
Create a private option with its default value.
Definition OptionSet.h:488
The solver solves a system of equations.
Definition Solver.h:37
Scheduler for work dispatching.
Definition WorkScheduler.h:48
Definition DiagnosticsInterface.h:31
std::string VariableName
Definition types.h:75