def compute(): if CTK.t == []: return if (CTK.__MAINTREE__ <= 0): CTK.TXT.insert('START', 'Fail on a temporary tree.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return type = VARS[0].get() var1 = VARS[2].get() if (type == 'INT((v1,v2,v3).ndS)' or 'INT((v1,v2,v3)^OMdS)'): var2 = VARS[3].get() var3 = VARS[4].get() vector = [var1, var2, var3] if (type == 'INT((v1,v2,v3)^OMdS)' or type == 'INT(v1n^OMdS)'): center = CTK.varsFromWidget(VARS[1].get(), type=1) if (len(center) != 3): CTK.TXT.insert('START', 'Center for moment integration is incorrect.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return nzs = CPlot.getSelectedZones() if (nzs == []): CTK.TXT.insert('START', 'Selection is empty.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return res1 = 0. res2 = 0. res3 = 0. for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] z = CTK.t[2][nob][2][noz] if (type == 'INT(v1dS)'): res1 += P.integ(z, var1)[0] elif (type == 'INT(v1.ndS)'): res = P.integNorm(z, var1)[0] res1 += res[0] res2 += res[1] res3 += res[2] elif (type == 'INT((v1,v2,v3).ndS)'): res1 += P.integNormProduct(z, vector) elif (type == 'INT((v1,v2,v3)^OMdS)'): res = P.integMoment(z, center, vector) res1 += res[0] res2 += res[1] res3 += res[2] elif (type == 'INT(v1n^OMdS)'): res = P.integMomentNorm(z, center, var1)[0] res1 += res[0] res2 += res[1] res3 += res[2] if (type == 'INT((v1,v2,v3)^OMdS)' or type == 'INT(v1n^OMdS)' or type == 'INT(v1.ndS)'): res = [res1, res2, res3] else: res = res1 CTK.TXT.insert('START', 'Res=' + str(res) + '.\n')
# - integMomentNorm (pyTree)- import Converter.PyTree as C import Generator.PyTree as G import Post.PyTree as P m = G.cartTetra((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 1)) m = C.initVars(m, 'Density', 1.) res = P.integMomentNorm(m, var='Density', center=(5., 5., 0.)) print(res)
import Converter.Internal as Internal import Generator.PyTree as G import Post.PyTree as P import KCore.test as test ni = 11; nj = 11 def f1(x,y): return 2*x + y def f2(x,y): return 3*x*y + 4 # STRUCT 2D ni = 30; nj = 40 m = G.cart((0,0,0), (10./(ni-1),10./(nj-1),1), (ni,nj,1)) m = C.initVars(m,'vx', f1, ['CoordinateX','CoordinateY']) m = C.node2Center(m, Internal.__GridCoordinates__) m = C.initVars(m,'centers:vy', f2, ['CoordinateX','CoordinateY']) res = P.integMomentNorm(m,(5.,5.,1.),'vx')+\ P.integMomentNorm(m,(5.,5.,1.),'centers:vy') test.testO(res,1) #TRI ni = 30; nj = 40 m2 = G.cartTetra((0,0,0), (10./(ni-1),10./(nj-1),1), (ni,nj,1)) m2 = C.node2Center(m, Internal.__GridCoordinates__) m2 = C.initVars(m2,'centers:vy', f2, ['CoordinateX','CoordinateY']) res = P.integMomentNorm(m2,(5.,5.,1.),'vx')+\ P.integMomentNorm(m2,(5.,5.,1.),'centers:vy') test.testO(res,2) # ARBRE t = C.newPyTree(['Base',2,'Base2',2]) t[2][1] = C.addState(t[2][1], 'Mach', 0.6); t[2][1][2].append(m)