Ejemplo n.º 1
0
# traitement sur des zones
import Transform.PyTree as T
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

# Structure 3D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 3))
a = C.addVars(a, 'Density')
a = C.addVars(a, 'centers:cellN')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2, 3])
t = C.newPyTree(['Base', a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t = T.symetrize(t, (0., 0., 0.), (1, 0, 0), (0, 0, 1))
test.testT(t, 1)

# Structure 2D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
a = C.addVars(a, 'Density')
a = C.addVars(a, 'centers:cellN')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2])
t = C.newPyTree(['Base', 2, a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = T.symetrize(t, (0., 0., 0.), (1, 0, 0), (0, 0, 1))
test.testT(t, 2)

# TETRA
Ejemplo n.º 2
0
def symetrize():
    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
    axis = VARS[4].get()
    nzs = CPlot.getSelectedZones()
    if nzs == []:
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

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

    xmin = bb[0]
    ymin = bb[1]
    zmin = bb[2]
    xmax = bb[3]
    ymax = bb[4]
    zmax = bb[5]
    if axis == 'around XY-':
        X = ((xmin + xmax) * 0.5, (ymin + ymax) * 0.5, zmin)
        axe1 = (1., 0., 0.)
        axe2 = (0., 1., 0.)
    elif axis == 'XY+':
        X = ((xmin + xmax) * 0.5, (ymin + ymax) * 0.5, zmax)
        axe1 = (1., 0., 0.)
        axe2 = (0., 1., 0.)
    elif axis == 'around XZ-':
        X = ((xmin + xmax) * 0.5, ymin, (zmin + zmax) * 0.5)
        axe1 = (1., 0., 0.)
        axe2 = (0., 0., 1.)
    elif axis == 'around XZ+':
        X = ((xmin + xmax) * 0.5, ymax, (zmin + zmax) * 0.5)
        axe1 = (1., 0., 0.)
        axe2 = (0., 0., 1.)
    elif axis == 'around YZ-':
        X = (xmin, (ymin + ymax) * 0.5, (zmin + zmax) * 0.5)
        axe1 = (0., 1., 0.)
        axe2 = (0., 0., 1.)
    elif axis == 'around YZ+':
        X = (xmax, (ymin + ymax) * 0.5, (zmin + zmax) * 0.5)
        axe1 = (0., 1., 0.)
        axe2 = (0., 0., 1.)
    elif axis == 'around view':
        X = CPlot.getState('posEye')
        Y = CPlot.getState('posCam')
        axe1 = (X[0] - Y[0], X[1] - Y[1], X[2] - Y[2])
        axe2 = CPlot.getState('dirCam')
    else:
        X = (0., 0., 0.)
        axe1 = (1., 0., 0.)
        axe2 = (0., 1., 0.)

    CTK.saveTree()
    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        a = T.symetrize(CTK.t[2][nob][2][noz], (X[0], X[1], X[2]), axe1, axe2)
        CTK.replace(CTK.t, nob, noz, a)
    CTK.TXT.insert('START', 'Zones have been symmetrized.\n')
    CTK.TKTREE.updateApp()
    CPlot.render()
Ejemplo n.º 3
0
# - symetrize (pyTree) -
# traitement sur des zones
import Transform.PyTree as T
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

# Structure 3D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 3))
C._addVars(a, 'Density')
C._addVars(a, 'centers:cellN')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2, 3])
a = T.symetrize(a, (0., 0., 0.), (1, 0, 0), (0, 0, 1))
test.testT(a, 1)

# Structure 2D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
C._addVars(a, 'Density')
C._addVars(a, 'centers:cellN')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2])
a = T.symetrize(a, (0., 0., 0.), (1, 0, 0), (0, 0, 1))
test.testT(a, 2)

# TETRA
a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 3))
C._addVars(a, 'Density')
C._addVars(a, 'centers:cellN')
Ejemplo n.º 4
0

a = D.sphere((0, 0, 0), 1., 20)
a = C.convertArray2Tetra(a)
a = G.close(a)
surf = C.newPyTree(['SURF', 2])
surf[2][1][2].append(a)

snear = [0.5]

# symetrize the bodies wrt. X/Y/Z planes
for coord in dico.keys():
    for zone in Internal.getByType(surf, 'Zone_t')[2]:
    if coord=='CoordinateX':
        surf[2][1][2].append(T.symetrize(zone,
                                         (dico[coord], 0., 0.),
                                         (0, 1, 0),
                                         (0, 0, 1)))
    if coord=='CoordinateY':
        surf[2][1][2].append(T.symetrize(zone,
                                         (0., dico[coord], 0.),
                                         (1, 0, 0),
                                         (0, 0, 1)))
    if coord=='CoordinateZ':
        surf[2][1][2].append(T.symetrize(zone,
                                         (0., 0., dico[coord]),
                                         (1, 0, 0),
                                         (0, 1, 0)))
    snear+=snear

octr = G.octree(surf, snear, dfar=5.)