26 namespace ComponentTransport
32 std::array
const required_properties_medium = {
38 std::array
const required_properties_liquid_phase = {
42 std::array
const required_properties_components = {
49 auto const element_id = element->getID();
51 auto const& medium = *media_map.
getMedium(element_id);
56 auto const& liquid_phase = medium.phase(
"AqueousLiquid");
60 auto const number_of_components = liquid_phase.numberOfComponents();
61 for (std::size_t component_id = 0; component_id < number_of_components;
64 if (!liquid_phase.hasComponent(component_id))
67 "The component {:d} in the AqueousLiquid phase isn't "
71 auto const& component = liquid_phase.component(component_id);
80 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
81 std::vector<ProcessVariable>
const& variables,
82 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
83 unsigned const integration_order,
85 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
86 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media,
87 std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
88 chemical_solver_interface)
93 DBUG(
"Create ComponentTransportProcess.");
95 auto const coupling_scheme =
99 const bool use_monolithic_scheme = (coupling_scheme !=
"staggered");
106 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
112 variables, pv_config,
119 auto it = std::find_if(
120 collected_process_variables.cbegin(),
121 collected_process_variables.cend(),
122 [](std::reference_wrapper<ProcessLib::ProcessVariable>
const& pv)
123 { return pv.get().getNumberOfGlobalComponents() != 1; });
125 if (it != collected_process_variables.end())
128 "Number of components for process variable '{:s}' should be 1 "
132 it->get().getNumberOfGlobalComponents());
134 int const hydraulic_process_id = 0;
135 int const first_transport_process_id = use_monolithic_scheme ? 0 : 1;
139 if (use_monolithic_scheme)
141 process_variables.push_back(std::move(collected_process_variables));
145 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>
146 per_process_variable;
148 if (!chemical_solver_interface)
150 for (
auto& pv : collected_process_variables)
152 per_process_variable.emplace_back(pv);
153 process_variables.push_back(std::move(per_process_variable));
158 auto sort_by_component =
159 [&per_process_variable,
160 collected_process_variables](
auto const& c_name)
162 auto pv = std::find_if(collected_process_variables.begin(),
163 collected_process_variables.end(),
164 [&c_name](
auto const& v) ->
bool
165 { return v.get().getName() == c_name; });
167 if (pv == collected_process_variables.end())
170 "Component {:s} given in "
171 "<chemical_system>/<solution>/"
172 "<components> is not found in specified "
173 "coupled processes (see "
174 "<process>/<process_variables>/"
179 per_process_variable.emplace_back(*pv);
180 return std::move(per_process_variable);
183 auto const components =
184 chemical_solver_interface->getComponentList();
186 per_process_variable.emplace_back(collected_process_variables[0]);
187 process_variables.push_back(std::move(per_process_variable));
189 assert(components.size() + 1 == collected_process_variables.size());
190 std::transform(components.begin(), components.end(),
191 std::back_inserter(process_variables),
197 Eigen::VectorXd specific_body_force;
198 std::vector<double>
const b =
201 assert(!b.empty() && b.size() < 4);
205 "specific body force (gravity vector) has {:d} components, mesh "
212 specific_body_force.resize(b.size());
213 std::copy_n(b.data(), b.size(), specific_body_force.data());
216 bool const non_advective_form =
220 bool chemically_induced_porosity_change =
225 auto const temperature = ParameterLib::findOptionalTagParameter<double>(
227 config,
"temperature_field", parameters, 1, &mesh);
237 DBUG(
"Check the media properties of ComponentTransport process ...");
239 DBUG(
"Media properties verified.");
242 std::move(media_map),
247 chemically_induced_porosity_change,
248 chemical_solver_interface.get(),
249 std::move(lookup_table),
250 hydraulic_process_id,
251 first_transport_process_id};
257 std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
258 auto surfaceflux_config =
261 if (surfaceflux_config)
264 *surfaceflux_config, meshes);
267 return std::make_unique<ComponentTransportProcess>(
268 std::move(
name), mesh, std::move(jacobian_assembler), parameters,
269 integration_order, std::move(process_variables),
270 std::move(process_data), std::move(secondary_variables),
271 use_monolithic_scheme, std::move(surfaceflux),
272 std::move(chemical_solver_interface));
void DBUG(char const *fmt, Args const &... args)
void checkConfigParameter(std::string const ¶m, T const &value) const
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
std::optional< T > getConfigParameterOptional(std::string const ¶m) const
T getConfigParameter(std::string const ¶m) const
ConfigTree getConfigSubtree(std::string const &root) const
Medium * getMedium(std::size_t element_id)
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
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.
@ transversal_dispersivity
used to compute the hydrodynamic dispersion tensor.
@ retardation_factor
specify retardation factor used in component transport process.
void checkRequiredProperties(Component const &c, Container const &required_properties)
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::unique_ptr< Process > createComponentTransportProcess(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 ¶meters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media, std::unique_ptr< ChemistryLib::ChemicalSolverInterface > &&chemical_solver_interface)
std::unique_ptr< LookupTable > createLookupTable(std::optional< std::string > const tabular_file, std::vector< std::vector< std::reference_wrapper< ProcessVariable >>> const &process_variables)
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
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)
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes)