void MethodTransform::sync_all() { std::vector<MethodTransform*> transforms; for (auto& centry : s_cache) { transforms.push_back(centry.second); } std::vector<WorkItem<MethodTransform>> workitems(transforms.size()); auto mt_sync = [](MethodTransform* mt) { mt->sync(); }; for (size_t i = 0; i < transforms.size(); i++) { workitems[i].init(mt_sync, transforms[i]); } WorkQueue wq; if (workitems.size() > 0) { wq.run_work_items(&workitems[0], (int)workitems.size()); } }
void startRunManager(openstudio::runmanager::RunManager& rm, const openstudio::path& osmPath, const openstudio::path& modelTempDir, std::vector <double> useRadianceForDaylightingCalculations, bool requireCalibrationReports, QWidget* parent) { // openstudio::path rmdbPath = modelTempDir / toPath("resources/run.db"); openstudio::path simulationDir = toPath("run"); try { // disconnect signals from current jobs before clearing jobs std::vector<openstudio::runmanager::Job> jobs = rm.getJobs(); for (auto itr = jobs.begin(); itr != jobs.end(); ++itr) { itr->disconnect(); } rm.setPaused(true); // clear current jobs rm.clearJobs(); if (boost::filesystem::exists(modelTempDir / toPath("resources") / simulationDir)) { boost::filesystem::remove_all(modelTempDir / toPath("resources") / simulationDir); } boost::optional<analysisdriver::SimpleProject> p = OSAppBase::instance()->project(); if (p) { openstudio::runmanager::ConfigOptions co(true); analysis::Problem prob = p->analysis().problem(); analysisdriver::AnalysisRunOptions runOptions = standardRunOptions(*p); std::vector<runmanager::WorkItem> workitems(prob.createWorkflow(p->baselineDataPoint(), runOptions.rubyIncludeDirectory()).toWorkItems()); openstudio::BCLMeasure reportRequestMeasure = openstudio::BCLMeasure::reportRequestMeasure(); openstudio::BCLMeasure standardReportsMeasure = openstudio::BCLMeasure::standardReportMeasure(); openstudio::BCLMeasure calibrationReportsMeasure = openstudio::BCLMeasure::calibrationReportMeasure(); // DLM: always add this measure even if the user has their own copy, this is more clear //bool standardReportsFound = findBCLMeasureWorkItem(workitems, standardReportsMeasure.uuid()); //if (!standardReportsFound){ bool test = addReportingMeasureWorkItem(workitems, standardReportsMeasure); OS_ASSERT(test); //} // DLM: always add this measure even if the user has their own copy, this is more clear //bool calibrationReportsFound = findBCLMeasureWorkItem(workitems, calibrationReportsMeasure.uuid()); //if (requireCalibrationReports && !calibrationReportsFound){ if (requireCalibrationReports){ bool test = addReportingMeasureWorkItem(workitems, calibrationReportsMeasure); OS_ASSERT(test); } /* // check if we need to use radiance if (useRadianceForDaylightingCalculations) { std::vector<openstudio::runmanager::ToolInfo> rad = co.getTools().getAllByName("rad").tools(); if (!rad.empty()) { openstudio::path radiancePath = rad.back().localBinPath.parent_path(); bool modeltoidffound(false); for (auto itr = workitems.begin(); itr != workitems.end(); ++itr) { if (itr->type == openstudio::runmanager::JobType::ModelToIdf) { workitems.insert(itr, runmanager::Workflow::radianceDaylightCalculations(runOptions.rubyIncludeDirectory(), radiancePath)); modeltoidffound = true; break; } } OS_ASSERT(modeltoidffound); } else { QMessageBox::information(parent, "Error with initiating simulation.", "Radiance simulation requested but radiance was not found.\nRadiance simulation will be skipped.", QMessageBox::Ok); } } */ // add the report request measure before energyplus but after any other energyplus measures test = addReportRequestMeasureWorkItem(workitems, reportRequestMeasure); OS_ASSERT(test); runmanager::Workflow wf(workitems); wf.add(co.getTools()); //openstudio::runmanager::JobParams params; //params.append("cleanoutfiles", "none"); //wf.add(params); runmanager::Job j = wf.create(modelTempDir / toPath("resources") / simulationDir, modelTempDir / openstudio::toPath("in.osm")); runmanager::JobFactory::optimizeJobTree(j); rm.enqueue(j, true); } // connect signals to new jobs jobs = rm.getJobs(); for (auto itr = jobs.begin(); itr != jobs.end(); ++itr) { if (parent){ bool isConnected = itr->connect(SIGNAL(outputDataAdded(const openstudio::UUID &, const std::string &)), parent, SLOT(outputDataAdded(const openstudio::UUID &, const std::string &))); OS_ASSERT(isConnected); } if (!itr->parent()) { // need to reset the base path of the top level job so it can find its osm in the saved // location // run in model dir //itr->setBasePath(osmPath.parent_path() / osmPath.stem()); // run in temp dir itr->setBasePath(modelTempDir / toPath("resources")); if (parent){ bool isConnected = itr->connect(SIGNAL(treeChanged(const openstudio::UUID &)), parent, SLOT(treeChanged(const openstudio::UUID &))); OS_ASSERT(isConnected); } std::shared_ptr<OSDocument> currentDocument = OSAppBase::instance()->currentDocument(); if (currentDocument){ bool isConnected = itr->connect(SIGNAL(treeChanged(const openstudio::UUID &)), currentDocument.get(), SIGNAL(treeChanged(const openstudio::UUID &))); OS_ASSERT(isConnected); } } } rm.setPaused(false); } catch (const std::exception &e) {