def createNew_clone(folder, cloneFrom, newMeshInstance): """ Creates a new runConfig in a not previously existing folder, which has identical settings as an already existing runConfig. The newly created runConfig is then returned. This is a deep copy, runners, solvers, and analysis etc. are also cloned. """ #Create the new runConfig AcdOptiRunConfig.createNew(folder, cloneFrom.runner.type, None) newRC = AcdOptiRunConfig(folder, newMeshInstance) #Copy runner data newRC.runner.cloneInto(cloneFrom.runner) #Copy the solvers for solv in cloneFrom.solverSetups: print "Add solver " + str(solv) newSolv = AcdOptiSolverSetup.createNew_clone(folder, solv,newRC) newRC.solverSetups.append(newSolv) #Copy analysis for (anaName, ana) in cloneFrom.analysis.iteritems(): newRC.analysis[anaName] = ana.createNew_clone(os.path.join(folder, "analysis"), ana, newRC) newRC.refreshStatus() newRC.write() return newRC
def createNew(folder, runnerType, solverTypes=None): """ Create a new RunConfig, if wanted with ready-made SolverSetups and Runners created and attached. Input: - Folder : In which folder to store the setup files etc. - runnerType : String with the runner type wanted (example: Hopper) - solverTypes : String or list of strings with the types of SolverSetups wanted (as accepted by AcdOptiSolverSetup.createNew()). If None, don't attach any solvers """ print "AcdOptiRunConfig::createNew(), folder=" + folder #Construct the instance name from folder instname = folder if instname[-1] == "/": instname = instname[0:-1] instname = os.path.split(instname)[1] if os.path.isdir(folder): raise AcdOptiException_runConfig_createFail ("Folder \"" + folder + "\" already exists") os.mkdir(folder) #Create the SolverSetups: solverSetups = [] if solverTypes == None: pass #To simplify the "else" at the end... elif type(solverTypes) == str: solverSetups.append(AcdOptiSolverSetup.createNew(solverTypes, folder)) elif type(solverTypes) == list: for st in solverTypes: solverSetups.append(AcdOptiSolverSetup.createNew(st, folder)) else: raise AcdOptiException_runConfig_createFail ("Expected solverTypes to be a string or list of strings, got " + str(solverTypes)) #Create the runner AcdOptiRunner.createNew(runnerType, folder) #Create the paramFile paramFile = AcdOptiFileParser_simple(\ os.path.join(folder, "paramFile.set"), 'w') paramFile.dataDict.pushBack("fileID", "runConfigParamFile") paramFile.dataDict.pushBack("instName", instname) if len(solverSetups): paramFile.dataDict.pushBack("status", "initialized") else: paramFile.dataDict.pushBack("status", "not_initialized") paramFile.dataDict.pushBack("stageName", "") # paramFile.dataDict.pushBack("stageFolder", "") # paramFile.dataDict.pushBack("stageFile", "") # paramFile.dataDict.pushBack("finishedFolder", "") #Pushback all solverSetups under the same key for ssName in solverSetups: paramFile.dataDict.pushBack("solverSetup", ssName) #Runner type paramFile.dataDict.pushBack("runnerType", runnerType) #Analysis dictionary paramFile.dataDict.pushBack("analysis", DataDict()) paramFile.write() #Create the staging folder os.mkdir(os.path.join(folder, "stage")) #Create the finished folder os.mkdir(os.path.join(folder, "finished")) #Create the analysis folder os.mkdir(os.path.join(folder,"analysis"))