OGS 6.1.0-1721-g6382411ad
CreateConstitutiveRelation.cpp
Go to the documentation of this file.
1 
13 
14 #include "CreateCreepBGRa.h"
15 #include "CreateEhlers.h"
17 #include "CreateLubby2.h"
18 #include "MFront/CreateMFront.h"
19 
20 #include "MechanicsBase.h"
21 
22 #include "BaseLib/ConfigTree.h"
23 #include "BaseLib/Error.h"
24 
26 
27 namespace MaterialLib
28 {
29 namespace Solids
30 {
31 template <int DisplacementDim>
32 std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>>
34  std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters,
35  BaseLib::ConfigTree const& config)
36 {
37  auto const type =
39  config.peekConfigParameter<std::string>("type");
40 
41  if (type == "Ehlers")
42  {
43  return MaterialLib::Solids::Ehlers::createEhlers<DisplacementDim>(
44  parameters, config);
45  }
46  if (type == "LinearElasticIsotropic")
47  {
48  const bool skip_type_checking = false;
50  DisplacementDim>(parameters, config, skip_type_checking);
51  }
52  if (type == "Lubby2")
53  {
54  return MaterialLib::Solids::Lubby2::createLubby2<DisplacementDim>(
55  parameters, config);
56  }
57  if (type == "CreepBGRa")
58  {
59  return MaterialLib::Solids::Creep::createCreepBGRa<DisplacementDim>(
60  parameters, config);
61  }
62  if (type == "MFront")
63  {
64  return MaterialLib::Solids::MFront::createMFront<DisplacementDim>(
65  parameters, config);
66  }
67  OGS_FATAL("Cannot construct constitutive relation of given type '%s'.",
68  type.c_str());
69 }
70 
71 template <int DisplacementDim>
72 std::map<int,
73  std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>>>
75  std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters,
76  BaseLib::ConfigTree const& config)
77 {
78  auto const constitutive_relation_configs =
80  config.getConfigSubtreeList("constitutive_relation");
81 
82  std::map<int, std::unique_ptr<MechanicsBase<DisplacementDim>>>
83  constitutive_relations;
84 
85  for (auto const& constitutive_relation_config :
86  constitutive_relation_configs)
87  {
88  int const material_id =
90  constitutive_relation_config.getConfigAttribute<int>("id", 0);
91 
92  if (constitutive_relations.find(material_id) !=
93  constitutive_relations.end())
94  {
95  OGS_FATAL(
96  "Multiple constitutive relations were specified for the same "
97  "material id %d. Keep in mind, that if no material id is "
98  "specified, it is assumed to be 0 by default.",
99  material_id);
100  }
101 
102  constitutive_relations.emplace(
103  material_id,
104  createConstitutiveRelation<DisplacementDim>(
105  parameters, constitutive_relation_config));
106  }
107 
108  DBUG("Found %d constitutive relations.", constitutive_relations.size());
109 
110  return constitutive_relations;
111 }
112 
113 template std::map<int, std::unique_ptr<MaterialLib::Solids::MechanicsBase<2>>>
115  std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters,
116  BaseLib::ConfigTree const& config);
117 
118 template std::map<int, std::unique_ptr<MaterialLib::Solids::MechanicsBase<3>>>
120  std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters,
121  BaseLib::ConfigTree const& config);
122 }
123 }
std::unique_ptr< LinearElasticIsotropic< DisplacementDim > > createLinearElasticIsotropic(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config, const bool skip_type_checking)
template std::map< int, std::unique_ptr< MaterialLib::Solids::MechanicsBase< 3 > > > createConstitutiveRelations< 3 >(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config)
template std::map< int, std::unique_ptr< MaterialLib::Solids::MechanicsBase< 2 > > > createConstitutiveRelations< 2 >(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config)
T peekConfigParameter(std::string const &param) const
std::unique_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > createConstitutiveRelation(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config)
std::map< int, std::unique_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > > createConstitutiveRelations(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config)
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
Definition: ConfigTree.cpp:170
#define OGS_FATAL(fmt,...)
Definition: Error.h:71