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