src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACReturnPlenum.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | #include "../../model/Model.hpp" | ||
| 8 | #include "../../model/AirLoopHVACReturnPlenum.hpp" | ||
| 9 | #include "../../model/AirLoopHVACReturnPlenum_Impl.hpp" | ||
| 10 | #include "../../model/ThermalZone.hpp" | ||
| 11 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 12 | #include "../../model/ZoneHVACIdealLoadsAirSystem.hpp" | ||
| 13 | #include "../../model/ZoneHVACIdealLoadsAirSystem_Impl.hpp" | ||
| 14 | #include "../../model/Node.hpp" | ||
| 15 | #include "../../model/Node_Impl.hpp" | ||
| 16 | #include "../../model/PortList.hpp" | ||
| 17 | #include "../../model/PortList_Impl.hpp" | ||
| 18 | #include <utilities/idd/AirLoopHVAC_ReturnPlenum_FieldEnums.hxx> | ||
| 19 | #include <utilities/idd/NodeList_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 21 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 22 | #include <utilities/idd/IddEnums.hxx> | ||
| 23 | #include <utilities/idd/IddFactory.hxx> | ||
| 24 | |||
| 25 | using namespace openstudio::model; | ||
| 26 | |||
| 27 | namespace openstudio { | ||
| 28 | |||
| 29 | namespace energyplus { | ||
| 30 | |||
| 31 | 3 | boost::optional<IdfObject> ForwardTranslator::translateAirLoopHVACReturnPlenum(AirLoopHVACReturnPlenum& modelObject) { | |
| 32 | 3 | OptionalModelObject temp; | |
| 33 | 3 | OptionalString optS; | |
| 34 | 3 | std::string s; | |
| 35 | |||
| 36 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | IdfObject idfObject(openstudio::IddObjectType::AirLoopHVAC_ReturnPlenum); |
| 37 | |||
| 38 |
1/1✓ Branch 1 taken 3 times.
|
3 | m_idfObjects.push_back(idfObject); |
| 39 | |||
| 40 | // Name | ||
| 41 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | s = modelObject.name().get(); |
| 42 |
1/1✓ Branch 1 taken 3 times.
|
3 | idfObject.setName(s); |
| 43 | |||
| 44 | //((ZoneName)(Zone Name)) | ||
| 45 | //((ZoneNodeName)(Zone Node Name)) | ||
| 46 | |||
| 47 | // InducedAirOutletNodeorNodeListName | ||
| 48 | // This is only the zoneHVAC that meets a very specific criteria, | ||
| 49 | // see the method documentation in AirLoopHVACReturnPlenum_Impl | ||
| 50 |
1/1✓ Branch 3 taken 3 times.
|
3 | auto zoneHVAC = modelObject.getImpl<model::detail::AirLoopHVACReturnPlenum_Impl>()->zoneHVACIdealLoadsAirSystems(); |
| 51 | // If zoneHVAC is not empty we do a workaround, | ||
| 52 | // and we don't use the inducedAirOutletPortList because of an EnergyPlus bug | ||
| 53 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | if (zoneHVAC.empty()) { |
| 54 |
1/1✓ Branch 3 taken 3 times.
|
3 | PortList po = modelObject.getImpl<model::detail::AirLoopHVACReturnPlenum_Impl>()->inducedAirOutletPortList(); |
| 55 |
1/1✓ Branch 1 taken 3 times.
|
3 | std::vector<ModelObject> inducedNodes = po.modelObjects(); |
| 56 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!inducedNodes.empty()) { |
| 57 | ✗ | IdfObject nodeList(openstudio::IddObjectType::NodeList); | |
| 58 | ✗ | m_idfObjects.push_back(nodeList); | |
| 59 | ✗ | nodeList.setName(s + " Induced Air Node List"); | |
| 60 | ✗ | idfObject.setString(AirLoopHVAC_ReturnPlenumFields::InducedAirOutletNodeorNodeListName, nodeList.name().get()); | |
| 61 | ✗ | for (auto it = inducedNodes.begin(); it != inducedNodes.end(); ++it) { | |
| 62 | ✗ | IdfExtensibleGroup eg = nodeList.pushExtensibleGroup(); | |
| 63 | ✗ | eg.setString(NodeListExtensibleFields::NodeName, it->name().get()); | |
| 64 | ✗ | } | |
| 65 | ✗ | } | |
| 66 | 3 | } | |
| 67 | |||
| 68 | // OutletNodeName | ||
| 69 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!zoneHVAC.empty()) { |
| 70 | ✗ | auto node = zoneHVAC.front().airInletModelObject(); | |
| 71 | ✗ | OS_ASSERT(node); | |
| 72 | ✗ | idfObject.setString(AirLoopHVAC_ReturnPlenumFields::OutletNodeName, node->nameString()); | |
| 73 |
2/3✓ Branch 2 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
6 | } else if (boost::optional<model::ModelObject> node = modelObject.outletModelObject()) { |
| 74 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | idfObject.setString(AirLoopHVAC_ReturnPlenumFields::OutletNodeName, node->name().get()); |
| 75 | } else { | ||
| 76 | ✗ | idfObject.setString(AirLoopHVAC_ReturnPlenumFields::OutletNodeName, modelObject.nameString() + " Outlet Node"); | |
| 77 | 3 | } | |
| 78 | |||
| 79 | //// ZoneName | ||
| 80 | //// and | ||
| 81 | //// ZoneNodeName | ||
| 82 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (boost::optional<model::ThermalZone> zone = modelObject.thermalZone()) { |
| 83 |
3/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
|
6 | if (boost::optional<IdfObject> _zone = translateAndMapModelObject(zone.get())) { |
| 84 | ✗ | idfObject.setString(AirLoopHVAC_ReturnPlenumFields::ZoneName, _zone->name().get()); | |
| 85 | |||
| 86 | ✗ | model::Node node = zone->zoneAirNode(); | |
| 87 | ✗ | idfObject.setString(AirLoopHVAC_ReturnPlenumFields::ZoneNodeName, node.name().get()); | |
| 88 | 3 | } | |
| 89 | 3 | } | |
| 90 | |||
| 91 | // InletNodeName | ||
| 92 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto inletModelObjects = modelObject.inletModelObjects(); |
| 93 |
2/2✓ Branch 5 taken 4 times.
✓ Branch 6 taken 3 times.
|
7 | for (auto& inletModelObject : inletModelObjects) { |
| 94 |
1/1✓ Branch 1 taken 4 times.
|
4 | IdfExtensibleGroup eg = idfObject.pushExtensibleGroup(); |
| 95 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | eg.setString(AirLoopHVAC_ReturnPlenumExtensibleFields::InletNodeName, inletModelObject.name().get()); |
| 96 | 4 | } | |
| 97 | |||
| 98 |
1/1✓ Branch 1 taken 3 times.
|
6 | return boost::optional<IdfObject>(idfObject); |
| 99 | 3 | } | |
| 100 | |||
| 101 | } // namespace energyplus | ||
| 102 | |||
| 103 | } // namespace openstudio | ||
| 104 |