OGS
CreateThermoHydroMechanicsProcess.cpp
Go to the documentation of this file.
1 
12 
13 #include <cassert>
14 
19 #include "ParameterLib/Utils.h"
24 
25 namespace ProcessLib
26 {
27 namespace ThermoHydroMechanics
28 {
29 template <int DisplacementDim>
30 std::unique_ptr<Process> createThermoHydroMechanicsProcess(
31  std::string name, 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  std::optional<ParameterLib::CoordinateSystem> const&
36  local_coordinate_system,
37  unsigned const integration_order, BaseLib::ConfigTree const& config,
38  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
39 {
41  config.checkConfigParameter("type", "THERMO_HYDRO_MECHANICS");
42  DBUG("Create ThermoHydroMechanicsProcess.");
43 
44  auto const coupling_scheme =
46  config.getConfigParameterOptional<std::string>("coupling_scheme");
47  const bool use_monolithic_scheme =
48  !(coupling_scheme && (*coupling_scheme == "staggered"));
49 
50  // Process variable.
51 
53  auto const pv_config = config.getConfigSubtree("process_variables");
54 
55  ProcessVariable* variable_T;
56  ProcessVariable* variable_p;
57  ProcessVariable* variable_u;
58  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
59  process_variables;
60  if (use_monolithic_scheme) // monolithic scheme.
61  {
62  auto per_process_variables = findProcessVariables(
63  variables, pv_config,
64  {
65  "temperature",
67  "pressure",
69  "displacement"});
70  variable_T = &per_process_variables[0].get();
71  variable_p = &per_process_variables[1].get();
72  variable_u = &per_process_variables[2].get();
73  process_variables.push_back(std::move(per_process_variables));
74  }
75  else // staggered scheme.
76  {
77  using namespace std::string_literals;
78  for (auto const& variable_name :
79  {"temperature"s, "pressure"s, "displacement"s})
80  {
81  auto per_process_variables =
82  findProcessVariables(variables, pv_config, {variable_name});
83  process_variables.push_back(std::move(per_process_variables));
84  }
85  variable_T = &process_variables[0][0].get();
86  variable_p = &process_variables[1][0].get();
87  variable_u = &process_variables[2][0].get();
88  }
89 
90  if (variable_T->getShapeFunctionOrder() != 1)
91  {
92  OGS_FATAL(
93  "The shape function order of temperature must be 1 but its input "
94  "value in <process_variable><order> is {:d}. Please correct it.",
95  variable_T->getShapeFunctionOrder());
96  }
97  if (variable_p->getShapeFunctionOrder() != 1)
98  {
99  OGS_FATAL(
100  "The shape function order of pressure must be 1 but its input "
101  "value in <process_variable><order> is {:d}. Please correct it.",
102  variable_p->getShapeFunctionOrder());
103  }
104 
105  DBUG("Associate displacement with process variable '{:s}'.",
106  variable_u->getName());
107 
108  if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
109  {
110  OGS_FATAL(
111  "Number of components of the process variable '{:s}' is different "
112  "from the displacement dimension: got {:d}, expected {:d}",
113  variable_u->getName(),
114  variable_u->getNumberOfGlobalComponents(),
115  DisplacementDim);
116  }
117 
118  DBUG("Associate pressure with process variable '{:s}'.",
119  variable_p->getName());
120  if (variable_p->getNumberOfGlobalComponents() != 1)
121  {
122  OGS_FATAL(
123  "Pressure process variable '{:s}' is not a scalar variable but has "
124  "{:d} components.",
125  variable_p->getName(),
126  variable_p->getNumberOfGlobalComponents());
127  }
128 
129  DBUG("Associate temperature with process variable '{:s}'.",
130  variable_T->getName());
131  if (variable_T->getNumberOfGlobalComponents() != 1)
132  {
133  OGS_FATAL(
134  "temperature process variable '{:s}' is not a scalar variable but "
135  "has {:d} components.",
136  variable_T->getName(),
137  variable_T->getNumberOfGlobalComponents());
138  }
139 
140  auto solid_constitutive_relations =
141  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
142  parameters, local_coordinate_system, config);
143 
144  // Specific body force
145  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
146  {
147  std::vector<double> const b =
149  config.getConfigParameter<std::vector<double>>(
150  "specific_body_force");
151  if (b.size() != DisplacementDim)
152  {
153  OGS_FATAL(
154  "The size of the specific body force vector does not match the "
155  "displacement dimension. Vector size is {:d}, displacement "
156  "dimension is {:d}",
157  b.size(), DisplacementDim);
158  }
159 
160  std::copy_n(b.data(), b.size(), specific_body_force.data());
161  }
162 
163  auto media_map =
165 
166  // Initial stress conditions
167  auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
169  config, "initial_stress", parameters,
170  // Symmetric tensor size, 4 or 6, not a Kelvin vector.
172  &mesh);
173 
175  materialIDs(mesh), std::move(media_map),
176  std::move(solid_constitutive_relations), initial_stress,
177  specific_body_force};
178 
179  SecondaryVariableCollection secondary_variables;
180 
181  ProcessLib::createSecondaryVariables(config, secondary_variables);
182 
183  return std::make_unique<ThermoHydroMechanicsProcess<DisplacementDim>>(
184  std::move(name), mesh, std::move(jacobian_assembler), parameters,
185  integration_order, std::move(process_variables),
186  std::move(process_data), std::move(secondary_variables),
187  use_monolithic_scheme);
188 }
189 
190 template std::unique_ptr<Process> createThermoHydroMechanicsProcess<2>(
191  std::string name,
192  MeshLib::Mesh& mesh,
193  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
194  std::vector<ProcessVariable> const& variables,
195  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
196  std::optional<ParameterLib::CoordinateSystem> const&
197  local_coordinate_system,
198  unsigned const integration_order,
199  BaseLib::ConfigTree const& config,
200  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
201 
202 template std::unique_ptr<Process> createThermoHydroMechanicsProcess<3>(
203  std::string name,
204  MeshLib::Mesh& mesh,
205  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
206  std::vector<ProcessVariable> const& variables,
207  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
208  std::optional<ParameterLib::CoordinateSystem> const&
209  local_coordinate_system,
210  unsigned const integration_order,
211  BaseLib::ConfigTree const& config,
212  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
213 } // namespace ThermoHydroMechanics
214 } // 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
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
unsigned getShapeFunctionOrder() const
std::string const & getName() const
int getNumberOfGlobalComponents() const
Returns the number of components of the process variable.
Handles configuration of several secondary variables from the project file.
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
std::unique_ptr< Process > createThermoHydroMechanicsProcess(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::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
template std::unique_ptr< Process > createThermoHydroMechanicsProcess< 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, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
template std::unique_ptr< Process > createThermoHydroMechanicsProcess< 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::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
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)