OGS
CreateSmallDeformationNonlocalProcess.cpp
Go to the documentation of this file.
1 
12 
13 #include <cassert>
14 
16 #include "ParameterLib/Utils.h"
21 
22 namespace ProcessLib
23 {
24 namespace SmallDeformationNonlocal
25 {
26 template <int DisplacementDim>
27 std::unique_ptr<Process> createSmallDeformationNonlocalProcess(
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  std::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_NONLOCAL");
40  DBUG("Create SmallDeformationNonlocalProcess.");
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());
54 
55  if (per_process_variables.back().get().getNumberOfGlobalComponents() !=
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(),
62  per_process_variables.back().get().getNumberOfGlobalComponents(),
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 const& solid_density = ParameterLib::findParameter<double>(
75  config,
77  "solid_density", parameters, 1, &mesh);
78  DBUG("Use '{:s}' as solid density parameter.", solid_density.name);
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  auto const internal_length =
107  config.getConfigParameter<double>("internal_length");
108 
110  materialIDs(mesh), std::move(solid_constitutive_relations),
111  solid_density, specific_body_force,
112  reference_temperature, internal_length * internal_length};
113 
114  SecondaryVariableCollection secondary_variables;
115 
116  ProcessLib::createSecondaryVariables(config, secondary_variables);
117 
118  return std::make_unique<SmallDeformationNonlocalProcess<DisplacementDim>>(
119  std::move(name), mesh, std::move(jacobian_assembler), parameters,
120  integration_order, std::move(process_variables),
121  std::move(process_data), std::move(secondary_variables));
122 }
123 
124 template std::unique_ptr<Process> createSmallDeformationNonlocalProcess<2>(
125  std::string name,
126  MeshLib::Mesh& mesh,
127  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
128  std::vector<ProcessVariable> const& variables,
129  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
130  std::optional<ParameterLib::CoordinateSystem> const&
131  local_coordinate_system,
132  unsigned const integration_order,
133  BaseLib::ConfigTree const& config);
134 
135 template std::unique_ptr<Process> createSmallDeformationNonlocalProcess<3>(
136  std::string name,
137  MeshLib::Mesh& mesh,
138  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
139  std::vector<ProcessVariable> const& variables,
140  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
141  std::optional<ParameterLib::CoordinateSystem> const&
142  local_coordinate_system,
143  unsigned const integration_order,
144  BaseLib::ConfigTree const& config);
145 
146 } // namespace SmallDeformationNonlocal
147 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
Handles configuration of several secondary variables from the project file.
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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, std::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)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)