Пример #1
0
def _compressCartesian(t):
    zones = Internal.getZones(t)
    for z in zones:
        ztype = Internal.getZoneDim(z)
        if ztype[0] == 'Unstructured': continue
        gc = Internal.getNodeFromName1(z, Internal.__GridCoordinates__)
        if gc is None: continue
        xp = Internal.getNodeFromName1(gc, 'CoordinateX')
        yp = Internal.getNodeFromName1(gc, 'CoordinateY')
        zp = Internal.getNodeFromName1(gc, 'CoordinateZ')
        if xp is None: continue
        if yp is None: continue
        if zp is None: continue
        xp = xp[1].ravel(order='K')
        yp = yp[1].ravel(order='K')
        zp = zp[1].ravel(order='K')
        ni = ztype[1]
        nj = ztype[2]
        nk = ztype[3]
        x0 = xp[0]
        y0 = yp[0]
        z0 = zp[0]
        hi = xp[1] - x0
        if nj > 1: hj = yp[ni] - y0
        else: hj = 1.
        if nk > 1: hk = zp[ni * nj] - z0
        else: hk = 1.
        Internal._rmNodesFromName(gc, 'CoordinateX')
        Internal._rmNodesFromName(gc, 'CoordinateY')
        Internal._rmNodesFromName(gc, 'CoordinateZ')
        Internal.createChild(z,
                             'CartesianData',
                             'DataArray_t',
                             value=[x0, y0, z0, hi, hj, hk])
    return None
Пример #2
0
def _uncompressCartesian(t):
    import Generator.PyTree as G
    zones = Internal.getZones(t)
    for z in zones:
        ztype = Internal.getZoneDim(z)
        if ztype[0] == 'Unstructured': continue
        c = Internal.getNodeFromName1(z, 'CartesianData')
        if c is None: continue
        c = Internal.getValue(c)
        x0 = c[0]
        y0 = c[1]
        z0 = c[2]
        hi = c[3]
        hj = c[4]
        hk = c[5]
        tmp = G.cart((x0, y0, z0), (hi, hj, hk),
                     (ztype[1], ztype[2], ztype[3]))
        gc = Internal.getNodeFromName1(z, Internal.__GridCoordinates__)
        gct = Internal.getNodeFromName1(tmp, Internal.__GridCoordinates__)
        if gc is None: Internal._addChild(z, gct)
        else:
            Internal._rmNodesFromName(z, Internal.__GridCoordinates__)
            Internal._addChild(z, gct)
    return None
t = C.newPyTree(['Base', res])

# Mark solid and fluid points
X._applyBCOverlaps(t, depth=DEPTH, loc='nodes')
tc = Internal.copyRef(t)
tc = X.setInterpData(t, tc, loc='nodes', storage="inverse")
C._initVars(t, "cellN", 1.)
t = X.blankCells(t, [[body]], numpy.array([[1]]), blankingType='node_in')
X._setHoleInterpolatedPoints(t, depth=1, loc='nodes')
C._initVars(t, '{flag}=({cellN}>1.)')
t = DTW.distance2WallsEikonal(t, body, tc=tc, DEPTH=DEPTH, nitmax=10)
test.testT(t, 1)
# aux centres
t = C.newPyTree(['Base'])
t[2][1][2] = res
Internal._rmNodesFromName(t, "FlowSolution")
# Mark solid and fluid points
X._applyBCOverlaps(t, depth=DEPTH, loc='centers')
tc = C.node2Center(t)
tc = X.setInterpData(t, tc, loc='centers', storage="inverse")
C._initVars(t, "centers:cellN", 1.)
t = X.blankCells(t, [[body]], numpy.array([[1]]), blankingType='center_in')
X._setHoleInterpolatedPoints(t, depth=1)
C._initVars(t, '{centers:flag}=({centers:cellN}>1.)')
t = DTW.distance2WallsEikonal(t,
                              body,
                              tc=tc,
                              DEPTH=DEPTH,
                              loc='centers',
                              nitmax=10)
test.testT(t, 2)
Пример #4
0
import Converter.PyTree as C
import Transform.PyTree as T
import Geom.PyTree as D
import Converter.Internal as Internal
import KCore.test as test

a = D.sphere6((0.,0.,0.),1.,N=10)
C._initVars(a,'Fx=1.')
C._initVars(a,'Fy=2.')
C._initVars(a,'Fz=3.')
C._initVars(a[1],'toto=0.')

noz = 0
for z in Internal.getZones(a):
    if noz != 1:
        C._initVars(z,'{centers:Gx}=2.')
        C._initVars(z,'{centers:Gy}=1.')
    else:
        C._initVars(z,'{centers:Gy}=1.')
        C._initVars(z,'{centers:Gx}=2.')
    GC = Internal.getNodeFromType(z,'GridCoordinates_t')
    Internal._rmNodesFromName(z,GC[0])
    if noz == 1:
        XA = Internal.getNodeFromName(GC,'CoordinateX')
        Internal._rmNodesFromName(GC,'CoordinateX')
        GC[2].append(XA)
    z[2].append(GC)
    noz+=1
res = T.join(a[0:2])
test.testT(res,1)