OGS
CreateRichardsComponentTransportProcess.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
13
14namespace ProcessLib
15{
17{
18namespace
19{
21 MeshLib::Mesh const& mesh,
23{
24 std::array const required_properties_medium = {
32
33 std::array const required_properties_liquid_phase = {
36
37 std::array const required_properties_components = {
41
42 for (auto const element_id : mesh.getElements() | MeshLib::views::ids)
43 {
44 auto const& medium = *media_map.getMedium(element_id);
45 checkRequiredProperties(medium, required_properties_medium);
46
47 // check if liquid phase definition and the corresponding properties
48 // exist
49 auto const& liquid_phase = medium.phase("AqueousLiquid");
50 checkRequiredProperties(liquid_phase, required_properties_liquid_phase);
51
52 // check if components and the corresponding properties exist
53 auto const number_of_components = liquid_phase.numberOfComponents();
54 for (std::size_t component_id = 0; component_id < number_of_components;
55 ++component_id)
56 {
57 if (!liquid_phase.hasComponent(component_id))
58 {
60 "The component {:d} in the AqueousLiquid phase isn't "
61 "specified.",
62 component_id);
63 }
64 auto const& component = liquid_phase.component(component_id);
65 checkRequiredProperties(component, required_properties_components);
66 }
67 }
68}
69} // namespace
70
72 std::string const& name,
73 MeshLib::Mesh& mesh,
74 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
75 std::vector<ProcessVariable> const& variables,
76 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
77 unsigned const integration_order,
78 BaseLib::ConfigTree const& config,
79 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
80{
82 config.checkConfigParameter("type", "RichardsComponentTransport");
83
84 DBUG("Create RichardsComponentTransportProcess.");
85
86 auto const coupling_scheme =
88 config.getConfigParameterOptional<std::string>("coupling_scheme");
89 const bool use_monolithic_scheme =
90 !(coupling_scheme && (*coupling_scheme == "staggered"));
91
93
95 auto const pv_config = config.getConfigSubtree("process_variables");
96
97 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
98 process_variables;
99 if (use_monolithic_scheme) // monolithic scheme.
100 {
103 auto per_process_variables = findProcessVariables(
104 variables, pv_config,
105 {
106 "concentration",
108 "pressure"});
109 if (per_process_variables.size() > 2)
110 {
111 OGS_FATAL(
112 "By now RichardsComponentTransport process only supports "
113 "single component transport simulation.");
114 }
115 process_variables.push_back(std::move(per_process_variables));
116 }
117 else // staggered scheme.
118 {
119 OGS_FATAL("The staggered coupling scheme is not implemented.");
120 }
121
123 // Specific body force parameter.
124 Eigen::VectorXd specific_body_force;
125 std::vector<double> const b =
127 config.getConfigParameter<std::vector<double>>("specific_body_force");
128 assert(!b.empty() && b.size() < 4);
129 if (b.size() < mesh.getDimension())
130 {
131 OGS_FATAL(
132 "specific body force (gravity vector) has {:d} components, mesh "
133 "dimension is {:d}",
134 b.size(), mesh.getDimension());
135 }
136 bool const has_gravity = MathLib::toVector(b).norm() > 0;
137 if (has_gravity)
138 {
139 specific_body_force.resize(b.size());
140 std::copy_n(b.data(), b.size(), specific_body_force.data());
141 }
142
143 auto media_map =
145
146 DBUG(
147 "Check the media properties of RichardsComponentTransport process ...");
148 checkMPLProperties(mesh, media_map);
149 DBUG("Media properties verified.");
150
152 std::move(media_map), specific_body_force, has_gravity};
153
154 SecondaryVariableCollection secondary_variables;
155
156 ProcessLib::createSecondaryVariables(config, secondary_variables);
157
158 return std::make_unique<RichardsComponentTransportProcess>(
159 std::move(name), mesh, std::move(jacobian_assembler), parameters,
160 integration_order, std::move(process_variables),
161 std::move(process_data), std::move(secondary_variables),
162 use_monolithic_scheme);
163}
164
165} // namespace RichardsComponentTransport
166} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:100
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:79
Handles configuration of several secondary variables from the project file.
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
@ longitudinal_dispersivity
used to compute the hydrodynamic dispersion tensor.
@ transversal_dispersivity
used to compute the hydrodynamic dispersion tensor.
@ retardation_factor
specify retardation factor used in component transport process.
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:216
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
std::unique_ptr< Process > createRichardsComponentTransportProcess(std::string const &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)