OGS
CreateRichardsComponentTransportProcess.cpp
Go to the documentation of this file.
1
12
13#include "BaseLib/ConfigTree.h"
20
21namespace ProcessLib
22{
23namespace RichardsComponentTransport
24{
25namespace
26{
27void checkMPLProperties(
28 MeshLib::Mesh const& mesh,
30{
31 std::array const required_properties_medium = {
39
40 std::array const required_properties_liquid_phase = {
43
44 std::array const required_properties_components = {
48
49 for (auto const element_id : mesh.getElements() | MeshLib::views::ids)
50 {
51 auto const& medium = *media_map.getMedium(element_id);
52 checkRequiredProperties(medium, required_properties_medium);
53
54 // check if liquid phase definition and the corresponding properties
55 // exist
56 auto const& liquid_phase = medium.phase("AqueousLiquid");
57 checkRequiredProperties(liquid_phase, required_properties_liquid_phase);
58
59 // check if components and the corresponding properties exist
60 auto const number_of_components = liquid_phase.numberOfComponents();
61 for (std::size_t component_id = 0; component_id < number_of_components;
62 ++component_id)
63 {
64 if (!liquid_phase.hasComponent(component_id))
65 {
67 "The component {:d} in the AqueousLiquid phase isn't "
68 "specified.",
69 component_id);
70 }
71 auto const& component = liquid_phase.component(component_id);
72 checkRequiredProperties(component, required_properties_components);
73 }
74 }
75}
76} // namespace
77
79 std::string const& name,
80 MeshLib::Mesh& mesh,
81 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
82 std::vector<ProcessVariable> const& variables,
83 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
84 unsigned const integration_order,
85 BaseLib::ConfigTree const& config,
86 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
87{
89 config.checkConfigParameter("type", "RichardsComponentTransport");
90
91 DBUG("Create RichardsComponentTransportProcess.");
92
93 auto const coupling_scheme =
95 config.getConfigParameterOptional<std::string>("coupling_scheme");
96 const bool use_monolithic_scheme =
97 !(coupling_scheme && (*coupling_scheme == "staggered"));
98
100
102 auto const pv_config = config.getConfigSubtree("process_variables");
103
104 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
105 process_variables;
106 if (use_monolithic_scheme) // monolithic scheme.
107 {
110 auto per_process_variables = findProcessVariables(
111 variables, pv_config,
112 {
113 "concentration",
115 "pressure"});
116 if (per_process_variables.size() > 2)
117 {
118 OGS_FATAL(
119 "By now RichardsComponentTransport process only supports "
120 "single component transport simulation.");
121 }
122 process_variables.push_back(std::move(per_process_variables));
123 }
124 else // staggered scheme.
125 {
126 OGS_FATAL("The staggered coupling scheme is not implemented.");
127 }
128
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.empty() && b.size() < 4);
136 if (b.size() < mesh.getDimension())
137 {
138 OGS_FATAL(
139 "specific body force (gravity vector) has {:d} components, mesh "
140 "dimension is {:d}",
141 b.size(), mesh.getDimension());
142 }
143 bool const has_gravity = MathLib::toVector(b).norm() > 0;
144 if (has_gravity)
145 {
146 specific_body_force.resize(b.size());
147 std::copy_n(b.data(), b.size(), specific_body_force.data());
148 }
149
150 auto media_map =
152
153 DBUG(
154 "Check the media properties of RichardsComponentTransport process ...");
155 checkMPLProperties(mesh, media_map);
156 DBUG("Media properties verified.");
157
159 std::move(media_map), specific_body_force, has_gravity};
160
161 SecondaryVariableCollection secondary_variables;
162
163 ProcessLib::createSecondaryVariables(config, secondary_variables);
164
165 return std::make_unique<RichardsComponentTransportProcess>(
166 std::move(name), mesh, std::move(jacobian_assembler), parameters,
167 integration_order, std::move(process_variables),
168 std::move(process_data), std::move(secondary_variables),
169 use_monolithic_scheme);
170}
171
172} // namespace RichardsComponentTransport
173} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
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:109
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
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:225
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)