OGS
Phase.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 "Component.h"
19 
20 namespace MaterialPropertyLib
21 {
22 class Property;
23 }
24 namespace MaterialPropertyLib
25 {
30 class Phase final
31 {
32 public:
34  Phase(std::string&& phase_name,
35  std::vector<std::unique_ptr<Component>>&& components,
36  std::unique_ptr<PropertyArray>&& properties);
37 
40  Component const& component(std::size_t const& index) const;
41  bool hasComponent(std::size_t const& index) const;
42 
44  Component const& component(std::string const& 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 
55  std::size_t numberOfComponents() const;
56 
58  std::string description() const;
59 
60 public:
61  std::string const name;
62 
63 private:
64  std::vector<std::unique_ptr<Component>> const components_;
65 
72 };
73 
74 template <typename Container>
75 void checkRequiredProperties(Phase const& phase, Container const& required_properties)
76 {
77  for (auto const& p : required_properties)
78  {
79  if (!phase.hasProperty(p))
80  {
81  OGS_FATAL("The property '{:s}' is missing in the {:s} phase.",
82  property_enum_to_string[p], phase.name);
83  }
84  }
85 }
86 
87 } // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition: Error.h:26
This class defines components (substances).
Definition: Component.h:25
Property const & property(PropertyType const &p) const
Definition: Phase.cpp:51
PropertyArray properties_
Definition: Phase.h:71
std::string const name
Definition: Phase.h:61
std::string description() const
Short description of the phase with its name.
Definition: Phase.cpp:77
std::size_t numberOfComponents() const
A get-function for retrieving the number of components in this phase.
Definition: Phase.cpp:72
std::vector< std::unique_ptr< Component > > const components_
Definition: Phase.h:64
Property const & operator[](PropertyType const &p) const
Definition: Phase.cpp:62
bool hasProperty(PropertyType const &p) const
Definition: Phase.cpp:67
Phase(std::string &&phase_name, std::vector< std::unique_ptr< Component >> &&components, std::unique_ptr< PropertyArray > &&properties)
The Phase constructor is called with the optional phase name.
Definition: Phase.cpp:21
bool hasComponent(std::size_t const &index) const
Definition: Phase.cpp:37
Component const & component(std::size_t const &index) const
Definition: Phase.cpp:32
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
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96