Esempio n. 1
0
 def setup(self, paramters):
     self.foamRun("blockMesh")
     if self.nproc > 1:
         Decomposer(args=[
             "--method=metis", "--clear",
             self.casename(), self.nproc
         ])
Esempio n. 2
0
    def autoDecompose(self):
        """Automatically decomposes the grid with a metis-algorithm"""

        if path.isdir(path.join(self.casedir(),"processor0")):
            warning("A processor directory already exists. There might be a problem")

        defaultMethod="metis"

        if getFoamVersion()>=(1,6):
            defaultMethod="scotch"

        args=["--method="+defaultMethod,
              "--clear",
              self.casename(),
              self.nproc,
              "--job-id=%s" % self.fullJobId()]

        if self.multiRegion:
            args.append("--all-regions")

        deco=Decomposer(args=args)
Esempio n. 3
0
def runCasesFiles(names, cases, runArg, n):
    start = os.getcwd()
    for case in cases:
        os.chdir(case)
        # change customeRegexp
        customRegexpName = "customRegexp.base"
        with open(os.path.join(case, 'customRegexp.base'), 'w+') as fd:
            fd.write(custom_reg_exp_contents)
        title = "Residuals for %s" %case
        customRegexpFile = ParsedParameterFile(customRegexpName)
        customRegexpFile["myFigure"]["theTitle"] = ('"'+title+'"')
        customRegexpFile.writeFile()
        # delete the header lines - ParsedParameterFile requires them, but the customRegexp dosen't seem to work when their around...
        lines = open(customRegexpName).readlines()
        open('customRegexp', 'w').writelines(lines[12:])
        print n
        #  if n>1 make sure case is decomposed into n processors
        if n > 1:
            print "decomposing %(case)s" % locals()
            ClearCase(" --processors-remove %(case)s" % locals())
            Decomposer('--silent %(case)s %(n)s' % locals())
Esempio n. 4
0
 def autoDecompose(self):
     """Decomposition used if no callback is specified"""
     deco = Decomposer(
         args=[self.caseDir,
               str(self["nrCpus"]), "--all-regions"])
Esempio n. 5
0
        subprocess.call(activator, shell=True)

        activator = 'funkySetFields -case '+refCase+' -field Ct -expression "1e-3" -condition "(pow(pos().x-'+str(pancakesCenters[pancackes,0])+',2) + pow(pos().y-'+str(pancakesCenters[pancackes,1])+',2) < pow('+str(radius)+',2) )&&(pos().z>0) && (pos().z<=(1e-6+0))" -time "0"'

        subprocess.call(activator, shell=True)
        dire=SolutionDirectory(refCase)
        sol=SolutionFile(dire.initialDir(),"Ct")
        sol.replaceBoundary("inlet","0")
        a= 'sh fixInlet.sh'
        subprocess.call(a, shell=True)

#        tobinary()
                # parallel decomposition
        if nproc > 1:
            args = ["--method=scotch", "--clear", refCase, nproc]
            Decomposer(args=args)

        run = BasicRunner(
            argv=[
                solver,
                "-case",
                caseName],
            silent=True,
            noLog=False)
        run.start()
        runCmd = 'pyFoamRunner.py advDiffMicellesNoFlow -case '+caseName+' > /dev/null 2>&1 &'
        # subprocess.call(runCmd, shell=True)
        post = 'mpirun -np ' + str(nproc) + ' foamToEnsight -case '+refCase+' -parallel -name pancanke_noflow_radius='+str(radius)+'_loc='+str(pancackes)
        subprocess.call(post, shell=True)
        a = "rm 0/t* 0/*.backup"
        subprocess.call(a, shell=True)
Esempio n. 6
0
 def run_decompose(self, work, wind_dict):
     if wind_dict['procnr'] < 2:
         self._r.status('skipped decompose')
         return
     ClearCase(args=work.name+'  --processors-remove')
     Decomposer(args=[work.name, wind_dict['procnr']])
Esempio n. 7
0
#! /usr/bin/env python

from PyFoam.Applications.Decomposer import Decomposer

Decomposer()
Esempio n. 8
0
        velBC.writeFile()

        #edit controlDict to account for change in U
        controlDict = ParsedParameterFile(
            path.join(clone_name, "system", "controlDict"))
        controlDict["functions"]["forcesCoeffs"]["liftDir"] = Vector(
            -sin(radians(angle)), cos(radians(angle)), 0)
        controlDict["functions"]["forcesCoeffs"]["dragDir"] = Vector(
            cos(radians(angle)), sin(radians(angle)), 0)
        controlDict["functions"]["forcesCoeffs"][
            "magUInf"] = mach * speedOfSound
        controlDict.writeFile()

        #implement parallelization
        print('Decomposing...')
        Decomposer(args=['--progress', clone_name, num_procs])
        CaseReport(args=['--decomposition', clone_name])
        machine = LAMMachine(nr=num_procs)

        #run simpleFoam
        foamRun = BasicRunner(argv=[solver, "-case", clone_name],
                              logname="simpleFoam")
        print("Running simpleFoam")
        foamRun.start()
        if not foamRun.runOK():
            error("There was a problem with simpleFoam")

        #get headers and last line of postprocessing file
        with open(
                path.join(clone_name, 'postProcessing', 'forcesCoeffs', '0',
                          'coefficient.dat'), "rb") as table:
Esempio n. 9
0
            'Cmu': Cmu
        })

    # 6: changing initial and boundary conditions for new z0
    # changing ks in nut, inside nutRoughWallFunction
    nutFile = ParsedParameterFile(path.join(work.initialDir(), "nut"))
    nutFile["boundaryField"]["ground"]["Ks"].setUniform(ks)
    nutFile.writeFile()

    #--------------------------------------------------------------------------------------
    # decomposing
    #--------------------------------------------------------------------------------------
    # removing U.template from 0/ directory
    subprocess.call("rm " + bmName + ".template ", shell=True)
    print "Decomposing"
    Decomposer(args=["--progress", work.name, procnr])
    CaseReport(args=["--decomposition", work.name])

    #--------------------------------------------------------------------------------------
    # running
    #--------------------------------------------------------------------------------------
    machine = LAMMachine(nr=procnr)
    # run case
    PlotRunner(args=[
        "--proc=%d" %
        procnr, "--with-all", "--progress", "simpleFoam", "-case", work.name
    ])
    #PlotRunner(args=["simpleFoam","-parallel","- proc =% d " % procnr, "-case",work.name])
    print "work.name = ", work.name
    Runner(args=["reconstructPar", "-latestTime", "-case", work.name])
Esempio n. 10
0
	print "\nCase " + str(i)
	print "======"
	
	# Utworzenie folderu case'u i-tej serii obliczeń i przekopiowanie do niego folderów "0", "constant" i "system" z case'u obliczanego w poprzedniej serii	
	case_i_dir = case_dir + "_" + str(i)
	orig=SolutionDirectory(case_prev_dir, archive=None, paraviewLink=False)	
	work=orig.cloneCase(case_i_dir)

	# Modyfikacja w pliku "turbulenceProperties" wartości wybranych współczynników modelu turbulencji i ich sczytanie 	
	turb_coeffs_values_updated = write_read_turbulence_coefficients(i, case_i_dir, turb_coeffs, turb_coeffs_values, delta_turb_coeffs)	
	turb_coeffs_values = turb_coeffs_values_updated

	# Dekompozycja case'u na potrzeby obliczeń równoległych	
	print "\nDecomposing case"
	Decomposer(args=["--progress", work.name, cpu_number])
	CaseReport(args=["--decomposition", work.name])
	machine=LAMMachine(nr=cpu_number)

	# Obliczenia	
	print "Running calculations\n"
	theRun=BasicRunner(argv=["simpleFoam", "-case", work.name], silent=True, lam=machine)
	theRun.start()
	print "Calculations finish\n"

	# Rekonstrukcja case'u po zakończeniu obliczeń	
	print "Reconstructing case\n"
	reconstruction=BasicRunner(argv=["reconstructPar", "-case", work.name], silent=True)
	reconstruction.start()

	# Lokalizacja punktu oderwania przepływu	
Esempio n. 11
0
 def decompose(self):
     Decomposer(args=[
         self.caseDir,
         str(self["nrCpus"]), "--method=simple", "--n=(2,1,1)",
         "--delta=1e-5"
     ])
Esempio n. 12
0
    template = TemplateFile(bmName + ".template")
    template.writeToFile(bmName, {'TKE': TKE})

    # run the new case
    # creating mesh
    if withBlock == 1:
        blockRun = BasicRunner(argv=["blockMesh", '-case', work.name],
                               silent=True,
                               server=False,
                               logname="blocky")
        print "Running blockMesh"
        blockRun.start()
        if not blockRun.runOK(): error("there was an error with blockMesh")
    # decomposing
    print "Decomposing"
    Decomposer(args=["--progress", work.name, 2])
    CaseReport(args=["--decomposition", work.name])
    # running
    machine = LAMMachine(nr=2)

    # laminar case for better first guess (rarely converges for 2D case with simpleFoam)
    print "running laminar case"
    turb = ParsedParameterFile(path.join(work.name, 'constant/RASProperties'))
    turb["turbulence"] = "off"
    turb.writeFile()
    dic = ParsedParameterFile(path.join(work.name, 'system/controlDict'))
    dic["stopAt"] = "endTime"
    dic["endTime"] = 750
    dic.writeFile()
    PlotRunner(args=["--proc=2", "simpleFoam", "-case", work.name])
    # turbulent turned on