OGS 6.1.0-1699-ge946d4c5f
CreateSmallDeformationProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
18 
20 #include "ProcessLib/Utils/ProcessUtils.h" // required for findParameter
21 
24 
25 namespace ProcessLib
26 {
27 namespace LIE
28 {
29 namespace SmallDeformation
30 {
31 template <int DisplacementDim>
32 std::unique_ptr<Process> createSmallDeformationProcess(
33  MeshLib::Mesh& mesh,
34  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
35  std::vector<ProcessVariable> const& variables,
36  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
37  unsigned const integration_order,
38  BaseLib::ConfigTree const& config)
39 {
41  config.checkConfigParameter("type", "SMALL_DEFORMATION_WITH_LIE");
42  DBUG("Create SmallDeformationProcess with LIE.");
43 
44  // Process variables
46  auto const pv_conf = config.getConfigSubtree("process_variables");
47  auto range =
49  pv_conf.getConfigParameterList<std::string>("process_variable");
50  std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
51 
52  std::size_t n_var_du = 0;
53  for (std::string const& pv_name : range)
54  {
55  if (pv_name != "displacement" && pv_name.find("displacement_jump") != 0)
56  {
57  OGS_FATAL(
58  "Found a process variable name '%s'. It should be "
59  "'displacement' or 'displacement_jumpN' or "
60  "'displacement_junctionN'");
61  }
62  if (pv_name.find("displacement_jump") == 0)
63  {
64  n_var_du++;
65  }
66 
67  auto variable = std::find_if(variables.cbegin(), variables.cend(),
68  [&pv_name](ProcessVariable const& v) {
69  return v.getName() == pv_name;
70  });
71 
72  if (variable == variables.end())
73  {
74  OGS_FATAL(
75  "Could not find process variable '%s' in the provided "
76  "variables "
77  "list for config tag <%s>.",
78  pv_name.c_str(), "process_variable");
79  }
80  DBUG("Found process variable '%s' for config tag <%s>.",
81  variable->getName().c_str(), "process_variable");
82 
83  per_process_variables.emplace_back(
84  const_cast<ProcessVariable&>(*variable));
85  }
86 
87  if (n_var_du < 1)
88  {
89  OGS_FATAL("No displacement jump variables are specified");
90  }
91 
92  DBUG("Associate displacement with process variable '%s'.",
93  per_process_variables.back().get().getName().c_str());
94 
95  if (per_process_variables.back().get().getNumberOfComponents() !=
96  DisplacementDim)
97  {
98  OGS_FATAL(
99  "Number of components of the process variable '%s' is different "
100  "from the displacement dimension: got %d, expected %d",
101  per_process_variables.back().get().getName().c_str(),
102  per_process_variables.back().get().getNumberOfComponents(),
103  DisplacementDim);
104  }
105  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
106  process_variables;
107  process_variables.push_back(std::move(per_process_variables));
108 
109  auto solid_constitutive_relations =
110  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
111  parameters, config);
112 
113  // Fracture constitutive relation.
114  // read type;
115  auto const fracture_model_config =
117  config.getConfigSubtree("fracture_model");
118 
119  auto const frac_type =
121  fracture_model_config.peekConfigParameter<std::string>("type");
122 
123  std::unique_ptr<MaterialLib::Fracture::FractureModelBase<DisplacementDim>>
124  fracture_model = nullptr;
125  if (frac_type == "LinearElasticIsotropic")
126  {
128  DisplacementDim>(parameters, fracture_model_config);
129  }
130  else if (frac_type == "MohrCoulomb")
131  {
132  fracture_model =
133  MaterialLib::Fracture::createMohrCoulomb<DisplacementDim>(
134  parameters, fracture_model_config);
135  }
136  else if (frac_type == "CohesiveZoneModeI")
137  {
138  fracture_model =
140  DisplacementDim>(parameters, fracture_model_config);
141  }
142  else
143  {
144  OGS_FATAL(
145  "Cannot construct fracture constitutive relation of given type "
146  "'%s'.",
147  frac_type.c_str());
148  }
149 
150  // Fracture properties
151  std::vector<FractureProperty> fracture_properties;
152  for (
153  auto fracture_properties_config :
155  config.getConfigSubtreeList("fracture_properties"))
156  {
157  fracture_properties.emplace_back(
158  fracture_properties.size(),
160  fracture_properties_config.getConfigParameter<int>("material_id"),
161  ProcessLib::findParameter<double>(
163  fracture_properties_config, "initial_aperture", parameters, 1));
164  }
165 
166  if (n_var_du < fracture_properties.size())
167  {
168  OGS_FATAL(
169  "The number of displacement jumps and the number of "
170  "<fracture_properties> "
171  "are not consistent");
172  }
173 
174  // Reference temperature
175  const auto& reference_temperature =
177  config.getConfigParameter<double>(
178  "reference_temperature", std::numeric_limits<double>::quiet_NaN());
179 
181  materialIDs(mesh), std::move(solid_constitutive_relations),
182  std::move(fracture_model), std::move(fracture_properties),
184 
185  SecondaryVariableCollection secondary_variables;
186 
187  NumLib::NamedFunctionCaller named_function_caller(
188  {"SmallDeformation_displacement"});
189 
190  ProcessLib::createSecondaryVariables(config, secondary_variables,
191  named_function_caller);
192 
193  return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
194  mesh, std::move(jacobian_assembler), parameters, integration_order,
195  std::move(process_variables), std::move(process_data),
196  std::move(secondary_variables), std::move(named_function_caller));
197 }
198 
199 template std::unique_ptr<Process> createSmallDeformationProcess<2>(
200  MeshLib::Mesh& mesh,
201  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
202  std::vector<ProcessVariable> const& variables,
203  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
204  unsigned const integration_order,
205  BaseLib::ConfigTree const& config);
206 
207 template std::unique_ptr<Process> createSmallDeformationProcess<3>(
208  MeshLib::Mesh& mesh,
209  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
210  std::vector<ProcessVariable> const& variables,
211  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
212  unsigned const integration_order,
213  BaseLib::ConfigTree const& config);
214 
215 } // namespace SmallDeformation
216 } // namespace LIE
217 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
template std::unique_ptr< Process > createSmallDeformationProcess< 3 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
T getConfigParameter(std::string const &param) const
Builds expression trees of named functions dynamically at runtime.
std::unique_ptr< Process > createSmallDeformationProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::unique_ptr< FractureModelBase< DisplacementDim > > createLinearElasticIsotropic(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config)
void checkConfigParameter(std::string const &param, T const &value) const
std::unique_ptr< FractureModelBase< DisplacementDim > > createCohesiveZoneModeI(std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters, BaseLib::ConfigTree const &config)
T peekConfigParameter(std::string const &param) const
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:342
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
Definition: ConfigTree.cpp:170
Handles configuration of several secondary variables from the project file.
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
template std::unique_ptr< Process > createSmallDeformationProcess< 2 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
Range< ValueIterator< T > > getConfigParameterList(std::string const &param) const