Пример #1
0
    def __init__(self, currentFolder):
        figureTracersUI.__init__(self)
        self.currentFolder = currentFolder
        self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
        
        [self.timedir,self.fields,bas] = currentFields(self.currentFolder)
        
        filename = '%s/system/controlDict'%self.currentFolder
        self.parsedData = ParsedParameterFile(filename,createZipped=False)
        
        self.tracersData = []
        if 'functions' in self.parsedData.getValueDict().keys():
            for key in self.parsedData['functions'].keys():
                if self.parsedData['functions'][key]['type'] == 'scalarTransport':
                    tracer = {}
                    tracer['name'] = key
                    tracer['patchName'] = self.parsedData['functions'][key]['patchName']
                    tracer['startTime'] = self.parsedData['functions'][key]['fvOptions']['S']['timeStart']
                    self.tracersData.append(tracer)

        for tracer in self.tracersData:
            item = QtGui.QListWidgetItem()
            item.setCheckState(QtCore.Qt.Unchecked)
            item.setText(tracer['name'])
            self.listWidget.addItem(item)
            
        from PyFoam.RunDictionary.BoundaryDict import BoundaryDict
        boundaries = BoundaryDict(str(self.currentFolder))
        for ipatch in boundaries.getValueDict():
            if boundaries[ipatch]['type']  != 'empty':
                self.comboBox.addItem(ipatch)
Пример #2
0
 def updateFieldFiles(self):
     #tengo que releer cada uno de los campos en el directorio actual, 
     #pisar los boundaries por los que aparece en constant/polyMesh/boundary
     #imponerles alguna CB por defecto dependiendo del tipo de patch
     boundaries = BoundaryDict(self.currentFolder)
     #veo los campos que tengo en el directorio inicial
     [timedir,fields,currtime] = currentFields(self.currentFolder, False)
     
     for ifield in fields:
         filename = '%s/%s'%(timedir,ifield)
         fieldData = ParsedParameterFile(filename,createZipped=False)
         
         fieldData['boundaryField'] = {}
         for ipatch in boundaries.getValueDict():
             if ipatch not in fieldData['boundaryField']:
                 if boundaries[ipatch]['nFaces']==0:
                     continue
                 patchDict={}
                 if ifield in unknowns:
                     patchDict['type'] = 'zeroGradient'
                 else:                    
                     patchDict['type'] = 'calculated'
                 fieldData['boundaryField'][ipatch] = patchDict
         
         fieldData.writeFile()
     
     return
Пример #3
0
    def updateFieldFiles(self):
        #tengo que releer cada uno de los campos en el directorio actual,
        #pisar los boundaries por los que aparece en constant/polyMesh/boundary
        #imponerles alguna CB por defecto dependiendo del tipo de patch
        boundaries = BoundaryDict(self.currentFolder)
        #veo los campos que tengo en el directorio inicial
        [timedir, fields, currtime] = currentFields(self.currentFolder, False)

        for ifield in fields:
            filename = '%s/%s' % (timedir, ifield)
            fieldData = ParsedParameterFile(filename, createZipped=False)

            fieldData['boundaryField'] = {}
            for ipatch in boundaries.getValueDict():
                if ipatch not in fieldData['boundaryField']:
                    if boundaries[ipatch]['nFaces'] == 0:
                        continue
                    patchDict = {}
                    if ifield in unknowns:
                        patchDict['type'] = 'zeroGradient'
                    else:
                        patchDict['type'] = 'calculated'
                    fieldData['boundaryField'][ipatch] = patchDict

            fieldData.writeFile()

        return
Пример #4
0
    def updateFieldFiles(self, timedir, fields, currtime):
        #tengo que releer cada uno de los campos en el directorio actual,
        #pisar los boundaries por los que aparece en constant/polyMesh/boundary
        #imponerles alguna CB por defecto dependiendo del tipo de patch
        boundaries = BoundaryDict(self.currentFolder)
        filename2 = '%s/system/changeDictionaryPetroSym' % self.currentFolder
        fieldData2 = []
        if os.path.isfile(filename2):
            fieldData2 = ParsedParameterFile(filename2, createZipped=False)

        for ifield in fields:
            filename = '%s/%s' % (timedir, ifield)
            fieldData = ParsedParameterFile(filename, createZipped=False)

            fieldData['boundaryField'] = {}
            for ipatch in boundaries.getValueDict():
                if ipatch not in fieldData['boundaryField']:
                    if boundaries[ipatch]['nFaces'] == 0:
                        continue
                    patchDict = {}
                    if ifield in unknowns:
                        if boundaries[ipatch]['type'] == 'empty':
                            patchDict['type'] = 'empty'
                        else:
                            patchDict['type'] = 'zeroGradient'
                    else:
                        patchDict['type'] = 'calculated'

                    if fieldData2 == []:
                        fieldData['boundaryField'][ipatch] = patchDict
                    else:
                        fieldData2['dictionaryReplacement'][ifield][
                            'boundaryField'][ipatch] = patchDict

            # poner el campo interno uniforme en cero
            if types[ifield] == 'scalar':
                if fieldData2 == []:
                    fieldData['internalField'] = 'uniform 0'
                else:
                    fieldData2['dictionaryReplacement'][ifield][
                        'internalField'] = 'uniform 0'
            elif types[ifield] == 'vector':
                if fieldData2 == []:
                    fieldData['internalField'] = 'uniform (0 0 0)'
                else:
                    fieldData2['dictionaryReplacement'][ifield][
                        'internalField'] = 'uniform (0 0 0)'

            fieldData.writeFile()

        if fieldData2 != []:
            fieldData2.writeFile()

        return
Пример #5
0
    def updateFieldFiles(self,timedir,fields,currtime):
        #tengo que releer cada uno de los campos en el directorio actual,
        #pisar los boundaries por los que aparece en constant/polyMesh/boundary
        #imponerles alguna CB por defecto dependiendo del tipo de patch
        boundaries = BoundaryDict(self.currentFolder)
        filename2 = '%s/system/changeDictionaryPetroSym'%self.currentFolder
        fieldData2 = []
        if os.path.isfile(filename2):
            fieldData2 = ParsedParameterFile(filename2,createZipped=False)

        for ifield in fields:
            filename = '%s/%s'%(timedir,ifield)
            fieldData = ParsedParameterFile(filename,createZipped=False)

            fieldData['boundaryField'] = {}
            for ipatch in boundaries.getValueDict():
                if ipatch not in fieldData['boundaryField']:
                    if boundaries[ipatch]['nFaces']==0:
                        continue
                    patchDict={}
                    if ifield in unknowns:
                        if boundaries[ipatch]['type']=='empty':
                            patchDict['type'] = 'empty'
                        else:
                            patchDict['type'] = 'zeroGradient'
                    else:
                        patchDict['type'] = 'calculated'
                    
                    if fieldData2==[]:
                        fieldData['boundaryField'][ipatch] = patchDict
                    else:
                        fieldData2['dictionaryReplacement'][ifield]['boundaryField'][ipatch] = patchDict
            
            # poner el campo interno uniforme en cero
            if types[ifield] == 'scalar':
                if fieldData2==[]:
                    fieldData['internalField'] = 'uniform 0'
                else:
                    fieldData2['dictionaryReplacement'][ifield]['internalField'] = 'uniform 0'
            elif types[ifield] == 'vector':
                if fieldData2==[]:
                    fieldData['internalField'] = 'uniform (0 0 0)'
                else:
                    fieldData2['dictionaryReplacement'][ifield]['internalField'] = 'uniform (0 0 0)'

            fieldData.writeFile()
        
        if fieldData2!=[]:
            fieldData2.writeFile()

        return
Пример #6
0
    def updateFieldFiles(self):
        #tengo que releer cada uno de los campos en el directorio actual,
        #pisar los boundaries por los que aparece en constant/polyMesh/boundary
        #imponerles alguna CB por defecto dependiendo del tipo de patch
        boundaries = BoundaryDict(self.currentFolder)
        #veo los campos que tengo en el directorio inicial
        [timedir, fields, currtime] = currentFields(self.currentFolder,
                                                    nproc=self.window().nproc,
                                                    filterTurb=False)

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

        for ifield in fields:
            if dictDict == []:
                filename = '%s/%s' % (timedir, ifield)
                fieldData = ParsedParameterFile(filename, createZipped=False)
            else:
                fieldData = dictDict['dictionaryReplacement'][ifield]

            oldKeys = fieldData['boundaryField'].keys()
            fieldData['boundaryField'] = {}
            for ipatch in boundaries.getValueDict():
                if ipatch not in fieldData['boundaryField']:
                    if boundaries[ipatch]['nFaces'] == 0:
                        continue
                    patchDict = {}
                    if ifield in unknowns:
                        if boundaries[ipatch]['type'] == 'empty':
                            patchDict['type'] = 'empty'
                            if ipatch in oldKeys:
                                patchDict['ZZvalue'] = '0'
                        else:
                            patchDict['type'] = 'zeroGradient'
                            if ipatch in oldKeys:
                                patchDict['ZZvalue'] = '0'
                    else:
                        patchDict['type'] = 'calculated'
                        if ipatch in oldKeys:
                            patchDict['ZZvalue'] = '0'
                    fieldData['boundaryField'][ipatch] = patchDict

            # poner el campo interno uniforme en cero
            if types[ifield] == 'scalar':
                fieldData['internalField'] = 'uniform 0'
            elif types[ifield] == 'vector':
                fieldData['internalField'] = 'uniform (0 0 0)'

            if dictDict == []:
                fieldData.writeFile()

        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] = dictDict[
                        'dictionaryReplacement'][ikey]
            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.window().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)

        return
Пример #7
0
    def updateFieldFiles(self):
        #tengo que releer cada uno de los campos en el directorio actual,
        #pisar los boundaries por los que aparece en constant/polyMesh/boundary
        #imponerles alguna CB por defecto dependiendo del tipo de patch
        boundaries = BoundaryDict(self.currentFolder)
        #veo los campos que tengo en el directorio inicial
        [timedir,fields,currtime] = currentFields(self.currentFolder, nproc = self.window().nproc, filterTurb=False)
        
        fileDict = '%s/system/changeDictionaryPetroSym'%self.currentFolder
        dictDict = []
        if os.path.isfile(fileDict):
            dictDict = ParsedParameterFile(fileDict,createZipped=False)

        for ifield in fields:
            if dictDict==[]:
                filename = '%s/%s'%(timedir,ifield)
                fieldData = ParsedParameterFile(filename,createZipped=False)
            else:
                fieldData = dictDict['dictionaryReplacement'][ifield]

            oldKeys = fieldData['boundaryField'].keys()
            fieldData['boundaryField'] = {}
            for ipatch in boundaries.getValueDict():
                if ipatch not in fieldData['boundaryField']:
                    if boundaries[ipatch]['nFaces']==0:
                        continue
                    patchDict={}
                    if ifield in unknowns:
                        if boundaries[ipatch]['type']=='empty':
                            patchDict['type'] = 'empty'
                            if ipatch in oldKeys:
                                patchDict['ZZvalue'] = '0'
                        else:
                            patchDict['type'] = 'zeroGradient'
                            if ipatch in oldKeys:
                                patchDict['ZZvalue'] = '0'
                    else:
                        patchDict['type'] = 'calculated'
                        if ipatch in oldKeys:
                                patchDict['ZZvalue'] = '0'
                    fieldData['boundaryField'][ipatch] = patchDict
            
            # poner el campo interno uniforme en cero
            if types[ifield] == 'scalar':
                fieldData['internalField'] = 'uniform 0'
            elif types[ifield] == 'vector':
                fieldData['internalField'] = 'uniform (0 0 0)'

            if dictDict==[]:
                fieldData.writeFile()

        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] = dictDict['dictionaryReplacement'][ikey]
            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.window().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)
            
        return