OGS
CreateConstitutiveRelation.cpp
Go to the documentation of this file.
1 
13 
14 #include "CreateCreepBGRa.h"
15 #include "CreateEhlers.h"
18 #include "CreateLubby2.h"
19 #ifdef OGS_USE_MFRONT
20 #include "MFront/CreateMFront.h"
21 #endif // OGS_USE_MFRONT
22 
23 #include "BaseLib/ConfigTree.h"
24 #include "BaseLib/Error.h"
25 #include "MechanicsBase.h"
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  std::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 #ifdef OGS_USE_MFRONT
75  return MaterialLib::Solids::MFront::createMFront<DisplacementDim>(
76  parameters, local_coordinate_system, config);
77 #else // OGS_USE_MFRONT
78  OGS_FATAL(
79  "OGS is compiled without MFront support. See OGS_USE_MFRONT CMake "
80  "option.");
81 #endif // OGS_USE_MFRONT
82  }
83  OGS_FATAL("Cannot construct constitutive relation of given type '{:s}'.",
84  type);
85 }
86 
87 template <int DisplacementDim>
88 std::map<int,
89  std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>>>
91  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
92  std::optional<ParameterLib::CoordinateSystem> const&
93  local_coordinate_system,
94  BaseLib::ConfigTree const& config)
95 {
96  auto const constitutive_relation_configs =
98  config.getConfigSubtreeList("constitutive_relation");
99 
100  std::map<int, std::unique_ptr<MechanicsBase<DisplacementDim>>>
101  constitutive_relations;
102 
103  for (auto const& constitutive_relation_config :
104  constitutive_relation_configs)
105  {
106  int const material_id =
108  constitutive_relation_config.getConfigAttribute<int>("id", 0);
109 
110  if (constitutive_relations.find(material_id) !=
111  constitutive_relations.end())
112  {
113  OGS_FATAL(
114  "Multiple constitutive relations were specified for the same "
115  "material id {:d}. Keep in mind, that if no material id is "
116  "specified, it is assumed to be 0 by default.",
117  material_id);
118  }
119 
120  constitutive_relations.emplace(
121  material_id,
122  createConstitutiveRelation<DisplacementDim>(
123  parameters,
124  local_coordinate_system,
125  constitutive_relation_config));
126  }
127 
128  DBUG("Found {:d} constitutive relations.", constitutive_relations.size());
129 
130  return constitutive_relations;
131 }
132 
133 template std::map<int, std::unique_ptr<MaterialLib::Solids::MechanicsBase<2>>>
135  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
136  std::optional<ParameterLib::CoordinateSystem> const&
137  local_coordinate_system,
138  BaseLib::ConfigTree const& config);
139 
140 template std::map<int, std::unique_ptr<MaterialLib::Solids::MechanicsBase<3>>>
142  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
143  std::optional<ParameterLib::CoordinateSystem> const&
144  local_coordinate_system,
145  BaseLib::ConfigTree const& config);
146 } // namespace Solids
147 } // namespace MaterialLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:29
T peekConfigParameter(std::string const &param) const
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
Definition: ConfigTree.cpp:173
std::unique_ptr< LinearElasticIsotropic< DisplacementDim > > createLinearElasticIsotropic(std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config, const bool skip_type_checking)
std::unique_ptr< LinearElasticOrthotropic< DisplacementDim > > createLinearElasticOrthotropic(std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, 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< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, BaseLib::ConfigTree const &config)
std::unique_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > createConstitutiveRelation(std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, BaseLib::ConfigTree const &config)
std::map< int, std::unique_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > > createConstitutiveRelations(std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, BaseLib::ConfigTree const &config)
template std::map< int, std::unique_ptr< MaterialLib::Solids::MechanicsBase< 2 > > > createConstitutiveRelations< 2 >(std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, BaseLib::ConfigTree const &config)