GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 92.3% 60 / 0 / 65
Functions: 100.0% 3 / 0 / 3
Branches: 70.2% 87 / 0 / 124

src/energyplus/ForwardTranslator/ForwardTranslateDesignSpecificationOutdoorAir.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
8 #include "../../model/Model.hpp"
9
10 #include "../../model/DesignSpecificationOutdoorAir.hpp"
11 #include "../../model/DesignSpecificationOutdoorAir_Impl.hpp"
12 #include "../../model/Schedule.hpp"
13 #include "../../model/Space.hpp"
14 #include "../../model/ThermalZone.hpp"
15
16 #include "../../utilities/core/Logger.hpp"
17 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
18 #include "../../utilities/plot/ProgressBar.hpp"
19
20 #include <utilities/idd/DesignSpecification_OutdoorAir_FieldEnums.hxx>
21 #include <utilities/idd/DesignSpecification_OutdoorAir_SpaceList_FieldEnums.hxx>
22 #include "../../utilities/idd/IddEnums.hpp"
23 #include <utilities/idd/IddEnums.hxx>
24 #include <utilities/idd/IddFactory.hxx>
25
26 using namespace openstudio::model;
27
28 namespace openstudio {
29
30 namespace energyplus {
31
32 namespace detail {
33 63 boost::optional<IdfObject> translateDesignSpecificationOutdoorAir(DesignSpecificationOutdoorAir& modelObject) {
34 63 boost::optional<std::string> s;
35 63 boost::optional<double> value;
36
37
2/2
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
63 IdfObject idfObject(IddObjectType::DesignSpecification_OutdoorAir);
38
39
3/3
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
63 idfObject.setString(DesignSpecification_OutdoorAirFields::Name, modelObject.name().get());
40
41
1/1
✓ Branch 1 taken 63 times.
63 std::string outdoorAirMethod = modelObject.outdoorAirMethod();
42
1/1
✓ Branch 1 taken 63 times.
63 idfObject.setString(DesignSpecification_OutdoorAirFields::OutdoorAirMethod, outdoorAirMethod);
43
44
1/1
✓ Branch 1 taken 63 times.
63 double flowPerPerson = modelObject.outdoorAirFlowperPerson();
45
1/1
✓ Branch 1 taken 63 times.
63 double flowPerArea = modelObject.outdoorAirFlowperFloorArea();
46
1/1
✓ Branch 1 taken 63 times.
63 double flowPerZone = modelObject.outdoorAirFlowRate();
47
1/1
✓ Branch 1 taken 63 times.
63 double ach = modelObject.outdoorAirFlowAirChangesperHour();
48
49
14/26
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 61 times.
✓ Branch 9 taken 2 times.
✓ Branch 12 taken 2 times.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 61 times.
✓ Branch 19 taken 2 times.
✓ Branch 20 taken 61 times.
✓ Branch 21 taken 63 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 63 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 63 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
193 if (istringEqual(outdoorAirMethod, "Sum") || istringEqual(outdoorAirMethod, "Maximum")) {
50
51
1/1
✓ Branch 1 taken 63 times.
63 idfObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowperPerson, flowPerPerson);
52
1/1
✓ Branch 1 taken 63 times.
63 idfObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowperZoneFloorArea, flowPerArea);
53
1/1
✓ Branch 1 taken 63 times.
63 idfObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowperZone, flowPerZone);
54
1/1
✓ Branch 1 taken 63 times.
63 idfObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowAirChangesperHour, ach);
55
56 } else {
57 ✗ LOG_FREE(Error, "openstudio.energyplus.ForwardTranslator",
58 "Unknown OutdoorAirMethod '" << outdoorAirMethod << "' specified for OS:DesignSpecification:OutdoorAir named '"
59 << modelObject.name().get() << "'");
60 ✗ return boost::none;
61 }
62
63
1/1
✓ Branch 1 taken 63 times.
63 boost::optional<Schedule> schedule = modelObject.outdoorAirFlowRateFractionSchedule();
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if (schedule) {
65 ✗ idfObject.setString(DesignSpecification_OutdoorAirFields::OutdoorAirScheduleName, schedule->name().get());
66 }
67
68
1/1
✓ Branch 1 taken 63 times.
63 return idfObject;
69 63 }
70 } // namespace detail
71
72 166 boost::optional<IdfObject> ForwardTranslator::getOrCreateThermalZoneDSOA(const model::ThermalZone& z) {
73
74
2/2
✓ Branch 1 taken 166 times.
✓ Branch 4 taken 166 times.
166 auto objInMapIt = m_zoneDSOAsMap.find(z.handle());
75
2/2
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 140 times.
166 if (objInMapIt != m_zoneDSOAsMap.end()) {
76
1/1
✓ Branch 2 taken 26 times.
26 return objInMapIt->second;
77 }
78
79 63 auto translateAndMapDSOA = [this](DesignSpecificationOutdoorAir& dsoa) -> boost::optional<IdfObject> {
80
2/2
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
63 auto objInMapIt = m_map.find(dsoa.handle());
81
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 61 times.
63 if (objInMapIt != m_map.end()) {
82
1/1
✓ Branch 2 taken 2 times.
2 return objInMapIt->second;
83 }
84
85
1/1
✓ Branch 1 taken 61 times.
61 auto idf_dsoa_ = detail::translateDesignSpecificationOutdoorAir(dsoa);
86
87
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (idf_dsoa_) {
88
2/2
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
61 m_idfObjects.push_back(*idf_dsoa_);
89
3/3
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
61 m_map.emplace(dsoa.handle(), *idf_dsoa_);
90
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if (m_progressBar) {
92 ✗ m_progressBar->setValue((int)m_map.size());
93 }
94 }
95 61 return idf_dsoa_;
96 61 };
97
98
1/1
✓ Branch 1 taken 140 times.
140 auto spaces = z.spacesWithDesignSpecificationOutdoorAir();
99
2/2
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 28 times.
140 if (spaces.empty()) {
100
2/2
✓ Branch 1 taken 112 times.
✓ Branch 4 taken 112 times.
112 m_zoneDSOAsMap.emplace(z.handle(), boost::none);
101 112 return boost::none;
102 }
103
104 28 OptionalIdfObject result;
105
106
7/7
✓ Branch 1 taken 28 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 6 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 13 times.
28 if (m_forwardTranslatorOptions.excludeSpaceTranslation() || spaces.size() == 1) {
107 // Spaces, and therefore DSOAs have been combined already
108
3/3
✓ Branch 2 taken 15 times.
✓ Branch 5 taken 15 times.
✓ Branch 8 taken 15 times.
15 auto dsoa = spaces.front().designSpecificationOutdoorAir().get();
109
1/1
✓ Branch 1 taken 15 times.
15 result = translateAndMapDSOA(dsoa);
110 15 } else {
111
112 // DSOA:SpaceList
113
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 IdfObject dsoa_sp(IddObjectType::DesignSpecification_OutdoorAir_SpaceList);
114
3/3
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
13 dsoa_sp.setName(z.nameString() + " DSOA Space List");
115
116 // sort by space name so we ensure consistency/reproducibility
117
1/1
✓ Branch 3 taken 13 times.
13 std::sort(spaces.begin(), spaces.end(), WorkspaceObjectNameLess());
118
2/2
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 13 times.
61 for (const auto& s : spaces) {
119
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 auto dsoa = *(s.designSpecificationOutdoorAir());
120
2/3
✓ Branch 1 taken 48 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
96 if (auto dsoa_ = translateAndMapDSOA(dsoa)) {
121
4/6
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 8 taken 96 times.
✓ Branch 9 taken 48 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
192 dsoa_sp.pushExtensibleGroup({s.nameString(), dsoa_->nameString()});
122 48 }
123 48 }
124
125
1/1
✓ Branch 1 taken 13 times.
13 m_idfObjects.push_back(dsoa_sp);
126
1/1
✓ Branch 1 taken 13 times.
13 result = dsoa_sp;
127 13 }
128
129
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if (result) {
130
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
28 m_zoneDSOAsMap.emplace(z.handle(), result);
131 } else {
132 ✗ m_zoneDSOAsMap.emplace(z.handle(), boost::none);
133 }
134
135 28 return result;
136 188 }
137
138 } // namespace energyplus
139
140 } // namespace openstudio
141