OGS 6.2.1-97-g73d1aeda3
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  std::string name,
29  MeshLib::Mesh& mesh,
30  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
31  std::vector<ProcessVariable> const& variables,
32  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
33  boost::optional<ParameterLib::CoordinateSystem> const&
34  local_coordinate_system,
35  unsigned const integration_order,
36  BaseLib::ConfigTree const& config)
37 {
39  config.checkConfigParameter("type", "SMALL_DEFORMATION");
40  DBUG("Create SmallDeformationProcess.");
41 
42  // Process variable.
43 
45  auto const pv_config = config.getConfigSubtree("process_variables");
46 
47  auto per_process_variables = findProcessVariables(
48  variables, pv_config,
49  {
50  "process_variable"});
51 
52  DBUG("Associate displacement with process variable '%s'.",
53  per_process_variables.back().get().getName().c_str());
54 
55  if (per_process_variables.back().get().getNumberOfComponents() !=
56  DisplacementDim)
57  {
58  OGS_FATAL(
59  "Number of components of the process variable '%s' is different "
60  "from the displacement dimension: got %d, expected %d",
61  per_process_variables.back().get().getName().c_str(),
62  per_process_variables.back().get().getNumberOfComponents(),
63  DisplacementDim);
64  }
65  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
66  process_variables;
67  process_variables.push_back(std::move(per_process_variables));
68 
69  auto solid_constitutive_relations =
70  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
71  parameters, local_coordinate_system, config);
72 
73  // Solid density
74  auto& solid_density = ParameterLib::findParameter<double>(
75  config,
77  "solid_density", parameters, 1, &mesh);
78  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
79 
80  // Specific body force
81  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
82  {
83  std::vector<double> const b =
85  config.getConfigParameter<std::vector<double>>(
86  "specific_body_force");
87  if (b.size() != DisplacementDim)
88  {
89  OGS_FATAL(
90  "The size of the specific body force vector does not match the "
91  "displacement dimension. Vector size is %d, displacement "
92  "dimension is %d",
93  b.size(), DisplacementDim);
94  }
95 
96  std::copy_n(b.data(), b.size(), specific_body_force.data());
97  }
98 
99  // Reference temperature
100  const auto& reference_temperature =
102  config.getConfigParameter<double>(
103  "reference_temperature", std::numeric_limits<double>::quiet_NaN());
104 
105  // Non-equilibrium variables
106  ParameterLib::Parameter<double> const* nonequilibrium_stress = nullptr;
107  const auto& nonequilibrium_state_variables_config =
109  config.getConfigSubtreeOptional("nonequilibrium_state_variables");
110  if (nonequilibrium_state_variables_config)
111  {
112  nonequilibrium_stress = &ParameterLib::findParameter<double>(
113  *nonequilibrium_state_variables_config,
115  "stress", parameters,
117  DisplacementDim>::value);
118  }
119 
121  materialIDs(mesh), std::move(solid_constitutive_relations),
122  solid_density, specific_body_force,
123  nonequilibrium_stress, reference_temperature};
124 
125  SecondaryVariableCollection secondary_variables;
126 
127  NumLib::NamedFunctionCaller named_function_caller(
128  {"SmallDeformation_displacement"});
129 
130  ProcessLib::createSecondaryVariables(config, secondary_variables,
131  named_function_caller);
132 
133  return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
134  std::move(name), mesh, std::move(jacobian_assembler), parameters,
135  integration_order, std::move(process_variables),
136  std::move(process_data), std::move(secondary_variables),
137  std::move(named_function_caller));
138 }
139 
140 template std::unique_ptr<Process> createSmallDeformationProcess<2>(
141  std::string name,
142  MeshLib::Mesh& mesh,
143  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
144  std::vector<ProcessVariable> const& variables,
145  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
146  boost::optional<ParameterLib::CoordinateSystem> const&
147  local_coordinate_system,
148  unsigned const integration_order,
149  BaseLib::ConfigTree const& config);
150 
151 template std::unique_ptr<Process> createSmallDeformationProcess<3>(
152  std::string name,
153  MeshLib::Mesh& mesh,
154  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
155  std::vector<ProcessVariable> const& variables,
156  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
157  boost::optional<ParameterLib::CoordinateSystem> const&
158  local_coordinate_system,
159  unsigned const integration_order,
160  BaseLib::ConfigTree const& config);
161 
162 } // namespace SmallDeformation
163 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
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)
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(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)
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
Handles configuration of several secondary variables from the project file.
#define OGS_FATAL(fmt,...)
Definition: Error.h:63