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