OGS
CreateSmallDeformationProcess.cpp
Go to the documentation of this file.
1 
12 
13 #include <cassert>
14 
19 #include "ParameterLib/Utils.h"
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  std::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  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, "process_variable");
80  }
81  DBUG("Found process variable '{:s}' for config tag <{:s}>.",
82  variable->getName(), "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());
95 
96  if (per_process_variables.back().get().getNumberOfGlobalComponents() !=
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(),
103  per_process_variables.back().get().getNumberOfGlobalComponents(),
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 == "Coulomb")
132  {
133  fracture_model = MaterialLib::Fracture::createCoulomb<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);
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  ParameterLib::findParameter<double>(
163  fracture_properties_config, "initial_aperture", parameters, 1,
164  &mesh));
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> 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  ProcessLib::createSecondaryVariables(config, secondary_variables);
188 
189  return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
190  std::move(name), mesh, std::move(jacobian_assembler), parameters,
191  integration_order, std::move(process_variables),
192  std::move(process_data), std::move(secondary_variables));
193 }
194 
195 template std::unique_ptr<Process> createSmallDeformationProcess<2>(
196  std::string name,
197  MeshLib::Mesh& mesh,
198  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
199  std::vector<ProcessVariable> const& variables,
200  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
201  std::optional<ParameterLib::CoordinateSystem> const&
202  local_coordinate_system,
203  unsigned const integration_order,
204  BaseLib::ConfigTree const& config);
205 
206 template std::unique_ptr<Process> createSmallDeformationProcess<3>(
207  std::string name,
208  MeshLib::Mesh& mesh,
209  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
210  std::vector<ProcessVariable> const& variables,
211  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
212  std::optional<ParameterLib::CoordinateSystem> const&
213  local_coordinate_system,
214  unsigned const integration_order,
215  BaseLib::ConfigTree const& config);
216 
217 } // namespace SmallDeformation
218 } // namespace LIE
219 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
T peekConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
Definition: ConfigTree.cpp:169
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
Range< ValueIterator< T > > getConfigParameterList(std::string const &param) 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)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
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, 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 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 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)