Exemple #1
0
    def run(self):
        sol = SolutionDirectory(self.parser.getArgs()[0])
        if not self.opts.init:
            vcs = sol.determineVCS()
            if vcs == None:
                self.error("not under version control")
            if not vcs in self.vcsChoices:
                self.error("Unsupported VCS", vcs)
        else:
            vcs = self.opts.vcs

        vcsInter = getVCS(vcs, path=sol.name, init=self.opts.init)

        vcsInter.addPath(path.join(sol.name, "constant"), rules=ruleList)
        vcsInter.addPath(path.join(sol.name, "system"), rules=ruleList)
        if sol.initialDir() != None:
            vcsInter.addPath(sol.initialDir(), rules=ruleList)
        else:
            self.warning("No initial-directory found")

        # special PyFoam-files
        for f in ["customRegexp", "LocalConfigPyFoam"]:
            p = path.join(sol.name, f)
            if path.exists(p):
                vcsInter.addPath(p, rules=ruleList)

        # Add the usual files from the tutorials
        for g in ["Allrun*", "Allclean*"]:
            for f in glob(path.join(sol.name, g)):
                vcsInter.addPath(f, rules=ruleList)

        for a in self.opts.additional:
            vcsInter.addPath(a, rules=ruleList)

        vcsInter.commit(self.opts.commitMessage)
Exemple #2
0
    def run(self):
        sol=SolutionDirectory(self.parser.getArgs()[0])
        if not self.opts.init:
            vcs=sol.determineVCS()
            if vcs==None:
                self.error("not under version control")                
            if not vcs in self.vcsChoices:
                self.error("Unsupported VCS",vcs)
        else:
            vcs=self.opts.vcs

        vcsInter=getVCS(vcs,
                        path=sol.name,
                        init=self.opts.init)

        vcsInter.addPath(path.join(sol.name,"constant"),rules=ruleList)
        vcsInter.addPath(path.join(sol.name,"system"),rules=ruleList)
        if sol.initialDir()!=None:
            vcsInter.addPath(sol.initialDir(),rules=ruleList)
        else:
            self.warning("No initial-directory found")

        # special PyFoam-files
        for f in ["customRegexp","LocalConfigPyFoam"]:
            p=path.join(sol.name,f)
            if path.exists(p):
                vcsInter.addPath(p,rules=ruleList)

        # Add the usual files from the tutorials
        for g in ["Allrun*","Allclean*"]:
            for f in glob(path.join(sol.name,g)):
                vcsInter.addPath(f,rules=ruleList)
                
        for a in self.opts.additional:
            vcsInter.addPath(a,rules=ruleList)
            
        vcsInter.commit(self.opts.commitMessage)
Exemple #3
0
    def run(self):
        cName = self.parser.casePath()

        self.checkCase(cName)

        sol = SolutionDirectory(cName, archive=None)

        print_("Clearing out old timesteps ....")

        sol.clearResults()

        self.checkAndCommit(SolutionDirectory(cName, archive=None))

        run = BasicRunner(argv=self.parser.getArgs(),
                          server=self.opts.server,
                          logname="PyFoamMeshUtility")

        self.addLibFunctionTrigger(run, sol)

        self.addToCaseLog(cName, "Starting")

        run.start()

        self.setData(run.data)

        sol.reread(force=True)

        self.addToCaseLog(cName, "Ending")

        if sol.latestDir() != sol.initialDir():
            for f in listdir(path.join(sol.latestDir(), "polyMesh")):
                system("mv -f " + path.join(sol.latestDir(), "polyMesh", f) +
                       " " + sol.polyMeshDir())

            print_("\nClearing out new timesteps ....")

            sol.clearResults()
        else:
            print_("\n\n  No new timestep. Utility propably failed")
Exemple #4
0
    def run(self):
        cName=self.parser.casePath()

        self.checkCase(cName)

        sol=SolutionDirectory(cName,archive=None)

        print_("Clearing out old timesteps ....")

        sol.clearResults()

        self.checkAndCommit(SolutionDirectory(cName,archive=None))

        run=BasicRunner(argv=self.parser.getArgs(),
                        server=self.opts.server,
                        logname="PyFoamMeshUtility")

        self.addLibFunctionTrigger(run,sol)

        self.addToCaseLog(cName,"Starting")

        run.start()

        self.setData(run.data)

        sol.reread(force=True)

        self.addToCaseLog(cName,"Ending")

        if sol.latestDir()!=sol.initialDir():
            for f in listdir(path.join(sol.latestDir(),"polyMesh")):
                system("mv -f "+path.join(sol.latestDir(),"polyMesh",f)+" "+sol.polyMeshDir())

            print_("\nClearing out new timesteps ....")

            sol.clearResults()
        else:
            print_("\n\n  No new timestep. Utility propably failed")
Exemple #5
0
       [1.27760557e-04, 1.16715642e-04, 0.00000000e+00],
       [7.90107847e-05, 1.13855536e-04, 0.00000000e+00],
       [1.33227401e-05, 1.51324922e-04, 0.00000000e+00],
       [1.41335505e-04, 9.18499088e-05, 0.00000000e+00],
       [9.80882076e-05, 1.45416068e-04, 0.00000000e+00]])


i = 0
force = True  # force creating folders
generate = False  # generate cases
postpro = True # run pv post process
run = False  # run simulations
nproc = 30
caseList  = []
dire=SolutionDirectory(refCase)
sol=SolutionFile(dire.initialDir(),"Ct")
#activation disk radius (m)
radius = 10e-6


if force:
    print('ARRE YOU SUUUUUUUUUUURE ?')


k = 0
if postpro:
    for pancackes in range(pancakesCenters.shape[0]):

      cp = "cp " + refFile +" " + tmp
      subprocess.call(cp, shell=True)
Exemple #6
0
def main():
    solver = 'simpleFoam'
    case_dir = '.'
    n_proc = 4
    decompose_method = 'simple'
    decompose_coeffs = '(2 2 1)'
    log_file = 'log_' + solver
    mesh_points = 333329
    turb_type = 'laminar'
    turb_model = 'no'

    ip.set_turbulence_mode(
        case_dir, turb_type,
        turb_model)  #'laminar' or 'RAS', 'none' or 'kEpsilon' or 'kOmega'
    d_hyd = 4 * 0.02562 / 0.804201
    nu = 0.00001  # SET IN FILE
    I = 0.05
    Re_range = range(100, 1100, 100)

    glob_folders = [
        case_dir + '/' + s
        for s in ['processor*', '0/cellLevel', '0/pointLevel']
    ]
    glob_files = [case_dir + '/' + s for s in ['log*', 'PyFoam*']]

    for Re in Re_range:
        print("Re: {}".format(Re))
        print("Remove folders from previous run.")
        dir = SolutionDirectory(case_dir)
        dir.clearResults()
        for glob_exp in glob_folders:
            ip.rm_folder(glob_exp)
        for glob_exp in glob_files:
            ip.rm_file(glob_exp)

        ip.rm_folder(case_dir + '/postProcessing')

        print("Set inlet velocity.")
        U_value = Re * nu / d_hyd

        U_file = SolutionFile(dir.initialDir(), "U")
        U_file.replaceBoundary("inlet", "(0 %f 0)" % (U_value))
        ip.delete_line(case_dir + '/0/U', 'PyFoamRemoved')

        print("Set magUInf.")
        ip.change_line(case_dir + '/system/controlDict', 'magUInf',
                       '        magUInf     ' + str(U_value) + '; ')

        print("Set turbulent kinetic energy at inlet.")
        k_value = 1.5 * (U_value * I)**2
        ip.set_turbulence_boundary(case_dir, 'k', ["inlet", "monkey"], k_value)

        print("Set turbulent dissipation at inlet.")
        epsilon_value = 0.09**(3 / 4) * k_value**(3 / 2) / (0.07 * d_hyd)
        ip.set_turbulence_boundary(case_dir, 'epsilon', ["inlet", "monkey"],
                                   epsilon_value)

        print("Set specific turbulent dissipation at inlet.")
        omega_value = epsilon_value / k_value
        ip.set_turbulence_boundary(case_dir, 'omega', ["inlet", "monkey"],
                                   omega_value)

        print("Decompose case.")
        ip.set_decomposition(case_dir, n_proc, decompose_method,
                             decompose_coeffs)
        ip.bash_command('cd ' + case_dir + ' && decomposePar -force >> ' +
                        case_dir + '/' + log_file)

        print("Renumber mesh for speedup.")
        ip.bash_command('cd ' + case_dir + ' && mpirun -np ' + str(n_proc) +
                        ' renumberMesh -overwrite -parallel >> ' + case_dir +
                        '/' + log_file)

        print(turb_type + " simulation using " + turb_model +
              " turbulence model on mesh with " + str(mesh_points) +
              " mesh points.")
        print("Run " + solver + " in parallel.")
        ip.bash_command('cd ' + case_dir + ' && mpirun -np ' + str(n_proc) +
                        ' ' + solver + ' -parallel >> ' + case_dir + '/' +
                        log_file)

        print("Reconstruct case.")
        ip.bash_command('cd ' + case_dir + ' && reconstructPar >> ' +
                        case_dir + '/' + log_file)

        print("Copy results into results folder.")
        ip.make_folder(case_dir + '/Results')
        result_string = turb_type + '_' + turb_model + '_turbmodel_' + str(
            mesh_points) + '_meshpoints'
        ip.make_folder(case_dir + '/Results/forces_' + result_string)
        ip.make_folder(case_dir + '/Results/residuals_' + result_string)

        ip.copy_files(
            case_dir + '/postProcessing/forces/**/*.dat', case_dir +
            '/Results/forces_' + result_string + '/Re_' + str(Re) + '.dat', 9)
        ip.copy_files(
            case_dir + '/postProcessing/residuals/**/*.dat', case_dir +
            '/Results/residuals_' + result_string + '/Re_' + str(Re) + '.dat',
            2)
Exemple #7
0
from PyFoam.RunDictionary.SolutionFile import SolutionFile
from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory

solver="simpleFoam"
case="pitzDaily"
pCmd="calcPressureDifference"
mCmd="calcMassFlow"

dire=SolutionDirectory(case,archive="InletVariation")
dire.clearResults()
dire.addBackup("PyFoamSolve.logfile")
dire.addBackup("PyFoamSolve.analyzed")
dire.addBackup("Pressure.analyzed")
dire.addBackup("MassFlow.analyzed")

sol=SolutionFile(dire.initialDir(),"U")

maximum=1.
nr=10

f=dire.makeFile("InflowVariationResults")

for i in range(nr+1):
    # Set the boundary condition at the inlet
    val=(maximum*i)/nr
    print "Inlet velocity:",val
    sol.replaceBoundary("inlet","(%f 0 0)" %(val))

    # Run the solver
    run=ConvergenceRunner(BoundingLogAnalyzer(),argv=[solver,"-case",case],silent=True)
    run.start()
Exemple #8
0
from PyFoam.RunDictionary.SolutionFile import SolutionFile
from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory

import sys

file=sys.argv[1]
name=sys.argv[2]
bc =sys.argv[3]
neu=sys.argv[4]

dire=SolutionDirectory(file,archive="TestArchive")
sol=SolutionFile(dire.initialDir(),name)

print "Old internal",sol.readInternal()

sol.replaceInternal(neu)

print "New internal",sol.readInternal()

sol.purgeFile()

print "Reset internal",sol.readInternal()

print "Old boundary",sol.readBoundary(bc)

sol.replaceBoundary(bc,neu)

print "New boundary",sol.readBoundary(bc)

sol.purgeFile()