OGS
Component.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 <span>
7
8#include "Property.h"
9
10namespace MaterialPropertyLib
11{
18{
19public:
22 Component();
23
25 Component(std::string const& component_name,
26 std::unique_ptr<PropertyArray>&& properties);
27 virtual ~Component() = default;
28
30 Property const& property(PropertyType const& /*p*/) const;
31
32 Property const& operator[](PropertyType const& p) const;
33
34 bool hasProperty(PropertyType const& p) const;
35
36 template <typename T>
37 T value(PropertyType const p) const
38 {
39 return property(p).template value<T>();
40 }
41
42 template <typename T>
43 T value(PropertyType const p, VariableArray const& variable_array) const
44 {
45 return property(p).template value<T>(variable_array);
46 }
47
48 template <typename T>
50 VariableArray const& variable_array,
51 Variable const variable) const
52 {
53 return property(p).template dValue<T>(variable_array, variable);
54 }
55
56 template <typename T>
58 VariableArray const& variable_array,
59 Variable const variable1,
60 Variable const variable2) const
61 {
62 return property(p).template d2Value<T>(variable_array, variable1,
63 variable2);
64 }
65
67 std::string description() const;
68
69public:
70 std::string const name;
71
72protected:
75};
76
85std::unique_ptr<Component> newComponent(std::string const& component_name,
86 bool& isCustomComponent);
87
89 Component const& c,
90 std::span<PropertyType const> const required_properties);
91
92} // namespace MaterialPropertyLib
This class defines components (substances).
Definition Component.h:18
T dValue(PropertyType const p, VariableArray const &variable_array, Variable const variable) const
Definition Component.h:49
Property const & property(PropertyType const &) const
A get-function for retrieving a certain property.
Definition Component.cpp:24
T d2Value(PropertyType const p, VariableArray const &variable_array, Variable const variable1, Variable const variable2) const
Definition Component.h:57
Property const & operator[](PropertyType const &p) const
Definition Component.cpp:36
T value(PropertyType const p) const
Definition Component.h:37
virtual ~Component()=default
T value(PropertyType const p, VariableArray const &variable_array) const
Definition Component.h:43
PropertyArray properties_
The property array of the component.
Definition Component.h:74
bool hasProperty(PropertyType const &p) const
Definition Component.cpp:41
std::string description() const
Short description of the component with its name.
Definition Component.cpp:46
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
std::unique_ptr< Component > newComponent(std::string const &component_name, bool &isCustomComponent)