OGS
CreateTwoPhaseFlowWithPrhoProcess.cpp
Go to the documentation of this file.
1
11
12#include <cassert>
13
16#include "ParameterLib/Utils.h"
23
24namespace ProcessLib
25{
26namespace TwoPhaseFlowWithPrho
27{
29 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
30{
31 std::array const required_medium_properties = {
33 std::array const required_liquid_properties = {
35 std::array const required_gas_properties = {
38
39 for (auto const& m : media)
40 {
41 checkRequiredProperties(*m.second, required_medium_properties);
42 checkRequiredProperties(m.second->phase("AqueousLiquid"),
43 required_liquid_properties);
44 checkRequiredProperties(m.second->phase("Gas"),
45 required_gas_properties);
46 }
47}
48
49std::unique_ptr<Process> createTwoPhaseFlowWithPrhoProcess(
50 std::string const& name,
51 MeshLib::Mesh& mesh,
52 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
53 std::vector<ProcessVariable> const& variables,
54 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
55 unsigned const integration_order,
56 BaseLib::ConfigTree const& config,
57 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
58{
60 config.checkConfigParameter("type", "TWOPHASE_FLOW_PRHO");
61
62 DBUG("Create TwoPhaseFlowProcess with Prho model.");
63
65
67 auto const pv_config = config.getConfigSubtree("process_variables");
68
70 auto per_process_variables = findProcessVariables(
71 variables, pv_config,
72 {
73 "liquid_pressure",
75 "overall_mass_density"});
76 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
77 process_variables;
78 process_variables.push_back(std::move(per_process_variables));
79
80 SecondaryVariableCollection secondary_variables;
81
82 ProcessLib::createSecondaryVariables(config, secondary_variables);
84 // Specific body force
85 std::vector<double> const b =
87 config.getConfigParameter<std::vector<double>>("specific_body_force");
88 assert(!b.empty() && b.size() < 4);
89 Eigen::VectorXd specific_body_force(b.size());
90 bool const has_gravity = MathLib::toVector(b).norm() > 0;
91 if (has_gravity)
92 {
93 std::copy_n(b.data(), b.size(), specific_body_force.data());
94 }
95
97 auto const mass_lumping = config.getConfigParameter<bool>("mass_lumping");
98 // diffusion coeff
99 auto const& diff_coeff_b = ParameterLib::findParameter<double>(
100 config,
102 "diffusion_coeff_component_b", parameters, 1, &mesh);
103 auto const& diff_coeff_a = ParameterLib::findParameter<double>(
104 config,
106 "diffusion_coeff_component_a", parameters, 1, &mesh);
107 auto const& temperature = ParameterLib::findParameter<double>(
108 config,
110 "temperature", parameters, 1, &mesh);
111
113 auto const& mat_config = config.getConfigSubtree("material_property");
114
115 auto const material_ids = materialIDs(mesh);
116 if (material_ids != nullptr)
117 {
118 INFO("The twophase flow is in heterogeneous porous media.");
119 }
120 else
121 {
122 INFO("The twophase flow is in homogeneous porous media.");
123 }
124
125 auto media_map =
127 checkMPLProperties(media);
128
129 std::unique_ptr<TwoPhaseFlowWithPrhoMaterialProperties> material =
130 createTwoPhaseFlowPrhoMaterialProperties(mat_config, material_ids);
131
133 specific_body_force, has_gravity, mass_lumping,
134 diff_coeff_b, diff_coeff_a, temperature,
135 std::move(material), std::move(media_map)};
136
137 return std::make_unique<TwoPhaseFlowWithPrhoProcess>(
138 std::move(name), mesh, std::move(jacobian_assembler), parameters,
139 integration_order, std::move(process_variables),
140 std::move(process_data), std::move(secondary_variables));
141}
142
143} // namespace TwoPhaseFlowWithPrho
144} // namespace ProcessLib
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
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
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)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< TwoPhaseFlowWithPrhoMaterialProperties > createTwoPhaseFlowPrhoMaterialProperties(BaseLib::ConfigTree const &config, MeshLib::PropertyVector< int > const *const material_ids)
std::unique_ptr< Process > createTwoPhaseFlowWithPrhoProcess(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)