OGS
SelectSolidConstitutiveRelation.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <map>
13 
14 #include "MeshLib/PropertyVector.h"
15 
16 #include "MechanicsBase.h"
17 
18 namespace MaterialLib
19 {
20 namespace Solids
21 {
32 template <int DisplacementDim>
34  std::map<int, std::unique_ptr<MechanicsBase<DisplacementDim>>> const&
35  constitutive_relations,
36  MeshLib::PropertyVector<int> const* const material_ids,
37  std::size_t const element_id)
38 {
39  int material_id;
40  if (constitutive_relations.size() == 1 || material_ids == nullptr)
41  {
42  material_id = 0;
43  }
44  else
45  {
46  material_id = (*material_ids)[element_id];
47  }
48 
49  auto const constitutive_relation = constitutive_relations.find(material_id);
50  if (constitutive_relation == end(constitutive_relations))
51  {
52  OGS_FATAL(
53  "No constitutive relation found for material id {:d} and element "
54  "{:d}. There are {:d} constitutive relations available.",
55  material_id, element_id, constitutive_relations.size());
56  }
57 
58  if (constitutive_relation->second == nullptr)
59  {
60  OGS_FATAL(
61  "The constitutive relation found for material id {:d} and element "
62  "{:d} is a nullptr, which is impossible.",
63  material_id, element_id);
64  }
65 
66  return *constitutive_relation->second;
67 }
68 } // namespace Solids
69 } // namespace MaterialLib
#define OGS_FATAL(...)
Definition: Error.h:26
MechanicsBase< DisplacementDim > & selectSolidConstitutiveRelation(std::map< int, std::unique_ptr< MechanicsBase< DisplacementDim >>> const &constitutive_relations, MeshLib::PropertyVector< int > const *const material_ids, std::size_t const element_id)