OGS
CreateInitialStress.cpp
Go to the documentation of this file.
1
12#include "CreateInitialStress.h"
13
14#include <string>
15
16#include "BaseLib/ConfigTree.h"
17#include "InitialStress.h"
19#include "MeshLib/Mesh.h"
20#include "ParameterLib/Utils.h"
21
22namespace ProcessLib
23{
24template <int DisplacementDim>
26 BaseLib::ConfigTree const& config,
27 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
28 MeshLib::Mesh const& mesh, bool const mandatory_stress_type)
29{
30 auto const config_stress0 =
32 config.getConfigSubtreeOptional("initial_stress");
33
34 if (!config_stress0)
35 {
36 return {};
37 }
38
39 auto const stress0_type_opt =
41 config_stress0->getConfigAttributeOptional<std::string>("type");
42
43 // If the type is mandatory required but it is not presented:
44 if (mandatory_stress_type && !stress0_type_opt)
45 {
47 "The attribute \"type\" of the tag \"initial_stress\" is required "
48 "for the current process setting, for example using subtype = "
49 "\"StressSaturation_StrainPressureTemperature\" in TRM. "
50 "However it is missing.");
51 }
52
53 auto const stress0_type_str =
54 stress0_type_opt ? *stress0_type_opt : "effective";
55
56 InitialStress::Type stress0_type;
57 if (stress0_type_str == "total")
58 {
59 stress0_type = InitialStress::Type::Total;
60 }
61 else if (stress0_type_str == "effective")
62 {
63 stress0_type = InitialStress::Type::Effective;
64 }
65 else
66 {
68 "The initial stress type must be \"total\" or "
69 "\"effective\". But the given one is {:s}",
70 stress0_type_str);
71 }
72
73 auto const parameter_name = config_stress0->getValue<std::string>();
74 auto const initial_stress = &ParameterLib::findParameter<double>(
75 parameter_name, parameters,
77 &mesh);
78
79 return {initial_stress, stress0_type};
80}
81
83 BaseLib::ConfigTree const& config,
84 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
85 MeshLib::Mesh const& mesh, bool const mandatory_stress_type);
87 BaseLib::ConfigTree const& config,
88 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
89 MeshLib::Mesh const& mesh, bool const mandatory_stress_type);
90
91}; // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
Definition of the Mesh class.
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
template InitialStress createInitialStress< 2 >(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, MeshLib::Mesh const &mesh, bool const mandatory_stress_type)
template InitialStress createInitialStress< 3 >(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, MeshLib::Mesh const &mesh, bool const mandatory_stress_type)
InitialStress createInitialStress(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, MeshLib::Mesh const &mesh, bool const mandatory_stress_type)