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
12template<COMPARTMENT_NODE_TEMPLATE>
14{
15 friend class PBCompartment;//friend the serialization class
16public:
17
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 bool HasMapping(const NodeType& n) const
26 {
27 for (auto mine : m_AllNodes)
28 if (&n == mine)
29 return true;
30 return false;
31 }
32 virtual const std::vector<NodeType*>& GetNodes() const { return m_AllNodes; }
33 virtual const std::vector<NodeType*>& GetQuantityNodes() const { return m_QuantityNodes; }
34 virtual void RemoveNode(NodeType& node);
35 virtual void MapNode(NodeType& node);
36
37 virtual bool HasQuantity() const { return !m_QuantityNodes.empty(); }
38 virtual QuantityScalar& GetQuantity();
39 virtual double GetQuantity(const QuantityUnit& unit) const;
40
41 virtual bool HasPotential() const;
42 virtual PotentialScalar& GetPotential();
43 virtual double GetPotential(const PotentialUnit& unit) const;
44
45protected:
46 void SortNode(NodeType& node);
47
48 // I assume all nodes will have a pressure
49 std::vector<NodeType*> m_QuantityNodes;
50 std::vector<NodeType*> m_AllNodes;//Even nodes without quantity (ex. volume)
51
52 QuantityScalar* m_Quantity;
53 PotentialScalar* m_Potential;
54};
55
56#include "cdm/compartment/SECompartmentNodes.hxx"
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PBCompartment.h:28
Definition: SECompartmentNodes.h:14
QuantityScalar * m_Quantity
Definition: SECompartmentNodes.h:52
std::vector< NodeType * > m_AllNodes
Definition: SECompartmentNodes.h:50
virtual bool HasPotential() const
Definition: SECompartmentNodes.cpp:72
virtual bool HasMapping(const NodeType &n) const
Definition: SECompartmentNodes.h:25
virtual QuantityScalar & GetQuantity()
Definition: SECompartmentNodes.cpp:45
PotentialScalar * m_Potential
Definition: SECompartmentNodes.h:53
virtual void StateChange()
Definition: SECompartmentNodes.cpp:149
virtual const std::vector< NodeType * > & GetNodes() const
Definition: SECompartmentNodes.h:32
virtual void RemoveNode(NodeType &node)
Definition: SECompartmentNodes.cpp:38
SECompartmentNodes(Logger *logger)
Definition: SECompartmentNodes.cpp:9
virtual void Clear()
Definition: SECompartmentNodes.cpp:22
virtual PotentialScalar & GetPotential()
Definition: SECompartmentNodes.cpp:80
std::vector< NodeType * > m_QuantityNodes
Definition: SECompartmentNodes.h:49
void SortNode(NodeType &node)
Definition: SECompartmentNodes.cpp:135
virtual ~SECompartmentNodes()
Definition: SECompartmentNodes.cpp:16
virtual bool HasQuantity() const
Definition: SECompartmentNodes.h:37
virtual void MapNode(NodeType &node)
Definition: SECompartmentNodes.cpp:31
virtual const std::vector< NodeType * > & GetQuantityNodes() const
Definition: SECompartmentNodes.h:33
virtual bool HasMapping() const
Definition: SECompartmentNodes.h:24

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.