def view(): if CTK.t == []: return type = VARS[0].get() if type == 'Mesh': CTK.display(CTK.t) return if CTK.__MAINTREE__ == 1: CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones() tp = Internal.appendBaseName2ZoneName(CTK.t, separator=Internal.SEP1) active = [] zones = Internal.getZones(tp) for z in CTK.__MAINACTIVEZONES__: active.append(zones[z]) Z = None if type == 'cf>1': Z = P.selectCells(active, Filter1, [ 'interpCoefs1', 'interpCoefs2', 'interpCoefs3', 'interpCoefs4', 'interpCoefs5', 'interpCoefs6', 'interpCoefs7', 'interpCoefs8' ]) elif type == 'cellN=-99999': Z = selectWithFormula(active, '{cellN} == -99999') elif type == 'cellN=1': Z = selectWithFormula(active, '{cellN} == 1') elif type == 'cellN=0': Z = selectWithFormula(active, '{cellN} == 0') elif type == 'cellN=2': Z = selectWithFormula(active, '{cellN} == 2') elif type == 'cellN<0': Z = selectWithFormula(active, '{cellN} < 0') elif type == '0<cellN<1': Z = selectWithFormula(active, '({cellN}>0) & ({cellN}<1)') elif type == 'Orphan points': Z = X.extractChimeraInfo(active, 'orphan') elif type == 'Extrapolated points': Z = X.extractChimeraInfo(active, 'extrapolated') if Z is not None: CTK.TXT.insert('START', 'Filter ' + type + ' displayed.\n') CTK.dt = C.newPyTree(['Base']) CTK.dt[2][1][2] += Z CTK.display(CTK.dt, mainTree=CTK.CELLN) else: CTK.TXT.insert('START', 'Nothing to display.\n') CTK.TXT.insert('START', 'Error: ', 'Error')
# - appendBaseName2ZoneName (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Converter.Internal as Internal a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) a[0] = 'a' b = G.cart((11, 0, 0), (1, 1, 1), (10, 10, 10)) b[0] = 'b' t = C.newPyTree(['Base', a, b]) t = Internal.appendBaseName2ZoneName(t) #>> ['CGNSTree',None,[2 sons],'CGNSTree_t'] #>> |_['CGNSLibraryVersion',array([3.1],dtype='float64'),[0 son],'CGNSLibraryVersion_t'] #>> |_['Base',array(shape=(2,),dtype='int32',order='F'),[2 sons],'CGNSBase_t'] #>> |_['Base_a',array(shape=(3, 3),dtype='int32',order='F'),[2 sons],'Zone_t'] #>> | |_['ZoneType',array('Structured',dtype='|S1'),[0 son],'ZoneType_t'] #>> | ... #>> |_['Base_b',array(shape=(3, 3),dtype='int32',order='F'),[2 sons],'Zone_t'] #>> |_['ZoneType',array('Structured',dtype='|S1'),[0 son],'ZoneType_t'] #>> ... C.convertPyTree2File(t, 'out.cgns')
def view(event=None): if CTK.t == []: return BCTypes = [] selection = WIDGETS['BCLB'].curselection() for s in selection: t = WIDGETS['BCLB'].get(s) if t not in Internal.KNOWNBCS: t = 'FamilySpecified:' + t BCTypes.append(t) if 'FamilySpecified:-All BC-' in BCTypes: BCTypes = ['*'] if CTK.__MAINTREE__ == 1: CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones() tp = Internal.appendBaseName2ZoneName(CTK.t, updateRef=False, separator=Internal.SEP1) CTK.dt = C.newPyTree(['Base', 'Edges']) active = [] for z in CTK.__MAINACTIVEZONES__: active.append(tp[2][CTK.Nb[z] + 1][2][CTK.Nz[z]]) Z = [] for t in BCTypes: Z += C.extractBCOfType(active, t, topTree=tp) if t == 'BCWall': # Dans ce cas, affiche tous les types de BCWall Z += C.extractBCOfType(active, 'BCWallInviscid') Z += C.extractBCOfType(active, 'BCWallViscous') Z += C.extractBCOfType(active, 'BCWallViscousIsoThermal') CTK.dt[2][1][2] += Z if VARS[7].get() == '1': # display les edges des zones en + exts = [] for z in active: ztype = Internal.getZoneType(z) if ztype == 1: zp = P.exteriorFacesStructured(z) exts += zp else: #zp = P.exteriorFaces(z) #zp = P.sharpEdges(zp) zp = [] exts += zp CTK.dt[2][2][2] += exts C._fillMissingVariables(CTK.dt) # bug exteriorFaces # Activate lenZ = len(CTK.dt[2][1][2]) lenExts = len(CTK.dt[2][2][2]) active = [(i, 1) for i in range(lenZ + lenExts)] for i in range(lenZ): active[i] = (i, 1) for i in range(lenExts): active[i + lenZ] = (i + lenZ, 0) CTK.display(CTK.dt, mainTree=CTK.DEFINEDBC) CPlot.setActiveZones(active) CPlot.setState(edgifyDeactivatedZones=1) else: lenZ = len(CTK.dt[2][1][2]) active = [(i, 1) for i in range(lenZ)] C._fillMissingVariables(CTK.dt) # si BCDataSet != fields CTK.display(CTK.dt, mainTree=CTK.DEFINEDBC) CPlot.setActiveZones(active) CPlot.setState(edgifyDeactivatedZones=0)
def check(): if CTK.t == []: return node = Internal.getNodeFromName(CTK.t, 'EquationDimension') if node is not None: ndim = Internal.getValue(node) else: CTK.TXT.insert('START', 'EquationDimension not found (tkState). Using 3D.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') ndim = 3 # Varie de 0 a 180 degres global __SPLITFACTOR__ splitFactor = 180. - WIDGETS['splitFactor'].get() * 180. / 100. __SPLITFACTOR__ = splitFactor wins = C.getEmptyBC(CTK.t, ndim, splitFactor) if CTK.__MAINTREE__ == 1: CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones() CTK.dt = C.newPyTree(['Base', 'Edges']) tp = Internal.appendBaseName2ZoneName(CTK.t, updateRef=False, separator=Internal.SEP1, trailing=Internal.SEP1) bases = Internal.getBases(tp) nb = 0 for b in bases: nodes = Internal.getNodesFromType1(b, 'Zone_t') nz = 0 for z in nodes: ztype = Internal.getZoneType(z) winz = wins[nb][nz] if ztype == 1: # structure for w in winz: imin = w[0] imax = w[1] jmin = w[2] jmax = w[3] kmin = w[4] kmax = w[5] zp = T.subzone(z, (imin, jmin, kmin), (imax, jmax, kmax)) CTK.dt[2][1][2].append(zp) else: # non structure for w in winz: zp = T.subzone(z, w, type='faces') CTK.dt[2][1][2].append(zp) nz += 1 nb += 1 if VARS[7].get() == '1': # display les edges des zones en + exts = [] zones = Internal.getZones(tp) for z in zones: ztype = Internal.getZoneType(z) if ztype == 1: zp = P.exteriorFacesStructured(z) exts += zp else: #zp = P.exteriorFaces(z); zp = P.sharpEdges(zp) zp = [] exts += zp CTK.dt[2][2][2] += exts #C._fillMissingVariables(CTK.dt) # bug exteriorFacesStruct # Activate lenZ = len(CTK.dt[2][1][2]) lenExts = len(exts) active = [(i, 1) for i in range(lenZ + lenExts)] for i in range(lenZ): active[i] = (i, 1) for i in range(lenExts): active[i + lenZ] = (i + lenZ, 0) CTK.display(CTK.dt, mainTree=CTK.UNDEFINEDBC) CPlot.setActiveZones(active) CPlot.setState(edgifyDeactivatedZones=1) else: lenZ = len(CTK.dt[2][1][2]) active = [(i, 1) for i in range(lenZ)] CTK.display(CTK.dt, mainTree=CTK.UNDEFINEDBC) CPlot.setActiveZones(active) # modifie la couleur du bouton l = len(Internal.getZones(CTK.dt)) if l == 0: TTK.setButtonGreen(WIDGETS['undefinedBC']) else: TTK.setButtonRed(WIDGETS['undefinedBC']) WIDGETS['undefinedBC'].update()
def view(event=None): if CTK.t == []: return pos = float(VARS[1].get()) global VALUE VALUE = pos delta = float(VARS[4].get()) global DELTA DELTA = delta plane = VARS[0].get() order = int(VARS[3].get()) eps = float(VARS[2].get()) algo = VARS[5].get() nzs = CPlot.getSelectedZones() if nzs != []: point = CPlot.getActivePoint() if len(point) == 3: if plane == 'X': pos = point[0] elif plane == 'Y': pos = point[1] elif plane == 'Z': pos = point[2] VARS[1].set(str(pos)) VALUE = pos if plane == 'Mesh': CTK.display(CTK.t) return try: if CTK.__MAINTREE__ == 1: CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones() active = [] tp = Internal.appendBaseName2ZoneName(CTK.t, updateRef=False, separator=Internal.SEP1) for z in CTK.__MAINACTIVEZONES__: active.append(tp[2][CTK.Nb[z] + 1][2][CTK.Nz[z]]) temp = C.newPyTree(['Base']) temp[2][1][2] += active if plane == 'X' and algo == 'Slice1': p = P.isoSurfMC(active, 'CoordinateX', pos) elif plane == 'Y' and algo == 'Slice1': p = P.isoSurfMC(active, 'CoordinateY', pos) elif plane == 'Z' and algo == 'Slice1': p = P.isoSurfMC(active, 'CoordinateZ', pos) elif plane == 'X' and algo == 'Slice2': p = P.extractPlane(active, (1, 0, 0, -pos), order=order, tol=eps) elif plane == 'Y' and algo == 'Slice2': p = P.extractPlane(active, (0, 1, 0, -pos), order=order, tol=eps) elif plane == 'Z' and algo == 'Slice2': p = P.extractPlane(active, (0, 0, 1, -pos), order=order, tol=eps) elif plane == 'X' and algo == 'Select+': p = P.selectCells(temp, '{CoordinateX}>=' + str(VALUE)) elif plane == 'Y' and algo == 'Select+': p = P.selectCells(temp, '{CoordinateY}>=' + str(VALUE)) elif plane == 'Z' and algo == 'Select+': p = P.selectCells(temp, '{CoordinateZ}>=' + str(VALUE)) elif plane == 'X' and algo == 'Select-': p = P.selectCells(temp, '{CoordinateX}<=' + str(VALUE)) elif plane == 'Y' and algo == 'Select-': p = P.selectCells(temp, '{CoordinateY}<=' + str(VALUE)) elif plane == 'Z' and algo == 'Select-': p = P.selectCells(temp, '{CoordinateZ}<=' + str(VALUE)) elif plane == 'X' and algo == 'Select=': p = P.selectCells( temp, '({CoordinateX}>=' + str(VALUE - DELTA) + ') & ({CoordinateX}<=' + str(VALUE + DELTA) + ')') elif plane == 'Y' and algo == 'Select=': p = P.selectCells( temp, '({CoordinateY}>=' + str(VALUE - DELTA) + ') & ({CoordinateY}<=' + str(VALUE + DELTA) + ')') elif plane == 'Z' and algo == 'Select=': p = P.selectCells( temp, '({CoordinateZ}>=' + str(VALUE - DELTA) + ') & ({CoordinateZ}<=' + str(VALUE + DELTA) + ')') CTK.dt = C.newPyTree(['Base']) if algo == 'Slice1': CTK.dt[2][1][2] += p elif algo == 'Slice2': CTK.dt[2][1][2] += [p] else: CTK.dt[2][1][2] += p[2][1][2] CTK.display(CTK.dt, mainTree=CTK.SLICE) if CTK.TKPLOTXY is not None: CTK.TKPLOTXY.updateApp() except ValueError: CTK.TXT.insert('START', 'Intersection is empty.\n') return except Exception as e: Panels.displayErrors([0, str(e)], header='Error: slice') CTK.TXT.insert('START', 'Slice failed.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return