Ejemplo n.º 1
0
    def changePatchType(self, item):
        w = bcPatch(self.boundaries[item.text()]['type'])
        result = w.exec_()
        if result:
            patchType = w.getPatchType()
            self.boundaries[item.text()]['type'] = patchType
            self.boundaries.writeFile()

            for ifield in self.fields:

                filename = '%s/%s' % (self.timedir, ifield)
                fieldData = ParsedParameterFile(filename, createZipped=False)

                newDict = {}
                if patchType == 'empty':
                    newDict['type'] = 'empty'
                else:
                    if ifield in unknowns:
                        newDict['type'] = 'zeroGradient'
                    else:
                        newDict['type'] = 'calculated'

                fieldData['boundaryField'][item.text()] = newDict

                fieldData.writeFile()

            self.loadData()
Ejemplo n.º 2
0
    def changePatchType(self,item):
        texto = str(item.text())
        w = bcPatch(self.boundaries[texto]['type'])  
        result = w.exec_()
        if result:
            patchType = w.getPatchType()
            self.boundaries[texto]['type'] = patchType
            self.boundaries.writeFile()
            
            for ifield in self.fields:
                
                filename = '%s/%s'%(self.timedir,ifield)
                fieldData = ParsedParameterFile(filename,listLengthUnparsed=20,createZipped=False)

                newDict = {}
                if patchType == 'empty':
                    newDict['type'] = 'empty'
                else:
                    if ifield in unknowns:
                        newDict['type'] = 'zeroGradient'
                    else:
                        newDict['type'] = 'calculated'
                
                fieldData['boundaryField'][texto] = newDict

                fieldData.writeFile()

            self.loadData()
Ejemplo n.º 3
0
    def changePatchType(self, item):
        texto = str(item.text())
        w = bcPatch(self.boundaries[texto]['type'])
        result = w.exec_()
        if result:
            patchType = w.getPatchType()
            self.boundaries[texto]['type'] = patchType
            self.boundaries.writeFile()

            fileDict = '%s/system/changeDictionaryPetroSym' % self.currentFolder
            dictDict = []
            if os.path.isfile(fileDict):
                dictDict = ParsedParameterFile(fileDict, createZipped=False)

            for ifield in self.fields:

                if dictDict == []:
                    filename = '%s/%s' % (self.timedir, ifield)
                    fieldData = ParsedParameterFile(filename,
                                                    listLengthUnparsed=20,
                                                    createZipped=False)
                else:
                    fieldData = dictDict['dictionaryReplacement'][ifield]

                newDict = {}
                if patchType == 'empty':
                    newDict['type'] = 'empty'
                    newDict['ZZvalue'] = '0'
                else:
                    if ifield in unknowns:
                        newDict['type'] = 'zeroGradient'
                        newDict['ZZvalue'] = '0'
                    else:
                        newDict['type'] = 'calculated'
                        newDict['ZZvalue'] = '0'

                fieldData['boundaryField'][texto] = newDict

                if dictDict == []:
                    fieldData.writeFile()
                else:
                    dictDict['dictionaryReplacement'][ifield] = fieldData

            if dictDict != []:
                dictDict.writeFile()
                dictDictBak = ParsedParameterFile(fileDict, createZipped=False)
                keysDict = dictDict['dictionaryReplacement'].keys()
                dictDictBak['dictionaryReplacement'] = {}
                for ikey in keysDict:
                    if ikey in self.fields:
                        dictDictBak['dictionaryReplacement'][ikey] = {}
                        dictDictBak['dictionaryReplacement'][ikey][
                            'boundaryField'] = dictDict[
                                'dictionaryReplacement'][ikey]['boundaryField']
                dictDictBak.writeFileAs(
                    '%s/system/changeDictionaryPetroSym.bak' %
                    self.currentFolder)

                command = 'sed -i "s/ZZ/~/g" %s/system/changeDictionaryPetroSym.bak' % (
                    self.currentFolder)
                os.system(command)

                #chequear que no bloquee
                if self.nproc <= 1:
                    command = 'changeDictionary -case %s -dict %s/system/changeDictionaryPetroSym.bak 1> %s/changeDictionary.log 2> %s/error.log &' % (
                        self.currentFolder, self.currentFolder,
                        self.currentFolder, self.currentFolder)
                else:
                    command = 'mpirun -np %s changeDictionary -case %s -dict %s/system/changeDictionaryPetroSym.bak -parallel 1> %s/changeDictionary.log 2> %s/error.log &' % (
                        str(self.nproc), self.currentFolder,
                        self.currentFolder, self.currentFolder,
                        self.currentFolder)
                os.system(command)

            self.loadData()
Ejemplo n.º 4
0
    def changePatchType(self,item):
        texto = str(item.text())
        w = bcPatch(self.boundaries[texto]['type'])
        result = w.exec_()
        if result:
            patchType = w.getPatchType()
            self.boundaries[texto]['type'] = patchType
            self.boundaries.writeFile()
            
            fileDict = '%s/system/changeDictionaryPetroSym'%self.currentFolder
            dictDict = []
            if os.path.isfile(fileDict):
                dictDict = ParsedParameterFile(fileDict,createZipped=False)
                
            for ifield in self.fields:
                
                if dictDict==[]:
                    filename = '%s/%s'%(self.timedir,ifield)
                    fieldData = ParsedParameterFile(filename,listLengthUnparsed=20,createZipped=False)
                else:
                    fieldData = dictDict['dictionaryReplacement'][ifield]

                newDict = {}
                if patchType == 'empty':
                    newDict['type'] = 'empty'
                    newDict['ZZvalue'] = '0'
                else:
                    if ifield in unknowns:
                        newDict['type'] = 'zeroGradient'
                        newDict['ZZvalue'] = '0'
                    else:
                        newDict['type'] = 'calculated'
                        newDict['ZZvalue'] = '0'
                
                fieldData['boundaryField'][texto] = newDict

                if dictDict==[]:
                    fieldData.writeFile()
                else:
                    dictDict['dictionaryReplacement'][ifield] = fieldData
            
            if dictDict!=[]:
                dictDict.writeFile()
                dictDictBak = ParsedParameterFile(fileDict,createZipped=False)
                keysDict = dictDict['dictionaryReplacement'].keys()
                dictDictBak['dictionaryReplacement'] = {}
                for ikey in keysDict:
                    if ikey in self.fields:
                        dictDictBak['dictionaryReplacement'][ikey] = {}
                        dictDictBak['dictionaryReplacement'][ikey]['boundaryField'] = dictDict['dictionaryReplacement'][ikey]['boundaryField']
                dictDictBak.writeFileAs('%s/system/changeDictionaryPetroSym.bak'%self.currentFolder)
                
                command = 'sed -i "s/ZZ/~/g" %s/system/changeDictionaryPetroSym.bak'%(self.currentFolder)
                os.system(command)
                
                #chequear que no bloquee
                if self.nproc<=1:
                    command = 'changeDictionary -case %s -dict %s/system/changeDictionaryPetroSym.bak 1> %s/changeDictionary.log 2> %s/error.log &'%(self.currentFolder,self.currentFolder,self.currentFolder,self.currentFolder)
                else:
                    command = 'mpirun -np %s changeDictionary -case %s -dict %s/system/changeDictionaryPetroSym.bak -parallel 1> %s/changeDictionary.log 2> %s/error.log &'%(str(self.nproc),self.currentFolder,self.currentFolder,self.currentFolder,self.currentFolder)
                os.system(command)
            
            self.loadData()