OGS
MaterialPropertyLib::Medium Class Referencefinal

Detailed Description

This class is for material objects on the Medium scale.

A Medium consists of an arbitrarily long vector of phases and an array of properties.

Definition at line 31 of file Medium.h.

#include <Medium.h>

Public Member Functions

 Medium (int const material_id, std::vector< std::unique_ptr< Phase >> &&phases, std::unique_ptr< PropertyArray > &&properties)
 
Phase const & phase (std::size_t index) const
 
Phase const & phase (std::string const &phase_name) const
 A get-function for a particular phase by phase name. More...
 
bool hasPhase (std::string const &phase_name) const
 A query for a named phase. More...
 
Property const & property (PropertyType const &p) const
 
Property const & operator[] (PropertyType const &p) const
 
bool hasProperty (PropertyType const &p) const
 
std::size_t numberOfPhases () const
 
std::string description () const
 Short description of the medium. More...
 
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
 

Private Attributes

std::vector< std::unique_ptr< Phase > > const phases_
 The vector that holds the phases. More...
 
PropertyArray properties_
 
int const material_id_
 

Constructor & Destructor Documentation

◆ Medium()

MaterialPropertyLib::Medium::Medium ( int const  material_id,
std::vector< std::unique_ptr< Phase >> &&  phases,
std::unique_ptr< PropertyArray > &&  properties 
)

Definition at line 20 of file Medium.cpp.

23  : phases_(std::move(phases)), material_id_(material_id)
24 {
25  if (properties)
26  {
27  overwriteExistingProperties(properties_, *properties, this);
28  }
29 }
std::vector< std::unique_ptr< Phase > > const phases_
The vector that holds the phases.
Definition: Medium.h:94
PropertyArray properties_
Definition: Medium.h:101
void overwriteExistingProperties(PropertyArray &properties, PropertyArray &new_properties, std::variant< Medium *, Phase *, Component * > scale_pointer)
Definition: Property.h:312

References MaterialPropertyLib::overwriteExistingProperties(), and properties_.

Member Function Documentation

◆ d2Value()

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

Definition at line 83 of file Medium.h.

87  {
88  return property(p).template d2Value<T>(variable_array, variable1,
89  variable2);
90  }
Property const & property(PropertyType const &p) const
Definition: Medium.cpp:52

References property().

◆ description()

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

Short description of the medium.

Definition at line 78 of file Medium.cpp.

79 {
80  return "medium " + std::to_string(material_id_);
81 }

References material_id_.

Referenced by property().

◆ dValue()

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

Definition at line 75 of file Medium.h.

78  {
79  return property(p).template dValue<T>(variable_array, variable);
80  }

References property().

◆ hasPhase()

bool MaterialPropertyLib::Medium::hasPhase ( std::string const &  phase_name) const

A query for a named phase.

Definition at line 45 of file Medium.cpp.

46 {
47  return std::any_of(begin(phases_), end(phases_),
48  [&phase_name](auto const& phase)
49  { return phase->name == phase_name; });
50 }
Phase const & phase(std::size_t index) const
Definition: Medium.cpp:31
std::string const name
Definition: Phase.h:61
constexpr bool any_of(List const &values)
Checks if any of the elements in the given list is true.
Definition: Algorithm.h:325

References BaseLib::any_of(), MaterialPropertyLib::Phase::name, phase(), and phases_.

Referenced by MaterialPropertyLib::fluidPhase().

◆ hasProperty()

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

◆ numberOfPhases()

std::size_t MaterialPropertyLib::Medium::numberOfPhases ( ) const

A simple get-function for retrieving the number of phases the medium consists of.

Definition at line 73 of file Medium.cpp.

74 {
75  return phases_.size();
76 }

References phases_.

◆ operator[]()

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

Definition at line 63 of file Medium.cpp.

64 {
65  return property(p);
66 }

References property().

◆ phase() [1/2]

◆ phase() [2/2]

Phase const & MaterialPropertyLib::Medium::phase ( std::string const &  phase_name) const

A get-function for a particular phase by phase name.

Definition at line 36 of file Medium.cpp.

37 {
39  phases_.begin(), phases_.end(),
40  [&phase_name](std::unique_ptr<MaterialPropertyLib::Phase> const& phase)
41  { return phase->name == phase_name; },
42  "Could not find phase name '" + phase_name + "'.");
43 }
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
Definition: Algorithm.h:69

References BaseLib::findElementOrError(), phase(), and phases_.

◆ property()

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

A get-function for a property. The argument refers to the name of the property.

Definition at line 52 of file Medium.cpp.

53 {
54  Property const* const property = properties_[p].get();
55  if (property == nullptr)
56  {
57  OGS_FATAL("Trying to access undefined property '{:s}' of {:s}",
59  }
60  return *properties_[p];
61 }
#define OGS_FATAL(...)
Definition: Error.h:26
std::string description() const
Short description of the medium.
Definition: Medium.cpp:78
static const std::array< std::string, PropertyType::number_of_properties > property_enum_to_string
Definition: PropertyType.h:114

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

Referenced by d2Value(), dValue(), operator[](), ProcessLib::RichardsMechanics::updateSwellingStressAndVolumetricStrain(), and value().

◆ value() [1/2]

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

Definition at line 63 of file Medium.h.

64  {
65  return property(p).template value<T>();
66  }

References property().

◆ value() [2/2]

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

Definition at line 69 of file Medium.h.

70  {
71  return property(p).template value<T>(variable_array);
72  }

References property().

Member Data Documentation

◆ material_id_

int const MaterialPropertyLib::Medium::material_id_
private

The first material id for which the medium was created. Used in the description.

Definition at line 105 of file Medium.h.

Referenced by description().

◆ phases_

std::vector<std::unique_ptr<Phase> > const MaterialPropertyLib::Medium::phases_
private

The vector that holds the phases.

Definition at line 94 of file Medium.h.

Referenced by hasPhase(), numberOfPhases(), and phase().

◆ properties_

PropertyArray MaterialPropertyLib::Medium::properties_
private

The array that holds the medium properties.

Currently, these defaults is the volume fraction average.

Most properties are fine with the volume fraction average, but special-defaults are allowed as well...

Definition at line 101 of file Medium.h.

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


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