4template<COMPARTMENT_NODE_TEMPLATE>
11template<COMPARTMENT_NODE_TEMPLATE>
17template<COMPARTMENT_NODE_TEMPLATE>
20 m_QuantityNodes.clear();
22 SAFE_DELETE(m_Quantity);
23 SAFE_DELETE(m_Potential);
26template<COMPARTMENT_NODE_TEMPLATE>
29 if (std::find(m_AllNodes.begin(), m_AllNodes.end(), &node) == m_AllNodes.end())
30 m_AllNodes.push_back(&node);
33template<COMPARTMENT_NODE_TEMPLATE>
36 Remove(m_AllNodes, &node);
40template<COMPARTMENT_NODE_TEMPLATE>
43 if (m_QuantityNodes.size() == 1)
44 return m_QuantityNodes[0]->GetNextQuantity();
45 if (m_Quantity ==
nullptr)
46 m_Quantity =
new QuantityScalar();
47 m_Quantity->SetReadOnly(
false);
48 m_Quantity->Invalidate();
49 for (NodeType* n : m_QuantityNodes)
50 m_Quantity->Increment(n->GetNextQuantity());
51 m_Quantity->SetReadOnly(
true);
54template<COMPARTMENT_NODE_TEMPLATE>
57 if (m_QuantityNodes.empty())
59 if (m_QuantityNodes.size() == 1)
60 return m_QuantityNodes[0]->GetNextQuantity().GetValue(unit);
62 for (NodeType* n : m_QuantityNodes)
63 d += n->GetNextQuantity().GetValue(unit);
67template<COMPARTMENT_NODE_TEMPLATE>
70 for (NodeType* n : m_AllNodes)
71 if (n->HasNextPotential())
75template<COMPARTMENT_NODE_TEMPLATE>
78 if (m_AllNodes.size() == 1)
79 return m_AllNodes[0]->GetNextPotential();
81 const PotentialUnit* punit = m_AllNodes[0]->GetNextPotential().GetUnit();
83 if (m_Potential ==
nullptr)
84 m_Potential =
new PotentialScalar();
85 m_Potential->SetReadOnly(
false);
86 m_Potential->Invalidate();
88 m_Potential->SetValue(GetPotential(*punit), *punit);
89 m_Potential->SetReadOnly(
true);
92template<COMPARTMENT_NODE_TEMPLATE>
97 if (m_AllNodes.size() == 1)
98 return m_AllNodes[0]->GetNextPotential().GetValue(punit);
104 if (!m_QuantityNodes.empty())
107 const QuantityUnit* qunit = m_QuantityNodes[0]->GetNextQuantity().GetUnit();
108 double totalQuantity = 0;
109 for (NodeType* n : m_QuantityNodes)
110 if(n->HasNextPotential())
111 totalQuantity += n->GetNextQuantity().GetValue(*qunit);
112 for (NodeType* n : m_QuantityNodes)
113 if (n->HasNextPotential())
114 t += n->GetNextPotential().GetValue(punit) * (n->GetNextQuantity().GetValue(*qunit) / totalQuantity);
119 for (NodeType* n : m_AllNodes)
120 if (n->HasNextPotential())
123 t += n->GetNextPotential().GetValue(punit);
130template<COMPARTMENT_NODE_TEMPLATE>
133 if (!Contains(m_QuantityNodes, node))
135 if (node.HasQuantityBaseline())
136 m_QuantityNodes.push_back(&node);
140 if (!node.HasQuantityBaseline())
141 Remove(m_QuantityNodes,&node);
144template<COMPARTMENT_NODE_TEMPLATE>
147 m_QuantityNodes.clear();
148 for (NodeType* node : m_AllNodes)
153#include "cdm/compartment/electrical/SEElectricalCompartment.h"
155#include "cdm/compartment/fluid/SEFluidCompartment.h"
157#include "cdm/compartment/thermal/SEThermalCompartment.h"
virtual bool HasPotential() const
Definition: SECompartmentNodes.cpp:72
virtual QuantityScalar & GetQuantity()
Definition: SECompartmentNodes.cpp:45
virtual void StateChange()
Definition: SECompartmentNodes.cpp:149
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
void SortNode(NodeType &node)
Definition: SECompartmentNodes.cpp:135
virtual ~SECompartmentNodes()
Definition: SECompartmentNodes.cpp:16
virtual void MapNode(NodeType &node)
Definition: SECompartmentNodes.cpp:31
static double dNaN()
Definition: SEScalar.cpp:10