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 const 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>
146 const std::shared_ptr<Settings> _settings;
156 auto host_ptr =
dynamic_cast<const T *
>(_host ? _host :
this);
158 throw NEMLException(
"Internal error: Failed to retrieve host of object " +
name());
166 auto host_ptr =
dynamic_cast<T *
>(_host ? _host :
this);
168 throw NEMLException(
"Internal error: Failed to retrieve host of object " +
name());
176 auto obj_name = _input_options.contains(
name) ? _input_options.get<std::string>(
name) :
name;
179 throw NEMLException(
"Internal error: factory is nullptr for object " + this->
name());
181 if (!_factory->has_object(section, obj_name))
183 if (_input_options.contains(
name))
185 path() +
" failed to get an object via option '" +
name +
"' under section " + section +
186 ". Currently, " +
path() +
"/" +
name +
" = '" + obj_name +
187 "'. Check to make sure the object name is specified correctly in the input file.");
190 "' under section " + section +
".");
195 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:83
NEML2Object(const NEML2Object &)=delete
std::shared_ptr< T > get_driver(const std::string &name)
Get a driver from the factory.
Definition NEML2Object.h:228
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:154
std::shared_ptr< T > get_data(const std::string &name)
Get a data from the factory.
Definition NEML2Object.h:214
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
const std::string & type() const
A readonly reference to the object's type.
Definition NEML2Object.h:86
std::shared_ptr< T > get_es(const std::string &name)
Get an equation system from the factory.
Definition NEML2Object.h:200
std::shared_ptr< T > get_object(const std::string §ion, const std::string &name)
Definition NEML2Object.h:174
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::shared_ptr< T > get_model(const std::string &name)
Get a model from the factory.
Definition NEML2Object.h:221
std::shared_ptr< T > get_scheduler(const std::string &name)
Get a scheduler from the factory.
Definition NEML2Object.h:235
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.
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:207
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:52
T & set(const std::string &)
Definition OptionSet.h:298
The solver solves a system of equations.
Definition Solver.h:37
Scheduler for work dispatching.
Definition WorkScheduler.h:48
Definition DiagnosticsInterface.h:31