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