本文整理汇总了Python中PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile.getValueDict方法的典型用法代码示例。如果您正苦于以下问题:Python ParsedParameterFile.getValueDict方法的具体用法?Python ParsedParameterFile.getValueDict怎么用?Python ParsedParameterFile.getValueDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile
的用法示例。
在下文中一共展示了ParsedParameterFile.getValueDict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: materials
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
class materials(materialsUI):
def __init__(self,currentFolder,iphase):
materialsUI.__init__(self)
self.currentFolder = currentFolder
self.iphase = iphase
self.loadData()
#print self.data
self.setData()
def loadData(self):
filename = '%s/constant/transportProperties'%self.currentFolder
self.parsedData = ParsedParameterFile(filename,createZipped=False)
keys = self.parsedData.getValueDict().keys()
if 'phases' in keys:
self.data = self.parsedData[self.parsedData['phases'][self.iphase]].getValueDict()
else:
self.data = self.parsedData.getValueDict()
return
def setData(self):
for key in self.data.keys():
if hasattr(self, key):
if key=='name':
self.__getattribute__(key).setText(str(self.data[key]))
elif key in self.__dict__.keys():
self.__getattribute__(key).setText(str(self.data[key][-1]))
return
def toABM(self):
w = materialsABM()
result = w.exec_()
if result:
data = w.getSelectedData()
if data:
keys = self.parsedData.getValueDict().keys()
if 'phases' in keys:
oldname = self.parsedData['phases'][self.iphase]
newname = data['name']
del self.parsedData[oldname]
self.parsedData['phases'][self.iphase] = newname
self.parsedData[newname] = data
self.data = self.parsedData[self.parsedData['phases'][self.iphase]].getValueDict()
else:
keys = data.keys()
for key in keys:
self.parsedData[key] = data[key]
self.data = self.parsedData.getValueDict()
self.parsedData.writeFile()
self.setData()
return
示例2: accept
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
if str(self.name.text()) not in parsedData['functions'].keys():
parsedData['functions'][str(self.name.text())] = {}
parsedData['functions'][str(self.name.text())]['type'] = 'sets'
parsedData['functions'][str(self.name.text())]['outputControl'] = 'timeStep'
parsedData['functions'][str(self.name.text())]['outputInterval'] = self.spinBox.value()
parsedData['functions'][str(self.name.text())]['setFormat'] = 'raw'
parsedData['functions'][str(self.name.text())]['interpolationScheme'] = 'cellPoint'
ifield = self.comboBox.currentText()
if ifield not in self.fields:
#significa que es un vector
axis = 'distance' #ifield[-1]
ifield = ifield[0:-1]
else:
axis = 'distance' #por las dudas
parsedData['functions'][str(self.name.text())]['fields'] = [ifield]
dicc = {}
dicc['nPoints'] = self.nop.text()
dicc['start'] = '(%s %s %s)'%(str(self.p1_x.text()),str(self.p1_y.text()),str(self.p1_z.text()))
dicc['end'] = '(%s %s %s)'%(str(self.p2_x.text()),str(self.p2_y.text()),str(self.p2_z.text()))
dicc['type'] = 'uniform'
dicc['axis'] = axis
parsedData['functions'][str(self.name.text())]['sets'] = ['data',dicc]
parsedData.writeFile()
self.done(self.Accepted)
示例3: setData
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def setData(self,data):
#self.spinBox.setValue(data['nsteps']) if 'nsteps' in data.keys() else None
#self.nop.setValue(data['nop']) if 'nop' in data.keys() else None
self.name.setText(data['name']) if 'name' in data.keys() else None
#self.comboBox.setCurrentText(data['field']) if 'field' in data.keys() else None
#self.comboBox.setCurrentText(data['autorefreshing']) if 'autorefreshing' in data.keys() else None
self.p1_x.setText(data['p1x']) if 'p1x' in data.keys() else None
self.p1_y.setText(data['p1y']) if 'p1y' in data.keys() else None
self.p1_z.setText(data['p1z']) if 'p1z' in data.keys() else None
self.p2_x.setText(data['p2x']) if 'p2x' in data.keys() else None
self.p2_y.setText(data['p2y']) if 'p2y' in data.keys() else None
self.p2_z.setText(data['p2z']) if 'p2z' in data.keys() else None
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' in parsedData.getValueDict().keys():
if data['name'] in parsedData['functions'].keys():
dicc = parsedData['functions'][data['name']]
if dicc['type']=='sets':
self.name.setText(data['name'])
self.spinBox.setValue(dicc['outputInterval'])
return data
示例4: accept
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
#Logica para evitar que se llamen T* (como los tracers)
# if len(str(self.name.text()))>=2 and self.name.text()[0]=='T':
# for i in range(1,len(str(self.name.text()))):
# if ()
#Logica para evitar nombres repetidos
for key in parsedData['functions'].keys():
if key == str(self.name.text()):
w = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Error", "The name of the new figure and the name of the field must be different. Please select another name")
w.exec_()
return
if str(self.name.text()) not in parsedData['functions'].keys():
parsedData['functions'][str(self.name.text())] = {}
parsedData['functions'][str(self.name.text())]['type'] = 'residuals'
parsedData['functions'][str(self.name.text())]['outputControl'] = 'timeStep'
parsedData['functions'][str(self.name.text())]['outputInterval'] = self.spinBox.value()
parsedData['functions'][str(self.name.text())]['functionObjectLibs'] = ['"libutilityFunctionObjects.so"']
fields = []
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
fields.append(str(self.listWidget.item(i).text()))
parsedData['functions'][str(self.name.text())]['fields'] = fields
parsedData.writeFile()
self.done(self.Accepted)
示例5: exportData
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def exportData(self):
if self.nproc > 1:
w = QtGui.QMessageBox(
QtGui.QMessageBox.Information, "Error", "Data only can be exported in reconstructed cases"
)
w.exec_()
return
tt = ""
if self.time_4.currentText() == "Latest Time":
tt = "-latestTime"
opt = str(self.comboBox.currentText())
filename = "%s/export.log" % self.currentFolder
self.window().newLogTab("Export", filename)
if opt == "VTK":
action = "foamToVTK -case %s %s > %s &" % (self.currentFolder, tt, filename)
elif opt == "Fluent":
action = "foamMeshToFluent -case %s &" % (self.currentFolder)
os.system(action)
action = "cp %s/caseDicts/foamDataToFluentDict %s/system/foamDataToFluentDict" % (
os.path.dirname(os.path.realpath(__file__)),
self.currentFolder,
)
os.system(action)
parsedData = ParsedParameterFile("%s/system/foamDataToFluentDict" % self.currentFolder, createZipped=False)
ii = 10
for ifield in self.fields:
if ifield not in parsedData.getValueDict().keys():
parsedData[ifield] = ii
ii = ii + 1
action = "foamDataToFluent -case %s %s > %s &" % (self.currentFolder, tt, filename)
elif opt == "Ensight":
action = "foamToEnsight -case %s %s > %s &" % (self.currentFolder, tt, filename)
os.system(action)
return
示例6: accept
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
#Logica para evitar nombres repetidos
for key in self.parsedData['functions'].keys():
if key == str(self.name.text()):
w = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Error", "The name of the new figure and the name of the tracer must be different. Please select another name")
w.exec_()
return
dicc['outputInterval'] = self.spinBox.value()
fields = []
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
fields.append(str(self.listWidget.item(i).text()))
dicc['fields'] = fields
dicc['sourceName'] = str(self.comboBox.currentText())
parsedData['functions'][str(self.name.text())] = dicc
parsedData.writeFile()
self.done(self.Accepted)
示例7: accept
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
if str(self.objectName()) not in parsedData['functions'].keys():
parsedData['functions'][str(self.objectName())] = {}
parsedData['functions'][str(self.objectName())]['type'] = 'snapshots'
parsedData['functions'][str(self.objectName())]['outputControl'] = 'outputTime'
parsedData['functions'][str(self.objectName())]['functionObjectLibs'] = ['"libsnapshotsFunctionObjects.so"']
parsedData.writeFile()
示例8: setData
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def setData(self, data):
#buscar en el controlDict el function object 'name'
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' in parsedData.getValueDict().keys():
if data['name'] in parsedData['functions'].keys():
dicc = parsedData['functions'][data['name']]
if dicc['type']=='residuals':
self.name.setText(data['name'])
self.spinBox.setValue(dicc['outputInterval'])
for i in range(self.listWidget.count()):
if self.listWidget.item(i) in dicc['fields']:
self.listWidget.item(i).setCheckState(QtCore.Qt.Checked)
else:
self.listWidget.item(i).setCheckState(QtCore.Qt.Unchecked)
示例9: accept
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
dicc['outputInterval'] = self.spinBox.value()
fields = []
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
fields.append(str(self.listWidget.item(i).text()))
dicc['fields'] = fields
dicc['sourceName'] = str(self.comboBox.currentText())
parsedData['functions'][str(self.name.text())] = dicc
parsedData.writeFile()
self.done(self.Accepted)
示例10: accept
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
if str(self.name.text()) not in parsedData['functions'].keys():
parsedData['functions'][str(self.name.text())] = {}
parsedData['functions'][str(self.name.text())]['type'] = 'residuals'
parsedData['functions'][str(self.name.text())]['outputControl'] = 'timeStep'
parsedData['functions'][str(self.name.text())]['outputInterval'] = self.spinBox.value()
parsedData['functions'][str(self.name.text())]['functionObjectLibs'] = ['"libutilityFunctionObjects.so"']
fields = []
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
fields.append(str(self.listWidget.item(i).text()))
parsedData['functions'][str(self.name.text())]['fields'] = fields
parsedData.writeFile()
self.done(self.Accepted)
示例11: exportData
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
def exportData(self):
opt = str(self.comboBox.currentText())
filename = '%s/export.log'%self.currentFolder
self.window().newLogTab('Export',filename)
if opt=='VTK':
action = 'foamToVTK -case %s > %s &' %(self.currentFolder,filename)
elif opt=='Fluent':
action = 'foamMeshToFluent -case %s &' %(self.currentFolder)
os.system(action)
'cp caseDicts/foamDataToFluentDict %s/system/foamDataToFluentDict'%self.currentFolder
os.system(action)
parsedData = ParsedParameterFile('%s/system/foamDataToFluentDict'%self.currentFolder,createZipped=False)
ii = 10
for ifield in self.fields:
if ifield not in parsedData.getValueDict().keys():
parsedData[ifield] = ii
ii = ii + 1
action = 'foamDataToFluent -case %s > %s &' %(self.currentFolder,filename)
elif opt=='Ensight':
action = 'foamToEnsight -case %s > %s &' %(self.currentFolder,filename)
os.system(action)
return
示例12: tracers
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
class tracers(tracersUI):
def __init__(self, currentFolder):
tracersUI.__init__(self)
self.currentFolder = currentFolder
[self.timedir, fields, self.currtime] = utils.currentFields(str(self.currentFolder))
self.patches = []
self.emptys = []
self.colors = ["r", "b", "k", "g", "y", "c"]
self.firstPlot = True
self.loadCaseData()
self.refreshTable()
self.refreshTimeline()
def loadCaseData(self):
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)
if self.patches == []:
filename = "%s/U" % (self.timedir)
UData = ParsedParameterFile(filename, createZipped=False)
self.patches = UData["boundaryField"].keys()
for ipatch in self.patches:
if UData["boundaryField"][ipatch]["type"] == "empty":
self.emptys.append(ipatch)
def refreshTable(self):
for ii in range(self.tableWidget.rowCount() - 1, -1, -1):
self.tableWidget.removeRow(ii)
for i in range(len(self.tracersData)):
self.tableWidget.insertRow(i)
item1 = QtGui.QTableWidgetItem()
item2 = QtGui.QTableWidgetItem()
wdg1 = QtGui.QLineEdit()
wdg2 = QtGui.QComboBox()
wdg2.addItems(list(set(self.patches) - set(self.emptys)))
wdg1.setText(str(self.tracersData[i]["startTime"]))
wdg2.setCurrentIndex(wdg2.findText(self.tracersData[i]["patchName"]))
self.tableWidget.setItem(i, 0, item1)
self.tableWidget.setCellWidget(i, 0, wdg1)
self.tableWidget.setItem(i, 1, item2)
self.tableWidget.setCellWidget(i, 1, wdg2)
def refreshTimeline(self):
if not self.firstPlot:
self.figureLayout.removeWidget(self.canvas)
self.firstPlot = False
fig = Figure((2.0, 1.5), dpi=100)
self.canvas = FigureCanvas(fig)
self.canvas.setParent(self)
self.ax = fig.add_subplot(111)
self.ax.clear()
# levantar el controlDict y ver los tracers
Tf = float(self.parsedData["endTime"])
T = float(self.currtime)
dT = float(self.parsedData["deltaT"])
self.ax.set_ylim(0, 1.1)
self.ax.set_xlim(-10 * dT, Tf)
self.ax.plot([0, T - dT, T, T + dT, Tf], [0, 0, 1, 0, 0], "k", marker="o", label="Current Time")
i = 0
for itracer in self.tracersData:
Tini = float(itracer["startTime"])
if float(itracer["startTime"]) < T:
Tini = T
self.ax.plot([0, Tini, Tini + dT, Tf], [0, 0, 1, 1], self.colors[i % 6], label=itracer["name"])
i = i + 1
self.ax.set_title("Timeline")
self.ax.set_xlabel("Time [s]")
self.ax.set_ylabel("Event")
self.ax.legend(loc=0, fontsize="small")
self.figureLayout.addWidget(self.canvas)
def newTracer(self):
i = self.tableWidget.rowCount()
self.tableWidget.insertRow(i)
item1 = QtGui.QTableWidgetItem()
item2 = QtGui.QTableWidgetItem()
wdg1 = QtGui.QLineEdit()
wdg2 = QtGui.QComboBox()
wdg2.addItems(list(set(self.patches) - set(self.emptys)))
wdg1.setText("0")
self.tableWidget.setItem(i, 0, item1)
#.........这里部分代码省略.........
示例13: figureTracers
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
class figureTracers(figureTracersUI):
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)
def getData(self):
data = {}
data['name'] = str(self.name.text())
data['nsteps'] = self.spinBox.value()
data['fields'] = []
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
data['fields'].append(self.listWidget.item(i).text())
return data
def setData(self, data):
#buscar en el controlDict el function object 'name'
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' in parsedData.getValueDict().keys():
if data['name'] in parsedData['functions'].keys():
dicc = parsedData['functions'][data['name']]
if dicc['type']=='faceSource':
self.name.setText(data['name'])
self.spinBox.setValue(dicc['outputInterval'])
for i in range(self.listWidget.count()):
if self.listWidget.item(i) in dicc['fields']:
self.listWidget.item(i).setCheckState(QtCore.Qt.Checked)
else:
self.listWidget.item(i).setCheckState(QtCore.Qt.Unchecked)
def ckeckAccept(self, evnt):
allow = False
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
allow = True
break
if allow:
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)
else:
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
def accept(self):
filename = '%s/system/controlDict'%(self.currentFolder)
parsedData = ParsedParameterFile(filename,createZipped=False)
if 'functions' not in parsedData.getValueDict().keys():
parsedData['functions'] = {}
dicc['outputInterval'] = self.spinBox.value()
fields = []
for i in range(self.listWidget.count()):
if self.listWidget.item(i).checkState() == QtCore.Qt.Checked:
fields.append(str(self.listWidget.item(i).text()))
dicc['fields'] = fields
dicc['sourceName'] = str(self.comboBox.currentText())
parsedData['functions'][str(self.name.text())] = dicc
parsedData.writeFile()
self.done(self.Accepted)
示例14: tracers
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
class tracers(tracersUI):
def __init__(self, currentFolder, nproc):
tracersUI.__init__(self)
self.currentFolder = currentFolder
self.nproc = nproc
[self.timedir,fields,self.currtime] = utils.currentFields(str(self.currentFolder),nproc=self.nproc)
self.patches = []
self.emptys = []
self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
self.firstPlot = True
self.loadCaseData()
self.refreshTable()
self.refreshTimeline()
self.pushButton_3.setEnabled(False)
def loadCaseData(self):
filename = '%s/system/controlDict'%self.currentFolder
backupFile(filename)
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']
#TODO: cargar aca
if tracer['patchName']=='box':
tracer['p0'] = self.parsedData['functions'][key]['fvOptions']['S']['p0']
tracer['p1'] = self.parsedData['functions'][key]['fvOptions']['S']['p1']
self.tracersData.append(tracer)
if self.patches==[]:
boundaries = BoundaryDict(str(self.currentFolder))
self.patches = boundaries.patches()
for ipatch in self.patches:
if boundaries[ipatch]['type']=='empty':
self.emptys.append(ipatch)
self.pushButton_3.setEnabled(True)
def refreshTable(self):
for ii in range(self.tableWidget.rowCount()-1,-1,-1):
self.tableWidget.removeRow(ii)
for i in range(len(self.tracersData)):
self.tableWidget.insertRow(i)
item1 = QtGui.QTableWidgetItem()
item2 = QtGui.QTableWidgetItem()
item3 = QtGui.QTableWidgetItem()
item4 = QtGui.QTableWidgetItem()
wdg1 = QtGui.QLineEdit()
wdg2 = QtGui.QComboBox()
wdg3 = QtGui.QLineEdit()
wdg4 = QtGui.QLineEdit()
wdg2.addItems(list(set(self.patches)-set(self.emptys)))
wdg2.addItem('box')
wdg2.setObjectName(str(i))
wdg1.setText(str(self.tracersData[i]['startTime']))
wdg2.setCurrentIndex(wdg2.findText(self.tracersData[i]['patchName']))
#TODO: Hay que ver como cagarlo del archivo, preguntar a juan
wdg3.setText(str(self.tracersData[i]['p0'])) if self.tracersData[i]['patchName']=='box' else wdg3.setText("(0 0 0)")
wdg4.setText(str(self.tracersData[i]['p1'])) if self.tracersData[i]['patchName']=='box' else wdg4.setText("(0 0 0)")
wdg3.setEnabled(False) if self.tracersData[i]['patchName']!='box' else wdg3.setEnabled(True)
wdg4.setEnabled(False) if self.tracersData[i]['patchName']!='box' else wdg4.setEnabled(True)
QtCore.QObject.connect(wdg2, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.change_combobox)
wdg3.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp("\({1}-?\d+\.?\d*(e-?\d)?\s-?\d+\.?\d*(e-?\d)?\s-?\d+\.?\d*(e-?\d)?\){1}")))
wdg4.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp("\({1}-?\d+\.?\d*(e-?\d)?\s-?\d+\.?\d*(e-?\d)?\s-?\d+\.?\d*(e-?\d)?\){1}")))
QtCore.QObject.connect(wdg1,QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), self.checkAccept)
QtCore.QObject.connect(wdg2,QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.checkAccept)
QtCore.QObject.connect(wdg3,QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), self.checkAccept)
QtCore.QObject.connect(wdg4,QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), self.checkAccept)
self.tableWidget.setItem(i,0,item1)
self.tableWidget.setCellWidget(i,0,wdg1)
self.tableWidget.setItem(i,1,item2)
self.tableWidget.setCellWidget(i,1,wdg2)
self.tableWidget.setItem(i,2,item3)
self.tableWidget.setCellWidget(i,2,wdg3)
self.tableWidget.setItem(i,3,item4)
self.tableWidget.setCellWidget(i,3,wdg4)
self.pushButton_3.setEnabled(True)
def refreshTimeline(self):
if not self.firstPlot:
self.figureLayout.removeWidget(self.canvas)
self.canvas.destroy()
self.canvas.close()
self.firstPlot = False
fig = Figure((2.0, 1.5), dpi=100)
#.........这里部分代码省略.........
示例15: tracers
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getValueDict [as 别名]
class tracers(tracersUI):
def __init__(self, currentFolder):
tracersUI.__init__(self)
self.currentFolder = currentFolder
[self.timedir,fields,self.currtime] = utils.currentFields(str(self.currentFolder))
self.patches = []
self.emptys = []
self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
self.firstPlot = True
self.loadCaseData()
self.refreshTable()
self.refreshTimeline()
def loadCaseData(self):
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)
if self.patches==[]:
filename = '%s/U'%(self.timedir)
UData = ParsedParameterFile(filename,createZipped=False)
self.patches = UData['boundaryField'].keys()
for ipatch in self.patches:
if UData['boundaryField'][ipatch]['type']=='empty':
self.emptys.append(ipatch)
def refreshTable(self):
for ii in range(self.tableWidget.rowCount()-1,-1,-1):
self.tableWidget.removeRow(ii)
for i in range(len(self.tracersData)):
self.tableWidget.insertRow(i)
item1 = QtGui.QTableWidgetItem()
item2 = QtGui.QTableWidgetItem()
wdg1 = QtGui.QLineEdit()
wdg2 = QtGui.QComboBox()
wdg2.addItems(list(set(self.patches)-set(self.emptys)))
wdg1.setText(str(self.tracersData[i]['startTime']))
wdg2.setCurrentIndex(wdg2.findText(self.tracersData[i]['patchName']))
self.tableWidget.setItem(i,0,item1)
self.tableWidget.setCellWidget(i,0,wdg1)
self.tableWidget.setItem(i,1,item2)
self.tableWidget.setCellWidget(i,1,wdg2)
def refreshTimeline(self):
if not self.firstPlot:
self.figureLayout.removeWidget(self.canvas)
self.firstPlot = False
fig = Figure((2.0, 1.5), dpi=100)
self.canvas = FigureCanvas(fig)
self.canvas.setParent(self)
self.ax = fig.add_subplot(111)
self.ax.clear()
#levantar el controlDict y ver los tracers
Tf = float(self.parsedData['endTime'])
T = float(self.currtime)
dT = float(self.parsedData['deltaT'])
self.ax.set_ylim(0,1.1)
self.ax.set_xlim(-10*dT,Tf)
self.ax.plot([0,T-dT,T,T+dT,Tf],[0,0,1,0,0], 'k', marker='o', label='Current Time')
i = 0
for itracer in self.tracersData:
Tini = float(itracer['startTime'])
if float(itracer['startTime'])<T:
Tini = T
self.ax.plot([0,Tini,Tini+dT,Tf],[0,0,1,1], self.colors[i%6], label=itracer['name'])
i = i+1
self.ax.set_title('Timeline')
self.ax.set_xlabel('Time [s]')
self.ax.set_ylabel('Event')
self.ax.legend(loc=0, fontsize = 'small')
self.figureLayout.addWidget(self.canvas)
def newTracer(self):
i = self.tableWidget.rowCount()
self.tableWidget.insertRow(i)
item1 = QtGui.QTableWidgetItem()
item2 = QtGui.QTableWidgetItem()
wdg1 = QtGui.QLineEdit()
wdg2 = QtGui.QComboBox()
wdg2.addItems(list(set(self.patches)-set(self.emptys)))
#.........这里部分代码省略.........