Exemplo n.º 1
0
def oneovern():
    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
    args = VARS[0].get()
    args = args.split(';')
    if (len(args) != 3):
        CTK.TXT.insert('START', 'oneovern requires 3 steps.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
    ni = int(args[0])
    nj = int(args[1])
    nk = int(args[2])

    CTK.saveTree()

    fail = False
    errors = []
    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        try:
            a = T.oneovern(CTK.t[2][nob][2][noz], (ni, nj, nk))
            CTK.replace(CTK.t, nob, noz, a)
        except Exception as e:
            fail = True
            errors += [0, str(e)]

    if not fail: CTK.TXT.insert('START', 'oneovern done.\n')
    else:
        Panels.displayErrors(errors, header='Error: oneovern')
        CTK.TXT.insert('START', 'oneovern fails for at least one zone.\n')
        CTK.TXT.insert('START', 'Warning: ', 'Warning')
    CTK.TKTREE.updateApp()
    CPlot.render()
Exemplo n.º 2
0
# - oneovern (pyTree) -
import Transform.PyTree as T
import Converter.PyTree as C
import Generator.PyTree as G

a = G.cart((0,0,0), (1,1,1), (10,10,1))
a2 = T.oneovern(a, (2,2,1)); a2[0] = 'cart2'
C.convertPyTree2File([a,a2], "out.cgns")
Exemplo n.º 3
0
import Generator.PyTree as G
import Converter.PyTree as C
import Converter.Internal as Internal
import Transform.PyTree as T
import Connector.PyTree as X
import KCore.test as test
#
# 2D Case
#
a = G.cart((0.,0.,0.), (0.1, 0.1, 0.1), (11, 21, 1))
a = C.initVars(a, '{centers:Density}={centers:CoordinateX}')
a = C.initVars(a, '{F}={CoordinateY}*{CoordinateX}')
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
# partiellement coincident
a2 = G.cart((1., 0.4, 0.), (0.1, 0.1, 0.1), (11, 21, 1))
a2 = T.oneovern(a2,(2,2,1))
a2 = C.initVars(a2, '{centers:Density}={centers:CoordinateX}')
a2 = C.initVars(a2, '{F}={CoordinateY}*{CoordinateX}')
a2 = C.addBC2Zone(a2, 'overlap1', 'BCOverlap', 'imax')
t = C.newPyTree(['Base',2]); t[2][1][2] += [a, a2]
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = X.connectNearMatch(t, dim=2)
t = Internal.addGhostCells(t,t,2,adaptBCs=0,fillCorner=1)
t = Internal.rmGhostCells(t,t, 2, adaptBCs=0)
test.testT(t,1)
#
t = C.newPyTree(['Base',2]); t[2][1][2] += [a, a2]
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = X.connectNearMatch(t, dim=2)
t = Internal.addGhostCells(t,t,2,adaptBCs=1,fillCorner=1)
t = Internal.rmGhostCells(t,t, 2, adaptBCs=1)
Exemplo n.º 4
0
# - connectNearMatch 2D (pyTree)-
import Generator.PyTree as G
import Converter.PyTree as C
import Connector.PyTree as X
import Transform.PyTree as T
import KCore.test as test

a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 1))
# --- champ au centre
a = C.initVars(a, 'centers:Density', 1.)
# --- CL
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
# partiellement coincident
a2 = G.cart((1., 0.4, 0.), (0.1, 0.1, 0.1), (11, 21, 1))
a2 = T.oneovern(a2, (2, 2, 1))
# --- champ au noeud
a2 = C.initVars(a2, 'Density', 1.)
a2 = C.addBC2Zone(a2, 'overlap1', 'BCOverlap', 'imax')
t = C.newPyTree(['Base', 2])
t[2][1][2] += [a, a2]
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = X.connectNearMatch(t, dim=2)
test.testT(t, 1)

# coincident 1s2
a3 = G.cart((1.00001, -1.6, 0.), (0.1, 0.1, 0.1), (11, 21, 1))
a3 = T.oneovern(a3, (2, 2, 1))
a3[0] = 'cart3'
t[2][1][2] += [a3]
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = C.initVars(t, 'centers:Density', 1.)
Exemplo n.º 5
0
# - mergeCart (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

dh = 0.1; n = 11
A = []
a1 = G.cart((0.,0.,0.),(dh,dh,dh),(n,n,n)); a1 = T.oneovern(a1,(2,2,2))
a2 = G.cart((1.,0.,0.),(dh,dh,dh),(n,n,n)); a2 = T.oneovern(a2,(2,2,2))
a3 = G.cart((1.,1.,0.),(dh,dh,dh),(n,n,n))
a4 = G.cart((0.,1.,0.),(dh,dh,dh),(n,n,n))
A = [a1,a2,a3,a4]
for i in range(1,5): A[i-1][0] = 'cart'+str(i)

t = C.newPyTree(['Base']); t[2][1][2] += A
t[2][1][2] = T.mergeCart(t[2][1][2])
test.testT(t)
# - connectNearMatch (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import Transform.PyTree as T
import Converter.Internal as Internal
import Converter.elsAProfile as elsAProfile

a1 = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 3))
a1[0] = 'cart1'
a2 = G.cart((1., 0.2, 0.), (0.1, 0.1, 0.1), (11, 21, 3))
a2[0] = 'cart2'
a2 = T.oneovern(a2, (1, 2, 1))
t = C.newPyTree(['Base', a1, a2])
t = X.connectNearMatch(t)
Internal.printTree(Internal.getNodeFromName(t, 'nmatch1_0'))
#>> ['nmatch1_0',array('cart2',dtype='|S1'),[4 sons],'GridConnectivity_t']
#>>    |_['PointRange',array(shape=(3, 2),dtype='int32',order='F'),[0 son],'IndexRange_t']
#>>    |_['GridConnectivityType',array('Abutting',dtype='|S1'),[0 son],'GridConnectivityType_t']
#>>    |_['PointListDonor',array(shape=(3, 1),dtype='int32',order='C'),[0 son],'IndexArray_t']
#>>    |_['UserDefinedData',None,[3 sons],'UserDefinedData_t']
#>>        |_['PointRangeDonor',array(shape=(3, 2),dtype='int32',order='F'),[0 son],'DataArray_t']
#>>        |_['Transform',array(shape=(3,),dtype='int32',order='F'),[0 son],'DataArray_t']
#>>        |_['NMRatio',array(shape=(3,),dtype='float64',order='F'),[0 son],'DataArray_t']
tp = elsAProfile.adaptNearMatch(t)
Internal.printTree(Internal.getNodeFromName(tp, 'nmatch1_0'))
#>> ['nmatch1_0',array('cart2',dtype='|S1'),[4 sons],'GridConnectivity1to1_t']
#>>    |_['PointRange',array(shape=(3, 2),dtype='int32',order='F'),[0 son],'IndexRange_t']
#>>    |_['PointRangeDonor',array(shape=(3, 2),dtype='int32',order='F'),[0 son],'IndexRange_t']
#>>    |_['Transform',array(shape=(3,),dtype='int32',order='F'),[0 son],'"int[IndexDimension]"']
#>>    |_['.Solver#Property',None,[6 sons],'UserDefinedData_t']
# - oneovern (pyTree) -
import Transform.PyTree as T
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

# Structure 2D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
C._initVars(a, '{centers:celln}=({centers:CoordinateX}>5.)*{CoordinateX}')
C._initVars(a, '{Density}=3*{CoordinateX}*{CoordinateY}')
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.oneovern(a, (2, 2, 1))
test.testT(a, 1)

# Structure 3D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
C._initVars(a, '{Density}=3*{CoordinateX}*{CoordinateY}')
C._initVars(a, '{centers:celln}=({centers:CoordinateX}>5.)*{CoordinateX}')
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])
a1 = T.oneovern(a, (3, 3, 1))
test.testT(a1, 2)

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
C._initVars(a, '{centers:celln}=({centers:CoordinateX}>5.)*{CoordinateX}')
C._initVars(a, '{Density}=3*{CoordinateX}*{CoordinateY}')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'jmin')
Exemplo n.º 8
0
# - mergeCart (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T

dh = 0.1
n = 11
A = []
a1 = G.cart((0., 0., 0.), (dh, dh, dh), (n, n, n))
a1 = T.oneovern(a1, (2, 2, 2))
a2 = G.cart((1., 0., 0.), (dh, dh, dh), (n, n, n))
a2 = T.oneovern(a2, (2, 2, 2))
a3 = G.cart((1., 1., 0.), (dh, dh, dh), (n, n, n))
a4 = G.cart((0., 1., 0.), (dh, dh, dh), (n, n, n))
A = [a1, a2, a3, a4]
for i in range(1, 5):
    A[i - 1][0] = 'cart' + str(i)

t = C.newPyTree(['Base'])
t[2][1][2] += A
t[2][1][2] = T.mergeCart(t[2][1][2])
C.convertPyTree2File(t, "out.cgns")