Exemplo n.º 1
0
def addGhostCells(event=None):
    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
    nzs = CPlot.getSelectedZones()
    if nzs == []:
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
    N = CTK.varsFromWidget(VARS[0].get(), type=2)
    if len(N) != 1:
        CTK.TXT.insert('START', 'Number of ghost cell layers is incorrect.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
    N = N[0]

    CTK.saveTree()

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

    zones = Internal.addGhostCells(CTK.t, zones, N, adaptBCs=1)
    c = 0
    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        CTK.replace(CTK.t, nob, noz, zones[c])
        c += 1

    CTK.TXT.insert('START', 'Ghost cells added.\n')
    CTK.TKTREE.updateApp()
    CPlot.render()
Exemplo n.º 2
0
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal
import Connector.PyTree as X
import Geom.PyTree as D
import KCore.test as test

d = 2
a = D.sphere6((0, 0, 0), 0.5, N=20)
dk = G.cart((0, 0, 0), (0.01, 1, 1), (11, 1, 1))
a = G.addNormalLayers(a, dk)
t = C.newPyTree(['Base'])
t[2][1][2] = a
t = X.connectMatch(t, dim=3)
t = Internal.addGhostCells(t, t, d, adaptBCs=1)
#---------
# Centers
#---------
t = C.initVars(t, 'centers:F=0.')
tc = C.node2Center(t)
tc = C.initVars(tc, 'F={CoordinateX}*{CoordinateY}')
# stockage direct
t1 = X.setInterpDataForGhostCells__(t, tc, storage='direct', loc='centers')
t1 = X.setInterpTransfers(t1, tc, variables=['F'])
test.testT(t1, 1)

# stockage inverse
tc1 = X.setInterpDataForGhostCells__(t, tc, storage='inverse', loc='centers')
t1 = X.setInterpTransfers(t, tc1, variables=['F'])
test.testT(t1, 2)
#---------
                 trirac=[1, 2, 3],
                 rotationCenter=(0, 0, 0),
                 rotationAngle=(0., 0., 0.),
                 translation=(+1., 0., 0.))
a = C.addBC2Zone(a,
                 'per2',
                 'BCMatch', [ni, ni, 1, nj, 1, nk],
                 zoneDonor=a,
                 rangeDonor=[1, 1, 1, nj, 1, nk],
                 trirac=[1, 2, 3],
                 rotationCenter=(0, 0, 0),
                 rotationAngle=(0., 0., 0.),
                 translation=(-1., 0., 0.))

t = C.newPyTree(['Base', a])
t = Internal.addGhostCells(t, t, 2, adaptBCs=1, fillCorner=1)
test.testT(t, 1)

# cas periodicite par rotation
ni = 91
nj = 21
nk = 1
alpha = 90.
a = G.cylinder((0, 0, 0), 0.5, 1., 0., alpha, 1., (ni, nj, nk))
a = C.initVars(a, 'VelocityX=0.')
a = C.initVars(a, 'VelocityY=0.')
a = C.initVars(a, 'VelocityZ=1.')
vx = C.getField('VelocityX', a)[0]
vy = C.getField('VelocityY', a)[0]
nic = vx[2]
njc = vx[3]
Exemplo n.º 4
0
import Converter.Internal as Internal
import Transform.PyTree as T
import Connector.PyTree as X
import KCore.test as test

# 3D sur une zone
a = D.sphere((0, 0, 0), 1, N=10)
dhk = G.cart((0, 0, 0), (0.1, 1, 1), (2, 1, 1))
a = G.addNormalLayers(a, dhk)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, 'centers:F={centers:CoordinateX}')
a = C.initVars(a, 'Density={CoordinateX}')
t = C.newPyTree(['Base'])
t[2][1][2] = [a]
t = Internal.addGhostCells(t, t, 2, adaptBCs=0, fillCorner=1)
t = Internal.rmGhostCells(t, t, 2)
test.testT(t, 1)

# 3D sur un arbre
a = D.sphere((0, 0, 0), 1, N=10)
dhk = G.cart((0, 0, 0), (0.1, 1, 1), (2, 1, 1))
a = G.addNormalLayers(a, dhk)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, 'centers:F={centers:CoordinateX}**2')
a = C.initVars(a, 'Density=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base'])
t[2][1][2] = [a]
t = Internal.addGhostCells(t, t, 1, adaptBCs=0, fillCorner=1)
t = Internal.rmGhostCells(t, t, 1)
nobc = 1
for b in Internal.getNodesFromName(a, 'wall*'):
    d = Internal.newBCDataSet(name='BCDataSet',
                              value='UserDefined',
                              gridLocation='FaceCenter',
                              parent=b)
    d = Internal.newBCData('BCNeumann', parent=d)
    if dim == 2: nfaces = (N - 1)
    else: nfaces = (N - 1)**2
    d1 = Internal.newDataArray('Density', value=nfaces * [1. * nobc], parent=d)
    d2 = Internal.newDataArray('G', value=nfaces * [-1. * nobc], parent=d)
    nobc += 1
C._initVars(a, 'centers:Density=2.')
C._initVars(a, 'centers:G=2.')
t = C.newPyTree(['Base', a, dim])
t = Internal.addGhostCells(t, t, 2)
test.testT(t, 1)
#
N = 10
dim = 3
a = G.cart((0, 0, 0), (1, 1, 1), (N, N, N))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'jmax')
nobc = 1
for b in Internal.getNodesFromName(a, 'wall*'):
    d = Internal.newBCDataSet(name='BCDataSet',
                              value='UserDefined',
                              gridLocation='FaceCenter',
                              parent=b)
    d = Internal.newBCData('BCNeumann', parent=d)
    if dim == 2: nfaces = (N - 1)
Exemplo n.º 6
0
b = T.reorder(b, (1,2,3))
c = T.reorder(c, (3,1,2))

# Physical BC (here BCWall)
C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin')

# Chimere
#-----------------------------
# initialisation cellNatureField
C._initVars(a, 'centers:cellN', 1.)
C._initVars(b, 'centers:cellN', 0.)
#-----------------------------
# initialisation density
C._initVars(a, '{Density}=3.*{CoordinateX}+2.*{CoordinateY}')
C._initVars(a, 'StagnationPressure', 0.5)
C._initVars(c, 'StagnationPressure', 1.)
t = C.newPyTree(['Base',a,b,c])
# Matching BC
t = X.connectMatch(t)
a = t[2][1][2][0]

ag = Internal.addGhostCells(t, a, 2)
t[2][1][2].append(ag)

ag = Internal.rmGhostCells(t, ag, 1)
t[2][1][2].append(ag)
ag = Internal.rmGhostCells(t, ag, 1)
t[2][1][2].append(ag)

test.testT(t, 1)
Exemplo n.º 7
0
# - addGhostCells (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import Converter.Internal as Internal

a = G.cart((1,1,1), (1.,1.,1.), (4,2,3)); a[0]='cart1'
b = G.cart((1,1,-3), (1.,1.,0.5), (4,2,9)); b[0]='cart2'
a = C.addBC2Zone(a,'match','BCMatch','kmin',b[0],[1,4,1,2,9,9],[1,2,3])
b = C.addBC2Zone(b,'match','BCMatch','kmax',a[0],[1,4,1,2,1,1],[1,2,3])
t = C.newPyTree(['Base',a,b])
# Physical BC (here BCWall)
t = C.addBC2Zone(t, 'wall', 'BCWall', 'imin')
t = C.initVars(t, '{F}=3*{CoordinateX}+2*{CoordinateY}')
#
a = t[2][1][2][0]
ag = Internal.addGhostCells(t,a,2,adaptBCs=1)
t[2][1][2][0] = ag
ag = Internal.rmGhostCells(t,ag,2)
t[2][1][2][0] = ag
C.convertPyTree2File(t,'out.cgns')
import Geom.PyTree as D
import Converter.Internal as Internal
import Transform.PyTree as T
import Connector.PyTree as X
import KCore.test as test

# 3D sur une zone
a = D.sphere((0, 0, 0), 1, N=10)
dhk = G.cart((0, 0, 0), (0.1, 1, 1), (2, 1, 1))
a = G.addNormalLayers(a, dhk)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}')
a = C.initVars(a, '{Density}={CoordinateX}')
t = C.newPyTree(['Base', a])
a = Internal.addGhostCells(t, a, 1)
test.testT(a, 1)

# 3D sur un arbre
a = D.sphere((0, 0, 0), 1, N=10)
dhk = G.cart((0, 0, 0), (0.1, 1, 1), (2, 1, 1))
a = G.addNormalLayers(a, dhk)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a, '{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base', a])
t = Internal.addGhostCells(t, t, 1)
test.testT(t, 2)

#  2D sans frontieres exterieures