Beispiel #1
0
    def makeFile(self,name):
        """create a file in the solution directory and return a
        corresponding BasicFile-object

        @param name: Name of the file
        @rtype: L{BasicFile}"""
        return BasicFile(path.join(self.name,name))
    def generateCompanionFiles(self, caseDir, boundary):
        description="""\
Generate a setSet batch file based on the zone info specified in the ggi interfaces definition.
Generate a bash file for invoking setSet and setsToZones
Update GGI zone infoprmation in decomposeParDict
        """
        # Default file: genFaceSetForGgiZones.setSet 
        bfGenFaceSets = BasicFile(path.join(caseDir, self.parser.getOptions().genFaceSetForGgiZonesScriptName))

        print "    Updating file ", bfGenFaceSets.name, " for generating GGI zones faceSet using the setSet command"

        bnd=boundary.content

        if type(bnd)!=list:
            self.error("Problem with boundary file (not a list)")

        # Memorize list of GGI zones for later processing
        listOfGgiZones = []

        for index in range(0, len(bnd), 2):
            patchName = bnd[index]
            indexDefPatch=index+1
            if bnd[indexDefPatch]["type"]=='ggi' or bnd[indexDefPatch]["type"]=='cyclicGgi' or bnd[indexDefPatch]["type"]=='overlapGgi':
                bfGenFaceSets.writeLine([ "faceSet " + bnd[indexDefPatch]["zone"] + " new patchToFace "+ patchName ])
                listOfGgiZones.append(bnd[indexDefPatch]["zone"])

        bfGenFaceSets.writeLine([ "quit" ])
        bfGenFaceSets.close()

        # Default file: initGgiZones.sh
        bfInitGgiZones = BasicFile(path.join(caseDir, self.parser.getOptions().initGgiZonesScriptName))

        print "    Updating file ", bfInitGgiZones.name, " for inititalizing GGI zones"
        
        bfInitGgiZones.writeLine([ "#!/bin/bash" ])
        bfInitGgiZones.writeLine([ "setSet -batch " + self.parser.getOptions().genFaceSetForGgiZonesScriptName ])
        bfInitGgiZones.writeLine([ "setsToZones -noFlipMap" ])
        bfInitGgiZones.close()

        # Set execution permissions for this script (755)
        chmod(bfInitGgiZones.name, S_IRWXU|S_IRGRP|S_IXGRP|S_IXOTH|S_IROTH)

        # DecomposeParDict
        decomposeParDictPath=path.join(caseDir,"system","decomposeParDict")
        if path.exists(decomposeParDictPath):
            print "    Updating file ", decomposeParDictPath, " for GGI zones"
            decomposeParDict=ParsedParameterFile(decomposeParDictPath,debug=False,backup=True)
            dcp=decomposeParDict.content
            dcp["globalFaceZones"]="(\n    " + '\n    '.join(list(listOfGgiZones)) + "\n)"
            decomposeParDict.writeFile()
Beispiel #3
0
    def generateCompanionFiles(self, caseDir, boundary):
        description="""\
Generate a setSet batch file based on the zone info specified in the ggi interfaces definition.
Generate a bash file for invoking setSet and setsToZones
Update GGI zone infoprmation in decomposeParDict
        """
        # Default file: genFaceSetForGgiZones.setSet
        bfGenFaceSets = BasicFile(path.join(caseDir, self.parser.getOptions().genFaceSetForGgiZonesScriptName))

        print_("    Updating file ", bfGenFaceSets.name, " for generating GGI zones faceSet using the setSet command")

        bnd=boundary.content

        if type(bnd)!=list:
            self.error("Problem with boundary file (not a list)")

        # Memorize list of GGI zones for later processing
        listOfGgiZones = []

        for index in range(0, len(bnd), 2):
            patchName = bnd[index]
            indexDefPatch=index+1
            if bnd[indexDefPatch]["type"]=='ggi' or bnd[indexDefPatch]["type"]=='cyclicGgi' or bnd[indexDefPatch]["type"]=='overlapGgi':
                bfGenFaceSets.writeLine([ "faceSet " + bnd[indexDefPatch]["zone"] + " new patchToFace "+ patchName ])
                listOfGgiZones.append(bnd[indexDefPatch]["zone"])

        bfGenFaceSets.writeLine([ "quit" ])
        bfGenFaceSets.close()

        # Default file: initGgiZones.sh
        bfInitGgiZones = BasicFile(path.join(caseDir, self.parser.getOptions().initGgiZonesScriptName))

        print_("    Updating file ", bfInitGgiZones.name, " for inititalizing GGI zones")

        bfInitGgiZones.writeLine([ "#!/bin/bash" ])
        bfInitGgiZones.writeLine([ "setSet -batch " + self.parser.getOptions().genFaceSetForGgiZonesScriptName ])
        bfInitGgiZones.writeLine([ "setsToZones -noFlipMap" ])
        bfInitGgiZones.close()

        # Set execution permissions for this script (755)
        chmod(bfInitGgiZones.name, S_IRWXU|S_IRGRP|S_IXGRP|S_IXOTH|S_IROTH)

        # DecomposeParDict
        decomposeParDictPath=path.join(caseDir,"system","decomposeParDict")
        if path.exists(decomposeParDictPath):
            print_("    Updating file ", decomposeParDictPath, " for GGI zones")
            decomposeParDict=ParsedParameterFile(decomposeParDictPath,debug=False,backup=True)
            dcp=decomposeParDict.content
            dcp["globalFaceZones"]="(\n    " + '\n    '.join(list(listOfGgiZones)) + "\n)"
            decomposeParDict.writeFile()