MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / runPreProcess

Method runPreProcess

src/workflow/RunPreProcess.cpp:29–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace openstudio {
28
29void OSWorkflow::runPreProcess() {
30 state = State::PreProcess;
31
32 // Skip the pre-processor if halted
33 if (runner.halted()) {
34 LOG(Info, "Workflow halted, skipping the EnergyPlus pre-processor");
35 return;
36 }
37
38 auto runDirPath = workflowJSON.absoluteRunDir();
39 const bool skipEnergyPlusPreprocess = workflowJSON.runOptions()->skipEnergyPlusPreprocess();
40
41 // Save the preprocess file
42 if (!skipEnergyPlusPreprocess) {
43 // Save to run dir
44 auto savePath = runDirPath / "pre-preprocess.idf";
45 detailedTimeBlock("Saving Preprocess IDF to Run Dir", [this, &savePath]() {
46 // TODO: workflow gem was actually serializating via model.to_s for speed...
47 workspace_->save(savePath, true);
48 });
49 }
50
51 // Add any EnergyPlus Output Requests from Reporting Measures
52 LOG(Info, "Beginning to collect EnergyPlus output requests from Reporting measures.");
53 applyMeasures(MeasureType::ReportingMeasure, ApplyMeasureType::EnergyPlusOutputRequest);
54 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 if (!skipEnergyPlusPreprocess) {
58 LOG(Info, "Running EnergyPlus Preprocess");
59 detailedTimeBlock("Running EnergyPlus Preprocess", [this] {
60 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 for (auto meter : c_monthlyReports) {
67 auto idfObject_ = openstudio::IdfObject::load(std::string{meter});
68 OS_ASSERT(idfObject_);
69 workspace_->addObject(idfObject_.get());
70 }
71 for (auto meter : c_metersForced) {
72 auto idfObject_ = openstudio::IdfObject::load(std::string{meter});
73 OS_ASSERT(idfObject_);
74 workspace_->addObject(idfObject_.get());
75 }
76 });
77 LOG(Info, "Finished preprocess job for EnergyPlus simulation");
78 }
79
80 // Save final IDF
81 auto savePath = runDirPath / "in.idf";
82 detailedTimeBlock("Saving Final IDF to Run Dir", [this, &savePath]() {
83 // TODO: workflow gem was actually serializating via model.to_s for speed...
84 workspace_->save(savePath, true);
85 });
86 LOG(Debug, "Saved final IDF as " << savePath);

Callers

nothing calls this directly

Calls 11

haltedMethod · 0.80
absoluteRunDirMethod · 0.80
runOptionsMethod · 0.80
IdfObjectClass · 0.70
saveMethod · 0.45
emptyMethod · 0.45
getObjectsByTypeMethod · 0.45
addObjectMethod · 0.45
setStringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected