OGS 6.1.0-1699-ge946d4c5f
CreateRichardsComponentTransportProcess.cpp
Go to the documentation of this file.
1 
11 
13 
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<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= 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 = findParameter<double>(
96  config,
98  "molecular_diffusion_coefficient", parameters, 1);
99  DBUG("Use '%s' as molecular diffusion coefficient parameter.",
100  molecular_diffusion_coefficient.name.c_str());
101 
102  // Parameter for the longitudinal solute dispersivity.
103  auto const& solute_dispersivity_longitudinal = findParameter<double>(
104  config,
106  "solute_dispersivity_longitudinal", parameters, 1);
107  DBUG("Use '%s' as longitudinal solute dispersivity parameter.",
108  solute_dispersivity_longitudinal.name.c_str());
109 
110  // Parameter for the transverse solute dispersivity.
111  auto const& solute_dispersivity_transverse = findParameter<double>(
112  config,
114  "solute_dispersivity_transverse", parameters, 1);
115  DBUG("Use '%s' as transverse solute dispersivity parameter.",
116  solute_dispersivity_transverse.name.c_str());
117 
118  // Parameter for the retardation factor.
119  auto const& retardation_factor = findParameter<double>(
120  config,
122  "retardation_factor", parameters, 1);
123 
124  // Parameter for the decay rate.
125  auto const& decay_rate = findParameter<double>(
126  config,
128  "decay_rate", parameters, 1);
129 
130  // Specific body force parameter.
131  Eigen::VectorXd specific_body_force;
132  std::vector<double> const b =
134  config.getConfigParameter<std::vector<double>>("specific_body_force");
135  assert(b.size() > 0 && b.size() < 4);
136  if (b.size() < mesh.getDimension())
137  OGS_FATAL(
138  "specific body force (gravity vector) has %d components, mesh "
139  "dimension is %d",
140  b.size(), mesh.getDimension());
141  bool const has_gravity = MathLib::toVector(b).norm() > 0;
142  if (has_gravity)
143  {
144  specific_body_force.resize(b.size());
145  std::copy_n(b.data(), b.size(), specific_body_force.data());
146  }
147 
149  std::move(porous_media_properties),
150  fluid_reference_density,
151  std::move(fluid_properties),
152  molecular_diffusion_coefficient,
153  solute_dispersivity_longitudinal,
154  solute_dispersivity_transverse,
155  retardation_factor,
156  decay_rate,
157  specific_body_force,
158  has_gravity};
159 
160  SecondaryVariableCollection secondary_variables;
161 
162  NumLib::NamedFunctionCaller named_function_caller(
163  {"RichardsComponentTransport_concentration_pressure"});
164 
165  ProcessLib::createSecondaryVariables(config, secondary_variables,
166  named_function_caller);
167 
168  return std::make_unique<RichardsComponentTransportProcess>(
169  mesh, std::move(jacobian_assembler), parameters, integration_order,
170  std::move(process_variables), std::move(process_data),
171  std::move(secondary_variables), std::move(named_function_caller),
172  use_monolithic_scheme);
173 }
174 
175 } // namespace RichardsComponentTransport
176 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
PorousMediaProperties createPorousMediaProperties(MeshLib::Mesh &mesh, BaseLib::ConfigTree const &porous_medium_configs, std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters)
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)
void checkConfigParameter(std::string const &param, T const &value) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
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:71
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< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)