OGS
CreateSmallDeformationProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
17#include "ParameterLib/Utils.h"
22
23namespace ProcessLib
24{
25namespace SmallDeformation
26{
28 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
29{
30 for (auto const& m : media)
31 {
32 checkRequiredProperties(m.second->phase("Solid"),
33 {{MaterialPropertyLib::density}});
34 }
35}
36
37template <int DisplacementDim>
38std::unique_ptr<Process> createSmallDeformationProcess(
39 std::string const& name,
40 MeshLib::Mesh& mesh,
41 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
42 std::vector<ProcessVariable> const& variables,
43 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
44 std::optional<ParameterLib::CoordinateSystem> const&
45 local_coordinate_system,
46 unsigned const integration_order,
47 BaseLib::ConfigTree const& config,
48 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
49{
51 config.checkConfigParameter("type", "SMALL_DEFORMATION");
52 DBUG("Create SmallDeformationProcess.");
53
55
57 auto const pv_config = config.getConfigSubtree("process_variables");
58
60 auto per_process_variables = findProcessVariables(
61 variables, pv_config,
62 {
63 "process_variable"});
64
65 DBUG("Associate displacement with process variable '{:s}'.",
66 per_process_variables.back().get().getName());
67
68 if (per_process_variables.back().get().getNumberOfGlobalComponents() !=
69 DisplacementDim)
70 {
72 "Number of components of the process variable '{:s}' is different "
73 "from the displacement dimension: got {:d}, expected {:d}",
74 per_process_variables.back().get().getName(),
75 per_process_variables.back().get().getNumberOfGlobalComponents(),
76 DisplacementDim);
77 }
78 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
79 process_variables;
80 process_variables.push_back(std::move(per_process_variables));
81
83 auto solid_constitutive_relations =
85 parameters, local_coordinate_system, materialIDs(mesh), config);
86
88 if (config.getConfigParameterOptional<std::string>("solid_density"))
89 {
91 "The <solid_density> tag has been removed. Use <media> definitions "
92 "to specify solid's density.");
93 }
94
95 // Specific body force
96 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
97 {
98 std::vector<double> const b =
100 config.getConfigParameter<std::vector<double>>(
101 "specific_body_force");
102 if (b.size() != DisplacementDim)
103 {
104 OGS_FATAL(
105 "The size of the specific body force vector does not match the "
106 "displacement dimension. Vector size is {:d}, displacement "
107 "dimension is {:d}",
108 b.size(), DisplacementDim);
109 }
110
111 std::copy_n(b.data(), b.size(), specific_body_force.data());
112 }
113
115 auto const use_b_bar = config.getConfigParameter<bool>("use_b_bar", false);
116
117 auto media_map =
119 DBUG(
120 "Check the media properties of SmallDeformation process "
121 "...");
122 checkMPLProperties(media);
123 DBUG("Media properties verified.");
124
125 // Reference temperature
126 auto const reference_temperature = ParameterLib::findOptionalTagParameter<
127 double>(
129 config, "reference_temperature", parameters, 1, &mesh);
130 if (reference_temperature)
131 {
132 DBUG("Use '{:s}' as reference temperature parameter.",
133 (*reference_temperature).name);
134 }
135
136 // Initial stress conditions
137 auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
139 config, "initial_stress", parameters,
140 // Symmetric tensor size, 4 or 6, not a Kelvin vector.
142 &mesh);
143
145 materialIDs(mesh),
146 std::move(media_map),
147 std::move(solid_constitutive_relations),
148 initial_stress,
149 specific_body_force,
150 reference_temperature,
151 use_b_bar};
152
153 SecondaryVariableCollection secondary_variables;
154
155 ProcessLib::createSecondaryVariables(config, secondary_variables);
156
157 return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
158 std::move(name), mesh, std::move(jacobian_assembler), parameters,
159 integration_order, std::move(process_variables),
160 std::move(process_data), std::move(secondary_variables));
161}
162
163template std::unique_ptr<Process> createSmallDeformationProcess<2>(
164 std::string const& name,
165 MeshLib::Mesh& mesh,
166 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
167 std::vector<ProcessVariable> const& variables,
168 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
169 std::optional<ParameterLib::CoordinateSystem> const&
170 local_coordinate_system,
171 unsigned const integration_order,
172 BaseLib::ConfigTree const& config,
173 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
174
175template std::unique_ptr<Process> createSmallDeformationProcess<3>(
176 std::string const& name,
177 MeshLib::Mesh& mesh,
178 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
179 std::vector<ProcessVariable> const& variables,
180 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
181 std::optional<ParameterLib::CoordinateSystem> const&
182 local_coordinate_system,
183 unsigned const integration_order,
184 BaseLib::ConfigTree const& config,
185 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
186
187} // namespace SmallDeformation
188} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
Handles configuration of several secondary variables from the project file.
std::map< int, std::shared_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > > createConstitutiveRelations(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)
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Parameter< ParameterDataType > * findOptionalTagParameter(BaseLib::ConfigTree const &process_config, std::string const &tag, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:166
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)