Example #1
0
def SolverRun():
    p = projectutils.getActiveProject()

    if not p.runs:
        quickui.error("You should create a Run before doing this operation.")
        return
    SolverExecute(p=p,run=p.activerun)
Example #2
0
    def createSubdLink(self):
	if os.path.exists(os.path.join(self.project['projectdir'],'Subds_')+str(self.project[self.runname]['subdomains'])):
	   if not os.path.exists(os.path.join(self.path,'Subdomains')):
              os.symlink(os.path.join(self.project['projectdir'],'Subds_')+str(self.project[self.runname]['subdomains']),os.path.join(self.path,'Subdomains'))
        else:
           quickui.error(message='Unable to locate subdomain directory.')
	   raise OSError('Unable to locate subdomain directory.')
Example #3
0
def checkOutputFile(out={},key=None,status=False,errmsg=None):
    parent=tool.getToolWindow()

    if int(out['zip_opt']):
       status = quickui.runWithProgressDialog(parent,'Zipping',zip_File,pulse=True,key=key,output=out)

    if not status or (not os.path.isfile(out[key]) and not os.path.isfile(out[key]+'.gz') ):
       quickui.error(message=errmsg)
       raise IOError(errmsg)
Example #4
0
    def __init__(self, project=None, runname=None):
        self.project = projectutils.getActiveProject()

        self.runname=runname

        if not self.runname:
            self.runname = p.activerun
        
        path=os.path.join(self.project[self.runname]['path'],"run.tree")
        self.runtree=common.parseTree(path,root=self.runname)
        self.path= self.project[self.runname]['path']
          
        self.bcs=self.project['bcs']
        self.cellzone=self.project['cellzone']
 
        self.configs = self._readConfigTree()
        solverdata=self._getSolverData()
        self.rans_dir=os.path.join(self.project[self.runname]['path'],'Flowsolver_input')
        
        if not os.path.isdir(self.rans_dir):
	   os.mkdir(self.rans_dir)
           if not os.path.isdir(self.rans_dir):
	      quickui.error(message='Unbale to create Flowsolver_input dorectory.')
              raise OSError('Unbale to create Flowsolver_input dorectory.')

        templatePath=self._getTemplate('userchoice.inp_template')
        self._writeSolverData('/userchoice.inp',solverdata,templatePath,)
        templatePath=self._getTemplate('freestream.inp_template')
        self._writeSolverData('/freestream.inp',solverdata,templatePath,)
        templatePath=self._getTemplate('run_option.inp_template')
        self._writeSolverData('run_option.inp',solverdata,templatePath,)
        templatePath=self._getTemplate('boundary_information.inp_template')
        self._writeSolverData('boundary_information.inp',solverdata,templatePath,)
        templatePath=self._getTemplate('lift_drag_contrib.inp_template')
        self._writeSolverData('lift_drag_contrib.inp',solverdata,templatePath,)
        templatePath=self._getTemplate('halt.inp_template')
        self._writeSolverData('halt.inp',solverdata,templatePath,)

	self.createSubdLink()
Example #5
0
    def __init__(self,p=None,run=None):
	
	self.project=p or projectutils.getActiveProject()
	self.runname=run or self.project[self.runname]['name']
	self.no_of_subd=self.project[self.runname]['subdomains']
	self.runpath=os.path.join(self.project[self.runname]['path'])
	self.rep=project.getRepository()
	self.machfile=project.getMachineFile()
	self.flags=project.getSolverFlags()

	self.subd_dir=os.path.join(self.project['projectdir'],'Subds_')+str(self.no_of_subd)
	self.subd_dir_link=os.path.join(self.runpath,'Subdomains')

        if not os.path.isfile(os.path.join(self.runpath,'Flowsolver_input/userchoice.inp')) or \
	   not os.path.isfile(os.path.join(self.runpath,'Flowsolver_input/freestream.inp')) or \
	   not os.path.isfile(os.path.join(self.runpath,'Flowsolver_input/run_option.inp')) or \
	   not os.path.isfile(os.path.join(self.runpath,'Flowsolver_input/boundary_information.inp')) or \
	   not os.path.isfile(os.path.join(self.runpath,'Flowsolver_input/lift_drag_contrib.inp')):
	   quickui.error(message='Required Flow solver input files are not available for current run.\nPlease check.')
	   raise IOError('Required Flow solver input files are not available for current run. Please check.')

        if not self.machfile or not os.path.isfile(self.machfile):
	   quickui.error(message='Required Machine file is not found. Unable to execute.')
	   raise IOError('Required Machine file is not found. Unable to execute.')

        if os.path.exists(self.subd_dir):
	   if not os.path.islink(self.subd_dir_link) and not os.path.realpath(self.subd_dir_link)==self.subd_dir:
	      quickui.error(message='Invalid Subdomain directory.\nPlease check.')
	      raise IOError('Invalid Subdomain directory. Please check.')
	else:
	   quickui.error(message='Unable to locate subdomain directory.\nPlease check.')
	   raise IOError('Unable to locate subdomain directory. Please check.')

	extra_lib_path=os.getenv('EXTRA_LIB')
	flist=os.listdir(extra_lib_path)
	openmpi_dir=None
	pt=re.compile(('openmpi.'))
	for item in flist:
	    if re.match(pt,item):
	       openmpi_dir=os.path.join(extra_lib_path,item)
	       break
        if not openmpi_dir or not os.path.exists(openmpi_dir):
	   quickui.error(message='Unable to locate openmpi.\nPlease check.')
	   raise IOError('Unable to locate openmpi. Please check.')

	mpiexe=os.path.join(openmpi_dir,'bin/mpirun')

	if not os.path.isfile(mpiexe):
           quickui.error(message='Unable to locate mpirun command.\nPlease check.')
           raise IOError('Unable to locate mpirun command. Please check.')

	rans_exe=os.path.join(const.home,'bin/rans_3d_tempfac_mod2_WF')

	solvercmd=[mpiexe,'-machinefile',self.machfile,'-np',str(self.no_of_subd),rans_exe]
	if self.flags:
	   solvercmd.insert(1,self.flags)
	cpath=os.getcwd()
	os.chdir(self.runpath)
	p1=subprocess.Popen(solvercmd)

	p1.wait()
	os.chdir(cpath)
Example #6
0
def executeParallelPreprocessor(p,subds):

    out={}
    out['no_of_subds']=str(subds)

    parent = tool.getToolWindow()

    set_Parallel_Preprocess_Data(x=out,p=p)

    os.chdir(out['path'])

    if subds < 2:
       quickui.error(message='Number of subdomains are less than 2. Unable to Execute.')
       raise ValueError
    
    metis=os.path.join(const.home,"Third_Party/METIS/kmetis")

    if not metis:
       quickui.error(message='KMETIS not found. Unable to proceed')
       raise RuntimeError

    if os.path.exists(out['subd_dir']):
       msg="Subdomain Directory "+out['subd_dir']+" is already available. Do you want to overwrite?."
       subd=quickui.question(message=msg)
       if subd == -8:
	  shutil.rmtree(out['subd_dir'])
       else:
          return
 
    if out['graphfile'].endswith('.gz'):
       out['graphfile']=unzip_File(out['graphfile'])
      
    quickui.runWithProgressDialog(parent, "METIS", executeMetis, pulse=True, output=out)

    if int(out['zip_opt']):
       quickui.runWithProgressDialog(parent, "Zipping", zip_File, pulse=True, key='graphfile',output=out)
       #zip_File(key='graphfile',output=out,task=None)

    if not os.path.isfile(out['partfile']):
       quickui.error(message='Unable to create part file.')
       raise IOError

    if int(out['zip_opt']):
       quickui.runWithProgressDialog(parent, "Zipping", zip_File, pulse=True, key='partfile',output=out)
       #out['partfile']=zip_File(out['partfile'])


    if not os.path.isfile(out['cellzone_file']):
       quickui.error(message='cellzone.dat file not found in project directory. Unable to proceed.')
       raise IOError
 
    os.mkdir(out['subd_dir'])

    if not os.path.exists(out['subd_dir']):
       msg="Unable to create Subdomain Directory "+out['subd_dir']+"."
       subd=quickui.info(message=msg)
       raise OSError("Unable to create Subdomain Directory")
            
    os.chdir(out['subd_dir'])

    quickui.runWithProgressDialog(parent, "FEP", executeFEP, pulse=False,output=out)

    ps=re.compile(('SUBDOMAIN.'))

    slist=os.listdir(os.getcwd())
    lst=[]
    for item in slist:
       if re.match(ps,item):
          lst.append(item)

    if len(lst) != int(out['no_of_subds']):
       quickui.error(message='Unable to create SUBDOMAINS.')
       shutil.rmtree(out['subd_dir'])
       raise IOError

    os.chdir(out['cexepath'])
Example #7
0
def writeSolverData():
    p = projectutils.getActiveProject()
    if not p.runs:
        quickui.error("You should create a Run before doing this operation.")
        return
    SolverInpWriter(project=p, runname=p.activerun)