SEThermalCompartment.h
1 /**************************************************************************************
2 Copyright 2015 Applied Research Associates, Inc.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the License
5 at:
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software distributed under
8 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9 CONDITIONS OF ANY KIND, either express or implied. See the License for the
10 specific language governing permissions and limitations under the License.
11 **************************************************************************************/
12 #pragma once
13 #include <biogears/cdm/compartment/SECompartment.h>
14 #include <biogears/cdm/circuit/thermal/SEThermalCircuitNode.h>
15 #include <biogears/cdm/compartment/SECompartmentNodes.h>
16 #include <biogears/schema/cdm/Compartment.hxx>
17 
18 CDM_BIND_DECL(ThermalCompartmentData)
19 
20 namespace biogears {
21 class SEThermalCompartmentLink;
22 class SEScalarPower;
23 class PowerUnit;
24 
25 class SECompartmentManager;
26 class BIOGEARS_API SEThermalCompartment : public SECompartment {
27  friend class SECompartmentManager;
28  template <typename CompartmentType, typename CompartmentLinkType>
29  friend class SECompartmentGraph;
30 
31 protected:
32  SEThermalCompartment(const char* name, Logger* logger);
33  SEThermalCompartment(const std::string& name, Logger* logger);
34 public:
35  virtual ~SEThermalCompartment() override;
36 
37  virtual void Clear() override;
38 
39  virtual bool Load(const CDM::ThermalCompartmentData& in, SECircuitManager* circuits = nullptr);
40  virtual CDM::ThermalCompartmentData* Unload() override;
41 
42 protected:
43  virtual void Unload(CDM::ThermalCompartmentData& data);
44 
45 public:
46  virtual const SEScalar* GetScalar(const std::string& name) override;
47  virtual const SEScalar* GetScalar(const char* name) override;
48 
49  virtual bool HasChildren() const override { return !m_Children.empty(); }
50  virtual const std::vector<SEThermalCompartment*>& GetChildren() { return m_Children; }
51  virtual const std::vector<SEThermalCompartment*>& GetLeaves() { return m_Leaves; }
52 
53  virtual bool HasNodeMapping() const { return m_Nodes.HasMapping(); }
55  virtual void MapNode(SEThermalCircuitNode& node);
56 
57  virtual void StateChange() override;
58 
59  virtual bool HasHeatTransferRateIn() const;
60  virtual const SEScalarPower& GetHeatTransferRateIn();
61  virtual double GetHeatTransferRateIn(const PowerUnit& unit) const;
62 
63  virtual bool HasHeatTransferRateOut() const;
64  virtual const SEScalarPower& GetHeatTransferRateOut();
65  virtual double GetHeatTransferRateOut(const PowerUnit& unit) const;
66 
67  virtual bool HasHeat() const;
68  virtual SEScalarEnergy& GetHeat();
69  virtual double GetHeat(const EnergyUnit& unit) const;
70 
71  virtual bool HasTemperature() const;
72  virtual SEScalarTemperature& GetTemperature();
73  virtual double GetTemperature(const TemperatureUnit& unit) const;
74 
75  virtual void AddLink(SEThermalCompartmentLink& link);
76  virtual void RemoveLink(SEThermalCompartmentLink& link);
77  virtual void RemoveLinks();
78  virtual const std::vector<SEThermalCompartmentLink*>& GetLinks();
79 
80  virtual bool HasChild(const char* name);
81  virtual bool HasChild(const std::string& name);
82  virtual void AddChild(SEThermalCompartment& child);
83 
84 protected:
85  virtual double CalculateInFlow_W() const;
86  virtual double CalculateOutFlow_W() const;
87 
92 
93  std::vector<SEThermalCompartmentLink*> m_Links;
94  std::vector<SEThermalCompartmentLink*> m_IncomingLinks;
95  std::vector<SEThermalCompartmentLink*> m_OutgoingLinks;
96 
97  std::vector<SEThermalCompartment*> m_Children;
98  std::vector<SEThermalCompartment*> m_Leaves;
100 };
101 }
virtual bool HasChildren() const override
Definition: SEThermalCompartment.h:49
SECompartmentNodes< THERMAL_COMPARTMENT_NODE > m_Nodes
Definition: SEThermalCompartment.h:99
Definition: SEScalar.h:33
Definition: SEScalarTemperature.h:36
SEScalarEnergy * m_Heat
Definition: SEThermalCompartment.h:90
SEScalarTemperature * m_Temperature
Definition: SEThermalCompartment.h:91
Definition: SEThermalCompartment.h:26
virtual const std::vector< SEThermalCompartment * > & GetChildren()
Definition: SEThermalCompartment.h:50
virtual void StateChange()=0
virtual bool Load(const CDM::CompartmentData &in, SECircuitManager *circuits=nullptr)
Definition: SECompartment.cpp:38
Definition: SECompartmentManager.h:32
std::vector< SEThermalCompartment * > m_Children
Definition: SEThermalCompartment.h:97
Definition: SEScalarTemperature.h:18
std::vector< SEThermalCompartmentLink * > m_IncomingLinks
Definition: SEThermalCompartment.h:94
virtual const SEScalar * GetScalar(const char *name)=0
Definition: Logger.h:75
virtual const std::vector< SEThermalCompartment * > & GetLeaves()
Definition: SEThermalCompartment.h:51
virtual CDM::CompartmentData * Unload()=0
Definition: SEThermalCircuitNode.h:20
Definition: SEScalarPower.h:38
Definition: SEScalarPower.h:18
SEScalarPower * m_HeatTransferRateIn
Definition: SEThermalCompartment.h:88
Definition: SEScalarEnergy.h:36
std::vector< SEThermalCompartmentLink * > m_Links
Definition: SEThermalCompartment.h:93
Definition: SECompartment.h:31
Definition: SECompartmentGraph.h:25
SEScalarPower * m_HeatTransferRateOut
Definition: SEThermalCompartment.h:89
virtual bool HasNodeMapping() const
Definition: SEThermalCompartment.h:53
std::vector< SEThermalCompartmentLink * > m_OutgoingLinks
Definition: SEThermalCompartment.h:95
std::vector< SEThermalCompartment * > m_Leaves
Definition: SEThermalCompartment.h:98
virtual SECompartmentNodes< THERMAL_COMPARTMENT_NODE > & GetNodeMapping()
Definition: SEThermalCompartment.h:54
Definition: SEElectricalCircuit.h:18
Definition: SECircuitManager.h:53
Class corresponding to the ThermalCompartmentData schema type.
Definition: Compartment.hxx:4263
Definition: SEScalarEnergy.h:18
virtual void Clear()
Definition: SECompartment.cpp:34