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 =
51 checkRequiredProperties(liquid_phase, required_properties_liquid_phase);
52
53 // check if components and the corresponding properties exist
54 auto const number_of_components = liquid_phase.numberOfComponents();
55 for (std::size_t component_id = 0; component_id < number_of_components;
56 ++component_id)
57 {
58 if (!liquid_phase.hasComponent(component_id))
59 {
61 "The component {:d} in the AqueousLiquid phase isn't "
62 "specified.",
63 component_id);
64 }
65 auto const& component = liquid_phase.component(component_id);
66 checkRequiredProperties(component, required_properties_components);
67 }
68 }
69}
70} // namespace
71
73 std::string const& name,
74 MeshLib::Mesh& mesh,
75 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
76 std::vector<ProcessVariable> const& variables,
77 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
78 unsigned const integration_order,
79 BaseLib::ConfigTree const& config,
80 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
81{
83 config.checkConfigParameter("type", "RichardsComponentTransport");
84
85 DBUG("Create RichardsComponentTransportProcess.");
86
87 auto const coupling_scheme =
89 config.getConfigParameterOptional<std::string>("coupling_scheme");
90 const bool use_monolithic_scheme =
91 !(coupling_scheme && (*coupling_scheme == "staggered"));
92
94
96 auto const pv_config = config.getConfigSubtree("process_variables");
97
98 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
99 process_variables;
100 if (use_monolithic_scheme) // monolithic scheme.
101 {
104 auto per_process_variables = findProcessVariables(
105 variables, pv_config,
106 {
107 "concentration",
109 "pressure"});
110 if (per_process_variables.size() > 2)
111 {
112 OGS_FATAL(
113 "By now RichardsComponentTransport process only supports "
114 "single component transport simulation.");
115 }
116 process_variables.push_back(std::move(per_process_variables));
117 }
118 else // staggered scheme.
119 {
120 OGS_FATAL("The staggered coupling scheme is not implemented.");
121 }
122
124 // Specific body force parameter.
125 Eigen::VectorXd specific_body_force;
126 std::vector<double> const b =
128 config.getConfigParameter<std::vector<double>>("specific_body_force");
129 assert(!b.empty() && b.size() < 4);
130 if (b.size() < mesh.getDimension())
131 {
132 OGS_FATAL(
133 "specific body force (gravity vector) has {:d} components, mesh "
134 "dimension is {:d}",
135 b.size(), mesh.getDimension());
136 }
137 bool const has_gravity = MathLib::toVector(b).norm() > 0;
138 if (has_gravity)
139 {
140 specific_body_force.resize(b.size());
141 std::copy_n(b.data(), b.size(), specific_body_force.data());
142 }
143
144 auto media_map =
146
147 DBUG(
148 "Check the media properties of RichardsComponentTransport process ...");
149 checkMPLProperties(mesh, media_map);
150 DBUG("Media properties verified.");
151
153 std::move(media_map), specific_body_force, has_gravity};
154
155 SecondaryVariableCollection secondary_variables;
156
157 ProcessLib::createSecondaryVariables(config, secondary_variables);
158
159 return std::make_unique<RichardsComponentTransportProcess>(
160 std::move(name), mesh, std::move(jacobian_assembler), parameters,
161 integration_order, std::move(process_variables),
162 std::move(process_data), std::move(secondary_variables),
163 use_monolithic_scheme);
164}
165
166} // namespace RichardsComponentTransport
167} // 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:101
unsigned getDimension() const
Definition Mesh.h:80
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:218
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)