ABLATE Source Documentation  0.12.34
transportModel.hpp
1 #ifndef ABLATELIBRARY_TRANSPORTMODEL_HPP
2 #define ABLATELIBRARY_TRANSPORTMODEL_HPP
3 
4 #include <petscsystypes.h>
5 #include "eos/eos.hpp"
6 namespace ablate::eos::transport {
7 
8 enum class TransportProperty { Conductivity, Viscosity, Diffusivity };
9 
11  public:
12  virtual ~TransportModel() = default;
13 
20  [[nodiscard]] virtual ThermodynamicFunction GetTransportFunction(TransportProperty property, const std::vector<domain::Field>& fields) const = 0;
21 
28  [[nodiscard]] virtual ThermodynamicTemperatureFunction GetTransportTemperatureFunction(TransportProperty property, const std::vector<domain::Field>& fields) const = 0;
29 };
30 
36 constexpr std::string_view to_string(const TransportProperty& prop) {
37  switch (prop) {
38  case TransportProperty::Conductivity:
39  return "conductivity";
40  case TransportProperty::Viscosity:
41  return "viscosity";
42  case TransportProperty::Diffusivity:
43  return "diffusivity";
44  }
45  return "";
46 }
47 
53 constexpr TransportProperty from_string(const std::string_view& prop) {
54  if (prop == "conductivity") return TransportProperty::Conductivity;
55  if (prop == "viscosity") return TransportProperty::Viscosity;
56  if (prop == "diffusivity") return TransportProperty::Diffusivity;
57  throw std::invalid_argument("No known TransportProperty for " + std::string(prop));
58 }
59 
66 inline std::ostream& operator<<(std::ostream& out, const TransportProperty& prop) {
67  auto string = to_string(prop);
68  out << string;
69  return out;
70 }
71 
78 inline std::istream& operator>>(std::istream& in, TransportProperty& prop) {
79  std::string propString;
80  in >> propString;
81  prop = from_string(propString);
82  return in;
83 }
84 
85 } // namespace ablate::eos::transport
86 #endif // ABLATELIBRARY_TRANSPORTMODEL_HPP
Definition: transportModel.hpp:10
virtual ThermodynamicFunction GetTransportFunction(TransportProperty property, const std::vector< domain::Field > &fields) const =0
virtual ThermodynamicTemperatureFunction GetTransportTemperatureFunction(TransportProperty property, const std::vector< domain::Field > &fields) const =0