OGS
MaterialLib Namespace Reference

Detailed Description

Common convenitions for naming: x_D - deviatoric part of tensor x x_V - volumetric part of tensor x x_p - a variable related to plastic potential x_prev - value of x in previous time step

Variables used in the code: eps_D - deviatoric strain eps_p_D_dot - deviatoric increment of plastic strain eps_p_eff_dot - increment of effective plastic strain eps_p_V_dot - volumetric increment of plastic strain sigma_D_inverse_D - deviatoric part of sigma_D_inverse

derivation of the flow rule theta - J3 / J2^(3 / 2) from yield function dtheta_dsigma - derivative of theta sqrtPhi - square root of Phi from plastic potential flow_D - deviatoric part of flow flow_V - volumetric part of flow lambda_flow_D - deviatoric increment of plastic strain

Namespaces

namespace  Fluid
 
namespace  Fracture
 
namespace  PhysicalConstant
 
namespace  PorousMedium
 
namespace  Solids
 

Functions

std::vector< int > splitMaterialIdString (std::string const &material_id_string)
 
std::vector< int > parseMaterialIdString (std::string const &material_id_string, MeshLib::PropertyVector< int > const *const material_ids)
 
template<typename T , typename CreateMedium >
requires std::convertible_to< decltype(std::declval<CreateMedium>()(std::declval<int>())), std::shared_ptr<T>>
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)
 

Function Documentation

◆ createMediumForId()

template<typename T , typename CreateMedium >
requires std::convertible_to< decltype(std::declval<CreateMedium>()(std::declval<int>())), std::shared_ptr<T>>
void MaterialLib::createMediumForId ( int const id,
std::map< int, std::shared_ptr< T > > & media,
std::vector< int > const & material_ids_of_this_medium,
CreateMedium && create_medium )

Creates a new entry for the material id in the media map by either calling the create_medium function and creating a new shared pointer, or by reusing the existing shared pointer.

Definition at line 46 of file MediaCreation.h.

50{
51 if (media.find(id) != end(media))
52 {
54 "Multiple media were specified for the same material id '{:d}'. "
55 "Keep in mind, that if no material id is specified, it is assumed "
56 "to be 0 by default.",
57 id);
58 }
59
60 if (id == material_ids_of_this_medium[0])
61 {
62 media[id] = create_medium(id);
63 }
64 else
65 {
66 media[id] = media[material_ids_of_this_medium[0]];
67 }
68}
#define OGS_FATAL(...)
Definition Error.h:26

References OGS_FATAL.

Referenced by MaterialLib::Solids::createConstitutiveRelationsGeneric(), and ProjectData::parseMedia().

◆ parseMaterialIdString()

std::vector< int > MaterialLib::parseMaterialIdString ( std::string const & material_id_string,
MeshLib::PropertyVector< int > const *const material_ids )

Parses a comma separated list of integers or "*" string. Such lists occur in the medium definition in the OGS prj file. For the "*" input a vector of all (unique) material ids is returned. Error messages in this function refer to this specific purpose.

Definition at line 71 of file MediaCreation.cpp.

74{
75 if (material_id_string == "*")
76 {
77 if (material_ids == nullptr)
78 {
80 "MaterialIDs property is not defined in the mesh but it is "
81 "required to parse '*' definition.");
82 }
83
84 std::vector<int> material_ids_of_this_medium =
85 *material_ids |
86 ranges::views::adjacent_remove_if(std::equal_to<>()) |
87 ranges::to_vector;
88 BaseLib::makeVectorUnique(material_ids_of_this_medium);
89 DBUG("Catch all medium definition for material ids {}.",
90 fmt::join(material_ids_of_this_medium, ", "));
91 return material_ids_of_this_medium;
92 }
93
94 // Usual case of ids separated by comma.
95 return splitMaterialIdString(material_id_string);
96}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
void makeVectorUnique(std::vector< T > &v)
Definition Algorithm.h:180
std::vector< int > splitMaterialIdString(std::string const &material_id_string)

References DBUG(), BaseLib::makeVectorUnique(), OGS_FATAL, and splitMaterialIdString().

Referenced by MaterialLib::Solids::createConstitutiveRelationsGeneric(), and ProjectData::parseMedia().

◆ splitMaterialIdString()

std::vector< int > MaterialLib::splitMaterialIdString ( std::string const & material_id_string)

Parses a comma separated list of integers. Such lists occur in the medium definition in the OGS prj file. Error messages in this function refer to this specific purpose.

Definition at line 21 of file MediaCreation.cpp.

22{
23 auto const material_ids_strings =
24 BaseLib::splitString(material_id_string, ',');
25
26 std::vector<int> material_ids;
27 for (auto& mid_str : material_ids_strings)
28 {
29 std::size_t num_chars_processed = 0;
30 int material_id;
31 try
32 {
33 material_id = std::stoi(mid_str, &num_chars_processed);
34 }
35 catch (std::invalid_argument&)
36 {
38 "Could not parse material ID from '{}' to a valid integer.",
39 mid_str);
40 }
41 catch (std::out_of_range&)
42 {
44 "Could not parse material ID from '{}'. The integer value of "
45 "the given string exceeds the permitted range.",
46 mid_str);
47 }
48
49 if (num_chars_processed != mid_str.size())
50 {
51 // Not the whole string has been parsed. Check the rest.
52 if (auto const it = std::find_if_not(
53 begin(mid_str) + num_chars_processed, end(mid_str),
54 [](unsigned char const c) { return std::isspace(c); });
55 it != end(mid_str))
56 {
58 "Could not parse material ID from '{}'. Please separate "
59 "multiple material IDs by comma only. Invalid character: "
60 "'{}' at position {}.",
61 mid_str, *it, distance(begin(mid_str), it));
62 }
63 }
64
65 material_ids.push_back(material_id);
66 };
67
68 return material_ids;
69}
std::vector< std::string > splitString(std::string const &str)

References OGS_FATAL, and BaseLib::splitString().

Referenced by ProcessLib::HeatTransportBHE::createHeatTransportBHEProcess(), parseMaterialIdString(), and parseOutputMeshConfig().