OGS 6.2.0-97-g4a610c866
CreateRichardsComponentTransportProcess.cpp
Go to the documentation of this file.
1 
11 
14 #include "ParameterLib/Utils.h"
17 
21 
22 namespace ProcessLib
23 {
24 namespace RichardsComponentTransport
25 {
26 std::unique_ptr<Process> createRichardsComponentTransportProcess(
27  MeshLib::Mesh& mesh,
28  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
29  std::vector<ProcessVariable> const& variables,
30  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
31  unsigned const integration_order,
32  BaseLib::ConfigTree const& config)
33 {
35  config.checkConfigParameter("type", "RichardsComponentTransport");
36 
37  DBUG("Create RichardsComponentTransportProcess.");
38 
39  auto const staggered_scheme =
41  config.getConfigParameterOptional<std::string>("coupling_scheme");
42  const bool use_monolithic_scheme =
43  !(staggered_scheme && (*staggered_scheme == "staggered"));
44 
45  // Process variable.
46 
48  auto const pv_config = config.getConfigSubtree("process_variables");
49 
50  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
51  process_variables;
52  if (use_monolithic_scheme) // monolithic scheme.
53  {
54  auto per_process_variables = findProcessVariables(
55  variables, pv_config,
56  {
58  "concentration",
60  "pressure"});
61  process_variables.push_back(std::move(per_process_variables));
62  }
63  else // staggered scheme.
64  {
65  using namespace std::string_literals;
66  for (auto const& variable_name : {"concentration"s, "pressure"s})
67  {
68  auto per_process_variables =
69  findProcessVariables(variables, pv_config, {variable_name});
70  process_variables.push_back(std::move(per_process_variables));
71  }
72  }
73 
74  auto const& porous_medium_configs =
76  config.getConfigSubtree("porous_medium");
77  PorousMediaProperties porous_media_properties{
78  createPorousMediaProperties(mesh, porous_medium_configs, parameters)};
79 
81  auto const& fluid_config = config.getConfigSubtree("fluid");
82 
83  auto fluid_properties =
85 
86  // Parameter for the density of the fluid.
87  auto& fluid_reference_density = ParameterLib::findParameter<double>(
88  config,
90  "fluid_reference_density", parameters, 1);
91  DBUG("Use '%s' as fluid_reference_density parameter.",
92  fluid_reference_density.name.c_str());
93 
94  // Parameter for the longitudinal solute dispersivity.
95  auto const& molecular_diffusion_coefficient = ParameterLib::findParameter<
96  double>(
97  config,
99  "molecular_diffusion_coefficient", parameters, 1);
100  DBUG("Use '%s' as molecular diffusion coefficient parameter.",
101  molecular_diffusion_coefficient.name.c_str());
102 
103  // Parameter for the longitudinal solute dispersivity.
104  auto const& solute_dispersivity_longitudinal = ParameterLib::findParameter<
105  double>(
106  config,
108  "solute_dispersivity_longitudinal", parameters, 1);
109  DBUG("Use '%s' as longitudinal solute dispersivity parameter.",
110  solute_dispersivity_longitudinal.name.c_str());
111 
112  // Parameter for the transverse solute dispersivity.
113  auto const& solute_dispersivity_transverse = ParameterLib::findParameter<
114  double>(
115  config,
117  "solute_dispersivity_transverse", parameters, 1);
118  DBUG("Use '%s' as transverse solute dispersivity parameter.",
119  solute_dispersivity_transverse.name.c_str());
120 
121  // Parameter for the retardation factor.
122  auto const& retardation_factor = ParameterLib::findParameter<double>(
123  config,
125  "retardation_factor", parameters, 1);
126 
127  // Parameter for the decay rate.
128  auto const& decay_rate = ParameterLib::findParameter<double>(
129  config,
131  "decay_rate", parameters, 1);
132 
133  // Specific body force parameter.
134  Eigen::VectorXd specific_body_force;
135  std::vector<double> const b =
137  config.getConfigParameter<std::vector<double>>("specific_body_force");
138  assert(b.size() > 0 && b.size() < 4);
139  if (b.size() < mesh.getDimension())
140  {
141  OGS_FATAL(
142  "specific body force (gravity vector) has %d components, mesh "
143  "dimension is %d",
144  b.size(), mesh.getDimension());
145  }
146  bool const has_gravity = MathLib::toVector(b).norm() > 0;
147  if (has_gravity)
148  {
149  specific_body_force.resize(b.size());
150  std::copy_n(b.data(), b.size(), specific_body_force.data());
151  }
152 
154  std::move(porous_media_properties),
155  fluid_reference_density,
156  std::move(fluid_properties),
157  molecular_diffusion_coefficient,
158  solute_dispersivity_longitudinal,
159  solute_dispersivity_transverse,
160  retardation_factor,
161  decay_rate,
162  specific_body_force,
163  has_gravity};
164 
165  SecondaryVariableCollection secondary_variables;
166 
167  NumLib::NamedFunctionCaller named_function_caller(
168  {"RichardsComponentTransport_concentration_pressure"});
169 
170  ProcessLib::createSecondaryVariables(config, secondary_variables,
171  named_function_caller);
172 
173  return std::make_unique<RichardsComponentTransportProcess>(
174  mesh, std::move(jacobian_assembler), parameters, integration_order,
175  std::move(process_variables), std::move(process_data),
176  std::move(secondary_variables), std::move(named_function_caller),
177  use_monolithic_scheme);
178 }
179 
180 } // namespace RichardsComponentTransport
181 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
std::unique_ptr< Process > createRichardsComponentTransportProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
Builds expression trees of named functions dynamically at runtime.
std::unique_ptr< FluidProperties > createFluidProperties(BaseLib::ConfigTree const &config)
Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase >> const &parameters, int const num_components)
Definition: Utils.h:84
void checkConfigParameter(std::string const &param, T const &value) const
PorousMediaProperties createPorousMediaProperties(MeshLib::Mesh &mesh, BaseLib::ConfigTree const &porous_medium_configs, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
Handles configuration of several secondary variables from the project file.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:63