GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 93.9% 31 / 0 / 33
Functions: 100.0% 1 / 0 / 1
Branches: 88.2% 45 / 0 / 51

src/energyplus/ForwardTranslator/ForwardTranslateInteriorPartitionSurface.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 #include "../../model/InteriorPartitionSurface.hpp"
10 #include "../../model/InteriorPartitionSurface_Impl.hpp"
11 #include "../../model/InteriorPartitionSurfaceGroup.hpp"
12 #include "../../model/Space.hpp"
13 #include "../../model/ThermalZone.hpp"
14 #include "../../model/ConstructionBase.hpp"
15 #include "../../model/ConstructionBase_Impl.hpp"
16 #include "../../model/DaylightingDeviceShelf.hpp"
17
18 #include <utilities/idd/InternalMass_FieldEnums.hxx>
19 #include "../../utilities/idd/IddEnums.hpp"
20 #include <utilities/idd/IddEnums.hxx>
21 #include <utilities/idd/IddFactory.hxx>
22
23 using namespace openstudio::model;
24
25 using namespace std;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 162 boost::optional<IdfObject> ForwardTranslator::translateInteriorPartitionSurface(model::InteriorPartitionSurface& modelObject) {
32
2/3
✓ Branch 1 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
162 if (!modelObject.converttoInternalMass()) {
33 ✗ return boost::none;
34 }
35
36 // will get translated with light shelf
37
3/3
✓ Branch 1 taken 162 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 155 times.
324 if (modelObject.daylightingDeviceShelf()) {
38 7 return boost::none;
39 }
40
41
2/3
✓ Branch 1 taken 155 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 155 times.
155 if (modelObject.isAirWall()) {
42 ✗ return boost::none;
43 }
44
45
1/1
✓ Branch 1 taken 155 times.
155 boost::optional<ConstructionBase> construction = modelObject.construction();
46
2/2
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 35 times.
155 if (!construction) {
47 120 return boost::none;
48 }
49
50
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 IdfObject idfObject(openstudio::IddObjectType::InternalMass);
51
52
1/1
✓ Branch 1 taken 35 times.
35 m_idfObjects.push_back(idfObject);
53
54
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 idfObject.setString(InternalMassFields::Name, modelObject.nameString());
55
56
3/3
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
35 idfObject.setString(InternalMassFields::ConstructionName, construction->nameString());
57
58 // TODO: when m_forwardTranslatorOptions.excludeSpaceTranslation() is false, should we write the `Space or SpaceList Name` field? (cf InternalMass too)
59 35 double multiplier = 1.0;
60
1/1
✓ Branch 1 taken 35 times.
35 boost::optional<InteriorPartitionSurfaceGroup> group = modelObject.interiorPartitionSurfaceGroup();
61
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (group) {
62
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 multiplier = group->multiplier();
63
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 boost::optional<Space> space = group->space();
64
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (space) {
65
66 // Even if we want to bind to a Space Name, we need to write the Zone Name as it's a required field
67 // cf https://github.com/NREL/EnergyPlus/issues/9141
68
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 boost::optional<ThermalZone> thermalZone = space->thermalZone();
69
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (thermalZone) {
70
3/3
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
35 idfObject.setString(InternalMassFields::ZoneorZoneListName, thermalZone->nameString());
71 }
72
73
3/3
✓ Branch 1 taken 35 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 5 times.
35 if (!m_forwardTranslatorOptions.excludeSpaceTranslation()) {
74
4/4
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✓ Branch 10 taken 30 times.
30 idfObject.setString(InternalMassFields::SpaceorSpaceListName, space->name().get());
75 }
76 35 }
77 35 }
78
79
1/1
✓ Branch 1 taken 35 times.
35 boost::optional<double> surfaceArea = modelObject.surfaceArea();
80
1/2
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
35 if (!surfaceArea) {
81
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 surfaceArea = modelObject.grossArea();
82 }
83
84
2/2
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
35 idfObject.setDouble(InternalMassFields::SurfaceArea, multiplier * (*surfaceArea));
85
86
1/1
✓ Branch 1 taken 35 times.
35 return idfObject;
87 155 }
88
89 } // namespace energyplus
90
91 } // namespace openstudio
92