OGS
CreateThermalTwoPhaseFlowWithPPProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
15 #include "ParameterLib/Utils.h"
22 
23 namespace ProcessLib
24 {
25 namespace ThermalTwoPhaseFlowWithPP
26 {
27 std::unique_ptr<Process> createThermalTwoPhaseFlowWithPPProcess(
28  std::string name,
29  MeshLib::Mesh& mesh,
30  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
31  std::vector<ProcessVariable> const& variables,
32  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
33  unsigned const integration_order,
34  BaseLib::ConfigTree const& config,
35  std::map<std::string,
36  std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
37  curves)
38 {
40  config.checkConfigParameter("type", "THERMAL_TWOPHASE_WITH_PP");
41 
42  DBUG("Create nonisothermal two-phase flow model.");
44  auto const pv_config = config.getConfigSubtree("process_variables");
45 
46  auto per_process_variables = findProcessVariables(
47  variables, pv_config,
48  {
49  "gas_pressure",
51  "capillary_pressure",
53  "temperature"});
54  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
55  process_variables;
56  process_variables.push_back(std::move(per_process_variables));
57 
58  SecondaryVariableCollection secondary_variables;
59 
60  ProcessLib::createSecondaryVariables(config, secondary_variables);
61  // Specific body force
62  std::vector<double> const b =
64  config.getConfigParameter<std::vector<double>>("specific_body_force");
65  assert(!b.empty() && b.size() < 4);
66  Eigen::VectorXd specific_body_force(b.size());
67  bool const has_gravity = MathLib::toVector(b).norm() > 0;
68  if (has_gravity)
69  {
70  std::copy_n(b.data(), b.size(), specific_body_force.data());
71  }
72 
74  auto mass_lumping = config.getConfigParameter<bool>("mass_lumping");
75  // diffusion coeff
76  auto const& diff_coeff_b = ParameterLib::findParameter<double>(
77  config,
79  "diffusion_coeff_component_b", parameters, 1, &mesh);
80  auto const& diff_coeff_a = ParameterLib::findParameter<double>(
81  config,
83  "diffusion_coeff_component_a", parameters, 1, &mesh);
84 
85  // Parameter for the density of the solid.
86 
87  auto const& density_solid = ParameterLib::findParameter<double>(
88  config,
90  "density_solid", parameters, 1, &mesh);
91  DBUG("Use '{:s}' as density_solid parameter.", density_solid.name);
92 
93  // Parameter for the latent heat of evaporation.
94  auto const& latent_heat_evaporation = ParameterLib::findParameter<double>(
95  config,
97  "latent_heat_evaporation", parameters, 1, &mesh);
98  DBUG("Use '{:s}' as latent_heat_evaporation parameter.",
99  latent_heat_evaporation.name);
100 
102  auto const& mat_config = config.getConfigSubtree("material_property");
103 
104  std::unique_ptr<ThermalTwoPhaseFlowWithPPMaterialProperties> material =
106  mat_config, materialIDs(mesh), parameters);
107 
108  ThermalTwoPhaseFlowWithPPProcessData process_data{specific_body_force,
109  has_gravity,
110  mass_lumping,
111  diff_coeff_b,
112  diff_coeff_a,
113  density_solid,
114  latent_heat_evaporation,
115  std::move(material)};
116 
117  return std::make_unique<ThermalTwoPhaseFlowWithPPProcess>(
118  std::move(name), mesh, std::move(jacobian_assembler), parameters,
119  integration_order, std::move(process_variables),
120  std::move(process_data), std::move(secondary_variables), mat_config,
121  curves);
122 }
123 
124 } // namespace ThermalTwoPhaseFlowWithPP
125 } // namespace ProcessLib
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
Handles configuration of several secondary variables from the project file.
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
std::unique_ptr< ThermalTwoPhaseFlowWithPPMaterialProperties > createThermalTwoPhaseFlowWithPPMaterialProperties(BaseLib::ConfigTree const &config, MeshLib::PropertyVector< int > const *material_ids, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
std::unique_ptr< Process > createThermalTwoPhaseFlowWithPPProcess(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 &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
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)