Esempio n. 1
0
def connectNearMatch():
    if CTK.t == []: return
    eps = VARS[2].get()
    eps = float(eps)
    ratio = VARS[3].get()
    ratio = CTK.varsFromWidget(ratio, type=2)

    if len(ratio) != 1 and len(ratio) != 3:
        CTK.TXT.insert('START', 'Invalid ratio for nearmatch.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
    if len(ratio) == 1: ratio = ratio[0]

    node = Internal.getNodeFromName(CTK.t, 'EquationDimension')
    if node is not None: ndim = Internal.getValue(node)
    else:
        CTK.TXT.insert('START',
                       'EquationDimension not found (tkState). Using 3D.\n')
        CTK.TXT.insert('START', 'Warning: ', 'Warning')
        ndim = 3

    nzs = CPlot.getSelectedZones()
    CTK.saveTree()
    if CTK.__MAINTREE__ <= 0 or nzs == []:
        try:
            CTK.t = X.connectNearMatch(CTK.t, ratio=ratio, tol=eps, dim=ndim)
            CTK.TKTREE.updateApp()
            CTK.TXT.insert('START', 'n/m matching BCs successfully set.\n')
        except Exception as e:
            Panels.displayErrors([0, str(e)], header='Error: connectNearMatch')
            CTK.TXT.insert('START', 'n/m matching BCs failed.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
    else:
        sel = []
        for nz in nzs:
            nob = CTK.Nb[nz] + 1
            noz = CTK.Nz[nz]
            z = CTK.t[2][nob][2][noz]
            sel.append(z)
        try:
            sel = X.connectNearMatch(sel, ratio=ratio, tol=eps, dim=ndim)
            c = 0
            for nz in nzs:
                nob = CTK.Nb[nz] + 1
                noz = CTK.Nz[nz]
                CTK.t[2][nob][2][noz] = sel[c]
                c += 1
            CTK.TKTREE.updateApp()
            CTK.TXT.insert('START', 'n/m matching BCs successfully set.\n')
        except Exception as e:
            Panels.displayErrors([0, str(e)], header='Error: connectNearMatch')
            CTK.TXT.insert('START', 'n/m matching BCs failed.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
    check()
Esempio n. 2
0
#
# 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)
test.testT(t,2)

# geometrical extrapolation of corner cells
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)
Esempio n. 3
0
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.)
t = C.initVars(t, 'Density', 1.)
t = X.connectNearMatch(t, dim=2, tol=2.e-5)
test.testT(t, 2)
Esempio n. 4
0
#
# 2D Case
#
y0 = 0.4; dimPb = 2; nk = 1
a = G.cart((0.,0.,0.), (0.1, 0.1, 0.1), (11, 21,nk))
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.,y0, 0.), (0.1, 0.1, 0.1), (11, 21,nk))
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',a,a2])
t = X.connectNearMatch(t,2,dim=dimPb)
t = Internal.addGhostCells(t,t,2,adaptBCs=0,fillCorner=1)
test.testT(t,1)
#
t = C.newPyTree(['Base',a,a2])
t[2][1] = C.addState(t[2][1], 'EquationDimension',dimPb)
t = X.connectNearMatch(t,2, dim=dimPb)
t = Internal.addGhostCells(t,t,2,adaptBCs=1,fillCorner=1)
test.testT(t,2)

# geometrical extrapolation of corner cells
t = C.newPyTree(['Base',a,a2])
t[2][1] = C.addState(t[2][1], 'EquationDimension',dimPb)
t = X.connectNearMatch(t,2, dim=dimPb)
t = Internal.addGhostCells(t,t,2,adaptBCs=0,fillCorner=0)
test.testT(t,3)
# - 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']
Esempio n. 6
0
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, 20, 2))

# partiellement coincident
# --- CL
a2 = G.cart((1., 0.5, 0.), (0.1, 0.1, 0.1), (11, 21, 2))
a2 = T.oneovern(a2, (2, 2, 1))
a2 = C.addBC2Zone(a2, 'wall1', 'BCWall', 'jmax')
a2 = C.addBC2Zone(a2, 'overlap1', 'BCOverlap', 'jmin')
# --- champ aux centres
a2 = C.initVars(a2, 'centers:Density', 1.)
# --- champ aux noeuds
a2 = C.initVars(a2, 'cellN', 2.)
t = C.newPyTree(['Base'])
t[2][1][2] += [a, a2]
# --- Equation state
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t = X.connectNearMatch(t)
test.testT(t, 1)

# coincident
a3 = G.cart((1.00001, -1.4, 0.), (0.1, 0.1, 0.1), (11, 20, 2))
t[2][1][2].append(a3)
t = X.connectMatch(t, tol=2.e-5)
t = X.connectNearMatch(t, tol=2.e-5)
test.testT(t, 2)