OGS
LIE/SmallDeformation/CreateSmallDeformationProcess.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <cassert>
7
12#include "ParameterLib/Utils.h"
16
17namespace ProcessLib
18{
19namespace LIE
20{
22{
23template <int DisplacementDim>
24std::unique_ptr<Process> createSmallDeformationProcess(
25 std::string const& name,
26 MeshLib::Mesh& mesh,
27 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
28 std::vector<ProcessVariable> const& variables,
29 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
30 std::optional<ParameterLib::CoordinateSystem> const&
31 local_coordinate_system,
32 unsigned const integration_order,
33 BaseLib::ConfigTree const& config)
34{
36 config.checkConfigParameter("type", "SMALL_DEFORMATION_WITH_LIE");
37 DBUG("Create SmallDeformationProcess with LIE.");
38
41 auto const pv_conf = config.getConfigSubtree("process_variables");
43 auto range =
45 pv_conf.getConfigParameterList<std::string>("process_variable");
46 std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
47
48 std::size_t n_var_du = 0;
49 for (std::string const& pv_name : range)
50 {
51 if (pv_name != "displacement" &&
52 !pv_name.starts_with("displacement_jump"))
53 {
55 "Found a process variable name '{:s}'. It should be "
56 "'displacement' or 'displacement_jumpN' or "
57 "'displacement_junctionN'",
58 pv_name);
59 }
60 if (pv_name.starts_with("displacement_jump"))
61 {
62 n_var_du++;
63 }
64
65 auto variable = std::find_if(variables.cbegin(), variables.cend(),
66 [&pv_name](ProcessVariable const& v)
67 { return v.getName() == pv_name; });
68
69 if (variable == variables.end())
70 {
72 "Could not find process variable '{:s}' in the provided "
73 "variables "
74 "list for config tag <{:s}>.",
75 pv_name, "process_variable");
76 }
77 DBUG("Found process variable '{:s}' for config tag <{:s}>.",
78 variable->getName(), "process_variable");
79
80 per_process_variables.emplace_back(
81 const_cast<ProcessVariable&>(*variable));
82 }
83
84 if (n_var_du < 1)
85 {
86 OGS_FATAL("No displacement jump variables are specified");
87 }
88
89 DBUG("Associate displacement with process variable '{:s}'.",
90 per_process_variables.back().get().getName());
91
92 if (per_process_variables.back().get().getNumberOfGlobalComponents() !=
93 DisplacementDim)
94 {
96 "Number of components of the process variable '{:s}' is different "
97 "from the displacement dimension: got {:d}, expected {:d}",
98 per_process_variables.back().get().getName(),
99 per_process_variables.back().get().getNumberOfGlobalComponents(),
100 DisplacementDim);
101 }
102 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
103 process_variables;
104 process_variables.push_back(std::move(per_process_variables));
105
107 auto solid_constitutive_relations =
109 parameters, local_coordinate_system, materialIDs(mesh), config);
110
111 // Fracture constitutive relation.
112 // read type;
113 auto const fracture_model_config =
115 config.getConfigSubtree("fracture_model");
116
117 auto const frac_type =
119 fracture_model_config.peekConfigParameter<std::string>("type");
120
121 std::unique_ptr<MaterialLib::Fracture::FractureModelBase<DisplacementDim>>
122 fracture_model = nullptr;
123 if (frac_type == "LinearElasticIsotropic")
124 {
126 DisplacementDim>(parameters, fracture_model_config);
127 }
128 else if (frac_type == "Coulomb")
129 {
131 parameters, fracture_model_config);
132 }
133 else if (frac_type == "CohesiveZoneModeI")
134 {
135 fracture_model =
137 DisplacementDim>(parameters, fracture_model_config);
138 }
139 else
140 {
141 OGS_FATAL(
142 "Cannot construct fracture constitutive relation of given type "
143 "'{:s}'.",
144 frac_type);
145 }
146
147 // Fracture properties
148 std::vector<FractureProperty> fracture_properties;
149 for (
150 auto fracture_properties_config :
152 config.getConfigSubtreeList("fracture_properties"))
153 {
154 fracture_properties.emplace_back(
155 fracture_properties.size(),
157 fracture_properties_config.getConfigParameter<int>("material_id"),
160 fracture_properties_config, "initial_aperture", parameters, 1,
161 &mesh));
162 }
163
164 if (n_var_du < fracture_properties.size())
165 {
166 OGS_FATAL(
167 "The number of displacement jumps {} and the number of "
168 "<fracture_properties> {} are not consistent.",
169 n_var_du,
170 fracture_properties.size());
171 }
172
173 // Reference temperature
174 const auto& reference_temperature =
176 config.getConfigParameter<double>(
177 "reference_temperature", std::numeric_limits<double>::quiet_NaN());
178
180 auto const use_b_bar = config.getConfigParameter<bool>("use_b_bar", false);
181
183 materialIDs(mesh), std::move(solid_constitutive_relations),
184 std::move(fracture_model), std::move(fracture_properties),
185 reference_temperature, use_b_bar};
186
187 SecondaryVariableCollection secondary_variables;
188
189 ProcessLib::createSecondaryVariables(config, secondary_variables);
190
191 return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
192 std::move(name), mesh, std::move(jacobian_assembler), parameters,
193 integration_order, std::move(process_variables),
194 std::move(process_data), std::move(secondary_variables));
195}
196
197template std::unique_ptr<Process> createSmallDeformationProcess<2>(
198 std::string const& name,
199 MeshLib::Mesh& mesh,
200 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
201 std::vector<ProcessVariable> const& variables,
202 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
203 std::optional<ParameterLib::CoordinateSystem> const&
204 local_coordinate_system,
205 unsigned const integration_order,
206 BaseLib::ConfigTree const& config);
207
208template std::unique_ptr<Process> createSmallDeformationProcess<3>(
209 std::string const& name,
210 MeshLib::Mesh& mesh,
211 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
212 std::vector<ProcessVariable> const& variables,
213 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
214 std::optional<ParameterLib::CoordinateSystem> const&
215 local_coordinate_system,
216 unsigned const integration_order,
217 BaseLib::ConfigTree const& config);
218
219} // namespace SmallDeformation
220} // namespace LIE
221} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
T peekConfigParameter(std::string const &param) const
T getConfigParameter(std::string const &param) const
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
ConfigTree getConfigSubtree(std::string const &root) const
Range< ValueIterator< T > > getConfigParameterList(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
Handles configuration of several secondary variables from the project file.
std::unique_ptr< FractureModelBase< DisplacementDim > > createCohesiveZoneModeI(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, BaseLib::ConfigTree const &config)
std::unique_ptr< FractureModelBase< DisplacementDim > > createLinearElasticIsotropic(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, BaseLib::ConfigTree const &config)
std::unique_ptr< FractureModelBase< DisplacementDim > > createCoulomb(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, BaseLib::ConfigTree const &config)
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)
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)
template std::unique_ptr< Process > createSmallDeformationProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::unique_ptr< Process > createSmallDeformationProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
template std::unique_ptr< Process > createSmallDeformationProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)