GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 40 / 0 / 40
Functions: 100.0% 1 / 0 / 1
Branches: 97.7% 85 / 0 / 87

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/DefaultConstructionSet.hpp"
13 #include "../../model/Site.hpp"
14 #include "../../model/Site_Impl.hpp"
15 #include "../../model/SimulationControl.hpp"
16 #include "../../model/SimulationControl_Impl.hpp"
17 #include "../../model/ShadingSurfaceGroup.hpp"
18 #include "../../model/LifeCycleCost.hpp"
19
20 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
21 #include "../../utilities/idf/Workspace.hpp"
22 #include "../../utilities/idf/WorkspaceObjectOrder.hpp"
23 #include "../../utilities/core/Logger.hpp"
24 #include "../../utilities/core/Assert.hpp"
25 #include <utilities/idd/Building_FieldEnums.hxx>
26 #include <utilities/idd/IddEnums.hxx>
27
28 using namespace openstudio::model;
29
30 using namespace std;
31
32 namespace openstudio {
33
34 namespace energyplus {
35
36 870 boost::optional<IdfObject> ForwardTranslator::translateBuilding(Building& modelObject) {
37
1/1
✓ Branch 1 taken 870 times.
870 Model model = modelObject.model();
38
39
2/2
✓ Branch 1 taken 870 times.
✓ Branch 4 taken 870 times.
870 IdfObject idfObject(IddObjectType::Building);
40
1/1
✓ Branch 1 taken 870 times.
870 m_idfObjects.push_back(idfObject);
41
42
4/4
✓ Branch 1 taken 870 times.
✓ Branch 7 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 870 times.
872 for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) {
43
1/1
✓ Branch 1 taken 2 times.
2 translateAndMapModelObject(lifeCycleCost);
44 872 }
45
46
1/1
✓ Branch 1 taken 870 times.
870 OptionalString optS = modelObject.name();
47
1/2
✓ Branch 0 taken 870 times.
✗ Branch 1 not taken.
870 if (optS) {
48
3/3
✓ Branch 1 taken 870 times.
✓ Branch 4 taken 870 times.
✓ Branch 7 taken 870 times.
870 idfObject.setName(stripOS2(*optS));
49 }
50
51
3/3
✓ Branch 1 taken 870 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 855 times.
870 if (!modelObject.isNorthAxisDefaulted()) {
52
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
15 idfObject.setDouble(openstudio::BuildingFields::NorthAxis, modelObject.northAxis());
53 }
54
55 // terrain comes from Site
56
1/1
✓ Branch 1 taken 870 times.
870 OptionalSite site = model.getOptionalUniqueModelObject<Site>();
57
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 820 times.
870 if (site) {
58
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()) {
59
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());
60 }
61 }
62
63 // these fields come from SimulationControl
64
1/1
✓ Branch 1 taken 870 times.
870 OptionalSimulationControl simulationControl = model.getOptionalUniqueModelObject<SimulationControl>();
65
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 809 times.
870 if (simulationControl) {
66
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()) {
67
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());
68 }
69
70
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()) {
71
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 idfObject.setDouble(openstudio::BuildingFields::TemperatureConvergenceToleranceValue,
72 simulationControl->temperatureConvergenceToleranceValue());
73 }
74
75
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()) {
76
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());
77 }
78
79
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()) {
80
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());
81 }
82
83
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()) {
84
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());
85 }
86 }
87
88 // translate shading groups
89
1/1
✓ Branch 1 taken 870 times.
870 ShadingSurfaceGroupVector shadingSurfaceGroups = modelObject.shadingSurfaceGroups();
90
1/1
✓ Branch 3 taken 870 times.
870 std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess());
91
2/2
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 870 times.
910 for (ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups) {
92
1/1
✓ Branch 1 taken 40 times.
40 translateAndMapModelObject(shadingSurfaceGroup);
93 }
94
95
3/3
✓ Branch 1 taken 870 times.
✓ Branch 3 taken 867 times.
✓ Branch 4 taken 3 times.
870 if (!m_forwardTranslatorOptions.excludeConstructionAssignmentSets()) {
96 // NOTE: the DefaultConstructionSet of the Building is already merged with the DCS of the Building's SpaceType if needed (collapseToSpaceAndBuilding)
97
3/3
✓ Branch 1 taken 867 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 807 times.
1734 if (auto defaultConstructionSet_ = modelObject.defaultConstructionSet()) {
98
3/4
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
120 if (auto wo_ = translateAndMapModelObject(*defaultConstructionSet_)) {
99
3/3
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 7 taken 60 times.
60 idfObject.setString(BuildingFields::ConstructionAssignmentSetName, wo_->nameString());
100 60 }
101 867 }
102 }
103
104
1/1
✓ Branch 1 taken 870 times.
1740 return idfObject;
105 870 }
106
107 } // namespace energyplus
108
109 } // namespace openstudio
110