SEFluidCompartmentLink.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 
13 #pragma once
14 #include <biogears/cdm/circuit/fluid/SEFluidCircuitPath.h>
15 
16 #include <biogears/cdm/compartment/SECompartmentLink.h>
17 #include <biogears/cdm/properties/SEScalarVolumePerTime.h>
18 #include <biogears/schema/cdm/Compartment.hxx>
19 
20 #define FLUID_COMPARTMENT_LINK_TEMPLATE typename EdgeType, typename VertexType, typename CompartmentType
21 #define FLUID_COMPARTMENT_LINK_TYPES EdgeType, VertexType, CompartmentType
22 
23 namespace biogears {
24 template <FLUID_COMPARTMENT_LINK_TEMPLATE>
25 class SEFluidCompartmentLink : public SECompartmentLink, public EdgeType {
26 protected:
27  SEFluidCompartmentLink(CompartmentType& src, CompartmentType& tgt, const char* name);
28  SEFluidCompartmentLink(CompartmentType& src, CompartmentType& tgt, const std::string& name);
29 
30  public:
31  virtual ~SEFluidCompartmentLink();
32 
33  virtual void Clear() override;
34 
35  virtual bool Load(const CDM::FluidCompartmentLinkData& in, SECircuitManager* circuits = nullptr);
36  virtual CDM::FluidCompartmentLinkData* Unload() override = 0;
37 
38 protected:
39  virtual void Unload(CDM::FluidCompartmentLinkData& data);
40 
41 public:
42  virtual const SEScalar* GetScalar(const char* name) override;
43  virtual const SEScalar* GetScalar(const std::string& name) override;
44 
45  virtual std::string GetName() const override;
46  virtual const char* GetName_cStr() const override;
47 
48  virtual bool HasFlow() const;
49  virtual SEScalarVolumePerTime& GetFlow();
50  virtual double GetFlow(const VolumePerTimeUnit& unit) const;
51 
52  virtual CompartmentType& GetSourceCompartment() { return m_SourceCmpt; }
53  virtual CompartmentType& GetTargetCompartment() { return m_TargetCmpt; }
54 
55  virtual bool HasPath() { return m_Path != nullptr; }
56  virtual SEFluidCircuitPath* GetPath() { return m_Path; }
57  virtual void RemovePath() { m_Path = nullptr; }
58  virtual void MapPath(SEFluidCircuitPath& path)
59  {
60  Clear();
61  m_Path = &path;
62  }
63 
64 protected:
65  // For Transport
66  virtual bool HasFlux() const override{ return HasFlow(); }
67  virtual SEScalarVolumePerTime& GetFlux() override{ return GetFlow(); }
68  virtual double GetFlux(const VolumePerTimeUnit& unit) const { return GetFlow(unit); }
69 
70  virtual VertexType& GetSourceVertex() override{ return m_SourceVertex; }
71  virtual VertexType& GetTargetVertex() override{ return m_TargetVertex; }
72 
74  CompartmentType& m_SourceCmpt;
75  CompartmentType& m_TargetCmpt;
76  VertexType& m_SourceVertex;
77  VertexType& m_TargetVertex;
79 };
80 }
Definition: SEScalarVolumePerTime.h:18
Definition: SEFluidCircuitPath.h:25
Definition: SEScalarVolumePerTime.h:40
Definition: SEElectricalCircuit.h:18