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(int const material_id,
35  std::vector<std::unique_ptr<Phase>>&& phases,
36  std::unique_ptr<PropertyArray>&& properties);
37 
40  Phase const& phase(std::size_t index) const;
42  Phase const& phase(std::string const& phase_name) const;
43 
45  bool hasPhase(std::string const& phase_name) const;
46 
49  Property const& property(PropertyType const& p) const;
50 
51  Property const& operator[](PropertyType const& p) const;
52 
53  bool hasProperty(PropertyType const& p) const;
54 
57  std::size_t numberOfPhases() const;
58 
60  std::string description() const;
61 
62  template <typename T>
63  T value(PropertyType const p) const
64  {
65  return property(p).template value<T>();
66  }
67 
68  template <typename T>
69  T value(PropertyType const p, VariableArray const& variable_array) const
70  {
71  return property(p).template value<T>(variable_array);
72  }
73 
74  template <typename T>
75  T dValue(PropertyType const p,
76  VariableArray const& variable_array,
77  Variable const variable) const
78  {
79  return property(p).template dValue<T>(variable_array, variable);
80  }
81 
82  template <typename T>
83  T d2Value(PropertyType const p,
84  VariableArray const& variable_array,
85  Variable const variable1,
86  Variable const variable2) const
87  {
88  return property(p).template d2Value<T>(variable_array, variable1,
89  variable2);
90  }
91 
92 private:
94  std::vector<std::unique_ptr<Phase>> const phases_;
102 
105  int const material_id_;
106 };
107 
108 template <typename Container>
109 void checkRequiredProperties(Medium const& medium,
110  Container const& required_properties)
111 {
112  for (auto const& p : required_properties)
113  {
114  if (!medium.hasProperty(p))
115  {
116  OGS_FATAL(
117  "The property '{:s}' is missing in the medium definition.",
119  }
120  }
121 }
122 
124 Phase const& fluidPhase(Medium const& medium);
125 
126 } // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition: Error.h:26
T value(PropertyType const p, VariableArray const &variable_array) const
Definition: Medium.h:69
std::size_t numberOfPhases() const
Definition: Medium.cpp:73
Phase const & phase(std::size_t index) const
Definition: Medium.cpp:31
std::vector< std::unique_ptr< Phase > > const phases_
The vector that holds the phases.
Definition: Medium.h:94
bool hasPhase(std::string const &phase_name) const
A query for a named phase.
Definition: Medium.cpp:45
Medium(int const material_id, std::vector< std::unique_ptr< Phase >> &&phases, std::unique_ptr< PropertyArray > &&properties)
Definition: Medium.cpp:20
T value(PropertyType const p) const
Definition: Medium.h:63
PropertyArray properties_
Definition: Medium.h:101
T d2Value(PropertyType const p, VariableArray const &variable_array, Variable const variable1, Variable const variable2) const
Definition: Medium.h:83
Property const & property(PropertyType const &p) const
Definition: Medium.cpp:52
bool hasProperty(PropertyType const &p) const
Definition: Medium.cpp:68
Property const & operator[](PropertyType const &p) const
Definition: Medium.cpp:63
T dValue(PropertyType const p, VariableArray const &variable_array, Variable const variable) const
Definition: Medium.h:75
std::string description() const
Short description of the medium.
Definition: Medium.cpp:78
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:114
Phase const & fluidPhase(Medium const &medium)
Returns a gas or aqueous liquid phase of the given medium.
Definition: Medium.cpp:83
std::array< VariableType, static_cast< int >(Variable::number_of_variables)> VariableArray
Definition: VariableType.h:116
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96