diff --git a/tools/evaluation/FiguresAndTablesForPaper.py b/tools/evaluation/FiguresAndTablesForPaper.py index 5909038a6476d210c1a09cef9b9c1600d1517a8f..a547fee36dbb0a7c538e37f59ba978eb1a8bdcea 100644 --- a/tools/evaluation/FiguresAndTablesForPaper.py +++ b/tools/evaluation/FiguresAndTablesForPaper.py @@ -128,15 +128,21 @@ def table8(): endTime=0.16 listEvaluationPoints=[] l0Path=pathBV+'SI0004/vtu/AT_l0j0.vtu' + #read.changeNumberOFCellsiInVTU(SI+'data/',[4],[1,2,3,4],1) + #plotTact: plot=Plot(lL,tL,sdt,endTime,1,listEvaluationPoints) - plot.MeanTactSpace(SI,l0Path) + backupArray=[[-1.0,59.295870358255655,57.96067339027709,57.5545764529468,57.468872878475665],[49.749577731126486,45.46817896679911,43.798303227582146,43.28796384626254,43.16367877136338],[44.95291943209599,40.81325902629804,39.09870508453703,38.55494553911038,38.41666873598738],[43.36173025251009,38.80735467113771,36.91194880075053,36.30816906164418,36.15129271842806],[42.583927617282406,37.81610107773048,35.8441826475743,35.229766544910895,35.07516596693433]] + + ValueArray=plot.MeanTactSpace(SI,l0Path,backupArray) + #print('len value array: ', len(ValueArray)) + print('Plot finished') #tables tact L=4 J=4 savePath='images/' tabWriter = TableWriter(lL,tL,sdt,endTime,1,[SI],listEvaluationPoints) - tabWriter.writeMeanTactTable(SI,l0Path,savePath,L,J) + tabWriter.writeMeanTactTable(SI,l0Path,savePath,L,J,backupArray) if __name__=="__main__": #table2() #x diff --git a/tools/evaluation/utility/computing.py b/tools/evaluation/utility/computing.py index d42c5df3156a4c397848edab2d93514b093ac904..a357c923cff368162bc6731d96feafdd34a701a0 100644 --- a/tools/evaluation/utility/computing.py +++ b/tools/evaluation/utility/computing.py @@ -394,12 +394,14 @@ def RMSRefError(refDict,path,pathLevel0): diff=abs(dict1[key]-refDict[key]) sumDiffSquares+=diff*diff rmse=math.sqrt((1/len(evalPoints))*sumDiffSquares) + return rmse def computeMeanTact(p,pathLevel0): evalPoints,ateP=read.readVTU(pathLevel0) points, at = read.readVTU(p) - unactivatedPoints=0 + print('read VTU finished') + if len(points)==0: return 0.0 @@ -415,7 +417,8 @@ def computeMeanTact(p,pathLevel0): return -1.0 else: Sum+=value*value - + tact=math.sqrt((1/(len(evalPoints)))*Sum) + print('in compute',tact) return tact diff --git a/tools/evaluation/utility/latexTables.py b/tools/evaluation/utility/latexTables.py index 4b45156a739a6919d2b5e40ea53e0dab9395d257..c8d63b2f7fbbe1cc04168a667d0d425e2be34efc 100644 --- a/tools/evaluation/utility/latexTables.py +++ b/tools/evaluation/utility/latexTables.py @@ -1271,13 +1271,13 @@ class Table: block +='& -' block +='\\\\\n' return block - def writeMeanTactTabular(self,fn,l0path): + def writeMeanTactTabular(self,fn,l0path, varr=[]): block='' block+=self.writeBeginSpace() - block+=self.writeMeanTact(fn,l0path) + block+=self.writeMeanTact(fn,l0path,varr) block+=self.EndTabular() return block - def writeMeanTact(self,eP,l0Path): + def writeMeanTact(self,eP,l0Path,varr=[]): block ='' block += '$\\tact(v^{j,\ell})$' for l in self.lL: @@ -1288,7 +1288,11 @@ class Table: block+='$j='+str(j)+'$' for l in self.lL: path = eP+ 'vtu/AT_l'+str(l)+'j'+str(j)+'.vtu' - tact=comp.computeMeanTact(path,l0Path) + tact=-10 + if len(varr)!=0: + tact=varr[l][j] + else: + tact=comp.computeMeanTact(path,l0Path) if tact>0.0: block += " & $"+ str("%8.4f"%(tact))+"$" elif tact==-1: @@ -1299,6 +1303,7 @@ class Table: block+='\\\\\n' return block def writeRMSRefErrorTabular(self,L,J,eP,l0Path): + print('started RMSRefError') refPath=eP+'vtu/AT_l'+str(L)+'j'+str(J)+'.vtu' refPoints,atRef=read.readVTU(refPath) refDict={} @@ -1315,6 +1320,7 @@ class Table: for j in self.tL: block+='$j='+str(j)+'$' for l in self.lL: + print(l,j) path = eP+ 'vtu/AT_l'+str(l)+'j'+str(j)+'.vtu' rmseRef=comp.RMSRefError(refDict,path,l0Path) if rmseRef>0.0: @@ -1813,7 +1819,7 @@ class TableWriter: output_file.write(self.tab.EndTabular()) output_file.write(self.tab.writeEndTable()) - def writeMeanTactTable(self,fn,l0Path,sP,L,J): + def writeMeanTactTable(self,fn,l0Path,sP,L,J, vArr): cap='The activation time $\\tact(\V)$ and the difference with respect to the reference solution on different levels in space and time for the semi-implicit (\\SISVI) scheme (the numbers are displayed in ms)' label='tab:ActiAndError' filename=fn+'tex/'+'ActivationVentricles' @@ -1825,7 +1831,7 @@ class TableWriter: output_file.write('\\resizebox{9.3cm}{!}{\\input{'+sP+'ActivationSpace}}\n') output_file.write('\\\\[-6.2cm]\n') output_file.write('&\n') - output_file.write(self.tab.writeMeanTactTabular(fn,l0Path)) + output_file.write(self.tab.writeMeanTactTabular(fn,l0Path,vArr)) output_file.write('\\\\[1.9cm]\n') output_file.write('&\n') output_file.write(self.tab.writeRMSRefErrorTabular(L,J,fn,l0Path)) diff --git a/tools/evaluation/utility/plotting.py b/tools/evaluation/utility/plotting.py index 6576e232f1bc09e82472ac6553d2b021125c77a6..9bf9edaa1a919b33b9bf68c5111a135cef33b0ef 100644 --- a/tools/evaluation/utility/plotting.py +++ b/tools/evaluation/utility/plotting.py @@ -311,22 +311,30 @@ class Plot: self.saveTikz(eP,plotname) plt.close() return plotname - def MeanTactSpace(self,eP,l0Path): + def MeanTactSpace(self,eP,l0Path,vArr=[]): + vArray=[] for l in self.lL: tactList=[] jVector=[] for j in self.tL: - tact=comp.computeMeanTact(eP+'vtu/AT_l'+str(l)+'j'+str(j)+'.vtu',l0Path) + print(l,j) + tact=-10 + if len(vArr)==0: + tact=comp.computeMeanTact(eP+'vtu/AT_l'+str(l)+'j'+str(j)+'.vtu',l0Path) + else: + tact=vArr[l][j] if tact > 0.0 : tactList.append(tact) jVector.append(j) labelname= '$\\tact(\\V^{j,'+str(l)+'})$' plt.plot(jVector,tactList,label=labelname,marker=self.markerList[0],linewidth=3.5,color=self.colorList[l]) + vArray.append(tactList) self.DataTact() #plt.show() plotname='ActivationSpace' self.saveTikz(eP,plotname) plt.close() + return vArray def workPrecisionInSpace(self,L,J,j,fL,nL,refPath,eP,p,ydes,timeunit='min'): (t,Ref)=read.getDataFromTXT(refPath,read.createFilename(L,J,self.m),p) normRef=comp.L2(Ref,self.sdt,self.T,J,False) diff --git a/tools/evaluation/utility/reading.py b/tools/evaluation/utility/reading.py index d9a7e64bee19b6962d350ab832d0c7f03573f4a4..3b177d89325b1c377124ad27fa9872aabca31f6d 100644 --- a/tools/evaluation/utility/reading.py +++ b/tools/evaluation/utility/reading.py @@ -419,6 +419,18 @@ def writeActivationDataFiles(path,lL,tL,option=True): fn = createActiFilename(l,j) print(fn) extractDataFromVTU(path,fn,option) +def changeNumberOFCellsiInVTU(path,lL,tL,number): + for l in lL: + for j in tL: + fin=open(path+'AT_l'+str(l)+'j'+str(j)+'.vtu','r') + fout=open(path+'CAT_l'+str(l)+'j'+str(j)+'.vtu','w') + for line in fin: + if line == ' <Piece NumberOfPoints="71809719" NumberOfCells="420352000">\n': + fout.write(line.replace(' <Piece NumberOfPoints="71809719" NumberOfCells="420352000">\n', ' <Piece NumberOfPoints="71809719" NumberOfCells="1">\n')) + else: + fout.write(line) + fin.close() + fout.close() def readVTU(filename): try: f=open(filename, 'r')