void ParallelEnergyPlusSplitJob::startImpl(const std::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(); QWriteLocker l(&m_mutex); if (!m_input) { m_input = inputFile(); resetFiles(m_files, m_input); } LOG(Info, "ParallelEnergyPlusSplit starting, filename: " << toString(m_input->fullPath)); LOG(Info, "ParallelEnergyPlusSplit starting, outdir: " << toString(outpath)); JobErrors errors; errors.result = ruleset::OSResultValue::Success; l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); try { boost::filesystem::create_directories(outpath); FileInfo inputfile = inputFile(); openstudio::path input = inputfile.fullPath; LOG(Debug, "Splitting inputfile: " << toString(input) << " into " << m_numSplits << " parts"); std::vector<openstudio::path> outfilepaths = generateFileNames(outpath, m_numSplits); ParallelEnergyPlus p(input, m_numSplits, m_offset); for (int i = 0; i < m_numSplits; ++i) { p.writePartition(i, outfilepaths[i]); emitOutputFileChanged(RunManager_Util::dirFile(outfilepaths[i])); } } catch (const std::exception &e) { LOG(Debug, "Error executing split job: " << e.what()); errors.addError(ErrorType::Error, "Error with execution: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } setErrors(errors); }
Files ParallelEnergyPlusSplitJob::outputFilesImpl() const { // Save off the set of requiredfiles, see below std::vector<std::pair<QUrl, openstudio::path> > requiredFiles = inputFile().requiredFiles; std::vector<openstudio::path> files = generateFileNames(outdir(), m_numSplits); Files retval; for (std::vector<openstudio::path>::const_iterator itr = files.begin(); itr != files.end(); ++itr) { if (boost::filesystem::exists(*itr)) { FileInfo fi = RunManager_Util::dirFile(*itr); // we want to carry along the set of required files used in the original IDF to the children // (ie, the epw file) fi.requiredFiles = requiredFiles; retval.append(fi); } } return retval; }
void generateWaveBenchmarkTimeVariant(char *destinyFileName,char *folderName,void (*waveFunction)(structMatrix,structMatrix,structMatrix*,structMatrix*)) { /* * Initiating the mesh */ structMatrix mesh_hmatrix,mesh_vmatrix; structMatrix u_matrix_timeV[N_TIME_STEPS],v_matrix_timeV[N_TIME_STEPS]; // Initiating mesh mesh_hmatrix = initMatrix(N_HNODES,N_VNODES); mesh_vmatrix = initMatrix(N_HNODES,N_VNODES); loadMesh(mesh_hmatrix,mesh_vmatrix); char path[N_TIME_STEPS][MAX_FILENAME_LENGTH]; generateFileNames(path,destinyFileName,folderName); for(int i=0; i< N_TIME_STEPS; i++) { //printf("path[%d]: %s\n",i,path[i]); // Initializing u and v matrixes u_matrix_timeV[i] = initMatrix(N_HNODES,N_VNODES); v_matrix_timeV[i] = initMatrix(N_HNODES,N_VNODES); } // Calculations are handled via callback // This function must calculate for every time-step! waveFunction(mesh_hmatrix,mesh_vmatrix,u_matrix_timeV,v_matrix_timeV); // Printing matrixes to files for(int i=0; i< N_TIME_STEPS; i++) { char indexu[4],indexv[4],quiverexp[30]; sprintf(indexu,"u%d",i); sprintf(indexv,"v%d",i); sprintf(quiverexp,"quiver(x,y,%s,%s)\n",indexu,indexv); printMatrixToFile(u_matrix_timeV[i],path[i],indexu); printMatrixToFile(v_matrix_timeV[i],path[i],indexv); printMatrixToFile(mesh_hmatrix,path[i],"x"); printMatrixToFile(mesh_vmatrix,path[i],"y"); // At the end, print the "quiver" function FILE *destinyFile = fopen(path[i],"a"); fprintf(destinyFile,"%s",quiverexp); fclose(destinyFile); } // Memory freeing for(int i=0; i< N_TIME_STEPS; i++) { destroyMatrix(u_matrix_timeV[i]); destroyMatrix(v_matrix_timeV[i]); } destroyMatrix(mesh_hmatrix); destroyMatrix(mesh_vmatrix); // Generate the plotter script char plotterName[MAX_FILENAME_LENGTH]; FILE *plotter; strcpy(plotterName,"../testbench/"); strcat(plotterName,folderName); strcat(plotterName,"/"); strcat(plotterName,destinyFileName); strcat(plotterName,"_plotter.m"); plotter = fopen(plotterName,"w"); for(int i=0; i< N_TIME_STEPS; i++ ) { fprintf(plotter,"%s_%d \nprint -djpg %s_%d.jpg\n",destinyFileName,i,destinyFileName,i); } fclose(plotter); }