GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 34 / 0 / 34
Functions: 100.0% 1 / 0 / 1
Branches: 98.6% 73 / 0 / 74

src/energyplus/ForwardTranslator/ForwardTranslateBuilding.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/Building.hpp"
11 #include "../../model/Building_Impl.hpp"
12 #include "../../model/Site.hpp"
13 #include "../../model/Site_Impl.hpp"
14 #include "../../model/SimulationControl.hpp"
15 #include "../../model/SimulationControl_Impl.hpp"
16 #include "../../model/ShadingSurfaceGroup.hpp"
17 #include "../../model/LifeCycleCost.hpp"
18
19 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
20 #include "../../utilities/idf/Workspace.hpp"
21 #include "../../utilities/idf/WorkspaceObjectOrder.hpp"
22 #include "../../utilities/core/Logger.hpp"
23 #include "../../utilities/core/Assert.hpp"
24 #include <utilities/idd/Building_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26
27 using namespace openstudio::model;
28
29 using namespace std;
30
31 namespace openstudio {
32
33 namespace energyplus {
34
35 856 boost::optional<IdfObject> ForwardTranslator::translateBuilding(Building& modelObject) {
36
1/1
✓ Branch 1 taken 856 times.
856 Model model = modelObject.model();
37
38
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 IdfObject idfObject(IddObjectType::Building);
39
1/1
✓ Branch 1 taken 856 times.
856 m_idfObjects.push_back(idfObject);
40
41
4/4
✓ Branch 1 taken 856 times.
✓ Branch 7 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 856 times.
858 for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) {
42
1/1
✓ Branch 1 taken 2 times.
2 translateAndMapModelObject(lifeCycleCost);
43 858 }
44
45
1/1
✓ Branch 1 taken 856 times.
856 OptionalString optS = modelObject.name();
46
1/2
✓ Branch 0 taken 856 times.
✗ Branch 1 not taken.
856 if (optS) {
47
3/3
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
✓ Branch 7 taken 856 times.
856 idfObject.setName(stripOS2(*optS));
48 }
49
50
3/3
✓ Branch 1 taken 856 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 841 times.
856 if (!modelObject.isNorthAxisDefaulted()) {
51
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
15 idfObject.setDouble(openstudio::BuildingFields::NorthAxis, modelObject.northAxis());
52 }
53
54 // terrain comes from Site
55
1/1
✓ Branch 1 taken 856 times.
856 OptionalSite site = model.getOptionalUniqueModelObject<Site>();
56
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 806 times.
856 if (site) {
57
4/4
✓ Branch 1 taken 50 times.
✓ Branch 4 taken 50 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 46 times.
50 if (!site->isTerrainDefaulted()) {
58
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 idfObject.setString(openstudio::BuildingFields::Terrain, site->terrain());
59 }
60 }
61
62 // these fields come from SimulationControl
63
1/1
✓ Branch 1 taken 856 times.
856 OptionalSimulationControl simulationControl = model.getOptionalUniqueModelObject<SimulationControl>();
64
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 795 times.
856 if (simulationControl) {
65
4/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 56 times.
61 if (!simulationControl->isLoadsConvergenceToleranceValueDefaulted()) {
66
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 idfObject.setDouble(openstudio::BuildingFields::LoadsConvergenceToleranceValue, simulationControl->loadsConvergenceToleranceValue());
67 }
68
69
4/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 56 times.
61 if (!simulationControl->isTemperatureConvergenceToleranceValueDefaulted()) {
70
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 idfObject.setDouble(openstudio::BuildingFields::TemperatureConvergenceToleranceValue,
71 simulationControl->temperatureConvergenceToleranceValue());
72 }
73
74
4/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 56 times.
61 if (!simulationControl->isSolarDistributionDefaulted()) {
75
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 idfObject.setString(openstudio::BuildingFields::SolarDistribution, simulationControl->solarDistribution());
76 }
77
78
4/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 57 times.
61 if (!simulationControl->isMaximumNumberofWarmupDaysDefaulted()) {
79
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 idfObject.setInt(openstudio::BuildingFields::MaximumNumberofWarmupDays, simulationControl->maximumNumberofWarmupDays());
80 }
81
82
4/4
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 57 times.
61 if (!simulationControl->isMinimumNumberofWarmupDaysDefaulted()) {
83
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 idfObject.setInt(openstudio::BuildingFields::MinimumNumberofWarmupDays, simulationControl->minimumNumberofWarmupDays());
84 }
85 }
86
87 // translate shading groups
88
1/1
✓ Branch 1 taken 856 times.
856 ShadingSurfaceGroupVector shadingSurfaceGroups = modelObject.shadingSurfaceGroups();
89
1/1
✓ Branch 3 taken 856 times.
856 std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess());
90
2/2
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 856 times.
896 for (ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups) {
91
1/1
✓ Branch 1 taken 40 times.
40 translateAndMapModelObject(shadingSurfaceGroup);
92 }
93
94
1/1
✓ Branch 1 taken 856 times.
1712 return boost::optional<IdfObject>(idfObject);
95 856 }
96
97 } // namespace energyplus
98
99 } // namespace openstudio
100