OGS
MaterialPropertyLib::Component Class Reference

Detailed Description

This class defines components (substances).

The Component class is a base class used for not further specified components. Components are specified by the property 'name'. For specified components we derive special classes from this class (for clarity they are located in the 'components' subfolder).

Definition at line 24 of file Component.h.

#include <Component.h>

Inheritance diagram for MaterialPropertyLib::Component:
[legend]

Public Member Functions

 Component ()
 
 Component (std::string const &component_name, std::unique_ptr< PropertyArray > &&properties)
 Constructor for a custom component. More...
 
virtual ~Component ()=default
 
Property const & property (PropertyType const &) const
 A get-function for retrieving a certain property. More...
 
Property const & operator[] (PropertyType const &p) const
 
bool hasProperty (PropertyType const &p) const
 
template<typename T >
value (PropertyType const p) const
 
template<typename T >
value (PropertyType const p, VariableArray const &variable_array) const
 
template<typename T >
dValue (PropertyType const p, VariableArray const &variable_array, Variable const variable) const
 
template<typename T >
d2Value (PropertyType const p, VariableArray const &variable_array, Variable const variable1, Variable const variable2) const
 
std::string description () const
 Short description of the component with its name. More...
 

Public Attributes

std::string const name
 

Protected Attributes

PropertyArray properties_
 The property array of the component. More...
 

Constructor & Destructor Documentation

◆ Component() [1/2]

MaterialPropertyLib::Component::Component ( )

Default constructor of Component. This constructor is used when the component is not specified via the 'name'-tag.

Definition at line 20 of file Component.cpp.

20 {}

◆ Component() [2/2]

MaterialPropertyLib::Component::Component ( std::string const &  component_name,
std::unique_ptr< PropertyArray > &&  properties 
)

Constructor for a custom component.

Definition at line 22 of file Component.cpp.

24  : name(component_name)
25 {
26  if (properties)
27  {
28  overwriteExistingProperties(properties_, *properties, this);
29  }
30 }
std::string const name
Definition: Component.h:77
PropertyArray properties_
The property array of the component.
Definition: Component.h:81
void overwriteExistingProperties(PropertyArray &properties, PropertyArray &new_properties, std::variant< Medium *, Phase *, Component * > scale_pointer)
Definition: Property.h:322

References MaterialPropertyLib::overwriteExistingProperties(), and properties_.

◆ ~Component()

virtual MaterialPropertyLib::Component::~Component ( )
virtualdefault

Member Function Documentation

◆ d2Value()

template<typename T >
T MaterialPropertyLib::Component::d2Value ( PropertyType const  p,
VariableArray const &  variable_array,
Variable const  variable1,
Variable const  variable2 
) const
inline

Definition at line 64 of file Component.h.

68  {
69  return property(p).template d2Value<T>(variable_array, variable1,
70  variable2);
71  }
Property const & property(PropertyType const &) const
A get-function for retrieving a certain property.
Definition: Component.cpp:32

References property().

◆ description()

std::string MaterialPropertyLib::Component::description ( ) const

Short description of the component with its name.

Definition at line 54 of file Component.cpp.

55 {
56  return "component '" + name + "'";
57 }

References name.

Referenced by property().

◆ dValue()

template<typename T >
T MaterialPropertyLib::Component::dValue ( PropertyType const  p,
VariableArray const &  variable_array,
Variable const  variable 
) const
inline

Definition at line 56 of file Component.h.

59  {
60  return property(p).template dValue<T>(variable_array, variable);
61  }

References property().

◆ hasProperty()

bool MaterialPropertyLib::Component::hasProperty ( PropertyType const &  p) const

Definition at line 49 of file Component.cpp.

50 {
51  return properties_[p] != nullptr;
52 }

References properties_.

◆ operator[]()

Property const & MaterialPropertyLib::Component::operator[] ( PropertyType const &  p) const

Definition at line 44 of file Component.cpp.

45 {
46  return property(p);
47 }

References property().

◆ property()

Property const & MaterialPropertyLib::Component::property ( PropertyType const &  p) const

A get-function for retrieving a certain property.

Definition at line 32 of file Component.cpp.

33 {
34  Property const* const property = properties_[p].get();
35  if (property == nullptr)
36  {
37  OGS_FATAL("Trying to access undefined property '{:s}' of {:s}",
39  }
40 
41  return *properties_[p];
42 }
#define OGS_FATAL(...)
Definition: Error.h:26
std::string description() const
Short description of the component with its name.
Definition: Component.cpp:54
static const std::array< std::string, PropertyType::number_of_properties > property_enum_to_string
Definition: PropertyType.h:115

References description(), OGS_FATAL, properties_, and MaterialPropertyLib::property_enum_to_string.

Referenced by d2Value(), dValue(), operator[](), and value().

◆ value() [1/2]

template<typename T >
T MaterialPropertyLib::Component::value ( PropertyType const  p) const
inline

Definition at line 44 of file Component.h.

45  {
46  return property(p).template value<T>();
47  }

References property().

◆ value() [2/2]

template<typename T >
T MaterialPropertyLib::Component::value ( PropertyType const  p,
VariableArray const &  variable_array 
) const
inline

Definition at line 50 of file Component.h.

51  {
52  return property(p).template value<T>(variable_array);
53  }

References property().

Member Data Documentation

◆ name

std::string const MaterialPropertyLib::Component::name

Definition at line 77 of file Component.h.

Referenced by description().

◆ properties_

PropertyArray MaterialPropertyLib::Component::properties_
protected

The property array of the component.

Definition at line 81 of file Component.h.

Referenced by Component(), hasProperty(), and property().


The documentation for this class was generated from the following files: