SECompartmentNodes.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 
6 #define COMPARTMENT_NODE_TEMPLATE typename NodeType, typename PotentialScalar, typename PotentialUnit, typename QuantityScalar, typename QuantityUnit
7 #define COMPARTMENT_NODE_TYPES NodeType, PotentialScalar, PotentialUnit, QuantityScalar, QuantityUnit
8 #define ELECTRICAL_COMPARTMENT_NODE SEElectricalCircuitNode, SEScalarElectricPotential, ElectricPotentialUnit, SEScalarElectricCharge, ElectricChargeUnit
9 #define FLUID_COMPARTMENT_NODE SEFluidCircuitNode, SEScalarPressure, PressureUnit, SEScalarVolume, VolumeUnit
10 #define THERMAL_COMPARTMENT_NODE SEThermalCircuitNode, SEScalarTemperature, TemperatureUnit, SEScalarEnergy, EnergyUnit
11 
12 template<COMPARTMENT_NODE_TEMPLATE>
14 {
15  friend class PBCompartment;//friend the serialization class
16 public:
17 
18  SECompartmentNodes(Logger* logger);
19  virtual ~SECompartmentNodes();
20 
21  virtual void Clear();
22  virtual void StateChange(); //analyze and cache for optimization
23 
24  virtual bool HasMapping() const { return !m_AllNodes.empty(); }
25  virtual const std::vector<NodeType*>& GetNodes() const { return m_AllNodes; }
26  virtual void RemoveNode(NodeType& node);
27  virtual void MapNode(NodeType& node);
28 
29  virtual bool HasQuantity() const { return !m_QuantityNodes.empty(); }
30  virtual QuantityScalar& GetQuantity();
31  virtual double GetQuantity(const QuantityUnit& unit) const;
32 
33  virtual bool HasPotential() const;
34  virtual PotentialScalar& GetPotential();
35  virtual double GetPotential(const PotentialUnit& unit) const;
36 
37 protected:
38  void SortNode(NodeType& node);
39  virtual const std::vector<NodeType*>& GetAllNodes() const { return m_AllNodes; }
40  virtual const std::vector<NodeType*>& GetQuantityNodes() const { return m_QuantityNodes; }
41 
42  // I assume all nodes will have a pressure
43  std::vector<NodeType*> m_QuantityNodes;
44  std::vector<NodeType*> m_AllNodes;//Even nodes without quantity (ex. volume)
45 
46  QuantityScalar* m_Quantity;
47  PotentialScalar* m_Potential;
48 };
49 #include "compartment/SECompartmentNodes.inl"
50 
virtual void RemoveNode(NodeType &node)
std::vector< NodeType * > m_AllNodes
Definition: SECompartmentNodes.h:44
SECompartmentNodes(Logger *logger)
virtual QuantityScalar & GetQuantity()
Definition: SECompartmentNodes.h:13
QuantityScalar * m_Quantity
Definition: SECompartmentNodes.h:46
Definition: Logger.h:61
virtual const std::vector< NodeType * > & GetQuantityNodes() const
Definition: SECompartmentNodes.h:40
Definition: Logger.h:11
virtual void StateChange()
virtual bool HasMapping() const
Definition: SECompartmentNodes.h:24
virtual bool HasQuantity() const
Definition: SECompartmentNodes.h:29
virtual void MapNode(NodeType &node)
virtual const std::vector< NodeType * > & GetAllNodes() const
Definition: SECompartmentNodes.h:39
PotentialScalar * m_Potential
Definition: SECompartmentNodes.h:47
std::vector< NodeType * > m_QuantityNodes
Definition: SECompartmentNodes.h:43
virtual ~SECompartmentNodes()
void SortNode(NodeType &node)
virtual bool HasPotential() const
virtual PotentialScalar & GetPotential()
virtual const std::vector< NodeType * > & GetNodes() const
Definition: SECompartmentNodes.h:25
Definition: PBCompartment.h:27
virtual void Clear()