OGS
Medium.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <memory>
7#include <span>
8#include <string>
9#include <vector>
10
11#include "Phase.h"
12
13namespace MaterialPropertyLib
14{
15class Property;
16}
17namespace MaterialPropertyLib
18{
23class Medium final
24{
25public:
26 Medium(int const material_id,
27 std::vector<std::unique_ptr<Phase>>&& phases,
28 std::unique_ptr<PropertyArray>&& properties);
29
32 Phase const& phase(std::size_t index) const;
34 Phase const& phase(std::string const& phase_name) const;
35
37 bool hasPhase(std::string const& phase_name) const;
38
41 Property const& property(PropertyType const& p) const;
42
43 Property const& operator[](PropertyType const& p) const;
44
45 bool hasProperty(PropertyType const& p) const;
46
49 std::size_t numberOfPhases() const;
50
52 std::string description() const;
53
54 template <typename T>
55 T value(PropertyType const p) const
56 {
57 return property(p).template value<T>();
58 }
59
60 template <typename T>
61 T value(PropertyType const p, VariableArray const& variable_array) const
62 {
63 return property(p).template value<T>(variable_array);
64 }
65
66 template <typename T>
68 VariableArray const& variable_array,
69 Variable const variable) const
70 {
71 return property(p).template dValue<T>(variable_array, variable);
72 }
73
74 template <typename T>
76 VariableArray const& variable_array,
77 Variable const variable1,
78 Variable const variable2) const
79 {
80 return property(p).template d2Value<T>(variable_array, variable1,
81 variable2);
82 }
83
84private:
86 std::vector<std::unique_ptr<Phase>> const phases_;
94
97 int const material_id_;
98};
99
101 Medium const& medium,
102 std::span<PropertyType const> const required_properties);
103
105Phase const& fluidPhase(Medium const& medium);
106
107} // namespace MaterialPropertyLib
T value(PropertyType const p, VariableArray const &variable_array) const
Definition Medium.h:61
std::size_t numberOfPhases() const
Definition Medium.cpp:66
Phase const & phase(std::size_t index) const
Definition Medium.cpp:24
Medium(int const material_id, std::vector< std::unique_ptr< Phase > > &&phases, std::unique_ptr< PropertyArray > &&properties)
Definition Medium.cpp:12
std::vector< std::unique_ptr< Phase > > const phases_
The vector that holds the phases.
Definition Medium.h:86
bool hasPhase(std::string const &phase_name) const
A query for a named phase.
Definition Medium.cpp:38
T value(PropertyType const p) const
Definition Medium.h:55
PropertyArray properties_
Definition Medium.h:93
T d2Value(PropertyType const p, VariableArray const &variable_array, Variable const variable1, Variable const variable2) const
Definition Medium.h:75
Property const & property(PropertyType const &p) const
Definition Medium.cpp:45
bool hasProperty(PropertyType const &p) const
Definition Medium.cpp:61
Property const & operator[](PropertyType const &p) const
Definition Medium.cpp:56
T dValue(PropertyType const p, VariableArray const &variable_array, Variable const variable) const
Definition Medium.h:67
std::string description() const
Short description of the medium.
Definition Medium.cpp:71
void checkRequiredProperties(Component const &c, std::span< PropertyType const > const required_properties)
Definition Component.cpp:51
std::array< std::unique_ptr< Property >, PropertyType::number_of_properties > PropertyArray
Phase const & fluidPhase(Medium const &medium)
Returns a gas or aqueous liquid phase of the given medium.
Definition Medium.cpp:91