GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.2% 32 / 0 / 38
Functions: 100.0% 1 / 0 / 1
Branches: 48.2% 54 / 0 / 112

src/energyplus/ReverseTranslator/ReverseTranslateSurfacePropertySurroundingSurfaces.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 "../ReverseTranslator.hpp"
7
8 #include "../../model/SurfacePropertySurroundingSurfaces.hpp"
9
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Schedule_Impl.hpp"
12
13 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
14 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
15
16 #include <utilities/idd/SurfaceProperty_SurroundingSurfaces_FieldEnums.hxx>
17 #include <utilities/idd/IddEnums.hxx>
18
19 using namespace openstudio::model;
20
21 namespace openstudio {
22
23 namespace energyplus {
24
25 2 boost::optional<ModelObject> ReverseTranslator::translateSurfacePropertySurroundingSurfaces(const WorkspaceObject& workspaceObject) {
26 2 boost::optional<WorkspaceObject> wo_;
27 2 boost::optional<ModelObject> mo_;
28
29
1/1
✓ Branch 1 taken 2 times.
2 openstudio::model::SurfacePropertySurroundingSurfaces modelObject(m_model);
30
31 // Name
32
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 modelObject.setName(workspaceObject.nameString());
33
34 // Sky View Factor: Optional Double
35
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<double> skyViewFactor_ = workspaceObject.getDouble(SurfaceProperty_SurroundingSurfacesFields::SkyViewFactor)) {
36
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 modelObject.setSkyViewFactor(skyViewFactor_.get());
37 }
38
39 // Sky Temperature Schedule Name: Optional Object
40
3/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
4 if ((wo_ = workspaceObject.getTarget(SurfaceProperty_SurroundingSurfacesFields::SkyTemperatureScheduleName))) {
41
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
42
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto skyTemperatureSchedule_ = mo_->optionalCast<Schedule>()) {
43
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setSkyTemperatureSchedule(skyTemperatureSchedule_.get());
44 } else {
45 ✗ LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Sky Temperature Schedule Name'");
46 1 }
47 }
48 }
49 // Ground View Factor: Optional Double
50
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<double> groundViewFactor_ = workspaceObject.getDouble(SurfaceProperty_SurroundingSurfacesFields::GroundViewFactor)) {
51
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 modelObject.setGroundViewFactor(groundViewFactor_.get());
52 }
53
54 // Ground Temperature Schedule Name: Optional Object
55
3/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
4 if ((wo_ = workspaceObject.getTarget(SurfaceProperty_SurroundingSurfacesFields::GroundTemperatureScheduleName))) {
56
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
57
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<Schedule> _groundTemperatureSchedule = mo_->optionalCast<Schedule>()) {
58
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setGroundTemperatureSchedule(_groundTemperatureSchedule.get());
59 } else {
60 ✗ LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Ground Temperature Schedule Name'");
61 1 }
62 }
63 }
64
65 // Extensible groups
66
3/3
✓ Branch 1 taken 2 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 2 times.
8 for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) {
67
1/1
✓ Branch 1 taken 6 times.
6 auto weg = eg.cast<WorkspaceExtensibleGroup>();
68
69
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 auto surroundingSurfaceName = weg.getString(SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceName).get();
70
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (surroundingSurfaceName.empty()) {
71 ✗ LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has an empty Surrounding Surface Name field, skipping group");
72 }
73
74 // This has a default of 0, so roll with it
75
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 auto viewFactor = weg.getDouble(SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceViewFactor).get();
76
77
2/3
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
12 if ((wo_ = weg.getTarget(SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceTemperatureScheduleName))) {
78
3/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
12 if ((mo_ = translateAndMapWorkspaceObject(wo_.get()))) {
79
3/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
12 if (boost::optional<Schedule> tempSch_ = mo_->optionalCast<Schedule>()) {
80
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 modelObject.addSurroundingSurfaceGroup(surroundingSurfaceName, viewFactor, tempSch_.get());
81 } else {
82 ✗ LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has a wrong type for Temperature Schedule, expected Schedule, got "
83 << tempSch_->briefDescription());
84 6 }
85 } else {
86 ✗ LOG(Warn, "Could not translate Temperature Schedule for Extensible group " << eg.groupIndex());
87 }
88 } else {
89 ✗ LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) is missed the Temperature Schedule");
90 }
91 8 }
92
93
1/1
✓ Branch 1 taken 2 times.
4 return modelObject;
94 2 } // End of translate function
95
96 } // end namespace energyplus
97 } // end namespace openstudio
98