OGS
CreateConstitutiveRelationsGeneric.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "BaseLib/ConfigTree.h"
17
18namespace MaterialLib::Solids
19{
20template <typename SolidConstitutiveRelation>
21std::map<int, std::shared_ptr<SolidConstitutiveRelation>>
23 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
24 std::optional<ParameterLib::CoordinateSystem> const&
25 local_coordinate_system,
26 MeshLib::PropertyVector<int> const* const material_ids,
27 BaseLib::ConfigTree const& config,
28 std::unique_ptr<SolidConstitutiveRelation> (*create_constitutive_relation)(
29 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&,
30 std::optional<ParameterLib::CoordinateSystem> const&,
31 BaseLib::ConfigTree const&))
32{
33 auto const constitutive_relation_configs =
35 config.getConfigSubtreeList("constitutive_relation");
36
37 std::map<int, std::shared_ptr<SolidConstitutiveRelation>>
38 constitutive_relations;
39
40 for (auto const& constitutive_relation_config :
41 constitutive_relation_configs)
42 {
43 auto create = [&create_constitutive_relation,
44 &parameters,
45 &local_coordinate_system,
46 &constitutive_relation_config](int const /*id*/)
47 {
48 return create_constitutive_relation(parameters,
49 local_coordinate_system,
50 constitutive_relation_config);
51 };
52
53 auto const material_id_string =
55 constitutive_relation_config.getConfigAttribute<std::string>("id",
56 "0");
57
58 auto const material_ids_of_this_constitutive_relation =
59 MaterialLib::parseMaterialIdString(material_id_string,
60 material_ids);
61
62 for (auto const& material_id :
63 material_ids_of_this_constitutive_relation)
64 {
66 material_id,
67 constitutive_relations,
68 material_ids_of_this_constitutive_relation,
69 create);
70 }
71 }
72
73 DBUG("Found {:d} constitutive relations.", constitutive_relations.size());
74
75 return constitutive_relations;
76}
77
78} // namespace MaterialLib::Solids
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
std::map< int, std::shared_ptr< SolidConstitutiveRelation > > createConstitutiveRelationsGeneric(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, MeshLib::PropertyVector< int > const *const material_ids, BaseLib::ConfigTree const &config, std::unique_ptr< SolidConstitutiveRelation >(*create_constitutive_relation)(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &, std::optional< ParameterLib::CoordinateSystem > const &, BaseLib::ConfigTree const &))
void createMediumForId(int const id, std::map< int, std::shared_ptr< T > > &media, std::vector< int > const &material_ids_of_this_medium, CreateMedium &&create_medium)
std::vector< int > parseMaterialIdString(std::string const &material_id_string, MeshLib::PropertyVector< int > const *const material_ids)