OGS
Medium.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 #include "BaseLib/Error.h"
19 #include "Phase.h"
20 
21 namespace MaterialPropertyLib
22 {
23 class Property;
24 }
25 namespace MaterialPropertyLib
26 {
31 class Medium final
32 {
33 public:
34  Medium(std::vector<std::unique_ptr<Phase>>&& phases,
35  std::unique_ptr<PropertyArray>&& properties);
36 
39  Phase const& phase(std::size_t index) const;
41  Phase const& phase(std::string const& phase_name) const;
42 
44  bool hasPhase(std::string const& phase_name) const;
45 
48  Property const& property(PropertyType const& p) const;
49 
50  Property const& operator[](PropertyType const& p) const;
51 
52  bool hasProperty(PropertyType const& p) const;
53 
56  std::size_t numberOfPhases() const;
57 
59  static std::string description();
60 
61  template <typename T>
62  T value(PropertyType const p) const
63  {
64  return property(p).template value<T>();
65  }
66 
67  template <typename T>
68  T value(PropertyType const p, VariableArray const& variable_array) const
69  {
70  return property(p).template value<T>(variable_array);
71  }
72 
73  template <typename T>
74  T dValue(PropertyType const p,
75  VariableArray const& variable_array,
76  Variable const variable) const
77  {
78  return property(p).template dValue<T>(variable_array, variable);
79  }
80 
81  template <typename T>
82  T d2Value(PropertyType const p,
83  VariableArray const& variable_array,
84  Variable const variable1,
85  Variable const variable2) const
86  {
87  return property(p).template d2Value<T>(variable_array, variable1,
88  variable2);
89  }
90 
91 private:
93  std::vector<std::unique_ptr<Phase>> const phases_;
101 };
102 
103 template <typename Container>
104 void checkRequiredProperties(Medium const& medium,
105  Container const& required_properties)
106 {
107  for (auto const& p : required_properties)
108  {
109  if (!medium.hasProperty(p))
110  {
111  OGS_FATAL(
112  "The property '{:s}' is missing in the medium definition.",
114  }
115  }
116 }
117 
119 Phase const& fluidPhase(Medium const& medium);
120 
121 } // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition: Error.h:26
T value(PropertyType const p, VariableArray const &variable_array) const
Definition: Medium.h:68
std::size_t numberOfPhases() const
Definition: Medium.cpp:72
Phase const & phase(std::size_t index) const
Definition: Medium.cpp:30
Medium(std::vector< std::unique_ptr< Phase >> &&phases, std::unique_ptr< PropertyArray > &&properties)
Definition: Medium.cpp:20
std::vector< std::unique_ptr< Phase > > const phases_
The vector that holds the phases.
Definition: Medium.h:93
bool hasPhase(std::string const &phase_name) const
A query for a named phase.
Definition: Medium.cpp:44
T value(PropertyType const p) const
Definition: Medium.h:62
PropertyArray properties_
Definition: Medium.h:100
T d2Value(PropertyType const p, VariableArray const &variable_array, Variable const variable1, Variable const variable2) const
Definition: Medium.h:82
Property const & property(PropertyType const &p) const
Definition: Medium.cpp:51
bool hasProperty(PropertyType const &p) const
Definition: Medium.cpp:67
static std::string description()
Short description of the medium.
Definition: Medium.cpp:77
Property const & operator[](PropertyType const &p) const
Definition: Medium.cpp:62
T dValue(PropertyType const p, VariableArray const &variable_array, Variable const variable) const
Definition: Medium.h:74
std::array< std::unique_ptr< Property >, PropertyType::number_of_properties > PropertyArray
static const std::array< std::string, PropertyType::number_of_properties > property_enum_to_string
Definition: PropertyType.h:111
Phase const & fluidPhase(Medium const &medium)
Returns a gas or aqueous liquid phase of the given medium.
Definition: Medium.cpp:82
std::array< VariableType, static_cast< int >(Variable::number_of_variables)> VariableArray
Definition: VariableType.h:108
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96