OGS 6.2.1-97-g73d1aeda3
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  std::string name,
28  MeshLib::Mesh& mesh,
29  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
30  std::vector<ProcessVariable> const& variables,
31  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
32  unsigned const integration_order,
33  BaseLib::ConfigTree const& config)
34 {
36  config.checkConfigParameter("type", "RichardsComponentTransport");
37 
38  DBUG("Create RichardsComponentTransportProcess.");
39 
40  auto const staggered_scheme =
42  config.getConfigParameterOptional<std::string>("coupling_scheme");
43  const bool use_monolithic_scheme =
44  !(staggered_scheme && (*staggered_scheme == "staggered"));
45 
46  // Process variable.
47 
49  auto const pv_config = config.getConfigSubtree("process_variables");
50 
51  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
52  process_variables;
53  if (use_monolithic_scheme) // monolithic scheme.
54  {
55  auto per_process_variables = findProcessVariables(
56  variables, pv_config,
57  {
59  "concentration",
61  "pressure"});
62  process_variables.push_back(std::move(per_process_variables));
63  }
64  else // staggered scheme.
65  {
66  using namespace std::string_literals;
67  for (auto const& variable_name : {"concentration"s, "pressure"s})
68  {
69  auto per_process_variables =
70  findProcessVariables(variables, pv_config, {variable_name});
71  process_variables.push_back(std::move(per_process_variables));
72  }
73  }
74 
75  auto const& porous_medium_configs =
77  config.getConfigSubtree("porous_medium");
78  PorousMediaProperties porous_media_properties{
79  createPorousMediaProperties(mesh, porous_medium_configs, parameters)};
80 
82  auto const& fluid_config = config.getConfigSubtree("fluid");
83 
84  auto fluid_properties =
86 
87  // Parameter for the density of the fluid.
88  auto& fluid_reference_density = ParameterLib::findParameter<double>(
89  config,
91  "fluid_reference_density", parameters, 1, &mesh);
92  DBUG("Use '%s' as fluid_reference_density parameter.",
93  fluid_reference_density.name.c_str());
94 
95  // Parameter for the longitudinal solute dispersivity.
96  auto const& molecular_diffusion_coefficient = ParameterLib::findParameter<
97  double>(
98  config,
100  "molecular_diffusion_coefficient", parameters, 1, &mesh);
101  DBUG("Use '%s' as molecular diffusion coefficient parameter.",
102  molecular_diffusion_coefficient.name.c_str());
103 
104  // Parameter for the longitudinal solute dispersivity.
105  auto const& solute_dispersivity_longitudinal = ParameterLib::findParameter<
106  double>(
107  config,
109  "solute_dispersivity_longitudinal", parameters, 1, &mesh);
110  DBUG("Use '%s' as longitudinal solute dispersivity parameter.",
111  solute_dispersivity_longitudinal.name.c_str());
112 
113  // Parameter for the transverse solute dispersivity.
114  auto const& solute_dispersivity_transverse = ParameterLib::findParameter<
115  double>(
116  config,
118  "solute_dispersivity_transverse", parameters, 1, &mesh);
119  DBUG("Use '%s' as transverse solute dispersivity parameter.",
120  solute_dispersivity_transverse.name.c_str());
121 
122  // Parameter for the retardation factor.
123  auto const& retardation_factor = ParameterLib::findParameter<double>(
124  config,
126  "retardation_factor", parameters, 1, &mesh);
127 
128  // Parameter for the decay rate.
129  auto const& decay_rate = ParameterLib::findParameter<double>(
130  config,
132  "decay_rate", parameters, 1, &mesh);
133 
134  // Specific body force parameter.
135  Eigen::VectorXd specific_body_force;
136  std::vector<double> const b =
138  config.getConfigParameter<std::vector<double>>("specific_body_force");
139  assert(!b.empty() && b.size() < 4);
140  if (b.size() < mesh.getDimension())
141  {
142  OGS_FATAL(
143  "specific body force (gravity vector) has %d components, mesh "
144  "dimension is %d",
145  b.size(), mesh.getDimension());
146  }
147  bool const has_gravity = MathLib::toVector(b).norm() > 0;
148  if (has_gravity)
149  {
150  specific_body_force.resize(b.size());
151  std::copy_n(b.data(), b.size(), specific_body_force.data());
152  }
153 
155  std::move(porous_media_properties),
156  fluid_reference_density,
157  std::move(fluid_properties),
158  molecular_diffusion_coefficient,
159  solute_dispersivity_longitudinal,
160  solute_dispersivity_transverse,
162  decay_rate,
163  specific_body_force,
164  has_gravity};
165 
166  SecondaryVariableCollection secondary_variables;
167 
168  NumLib::NamedFunctionCaller named_function_caller(
169  {"RichardsComponentTransport_concentration_pressure"});
170 
171  ProcessLib::createSecondaryVariables(config, secondary_variables,
172  named_function_caller);
173 
174  return std::make_unique<RichardsComponentTransportProcess>(
175  std::move(name), mesh, std::move(jacobian_assembler), parameters,
176  integration_order, std::move(process_variables),
177  std::move(process_data), std::move(secondary_variables),
178  std::move(named_function_caller), use_monolithic_scheme);
179 }
180 
181 } // namespace RichardsComponentTransport
182 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase >> const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition: Utils.h:101
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)
Builds expression trees of named functions dynamically at runtime.
std::unique_ptr< FluidProperties > createFluidProperties(BaseLib::ConfigTree const &config)
specify retardation factor used in component transport process.
Definition: PropertyType.h:69
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)
std::unique_ptr< Process > createRichardsComponentTransportProcess(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, unsigned const integration_order, BaseLib::ConfigTree const &config)
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