OGS 6.2.0-97-g4a610c866
CreateSmallDeformationProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
15 #include "ParameterLib/Utils.h"
18 
21 
22 namespace ProcessLib
23 {
24 namespace SmallDeformation
25 {
26 template <int DisplacementDim>
27 std::unique_ptr<Process> createSmallDeformationProcess(
28  MeshLib::Mesh& mesh,
29  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
30  std::vector<ProcessVariable> const& variables,
31  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
32  boost::optional<ParameterLib::CoordinateSystem> const&
33  local_coordinate_system,
34  unsigned const integration_order,
35  BaseLib::ConfigTree const& config)
36 {
38  config.checkConfigParameter("type", "SMALL_DEFORMATION");
39  DBUG("Create SmallDeformationProcess.");
40 
41  // Process variable.
42 
44  auto const pv_config = config.getConfigSubtree("process_variables");
45 
46  auto per_process_variables = findProcessVariables(
47  variables, pv_config,
48  {
49  "process_variable"});
50 
51  DBUG("Associate displacement with process variable '%s'.",
52  per_process_variables.back().get().getName().c_str());
53 
54  if (per_process_variables.back().get().getNumberOfComponents() !=
55  DisplacementDim)
56  {
57  OGS_FATAL(
58  "Number of components of the process variable '%s' is different "
59  "from the displacement dimension: got %d, expected %d",
60  per_process_variables.back().get().getName().c_str(),
61  per_process_variables.back().get().getNumberOfComponents(),
62  DisplacementDim);
63  }
64  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
65  process_variables;
66  process_variables.push_back(std::move(per_process_variables));
67 
68  auto solid_constitutive_relations =
69  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
70  parameters, local_coordinate_system, config);
71 
72  // Solid density
73  auto& solid_density = ParameterLib::findParameter<double>(
74  config,
76  "solid_density", parameters, 1);
77  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
78 
79  // Specific body force
80  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
81  {
82  std::vector<double> const b =
84  config.getConfigParameter<std::vector<double>>(
85  "specific_body_force");
86  if (b.size() != DisplacementDim)
87  {
88  OGS_FATAL(
89  "The size of the specific body force vector does not match the "
90  "displacement dimension. Vector size is %d, displacement "
91  "dimension is %d",
92  b.size(), DisplacementDim);
93  }
94 
95  std::copy_n(b.data(), b.size(), specific_body_force.data());
96  }
97 
98  // Reference temperature
99  const auto& reference_temperature =
101  config.getConfigParameter<double>(
102  "reference_temperature", std::numeric_limits<double>::quiet_NaN());
103 
105  materialIDs(mesh), std::move(solid_constitutive_relations),
106  solid_density, specific_body_force, reference_temperature};
107 
108  SecondaryVariableCollection secondary_variables;
109 
110  NumLib::NamedFunctionCaller named_function_caller(
111  {"SmallDeformation_displacement"});
112 
113  ProcessLib::createSecondaryVariables(config, secondary_variables,
114  named_function_caller);
115 
116  return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
117  mesh, std::move(jacobian_assembler), parameters, integration_order,
118  std::move(process_variables), std::move(process_data),
119  std::move(secondary_variables), std::move(named_function_caller));
120 }
121 
122 template std::unique_ptr<Process> createSmallDeformationProcess<2>(
123  MeshLib::Mesh& mesh,
124  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
125  std::vector<ProcessVariable> const& variables,
126  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
127  boost::optional<ParameterLib::CoordinateSystem> const&
128  local_coordinate_system,
129  unsigned const integration_order,
130  BaseLib::ConfigTree const& config);
131 
132 template std::unique_ptr<Process> createSmallDeformationProcess<3>(
133  MeshLib::Mesh& mesh,
134  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
135  std::vector<ProcessVariable> const& variables,
136  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
137  boost::optional<ParameterLib::CoordinateSystem> const&
138  local_coordinate_system,
139  unsigned const integration_order,
140  BaseLib::ConfigTree const& config);
141 
142 } // namespace SmallDeformation
143 } // 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< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
Builds expression trees of named functions dynamically at runtime.
void checkConfigParameter(std::string const &param, T const &value) const
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)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:403
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
Handles configuration of several secondary variables from the project file.
#define OGS_FATAL(fmt,...)
Definition: Error.h:63