OGS 6.2.1-97-g73d1aeda3
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  std::string name,
31  MeshLib::Mesh& mesh,
32  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
33  std::vector<ProcessVariable> const& variables,
34  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
35  boost::optional<ParameterLib::CoordinateSystem> const&
36  local_coordinate_system,
37  unsigned const integration_order,
38  BaseLib::ConfigTree const& config)
39 {
41  config.checkConfigParameter("type", "SMALL_DEFORMATION_NONLOCAL");
42  DBUG("Create SmallDeformationNonlocalProcess.");
43 
44  // Process variable.
45 
47  auto const pv_config = config.getConfigSubtree("process_variables");
48 
49  auto per_process_variables = findProcessVariables(
50  variables, pv_config,
51  {
52  "process_variable"});
53 
54  DBUG("Associate displacement with process variable '%s'.",
55  per_process_variables.back().get().getName().c_str());
56 
57  if (per_process_variables.back().get().getNumberOfComponents() !=
58  DisplacementDim)
59  {
60  OGS_FATAL(
61  "Number of components of the process variable '%s' is different "
62  "from the displacement dimension: got %d, expected %d",
63  per_process_variables.back().get().getName().c_str(),
64  per_process_variables.back().get().getNumberOfComponents(),
65  DisplacementDim);
66  }
67  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
68  process_variables;
69  process_variables.push_back(std::move(per_process_variables));
70 
71  auto solid_constitutive_relations =
72  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
73  parameters, local_coordinate_system, config);
74 
75  // Solid density
76  auto& solid_density = ParameterLib::findParameter<double>(
77  config,
79  "solid_density", parameters, 1, &mesh);
80  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
81 
82  // Specific body force
83  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
84  {
85  std::vector<double> const b =
87  config.getConfigParameter<std::vector<double>>(
88  "specific_body_force");
89  if (b.size() != DisplacementDim)
90  {
91  OGS_FATAL(
92  "The size of the specific body force vector does not match the "
93  "displacement dimension. Vector size is %d, displacement "
94  "dimension is %d",
95  b.size(), DisplacementDim);
96  }
97 
98  std::copy_n(b.data(), b.size(), specific_body_force.data());
99  }
100 
101  // Reference temperature
102  const auto& reference_temperature =
104  config.getConfigParameter<double>(
105  "reference_temperature", std::numeric_limits<double>::quiet_NaN());
106 
107  auto const internal_length =
109  config.getConfigParameter<double>("internal_length");
110 
112  materialIDs(mesh), std::move(solid_constitutive_relations),
113  solid_density, specific_body_force,
114  reference_temperature, internal_length * internal_length};
115 
116  SecondaryVariableCollection secondary_variables;
117 
118  NumLib::NamedFunctionCaller named_function_caller(
119  {"SmallDeformationNonlocal_displacement"});
120 
121  ProcessLib::createSecondaryVariables(config, secondary_variables,
122  named_function_caller);
123 
124  return std::make_unique<SmallDeformationNonlocalProcess<DisplacementDim>>(
125  std::move(name), mesh, std::move(jacobian_assembler), parameters,
126  integration_order, std::move(process_variables),
127  std::move(process_data), std::move(secondary_variables),
128  std::move(named_function_caller));
129 }
130 
131 template std::unique_ptr<Process> createSmallDeformationNonlocalProcess<2>(
132  std::string name,
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 template std::unique_ptr<Process> createSmallDeformationNonlocalProcess<3>(
143  std::string name,
144  MeshLib::Mesh& mesh,
145  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
146  std::vector<ProcessVariable> const& variables,
147  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
148  boost::optional<ParameterLib::CoordinateSystem> const&
149  local_coordinate_system,
150  unsigned const integration_order,
151  BaseLib::ConfigTree const& config);
152 
153 } // namespace SmallDeformationNonlocal
154 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
std::unique_ptr< Process > createSmallDeformationNonlocalProcess(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
template std::unique_ptr< Process > createSmallDeformationNonlocalProcess< 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)
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
template std::unique_ptr< Process > createSmallDeformationNonlocalProcess< 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)