OGS
CreateRichardsComponentTransportProcess.cpp
Go to the documentation of this file.
1 
12 
19 
20 namespace ProcessLib
21 {
22 namespace RichardsComponentTransport
23 {
24 namespace
25 {
27  MeshLib::Mesh const& mesh,
29 {
30  std::array const required_properties_medium = {
38 
39  std::array const required_properties_liquid_phase = {
42 
43  std::array const required_properties_components = {
47 
48  for (auto const& element : mesh.getElements())
49  {
50  auto const element_id = element->getID();
51 
52  auto const& medium = *media_map.getMedium(element_id);
53  checkRequiredProperties(medium, required_properties_medium);
54 
55  // check if liquid phase definition and the corresponding properties
56  // exist
57  auto const& liquid_phase = medium.phase("AqueousLiquid");
58  checkRequiredProperties(liquid_phase, required_properties_liquid_phase);
59 
60  // check if components and the corresponding properties exist
61  auto const number_of_components = liquid_phase.numberOfComponents();
62  for (std::size_t component_id = 0; component_id < number_of_components;
63  ++component_id)
64  {
65  if (!liquid_phase.hasComponent(component_id))
66  {
67  OGS_FATAL(
68  "The component {:d} in the AqueousLiquid phase isn't "
69  "specified.",
70  component_id);
71  }
72  auto const& component = liquid_phase.component(component_id);
73  checkRequiredProperties(component, required_properties_components);
74  }
75  }
76 }
77 } // namespace
78 
79 std::unique_ptr<Process> createRichardsComponentTransportProcess(
80  std::string name,
81  MeshLib::Mesh& mesh,
82  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
83  std::vector<ProcessVariable> const& variables,
84  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
85  unsigned const integration_order,
86  BaseLib::ConfigTree const& config,
87  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
88 {
90  config.checkConfigParameter("type", "RichardsComponentTransport");
91 
92  DBUG("Create RichardsComponentTransportProcess.");
93 
94  auto const coupling_scheme =
96  config.getConfigParameterOptional<std::string>("coupling_scheme");
97  const bool use_monolithic_scheme =
98  !(coupling_scheme && (*coupling_scheme == "staggered"));
99 
100  // Process variable.
101 
103  auto const pv_config = config.getConfigSubtree("process_variables");
104 
105  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
106  process_variables;
107  if (use_monolithic_scheme) // monolithic scheme.
108  {
109  auto per_process_variables = findProcessVariables(
110  variables, pv_config,
111  {
112  "concentration",
114  "pressure"});
115  if (per_process_variables.size() > 2)
116  {
117  OGS_FATAL(
118  "By now RichardsComponentTransport process only supports "
119  "single component transport simulation.");
120  }
121  process_variables.push_back(std::move(per_process_variables));
122  }
123  else // staggered scheme.
124  {
125  OGS_FATAL("The staggered coupling scheme is not implemented.");
126  }
127 
128  // Specific body force parameter.
129  Eigen::VectorXd specific_body_force;
130  std::vector<double> const b =
132  config.getConfigParameter<std::vector<double>>("specific_body_force");
133  assert(!b.empty() && b.size() < 4);
134  if (b.size() < mesh.getDimension())
135  {
136  OGS_FATAL(
137  "specific body force (gravity vector) has {:d} components, mesh "
138  "dimension is {:d}",
139  b.size(), mesh.getDimension());
140  }
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 
148  auto media_map =
150 
151  DBUG(
152  "Check the media properties of RichardsComponentTransport process ...");
153  checkMPLProperties(mesh, *media_map);
154  DBUG("Media properties verified.");
155 
157  std::move(media_map), specific_body_force, has_gravity};
158 
159  SecondaryVariableCollection secondary_variables;
160 
161  ProcessLib::createSecondaryVariables(config, secondary_variables);
162 
163  return std::make_unique<RichardsComponentTransportProcess>(
164  std::move(name), mesh, std::move(jacobian_assembler), parameters,
165  integration_order, std::move(process_variables),
166  std::move(process_data), std::move(secondary_variables),
167  use_monolithic_scheme);
168 }
169 
170 } // namespace RichardsComponentTransport
171 } // 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 getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:71
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98
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)
@ longitudinal_dispersivity
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:58
@ transversal_dispersivity
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:100
@ retardation_factor
specify retardation factor used in component transport process.
Definition: PropertyType.h:81
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
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, 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)