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