Skip to content
Snippets Groups Projects
Commit 8dd4baa9 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MPL] Description function phase/medium/comp/prop.

Used in error printing.
parent dc06b996
No related branches found
No related tags found
No related merge requests found
...@@ -39,4 +39,9 @@ bool Component::hasProperty(PropertyType const& p) const ...@@ -39,4 +39,9 @@ bool Component::hasProperty(PropertyType const& p) const
{ {
return properties_[p] != nullptr; return properties_[p] != nullptr;
} }
std::string Component::description() const
{
return "component '" + name + "'";
}
} // namespace MaterialPropertyLib } // namespace MaterialPropertyLib
...@@ -66,6 +66,9 @@ public: ...@@ -66,6 +66,9 @@ public:
variable2); variable2);
} }
/// Short description of the component with its name.
std::string description() const;
public: public:
std::string const name; std::string const name;
......
...@@ -56,4 +56,9 @@ std::size_t Medium::numberOfPhases() const ...@@ -56,4 +56,9 @@ std::size_t Medium::numberOfPhases() const
{ {
return phases_.size(); return phases_.size();
} }
std::string Medium::description() const
{
return "medium";
}
} // namespace MaterialPropertyLib } // namespace MaterialPropertyLib
...@@ -47,6 +47,9 @@ public: ...@@ -47,6 +47,9 @@ public:
/// consists of. /// consists of.
std::size_t numberOfPhases() const; std::size_t numberOfPhases() const;
/// Short description of the medium.
std::string description() const;
template <typename T> template <typename T>
T value(PropertyType const p) const T value(PropertyType const p) const
{ {
......
...@@ -70,4 +70,8 @@ std::size_t Phase::numberOfComponents() const ...@@ -70,4 +70,8 @@ std::size_t Phase::numberOfComponents() const
return components_.size(); return components_.size();
} }
std::string Phase::description() const
{
return "phase '" + name + "'";
}
} // namespace MaterialPropertyLib } // namespace MaterialPropertyLib
...@@ -51,6 +51,9 @@ public: ...@@ -51,6 +51,9 @@ public:
/// A get-function for retrieving the number of components in this phase. /// A get-function for retrieving the number of components in this phase.
std::size_t numberOfComponents() const; std::size_t numberOfComponents() const;
/// Short description of the phase with its name.
std::string description() const;
public: public:
std::string const name; std::string const name;
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include <string> #include <string>
#include "Component.h"
#include "Medium.h"
#include "Phase.h"
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
PropertyDataType fromVector(std::vector<double> const& values) PropertyDataType fromVector(std::vector<double> const& values)
...@@ -99,4 +103,12 @@ PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/, ...@@ -99,4 +103,12 @@ PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/,
{ {
return 0.0; return 0.0;
} }
std::string Property::description() const
{
return "property '" + name_ + "' defined for " +
std::visit(
[](auto&& scale) -> std::string { return scale->description(); },
scale_);
}
} // namespace MaterialPropertyLib } // namespace MaterialPropertyLib
...@@ -197,6 +197,7 @@ private: ...@@ -197,6 +197,7 @@ private:
// Empty check for properties which can be defined on every scale, // Empty check for properties which can be defined on every scale,
// medium, phase or component // medium, phase or component
} }
std::string description() const;
private: private:
/// Corresponds to the PropertyDataType /// Corresponds to the PropertyDataType
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment