OGS 6.2.1-97-g73d1aeda3
CreateLiquidFlowProcess.cpp
Go to the documentation of this file.
1 
13 
14 #include <algorithm>
15 
18 #include "ParameterLib/Utils.h"
21 
22 #include "LiquidFlowProcess.h"
23 
24 namespace ProcessLib
25 {
26 namespace LiquidFlow
27 {
28 std::unique_ptr<Process> createLiquidFlowProcess(
29  std::string name,
30  MeshLib::Mesh& mesh,
31  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
32  std::vector<ProcessVariable> const& variables,
33  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
34  unsigned const integration_order,
35  BaseLib::ConfigTree const& config)
36 {
38  config.checkConfigParameter("type", "LIQUID_FLOW");
39 
40  DBUG("Create LiquidFlowProcess.");
41 
42  // Process variable.
43 
45  auto const pv_config = config.getConfigSubtree("process_variables");
46 
47  auto per_process_variables = findProcessVariables(
48  variables, pv_config,
49  {
50  "process_variable"});
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  NumLib::NamedFunctionCaller named_function_caller({"LiquidFlow_pressure"});
58 
59  ProcessLib::createSecondaryVariables(config, secondary_variables,
60  named_function_caller);
61 
62  // Get the gravity vector for the Darcy velocity
64  auto const& darcy_g_config = config.getConfigSubtree("darcy_gravity");
65  const auto gravity_axis_id_input =
67  darcy_g_config.getConfigParameter<int>("axis_id");
68  if (gravity_axis_id_input >= static_cast<int>(mesh.getDimension()))
69  {
70  OGS_FATAL(
71  "The gravity axis must be a number between 0 and one less than the "
72  "mesh dimension, which is %d. Read gravity axis %d from input "
73  "file.",
74  mesh.getDimension(), gravity_axis_id_input);
75  }
76  const auto g =
78  darcy_g_config.getConfigParameter<double>("g");
79  if (g < 0.)
80  {
81  OGS_FATAL("Gravity magnitude must be non-negative.");
82  }
83  const int gravity_axis_id = (g == 0.) ? -1 : gravity_axis_id_input;
84 
85  auto const& refT =
87  config.getConfigParameterOptional<double>("reference_temperature");
88  const double reference_temperature =
89  refT ? *refT
91 
93  auto const& mat_config = config.getConfigSubtree("material_property");
94 
95  auto const material_ids = materialIDs(mesh);
96  if (material_ids)
97  {
98  INFO("The liquid flow is in heterogeneous porous media.");
99  }
100  else
101  {
102  INFO("The liquid flow is in homogeneous porous media.");
103  }
104 
105  return std::make_unique<LiquidFlowProcess>(
106  std::move(name), mesh, std::move(jacobian_assembler), parameters,
107  integration_order, std::move(process_variables),
108  std::move(secondary_variables), std::move(named_function_caller),
109  material_ids, gravity_axis_id, g, reference_temperature, mat_config);
110 }
111 
112 } // namespace LiquidFlow
113 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
std::unique_ptr< Process > createLiquidFlowProcess(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)
T getConfigParameter(std::string const &param) const
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
Builds expression trees of named functions dynamically at runtime.
void checkConfigParameter(std::string const &param, T const &value) const
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:403
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
Handles configuration of several secondary variables from the project file.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
const double CelsiusZeroInKelvin
Zero degrees Celsius in Kelvin.
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:63