27#include "neml2/misc/errors.h"
28#include "neml2/base/InputFile.h"
60 const std::shared_ptr<Settings> &
settings()
const {
return _input_file.settings(); }
82 std::shared_ptr<T>
get_object(
const std::string & section,
83 const std::string &
name,
85 bool force_create =
true);
88 template <
class T = EquationSystem>
89 std::shared_ptr<T>
get_es(
const std::string &
name);
91 template <
class T = Solver>
94 template <
class T = Data>
97 template <
class T = Model>
100 template <
class T = Driver>
103 template <
class T = WorkScheduler>
114 void print(std::ostream & os = std::cout);
127 bool options_compatible(
const std::shared_ptr<NEML2Object> & obj,
const OptionSet & opts)
const;
136 std::map<std::string, std::map<std::string, std::vector<std::shared_ptr<NEML2Object>>>> _objects;
142 const std::string &
name,
151 if (_objects.count(section) && _objects.at(section).count(
name))
152 for (
const auto & neml2_obj : _objects[section][
name])
155 if (!options_compatible(neml2_obj, additional_options))
159 auto obj = std::dynamic_pointer_cast<T>(neml2_obj);
162 "Found object named " +
name +
" under section " + section +
163 ". But dynamic cast failed. Did you specify the correct object type?");
169 for (
const auto & options : _input_file[section])
170 if (options.first ==
name)
172 auto new_options = options.second;
173 new_options.set_private<
Factory *>(
"_factory",
this);
174 new_options.set_private<std::shared_ptr<Settings>>(
"_settings",
settings());
175 new_options += additional_options;
180 if (!_objects.count(section) || !_objects.at(section).count(
name))
182 ". Check to make sure the object is defined in the input file.");
184 auto obj = std::dynamic_pointer_cast<T>(_objects[section][
name].back());
188 ". But dynamic cast failed. Did you specify the correct object type?");
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
std::shared_ptr< T > get_object(const std::string §ion, const std::string &name, const OptionSet &additional_options=OptionSet(), bool force_create=true)
Retrive an object pointer under the given section with the given object name.
Definition Factory.h:141
std::shared_ptr< T > get_driver(const std::string &name)
Get a driver by its name.
Definition Factory.h:223
std::shared_ptr< T > get_data(const std::string &name)
Get a data by its name.
Definition Factory.h:209
void create_object(const std::string §ion, const OptionSet &options)
Manufacture a single NEML2Object.
std::shared_ptr< T > get_es(const std::string &name)
Get an equation system by its name.
Definition Factory.h:195
const std::shared_ptr< Settings > & settings() const
Global settings.
Definition Factory.h:60
std::shared_ptr< T > get_model(const std::string &name)
Get a model by its name.
Definition Factory.h:216
std::shared_ptr< T > get_scheduler(const std::string &name)
Get a scheduler by its name.
Definition Factory.h:230
bool has_object(const std::string §ion, const std::string &name)
Check if an object with the given name exists under the given section.
InputFile & input_file()
Get the input file.
Definition Factory.h:54
const InputFile & input_file() const
Get the input file.
Definition Factory.h:57
void clear()
Delete all factories and destruct all the objects.
std::shared_ptr< T > get_solver(const std::string &name)
Get a solver by its name.
Definition Factory.h:202
void print(std::ostream &os=std::cout)
List all the manufactured objects.
The base class for all constitutive models.
Definition Model.h:82
The base class of all "manufacturable" objects in the NEML2 library.
Definition NEML2Object.h:52
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:54
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 name(ElasticConstant p)