GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 86.0% 37 / 0 / 43
Functions: 100.0% 4 / 0 / 4
Branches: 72.2% 65 / 0 / 90

src/workflow/RunPreProcess.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 "OSWorkflow.hpp"
7
8 #include "RunPreProcessMonthlyReports.hpp"
9
10 #include "../utilities/idf/Workspace.hpp"
11 #include "../utilities/idf/IdfFile.hpp"
12 #include "../utilities/idf/IdfObject.hpp"
13 #include "../utilities/idd/IddObject.hpp"
14 #include "../utilities/idf/IdfExtensibleGroup.hpp"
15
16 #include "../utilities/filetypes/WorkflowJSON.hpp"
17 #include "../utilities/filetypes/RunOptions.hpp"
18 #include "../utilities/core/Filesystem.hpp"
19
20 #include <utilities/idd/IddEnums.hxx>
21 #include <utilities/idd/Output_SQLite_FieldEnums.hxx>
22
23 #include <array>
24 #include <string_view>
25 #include <string>
26
27 namespace openstudio {
28
29 12 void OSWorkflow::runPreProcess() {
30 12 state = State::PreProcess;
31
32 // Skip the pre-processor if halted
33
2/3
✓ Branch 1 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
12 if (runner.halted()) {
34 ✗ LOG(Info, "Workflow halted, skipping the EnergyPlus pre-processor");
35 ✗ return;
36 }
37
38
1/1
✓ Branch 1 taken 12 times.
12 auto runDirPath = workflowJSON.absoluteRunDir();
39
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 const bool skipEnergyPlusPreprocess = workflowJSON.runOptions()->skipEnergyPlusPreprocess();
40
41 // Save the preprocess file
42
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (!skipEnergyPlusPreprocess) {
43 // Save to run dir
44
1/1
✓ Branch 1 taken 12 times.
24 auto savePath = runDirPath / "pre-preprocess.idf";
45
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 detailedTimeBlock("Saving Preprocess IDF to Run Dir", [this, &savePath]() {
46 // TODO: workflow gem was actually serializating via model.to_s for speed...
47 12 workspace_->save(savePath, true);
48 12 });
49 12 }
50
51 // Add any EnergyPlus Output Requests from Reporting Measures
52
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 LOG(Info, "Beginning to collect EnergyPlus output requests from Reporting measures.");
53
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 applyMeasures(MeasureType::ReportingMeasure, ApplyMeasureType::EnergyPlusOutputRequest);
54
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 LOG(Info, "Finished collecting EnergyPlus output requests from Reporting measures.");
55
56 // TODO: I am extremely confused as to why we force add this stuff...
57
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (!skipEnergyPlusPreprocess) {
58
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 LOG(Info, "Running EnergyPlus Preprocess");
59
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 detailedTimeBlock("Running EnergyPlus Preprocess", [this] {
60
4/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
12 if (workspace_->getObjectsByType(IddObjectType::Output_SQLite).empty()) {
61 ✗ LOG(Info, "Adding SQL Output to IDF");
62 ✗ auto sqliteOutput_ = workspace_->addObject(IdfObject(IddObjectType::Output_SQLite));
63 ✗ sqliteOutput_->setString(Output_SQLiteFields::OptionType, "SimpleAndTabular");
64 ✗ }
65
66
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
108 for (auto meter : c_monthlyReports) {
67
2/2
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
96 auto idfObject_ = openstudio::IdfObject::load(std::string{meter});
68
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 4 not taken.
96 OS_ASSERT(idfObject_);
69
3/3
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 7 taken 96 times.
96 workspace_->addObject(idfObject_.get());
70 96 }
71
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 12 times.
96 for (auto meter : c_metersForced) {
72
2/2
✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
84 auto idfObject_ = openstudio::IdfObject::load(std::string{meter});
73
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 4 not taken.
84 OS_ASSERT(idfObject_);
74
3/3
✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
✓ Branch 7 taken 84 times.
84 workspace_->addObject(idfObject_.get());
75 84 }
76 12 });
77
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 LOG(Info, "Finished preprocess job for EnergyPlus simulation");
78 }
79
80 // Save final IDF
81
1/1
✓ Branch 1 taken 12 times.
24 auto savePath = runDirPath / "in.idf";
82
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 detailedTimeBlock("Saving Final IDF to Run Dir", [this, &savePath]() {
83 // TODO: workflow gem was actually serializating via model.to_s for speed...
84 12 workspace_->save(savePath, true);
85 12 });
86
6/6
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
12 LOG(Debug, "Saved final IDF as " << savePath);
87
88 // Perform pre-processing on in.idf to capture logic in RunManager
89
90
1/1
✓ Branch 1 taken 12 times.
12 saveIDFToRootDirIfDebug();
91 12 }
92 } // namespace openstudio
93