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)
b = G.cart((0, 0, 0), (2. / (Ni - 1), 2. / (Nj - 1), 1), (Ni, Nj, Nk))
b[0] = 'cart2'
a = T.rotate(a, (0, 0, 0), (0, 0, 1), 10.)
a = T.translate(a, (0.5, 0.5, 0))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
b = C.addBC2Zone(b, 'wall', 'BCWall', 'imin')

t = C.newPyTree(['Base1', 'Base2'])
t[2][1][2].append(a)
t[2][2][2].append(b)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t[2][2] = C.addState(t[2][2], 'EquationDimension', 2)
t = C.fillEmptyBCWith(t, 'overlap', 'BCOverlap', dim=2)
t = C.addVars(t, 'Density')
t = C.addVars(t, 'centers:Pressure')
t2 = X.optimizeOverlap(t)
test.testT(t2)
#
# priorite sur Base2
#
t2 = X.optimizeOverlap(t, priorities=['Base1', 1, 'Base2', 0])
test.testT(t2, 2)

# Like the first test, but using an intersection dictionnary:
interDict = X.getIntersectingDomains(t, method='hybrid')
t2 = X.optimizeOverlap(t, intersectionsDict=interDict)
test.testT(t2, 3)

# Like the second test, but using an Intersection Dictionnary:
t2 = X.optimizeOverlap(t,
                       priorities=['Base1', 1, 'Base2', 0],
Exemple #3
0
import Connector.PyTree as X
import Transform.PyTree as T
import Generator.PyTree as G
import KCore.test as test
a1 = G.cylinder((0., 0., 0.), 0.5, 1., 0., 180., 1., (25, 25, 10))
a1[0] = 'mesh1'
a2 = G.cylinder((0., 0., 0.), 0.5, 1., 45, 90., 1., (50, 50, 10))
a2[0] = 'mesh2'
a1 = C.addBC2Zone(a1, 'wall1', 'BCWall', 'imin')
a1 = C.addBC2Zone(a1, 'wall2', 'BCWall', 'imax')
a1 = C.addBC2Zone(a1, 'wall3', 'BCWall', 'jmin')
a1 = C.fillEmptyBCWith(a1, 'nref', 'BCFarfield')
a2 = C.addBC2Zone(a2, 'wall1', 'BCWall', 'jmin')
a2 = C.addBC2Zone(a2, 'ov1', 'BCOverlap', 'imin')
a2 = C.addBC2Zone(a2, 'ov2', 'BCOverlap', 'imax')
a2 = C.fillEmptyBCWith(a2, 'nref', 'BCFarfield')
t = C.newPyTree(['Base1', 'Base2'])
t[2][1][2].append(a1)
t[2][2][2].append(a2)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t[2][2] = C.addState(t[2][2], 'EquationDimension', 3)

t = X.applyBCOverlaps(t, depth=1)
t2 = X.optimizeOverlap(t, double_wall=1)
test.testT(t2)

# Same as first test, but now using an intersection dictionnary
interDict = X.getIntersectingDomains(t, method='hybrid')
t2 = X.optimizeOverlap(t, double_wall=1, intersectionsDict=interDict)
test.testT(t2, 2)
NK = 4 * int(H) + 1
a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., H, (11, 11, NK))
t = C.newPyTree(['Base', 'Base2'])
t[2][1][2] += [a]
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           translation=[0., 0., H])

H2 = 4 * H
NK = 2 * int(H2) + 1
b = G.cylinder((0., 0., -H), 0.1, 1., -30., 120., 3 * H, (11, 11, NK))
t[2][2][2] += [b]

# Same as first test, but now using an intersection dictionnary
interDict = X.getIntersectingDomains(t, method='hybrid')
t1 = X.optimizeOverlap(t, intersectionsDict=interDict)
test.testT(t1, 4)
# First test:
t = X.optimizeOverlap(t)
test.testT(t, 1)
# Periodicite par rotation
H = 1.
NK = 4 * int(H) + 1
a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., H, (11, 11, NK))
t = C.newPyTree(['Base', 'Base2'])
t[2][1][2] += [a]
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 90.])
H2 = 4 * H
NK = 2 * int(H2) + 1
Exemple #5
0
# - optimizeOverlap (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T
import Connector.PyTree as X

Ni = 50
Nj = 50
Nk = 2
a = G.cart((0, 0, 0), (1. / (Ni - 1), 1. / (Nj - 1), 1), (Ni, Nj, Nk))
b = G.cart((0, 0, 0), (2. / (Ni - 1), 2. / (Nj - 1), 1), (Ni, Nj, Nk))
b[0] = 'cart2'
a = T.rotate(a, (0, 0, 0), (0, 0, 1), 10.)
a = T.translate(a, (0.5, 0.5, 0))
t = C.newPyTree(['Base1', a, 'Base2', b])
t = X.optimizeOverlap(t)
C.convertPyTree2File(t, "out.cgns")
Exemple #6
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')
Exemple #7
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')