OGS
CreateTwoPhaseFlowWithPPProcess.cpp
Go to the documentation of this file.
1
11
12#include <cassert>
13
16#include "ParameterLib/Utils.h"
21namespace ProcessLib
22{
23namespace TwoPhaseFlowWithPP
24{
25std::unique_ptr<Process> createTwoPhaseFlowWithPPProcess(
26 std::string const& name,
27 MeshLib::Mesh& mesh,
28 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
29 std::vector<ProcessVariable> const& variables,
30 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
31 unsigned const integration_order,
32 BaseLib::ConfigTree const& config,
33 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
34{
36 config.checkConfigParameter("type", "TWOPHASE_FLOW_PP");
37
39
40 DBUG("Create TwoPhaseFlowProcess with PP model.");
42 auto const pv_config = config.getConfigSubtree("process_variables");
43
45 auto per_process_variables = findProcessVariables(
46 variables, pv_config,
47 {
48 "gas_pressure",
50 "capillary_pressure"});
51 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
52 process_variables;
53 process_variables.push_back(std::move(per_process_variables));
54
55 SecondaryVariableCollection secondary_variables;
56
57 ProcessLib::createSecondaryVariables(config, secondary_variables);
58
60 // Specific body force
61 std::vector<double> const b =
63 config.getConfigParameter<std::vector<double>>("specific_body_force");
64 assert(!b.empty() && b.size() < 4);
65 Eigen::VectorXd specific_body_force(b.size());
66 bool const has_gravity = MathLib::toVector(b).norm() > 0;
67 if (has_gravity)
68 {
69 std::copy_n(b.data(), b.size(), specific_body_force.data());
70 }
71
73 auto const mass_lumping = config.getConfigParameter<bool>("mass_lumping");
74
75 auto const& temperature = ParameterLib::findParameter<double>(
76 config,
78 "temperature", parameters, 1, &mesh);
79
80 auto const material_ids = materialIDs(mesh);
81 if (material_ids)
82 {
83 INFO("The twophase flow is in heterogeneous porous media.");
84 }
85 else
86 {
87 INFO("The twophase flow is in homogeneous porous media.");
88 }
89
90 auto media_map =
92
93 TwoPhaseFlowWithPPProcessData process_data{specific_body_force, has_gravity,
94 mass_lumping, temperature,
95 std::move(media_map)};
96
97 return std::make_unique<TwoPhaseFlowWithPPProcess>(
98 std::move(name), mesh, std::move(jacobian_assembler), parameters,
99 integration_order, std::move(process_variables),
100 std::move(process_data), std::move(secondary_variables));
101}
102
103} // namespace TwoPhaseFlowWithPP
104} // 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.
std::unique_ptr< Process > createTwoPhaseFlowWithPPProcess(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)