def optimize():
    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
    dw = 1
    if VARS[0].get() == 'inactive': dw = 0

    depth = VARS[7].get()
    depth = int(depth)

    # Creation de l'arbre temporaire
    nzs = CPlot.getSelectedZones()
    if nzs == []:
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    # copie du premier niveau sans les enfants
    t = ['tree', None, [], 'CGNSTree_t']
    for i in CTK.t[2]:
        t[2].append([i[0], i[1], [], i[3]])

    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        t[2][nob][2].append(z)

    # Recuperation des priorites dans l'arbre
    bases = Internal.getBases(CTK.t)
    prios = []
    for b in bases:
        cont = Internal.getNodesFromName1(b, '.Solver#Chimera')
        if cont != []:
            prio = Internal.getNodesFromName3(cont[0], 'Priority')
            if prio != []:
                prios.append(b[0])
                prios.append(int(prio[0][1][0, 0]))

    # Optimisation du recouvrement
    CTK.saveTree()
    t = X.optimizeOverlap(t, double_wall=dw, priorities=prios)
    t = X.maximizeBlankedCells(t, depth=depth)

    c = [0 for x in xrange(len(bases))]
    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        CTK.t[2][nob][2][noz] = t[2][nob][2][c[nob - 1]]
        c[nob - 1] += 1

    CTK.TXT.insert('START', 'Overlapping optimized.\n')
    CTK.TKTREE.updateApp()
    CTK.display(CTK.t)
Esempio n. 2
0
# - maximizeBlankedCells (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G

def F(x,y):
    if (x+y<1): return 1
    else: return 2
    
Ni = 50; Nj = 50
a = G.cart((0,0,0),(1./(Ni-1),1./(Nj-1),1),(Ni,Nj,1))
a = C.initVars(a,'cellN', F,
               ['CoordinateX','CoordinateY'])
a = C.node2Center(a, 'cellN')
a = C.rmVars(a,'cellN')
t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
t = X.maximizeBlankedCells(t, 2)
C.convertPyTree2File(t, 'out.cgns')
Esempio n. 3
0
t = C.addBase2PyTree(t, 'CARTESIAN')
t[2][2][2] = res
# ajout d un plan en k
t = T.addkplane(t)
#
#---------------------------
# Assemblage Chimere
#---------------------------
DEPTH = 2
# bodies description
bodies = []
bases = Internal.getNodesFromType(t, 'CGNSBase_t')
for b in bases:
    walls = C.extractBCOfType(b, 'BCWall')
    if walls != []: bodies.append(walls)

# blanking
BM = numpy.array([[0], [1]])
t = X.blankCells(t, bodies, BM, depth=DEPTH, dim=2)
t = X.setHoleInterpolatedPoints(t, depth=DEPTH)
t = X.applyBCOverlaps(t, depth=DEPTH)
t = X.optimizeOverlap(t, priorities=['Cylindre1', 0, 'CARTESIAN', 1])
t = X.maximizeBlankedCells(t, depth=DEPTH)
t = X.setInterpolations(t, loc='cell')

# Arbre a la Cassiopee
C.convertPyTree2File(t, 'out_cassiopee.cgns')

# Arbre a la elsA
t = CE.convert2elsAxdt(t)
C.convertPyTree2File(t, 'out_elsa.cgns')
    if (x + y < 1): return 1
    else: return 2


# CAS 2D
Ni = 50
Nj = 50
a = G.cart((0, 0, 0), (1. / (Ni - 1), 1. / (Nj - 1), 1), (Ni, Nj, 1))
C._initVars(a, 'cellN', F, ['CoordinateX', 'CoordinateY'])
a = C.node2Center(a, 'cellN')
C._rmVars(a, 'cellN')
t = C.newPyTree(['Base', 2])
t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
C._addVars(t, 'Density')
t2 = X.maximizeBlankedCells(t, depth=1, dir=0)
test.testT(t2, 1)
t2 = X.maximizeBlankedCells(t, depth=2, dir=0)
test.testT(t2, 2)
t2 = X.maximizeBlankedCells(t, depth=2, dir=1)
test.testT(t2, 21)

# CAS 3D
Ni = 50
Nj = 50
Nk = 20
a = G.cart((0, 0, 0), (1. / (Ni - 1), 1. / (Nj - 1), 1. / (Nk - 1)),
           (Ni, Nj, Nk))
a = C.initVars(a, 'cellN', F, ['CoordinateX', 'CoordinateY'])
a = C.node2Center(a, 'cellN')
a = C.rmVars(a, 'cellN')
Esempio n. 5
0
# ==============================================================================
# 2. Blanking
# ==============================================================================
# bodies description
bodyC1 = C.extractBCOfType(t[2][1][2], 'BCWall')
bodyC2 = C.extractBCOfType(t[2][2][2], 'BCWall')
bodies = [bodyC1, bodyC2]
# blanking matrix
BM = numpy.array([[0, 1], [1, 0], [1, 1]])
# blanking
t = X.blankCells(t, bodies, BM, depth=2, dim=2)
# set interpolated cells around interpolated points
t = X.setHoleInterpolatedPoints(t, depth=2)
# ==============================================================================
# 3. Overlap optimisation with a high priority to cylinders
# ==============================================================================
t = X.optimizeOverlap(t, priorities=['Corps1', 0, 'Corps2', 0, 'Bgrd', 1])
t = X.maximizeBlankedCells(t, depth=2)
# ==============================================================================
# 4. Convert indices of cellN = 0 into OversetHoles nodes
# ==============================================================================
t = X.cellN2OversetHoles(t)
# ==============================================================================
# 5. Computes Chimera connectivity
# ==============================================================================
t = X.setInterpolations(t, loc='cell')
# ==============================================================================
# 6. Save file
# ==============================================================================
C.convertPyTree2File(t, 'comp0.cgns')