SECircuitNode.hxx
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 template<CIRCUIT_NODE_TEMPLATE>
5 SECircuitNode<CIRCUIT_NODE_TYPES>::SECircuitNode(const std::string& name, Logger* logger) : Loggable(logger), m_Name(name)
6 {
7  m_Potential = nullptr;
8  m_NextPotential = nullptr;
9  m_Quantity = nullptr;
10  m_NextQuantity = nullptr;
11  m_QuantityBaseline = nullptr;
12 }
13 
14 template<CIRCUIT_NODE_TEMPLATE>
16 {
17  Clear();
18 }
19 
20 template<CIRCUIT_NODE_TEMPLATE>
22 {
23  SAFE_DELETE(m_Potential);
24  SAFE_DELETE(m_NextPotential);
25  SAFE_DELETE(m_Quantity);
26  SAFE_DELETE(m_NextQuantity);
27  SAFE_DELETE(m_QuantityBaseline);
28 }
29 
30 template<CIRCUIT_NODE_TEMPLATE>
32 {
33  return m_Name;
34 }
35 
36 template<CIRCUIT_NODE_TEMPLATE>
38 {
39  return m_IsPartOfBlackBox;
40 }
41 template<CIRCUIT_NODE_TEMPLATE>
43 {
45 }
46 
47 template<CIRCUIT_NODE_TEMPLATE>
49 {
50  return m_IsBlackBoxMiddle;
51 }
52 
53 template<CIRCUIT_NODE_TEMPLATE>
55 {
56  return m_Potential == nullptr ? false : m_Potential->IsValid();
57 }
58 template<CIRCUIT_NODE_TEMPLATE>
60 {
61  if (m_Potential == nullptr)
62  m_Potential = new PotentialScalar();
63  return *m_Potential;
64 }
65 
66 template<CIRCUIT_NODE_TEMPLATE>
68 {
69  return m_NextPotential == nullptr ? false : m_NextPotential->IsValid();
70 }
71 template<CIRCUIT_NODE_TEMPLATE>
73 {
74  if (m_NextPotential == nullptr)
75  m_NextPotential = new PotentialScalar();
76  return *m_NextPotential;
77 }
78 
79 template<CIRCUIT_NODE_TEMPLATE>
81 {
82  m_PotentialType = eBlackBox_Property_Type::Calculate;
83 }
84 template<CIRCUIT_NODE_TEMPLATE>
86 {
87  return m_PotentialType == eBlackBox_Property_Type::Imposed;
88 }
89 template<CIRCUIT_NODE_TEMPLATE>
90 void SECircuitNode<CIRCUIT_NODE_TYPES>::ImposePotential(double v, const PotentialUnit& unit)
91 {
92  m_PotentialType = eBlackBox_Property_Type::Imposed;
93  if (m_NextPotential == nullptr)
94  m_NextPotential = new PotentialScalar();
95  m_NextPotential->ForceValue(v, unit);
96 }
97 template<CIRCUIT_NODE_TEMPLATE>
98 void SECircuitNode<CIRCUIT_NODE_TYPES>::ImposePotential(const PotentialScalar& s)
99 {
100  m_PotentialType = eBlackBox_Property_Type::Imposed;
101  if (m_NextPotential == nullptr)
102  m_NextPotential = new PotentialScalar();
103  m_NextPotential->Force(s);
104 }
105 
106 template<CIRCUIT_NODE_TEMPLATE>
108 {
109  return m_Quantity == nullptr ? false : m_Quantity->IsValid();
110 }
111 template<CIRCUIT_NODE_TEMPLATE>
113 {
114  if (m_Quantity == nullptr)
115  m_Quantity = new QuantityScalar();
116  return *m_Quantity;
117 }
118 
119 template<CIRCUIT_NODE_TEMPLATE>
121 {
122  return m_NextQuantity == nullptr ? false : m_NextQuantity->IsValid();
123 }
124 template<CIRCUIT_NODE_TEMPLATE>
126 {
127  if (m_NextQuantity == nullptr)
128  m_NextQuantity = new QuantityScalar();
129  return *m_NextQuantity;
130 }
131 
132 template<CIRCUIT_NODE_TEMPLATE>
134 {
135  return m_QuantityBaseline == nullptr ? false : m_QuantityBaseline->IsValid();
136 }
137 template<CIRCUIT_NODE_TEMPLATE>
139 {
140  if (m_QuantityBaseline == nullptr)
141  m_QuantityBaseline = new QuantityScalar();
142  return *m_QuantityBaseline;
143 }
144 
145 template<CIRCUIT_NODE_TEMPLATE>
147 {
148  m_QuantityType = eBlackBox_Property_Type::Calculate;
149 }
150 template<CIRCUIT_NODE_TEMPLATE>
152 {
153  return m_QuantityType == eBlackBox_Property_Type::Imposed;
154 }
155 template<CIRCUIT_NODE_TEMPLATE>
156 void SECircuitNode<CIRCUIT_NODE_TYPES>::ImposeQuantity(double v, const QuantityUnit& unit)
157 {
158  m_QuantityType = eBlackBox_Property_Type::Imposed;
159  m_NextQuantity->ForceValue(v, unit);
160 }
161 template<CIRCUIT_NODE_TEMPLATE>
162 void SECircuitNode<CIRCUIT_NODE_TYPES>::ImposeQuantity(const QuantityScalar& s)
163 {
164  m_QuantityType = eBlackBox_Property_Type::Imposed;
165  m_NextQuantity->Force(s);
166 }
167 
168 template<CIRCUIT_NODE_TEMPLATE>
170 {
171  return m_CalculatorIndex;
172 }
173 template<CIRCUIT_NODE_TEMPLATE>
175 {
176  m_CalculatorIndex = index;
177 }
178 
179 template<CIRCUIT_NODE_TEMPLATE>
181 {
182  m_IsReferenceNode = false;
183 }
184 template<CIRCUIT_NODE_TEMPLATE>
186 {
187  m_IsReferenceNode = true;
188 }
189 template<CIRCUIT_NODE_TEMPLATE>
191 {
192  return m_IsReferenceNode;
193 }
194 
195 #include "cdm/circuit/fluid/SEFluidCircuitNode.h"
196 template class SECircuitNode<FLUID_CIRCUIT_NODE>;
197 #include "cdm/circuit/electrical/SEElectricalCircuitNode.h"
199 #include "cdm/circuit/thermal/SEThermalCircuitNode.h"
Definition: Logger.h:23
Definition: Logger.h:71
bool IsReferenceNode() const
void SetCalculatorIndex(const int index)
virtual PotentialScalar & GetPotential()
void RemoveAsReferenceNode()
bool m_IsPartOfBlackBox
Definition: SECircuitNode.h:78
virtual void ImposeQuantity(const QuantityScalar &s)
QuantityScalar * m_Quantity
Definition: SECircuitNode.h:88
virtual bool IsQuantityImposed() const
int GetCalculatorIndex() const
bool m_IsReferenceNode
Definition: SECircuitNode.h:95
void SetAsReferenceNode()
virtual bool IsPartOfBlackBox() const
virtual bool IsPotentialImposed() const
SECircuitNode(const std::string &name, Logger *logger)
QuantityScalar * m_NextQuantity
Definition: SECircuitNode.h:89
virtual std::string GetName() const
virtual void ImposePotential(const PotentialScalar &s)
virtual void SetPartOfBlackBox(bool b)
PotentialScalar * m_Potential
Definition: SECircuitNode.h:81
eBlackBox_Property_Type m_QuantityType
Definition: SECircuitNode.h:91
bool m_IsBlackBoxMiddle
Definition: SECircuitNode.h:79
eBlackBox_Property_Type m_PotentialType
Definition: SECircuitNode.h:83
virtual bool HasNextPotential() const
virtual void RemoveImposedPotential()
virtual bool HasNextQuantity() const
virtual bool IsBlackBoxMiddle() const
virtual QuantityScalar & GetNextQuantity()
std::string m_Name
Definition: SECircuitNode.h:77
virtual QuantityScalar & GetQuantity()
virtual QuantityScalar & GetQuantityBaseline()
virtual bool HasQuantityBaseline() const
virtual void RemoveImposedQuantity()
virtual PotentialScalar & GetNextPotential()
QuantityScalar * m_QuantityBaseline
Definition: SECircuitNode.h:90
PotentialScalar * m_NextPotential
Definition: SECircuitNode.h:82
int m_CalculatorIndex
Definition: SECircuitNode.h:94
virtual bool HasQuantity() const
virtual bool HasPotential() const
virtual ~SECircuitNode()
virtual void Clear()

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.