SECircuitNode.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5#include "cdm/properties/SEScalarElectricCharge.h"
6#include "cdm/properties/SEScalarElectricPotential.h"
7#include "cdm/properties/SEScalarPressure.h"
8#include "cdm/properties/SEScalarVolume.h"
9#include "cdm/properties/SEScalarTemperature.h"
10#include "cdm/properties/SEScalarEnergy.h"
11
12enum class eBlackBox_Property_Type
13{
14 Calculate = 0,
15 Imposed
16};
17
18#define CIRCUIT_NODE_TEMPLATE typename PotentialScalar, typename QuantityScalar, \
19 typename PotentialUnit, typename QuantityUnit
20#define CIRCUIT_NODE_TYPES PotentialScalar,QuantityScalar, \
21 PotentialUnit,QuantityUnit
22#define ELECTRICAL_CIRCUIT_NODE SEScalarElectricPotential, SEScalarElectricCharge, \
23 ElectricPotentialUnit, ElectricChargeUnit
24#define FLUID_CIRCUIT_NODE SEScalarPressure, SEScalarVolume, \
25 PressureUnit, VolumeUnit
26#define THERMAL_CIRCUIT_NODE SEScalarTemperature, SEScalarEnergy, \
27 TemperatureUnit, EnergyUnit
28
29template<CIRCUIT_NODE_TEMPLATE>
30class SECircuitNode : public Loggable
31{
32 friend class PBCircuit;//friend the serialization class
33 template< typename NodeType, typename PathType> friend class SECircuit;
34protected:
35 SECircuitNode(const std::string& name, Logger* logger);
36public:
37 virtual ~SECircuitNode();
38
39 virtual void Clear(); //clear memory
40
41 virtual std::string GetName() const;
42
43 virtual bool IsPartOfBlackBox() const;
44 virtual void SetPartOfBlackBox(bool b);
45 virtual bool IsBlackBoxMiddle() const;
46
47 virtual bool HasPotential() const;
48 virtual PotentialScalar& GetPotential();
49 virtual bool HasNextPotential() const;
50 virtual PotentialScalar& GetNextPotential();
51
52 virtual void RemoveImposedPotential();
53 virtual bool IsPotentialImposed() const;
54 virtual void ImposePotential(const PotentialScalar& s);
55 virtual void ImposePotential(double v, const PotentialUnit& unit);
56
57 virtual bool HasQuantity() const;
58 virtual QuantityScalar& GetQuantity();
59 virtual bool HasNextQuantity() const;
60 virtual QuantityScalar& GetNextQuantity();
61 virtual bool HasQuantityBaseline() const;
62 virtual QuantityScalar& GetQuantityBaseline();
63
64 virtual void RemoveImposedQuantity();
65 virtual bool IsQuantityImposed() const;
66 virtual void ImposeQuantity(const QuantityScalar& s);
67 virtual void ImposeQuantity(double v, const QuantityUnit& unit);
68
69 void SetCalculatorIndex(const int index);
70 int GetCalculatorIndex() const;
71
72 bool IsReferenceNode() const;
75
76protected:
77 std::string m_Name;
78 bool m_IsPartOfBlackBox = false;
79 bool m_IsBlackBoxMiddle = false;
80
81 PotentialScalar* m_Potential;
82 PotentialScalar* m_NextPotential;
83 eBlackBox_Property_Type m_PotentialType = eBlackBox_Property_Type::Calculate;
84
86 // Quantity Types //
88 QuantityScalar* m_Quantity;
89 QuantityScalar* m_NextQuantity;
90 QuantityScalar* m_QuantityBaseline;
91 eBlackBox_Property_Type m_QuantityType = eBlackBox_Property_Type::Calculate;
92
93private:
95 bool m_IsReferenceNode = false;
96};
97
98
99#include "cdm/circuit/SECircuitNode.hxx"
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PBCircuit.h:26
Definition: SECircuit.h:13
Definition: SECircuitNode.h:31
bool IsReferenceNode() const
virtual void ImposePotential(double v, const PotentialUnit &unit)
void SetCalculatorIndex(const int index)
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 QuantityScalar & GetQuantity()
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 QuantityScalar & GetNextQuantity()
virtual bool HasNextPotential() const
virtual void RemoveImposedPotential()
virtual bool HasNextQuantity() const
virtual bool IsBlackBoxMiddle() const
std::string m_Name
Definition: SECircuitNode.h:77
virtual PotentialScalar & GetNextPotential()
virtual void ImposeQuantity(double v, const QuantityUnit &unit)
virtual bool HasQuantityBaseline() const
virtual void RemoveImposedQuantity()
QuantityScalar * m_QuantityBaseline
Definition: SECircuitNode.h:90
PotentialScalar * m_NextPotential
Definition: SECircuitNode.h:82
int m_CalculatorIndex
Definition: SECircuitNode.h:94
virtual QuantityScalar & GetQuantityBaseline()
virtual bool HasQuantity() const
virtual bool HasPotential() const
virtual ~SECircuitNode()
virtual PotentialScalar & GetPotential()
virtual void Clear()

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.