SEFluidCompartment.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5#include "cdm/compartment/SECompartment.h"
6#include "cdm/circuit/fluid/SEFluidCircuitNode.h"
7#include "cdm/compartment/SECompartmentNodes.h"
8#include "cdm/substance/SESubstanceTransport.h"
9
10class SESubstance;
12template<typename EdgeType, typename VertexType, typename CompartmentType> class SEFluidCompartmentLink;
13
14#define FLUID_COMPARTMENT_TEMPLATE typename LinkType, typename VertexType, typename TransportSubstanceType, typename SubstanceQuantityType
15#define FLUID_COMPARTMENT_TYPES LinkType, VertexType, TransportSubstanceType, SubstanceQuantityType
16
17template<FLUID_COMPARTMENT_TEMPLATE>
18class SEFluidCompartment : public SECompartment, public VertexType
19{
20 friend class PBCompartment;//friend the serialization class
21 template<typename CompartmentType, typename CompartmentLinkType> friend class SECompartmentGraph;
22protected:
23 SEFluidCompartment(const std::string& name, Logger* logger);
24public:
25 virtual ~SEFluidCompartment();
26
27 void Clear() override;
28
29 std::string GetName() const override { return m_Name; }
30
31 const SEScalar* GetScalar(const std::string& name) override;
32
33 bool HasChildren() const override { return !m_FluidChildren.empty(); }
34
35 virtual bool HasNodeMapping() const { return m_Nodes.HasMapping(); }
37 virtual void MapNode(SEFluidCircuitNode& node);
38
39 virtual void Sample(bool CycleStart);
40 virtual void SampleFlow(); // We can add other sampling support as needed, just follow the pattern
41
42 virtual bool HasInFlow() const;
43 virtual const SEScalarVolumePerTime& GetInFlow() const;
44 virtual double GetInFlow(const VolumePerTimeUnit& unit) const;
45
46 virtual bool HasAverageInFlow() const;
47 virtual const SEScalarVolumePerTime& GetAverageInFlow() const;
48 virtual double GetAverageInFlow(const VolumePerTimeUnit& unit) const;
49
50 virtual bool HasOutFlow() const;
51 virtual const SEScalarVolumePerTime& GetOutFlow() const;
52 virtual double GetOutFlow(const VolumePerTimeUnit& unit) const;
53
54 virtual bool HasAverageOutFlow() const;
55 virtual const SEScalarVolumePerTime& GetAverageOutFlow() const;
56 virtual double GetAverageOutFlow(const VolumePerTimeUnit& unit) const;
57
58 virtual bool HasPressure() const;
60 virtual double GetPressure(const PressureUnit& unit) const;
61
62 virtual bool HasVolume() const;
63 virtual SEScalarVolume& GetVolume();
64 virtual double GetVolume(const VolumeUnit& unit) const;
65
66 virtual bool HasSubstanceQuantities() const;
67 virtual bool HasSubstanceQuantity(const SESubstance& substance) const;
68 virtual SubstanceQuantityType* GetSubstanceQuantity(const SESubstance& substance) const;
69 virtual const std::vector<SubstanceQuantityType*>& GetSubstanceQuantities() const;
70 virtual void ZeroSubstanceQuantities();
71
72 virtual void AddLink(LinkType& link);
73 virtual void RemoveLink(LinkType& link);
74 virtual void RemoveLinks();
75 virtual const std::vector<LinkType*>& GetLinks();
76
77 virtual bool HasChild(const SEFluidCompartment& cmpt);
78
79protected:
80 virtual void RemoveSubstanceQuantity(const SESubstance& substance);
81
82 bool HasQuantity() const override { return HasVolume(); }
83 SEScalarVolume& GetQuantity() override { return GetVolume(); }
84
85 virtual double CalculateInFlow_mL_Per_s() const;
86 virtual double CalculateOutFlow_mL_Per_s() const;
87
88 std::vector<TransportSubstanceType*>& GetTransportSubstances() override { return m_TransportSubstances; }
89
97
100
101 std::vector<SubstanceQuantityType*> m_SubstanceQuantities;
102 std::vector<TransportSubstanceType*> m_TransportSubstances;
103
104 std::vector<LinkType*> m_Links;
105 std::vector<LinkType*> m_IncomingLinks;
106 std::vector<LinkType*> m_OutgoingLinks;
107 std::vector<SEFluidCompartment*> m_FluidChildren;
109};
110
111#include "cdm/compartment/fluid/SEFluidCompartment.hxx"
Definition: Logger.h:71
Definition: PBCompartment.h:28
Definition: SEScalarPressure.h:8
Definition: SECompartmentGraph.h:11
Definition: SECompartment.h:14
std::string m_Name
Definition: SECompartment.h:32
virtual bool HasMapping() const
Definition: SECompartmentNodes.h:24
Definition: SEFluidCircuitNode.h:10
Definition: SEFluidCompartment.h:19
bool HasChildren() const override
Definition: SEFluidCompartment.h:33
virtual double CalculateOutFlow_mL_Per_s() const
Definition: SEFluidCompartment.cpp:236
bool HasQuantity() const override
Definition: SEFluidCompartment.h:82
virtual bool HasVolume() const
Definition: SEFluidCompartment.cpp:342
virtual void ZeroSubstanceQuantities()
Definition: SEFluidCompartment.cpp:438
virtual void RemoveSubstanceQuantity(const SESubstance &substance)
Definition: SEFluidCompartment.cpp:423
virtual ~SEFluidCompartment()
Definition: SEFluidCompartment.cpp:26
virtual SEScalarPressure & GetPressure()
Definition: SEFluidCompartment.cpp:274
SEScalarVolumePerTime * m_OutFlow
Definition: SEFluidCompartment.h:91
virtual void RemoveLink(LinkType &link)
Definition: SEFluidCompartment.cpp:473
virtual bool HasAverageOutFlow() const
Definition: SEFluidCompartment.cpp:188
virtual bool HasInFlow() const
Definition: SEFluidCompartment.cpp:103
std::vector< TransportSubstanceType * > m_TransportSubstances
Definition: SEFluidCompartment.h:102
std::vector< LinkType * > m_Links
Definition: SEFluidCompartment.h:104
virtual void AddLink(LinkType &link)
Definition: SEFluidCompartment.cpp:447
virtual SECompartmentNodes< FLUID_COMPARTMENT_NODE > & GetNodeMapping()
Definition: SEFluidCompartment.h:36
SEScalarVolume & GetQuantity() override
Definition: SEFluidCompartment.h:83
std::vector< SubstanceQuantityType * > m_SubstanceQuantities
Definition: SEFluidCompartment.h:101
SERunningAverage * m_AverageInFlow_mL_Per_s
Definition: SEFluidCompartment.h:95
virtual const std::vector< SubstanceQuantityType * > & GetSubstanceQuantities() const
Definition: SEFluidCompartment.cpp:418
std::vector< LinkType * > m_OutgoingLinks
Definition: SEFluidCompartment.h:106
virtual bool HasSubstanceQuantity(const SESubstance &substance) const
Definition: SEFluidCompartment.cpp:397
virtual bool HasAverageInFlow() const
Definition: SEFluidCompartment.cpp:134
virtual void RemoveLinks()
Definition: SEFluidCompartment.cpp:480
std::vector< TransportSubstanceType * > & GetTransportSubstances() override
Definition: SEFluidCompartment.h:88
virtual bool HasSubstanceQuantities() const
Definition: SEFluidCompartment.cpp:392
virtual const SEScalarVolumePerTime & GetAverageInFlow() const
Definition: SEFluidCompartment.cpp:139
virtual void MapNode(SEFluidCircuitNode &node)
Definition: SEFluidCompartment.cpp:69
virtual const SEScalarVolumePerTime & GetInFlow() const
Definition: SEFluidCompartment.cpp:113
SEScalarVolumePerTime * m_AverageOutFlow
Definition: SEFluidCompartment.h:94
virtual const SEScalarVolumePerTime & GetAverageOutFlow() const
Definition: SEFluidCompartment.cpp:193
SEScalarVolumePerTime * m_InFlow
Definition: SEFluidCompartment.h:90
virtual bool HasNodeMapping() const
Definition: SEFluidCompartment.h:35
std::vector< SEFluidCompartment * > m_FluidChildren
Definition: SEFluidCompartment.h:107
virtual bool HasPressure() const
Definition: SEFluidCompartment.cpp:260
SEScalarVolumePerTime * m_AverageInFlow
Definition: SEFluidCompartment.h:93
bool m_SampleFlow
Definition: SEFluidCompartment.h:92
SECompartmentNodes< FLUID_COMPARTMENT_NODE > m_Nodes
Definition: SEFluidCompartment.h:108
virtual bool HasChild(const SEFluidCompartment &cmpt)
Definition: SEFluidCompartment.cpp:491
virtual SEScalarVolume & GetVolume()
Definition: SEFluidCompartment.cpp:356
SERunningAverage * m_AverageOutFlow_mL_Per_s
Definition: SEFluidCompartment.h:96
void Clear() override
Definition: SEFluidCompartment.cpp:32
std::vector< LinkType * > m_IncomingLinks
Definition: SEFluidCompartment.h:105
SEFluidCompartment(const std::string &name, Logger *logger)
Definition: SEFluidCompartment.cpp:13
virtual const std::vector< LinkType * > & GetLinks()
Definition: SEFluidCompartment.cpp:485
std::string GetName() const override
Definition: SEFluidCompartment.h:29
virtual SubstanceQuantityType * GetSubstanceQuantity(const SESubstance &substance) const
Definition: SEFluidCompartment.cpp:408
virtual void SampleFlow()
Definition: SEFluidCompartment.cpp:95
virtual const SEScalarVolumePerTime & GetOutFlow() const
Definition: SEFluidCompartment.cpp:167
SEScalarVolume * m_Volume
Definition: SEFluidCompartment.h:99
SEScalarPressure * m_Pressure
Definition: SEFluidCompartment.h:98
virtual void Sample(bool CycleStart)
Definition: SEFluidCompartment.cpp:78
const SEScalar * GetScalar(const std::string &name) override
Definition: SEFluidCompartment.cpp:51
virtual double CalculateInFlow_mL_Per_s() const
Definition: SEFluidCompartment.cpp:211
virtual bool HasOutFlow() const
Definition: SEFluidCompartment.cpp:157
Definition: SERunningAverage.h:8
Definition: SEScalar.h:19
Definition: SEScalarPressure.h:29
Definition: SEScalarVolume.h:28
Definition: SEScalarVolumePerTime.h:32
Definition: SESubstance.h:15
Definition: SEScalarVolumePerTime.h:8
Definition: SEScalarVolume.h:8

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.