SESubstanceTransport.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 #ifdef MSVC
6  #pragma warning(disable : 4503)
7 #endif
8 
9 #define SUBSTANCE_TRANSPORTER_TEMPLATE typename GraphType, typename FluxUnit, typename QuantityUnit, typename ExtensiveUnit, typename IntensiveUnit
10 
11 #define TRANSPORT_AMOUNT_TYPES ExtensiveScalar, IntensiveScalar
12 template<typename ExtensiveScalar, typename IntensiveScalar>
14 {
15  template<SUBSTANCE_TRANSPORTER_TEMPLATE> friend class SESubstanceTransporter;
16 public:
18 
19  virtual void Invalidate() = 0;
20 
21  virtual bool HasExtensive() const = 0;
22  virtual ExtensiveScalar& GetExtensive() = 0;
23 
24  virtual bool HasIntensive() const = 0;
25  virtual IntensiveScalar& GetIntensive() = 0;
26 };
29 
30 #define TRANSPORT_VERTEX_TYPES QuantityScalar, ExtensiveScalar, IntensiveScalar
31 template <typename QuantityScalar, typename ExtensiveScalar, typename IntensiveScalar>
33 {
34  template<SUBSTANCE_TRANSPORTER_TEMPLATE> friend class SESubstanceTransporter;
35 public:
37 
38  virtual std::string GetName() const = 0;
39 
40 protected:
41  virtual bool HasQuantity() const = 0;
42  virtual QuantityScalar& GetQuantity() = 0;
43 
44  virtual std::vector<SESubstanceTransportAmount<TRANSPORT_AMOUNT_TYPES>*>& GetTransportSubstances() = 0;
45 };
48 
49 #define TRANSPORT_EDGE_TYPES FluxScalar, QuantityScalar, ExtensiveScalar, IntensiveScalar
50 template <typename FluxScalar, typename QuantityScalar, typename ExtensiveScalar, typename IntensiveScalar>
52 {
53  template<SUBSTANCE_TRANSPORTER_TEMPLATE> friend class SESubstanceTransporter;
54 public:
56 
57  virtual std::string GetName() const = 0;
58 
59 protected:
60  virtual bool HasFlux() const = 0;
61  virtual FluxScalar& GetFlux() = 0;
62 
63  virtual SESubstanceTransportVertex<TRANSPORT_VERTEX_TYPES>& GetSourceVertex() = 0;
64  virtual SESubstanceTransportVertex<TRANSPORT_VERTEX_TYPES>& GetTargetVertex() = 0;
65 };
68 
69 template <typename FluxScalar, typename QuantityScalar, typename ExtensiveScalar, typename IntensiveScalar>
71 {
72  template<SUBSTANCE_TRANSPORTER_TEMPLATE> friend class SESubstanceTransporter;
73 public:
75 
76 protected:
77  virtual void BalanceByIntensive() = 0;// Transporter calculates the new concentration
78  virtual size_t GetVertexIndex(const SESubstanceTransportVertex<TRANSPORT_VERTEX_TYPES>& v) const = 0;
79  virtual const std::vector<SESubstanceTransportVertex<TRANSPORT_VERTEX_TYPES>*>& GetVerticies() const = 0;
80  virtual const std::vector<SESubstanceTransportEdge<TRANSPORT_EDGE_TYPES>*>* GetSourceEdges(const SESubstanceTransportVertex<TRANSPORT_VERTEX_TYPES>& v) const = 0;
81  virtual const std::vector<SESubstanceTransportEdge<TRANSPORT_EDGE_TYPES>*>* GetTargetEdges(const SESubstanceTransportVertex<TRANSPORT_VERTEX_TYPES>& v) const = 0;
82 };
85 
86 template <SUBSTANCE_TRANSPORTER_TEMPLATE>
88 {
89 public:
90  SESubstanceTransporter(const FluxUnit& fUnit, const QuantityUnit& qUnit, const ExtensiveUnit& eUnit, const IntensiveUnit& iUnit, Logger* logger);
92 
93  void Transport(GraphType& graph, double timeStep_s);
94 
95 protected:
96  const FluxUnit &m_FluxUnit;
97  const QuantityUnit &m_QuantityUnit;
98  const ExtensiveUnit &m_ExtensiveUnit;
99  const IntensiveUnit &m_IntensiveUnit;
100 };
101 
102 class SEGasTransporter : public SESubstanceTransporter<SEGasTransportGraph, VolumePerTimeUnit, VolumeUnit, VolumeUnit, NoUnit>
103 {
104 public:
105  SEGasTransporter(Logger* logger);
106  SEGasTransporter(const VolumePerTimeUnit& fUnit, const VolumeUnit& qUnit, const VolumeUnit& eUnit, Logger* logger);
107  ~SEGasTransporter();
108 };
109 
110 class SELiquidTransporter : public SESubstanceTransporter<SELiquidTransportGraph, VolumePerTimeUnit, VolumeUnit, MassUnit, MassPerVolumeUnit>
111 {
112 public:
113  SELiquidTransporter(Logger* logger);
114  SELiquidTransporter(const VolumePerTimeUnit& fUnit, const VolumeUnit& qUnit, const MassUnit& eUnit, const MassPerVolumeUnit& iUnit, Logger* logger);
116 };
117 
118 #include "substance/SESubstanceTransport.inl"
Definition: SESubstanceTransport.h:13
Definition: SEScalarVolume.h:7
virtual ~SESubstanceTransportVertex()
Definition: SESubstanceTransport.h:36
virtual IntensiveScalar & GetIntensive()=0
Definition: Logger.h:61
Definition: SEScalarMassPerVolume.h:7
Definition: SESubstanceTransport.h:70
virtual ExtensiveScalar & GetExtensive()=0
const FluxUnit & m_FluxUnit
Definition: SESubstanceTransport.h:96
Definition: SEScalarVolumePerTime.h:7
Definition: SESubstanceTransport.h:51
Definition: Logger.h:11
virtual ~SESubstanceTransporter()
Definition: SESubstanceTransport.h:91
friend class SESubstanceTransporter
Definition: SESubstanceTransport.h:15
virtual bool HasExtensive() const =0
virtual bool HasIntensive() const =0
Definition: SESubstanceTransport.h:32
Definition: SESubstanceTransport.h:110
virtual ~SESubstanceTransportEdge()
Definition: SESubstanceTransport.h:55
const ExtensiveUnit & m_ExtensiveUnit
Definition: SESubstanceTransport.h:98
Definition: SESubstanceTransport.h:102
const IntensiveUnit & m_IntensiveUnit
Definition: SESubstanceTransport.h:99
virtual ~SESubstanceTransportAmount()
Definition: SESubstanceTransport.h:17
virtual ~SESubstanceTransportGraph()
Definition: SESubstanceTransport.h:74
virtual void Invalidate()=0
Definition: SEScalarMass.h:7
const QuantityUnit & m_QuantityUnit
Definition: SESubstanceTransport.h:97
Definition: SESubstanceTransport.h:87