Exemple #1
0
def test():
    T1 = CGL.newCGNSTree()
    b1 = CGL.newCGNSBase(T1, 'B1', 3, 3)
    b2 = CGL.newCGNSBase(T1, 'B2', 3, 3)
    f1 = CGL.newFamily(b1, 'F1')
    f2 = CGL.newFamily(b1, 'F2')
    f1 = CGL.newFamily(b2, 'F1')
    f2 = CGL.newFamily(b2, 'F2')
    f3 = CGL.newFamily(b2, 'F3')
    f4 = CGL.newFamily(b2, 'F4')
    z1 = CGL.newZone(b1, 'Z1', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z2 = CGL.newZone(b1, 'Z2', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z3 = CGL.newZone(b1, 'Z3', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z4 = CGL.newZone(b1, 'Z4', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z5 = CGL.newZone(b1, 'Z5', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z1 = CGL.newZone(b2, 'Z1', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z2 = CGL.newZone(b2, 'Z2', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z3 = CGL.newZone(b2, 'Z3', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))

    T2 = CGL.newCGNSTree()
    b1 = CGL.newCGNSBase(T2, 'B1', 3, 3)
    b2 = CGL.newCGNSBase(T2, 'B2', 3, 3)
    b3 = CGL.newCGNSBase(T2, 'B3', 2, 2)
    f1 = CGL.newFamily(b1, 'F1')
    f1 = CGL.newFamily(b2, 'F1')
    f2 = CGL.newFamily(b2, 'F2')
    f3 = CGL.newFamily(b2, 'F3')
    f4 = CGL.newFamily(b2, 'F4')
    f5 = CGL.newFamily(b2, 'F5')
    f1 = CGL.newFamily(b3, 'F1')
    f2 = CGL.newFamily(b3, 'F2')
    z1 = CGL.newZone(b1, 'Z1', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z2 = CGL.newZone(b1, 'Z2', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z3 = CGL.newZone(b1, 'Z3', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z1 = CGL.newZone(b2, 'Z1', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z2 = CGL.newZone(b2, 'Z2', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z3 = CGL.newZone(b2, 'Z3', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    z4 = CGL.newZone(b2, 'Z4', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))

    T3 = CGL.newCGNSTree()
    b1 = CGL.newCGNSBase(T3, 'B1', 3, 3)
    b2 = CGL.newCGNSBase(T3, 'B7', 3, 3)
    b3 = CGL.newCGNSBase(T3, 'B8', 2, 2)
    f1 = CGL.newFamily(b1, 'F1')
    f1 = CGL.newFamily(b2, 'F8')

    Tlist = []
    for TT in [T1, T2, T3]: Tlist.append(TT)

    count = 0
    for t in Tlist:
        CGM.save('merge-T%.2d.hdf' % count, t, flags=CGM.S2P_TRACE)
        count += 1
    T = mergeTrees(Tlist)
    CGM.save('merge-Result.hdf', T, flags=CGM.S2P_TRACE)
    return T
Exemple #2
0
def makeCorrectTree(vertexsize, cellsize, ntris):
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, 'Base', 3, 3)
    s = NPY.array([[vertexsize, cellsize, 0]], dtype='int32', order='F')
    z = CGL.newZone(b, 'Zone', s, CGK.Unstructured_s)
    g = CGL.newGridCoordinates(z, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    tetras = CGL.newElements(z, 'TETRAS', CGK.TETRA_4_s,
                             NPY.ones((cellsize * 4), dtype='int32'),
                             NPY.array([[1, cellsize]], 'i', order='F'))
    tris = CGL.newElements(
        z, 'TRIS', CGK.TRI_3_s, NPY.ones((ntris * 3), dtype='int32'),
        NPY.array([[cellsize + 1, cellsize + ntris]], 'i', order='F'))
    zbc = CGL.newZoneBC(z)
    n = CGL.newBoundary(zbc,
                        'BC', [range(cellsize + 1, cellsize + ntris + 1)],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointList_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    return (T, b, z, zbc, n, g)
Exemple #3
0
def makeCorrectTree():
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, 'Base', 3, 3)
    z1 = CGL.newZone(b, 'Zone1',
                     NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    g = CGL.newGridCoordinates(z1, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s,
                         NPY.ones((5, 7, 9), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s,
                         NPY.ones((5, 7, 9), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s,
                         NPY.ones((5, 7, 9), dtype='float64', order='F'))
    s = NPY.array([[vertexsize, cellsize, 0]], dtype='int32', order='F')
    z2 = CGL.newZone(b, 'Zone2', s, CGK.Unstructured_s)
    g = CGL.newGridCoordinates(z2, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    tetras = CGL.newElements(z2, 'TETRAS', CGK.TETRA_4_s,
                             NPY.ones((cellsize * 4), dtype='int32'),
                             NPY.array([[1, cellsize]], 'i', order='F'))
    tris = CGL.newElements(
        z2, 'TRIS', CGK.TRI_3_s, NPY.ones((ntris * 3), dtype='int32'),
        NPY.array([[cellsize + 1, cellsize + ntris]], 'i', order='F'))
    z3 = CGU.copyNode(z1, 'Zone3')
    b[2].append(z3)
    z4 = CGU.copyNode(z2, 'Zone4')
    b[2].append(z4)
    z = [z1, z2, z3, z4]
    return (T, b, z)
Exemple #4
0
def genTrees():
    tree = CGL.newCGNSTree()
    b = CGL.newBase(tree, '{Base}', 2, 3)
    z = CGL.newZone(b, '{Zone}', numpy.array([[5, 4, 0], [7, 6, 0]], order='F'))
    g = CGL.newGridCoordinates(z, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s, numpy.ones((5, 7), dtype='d', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s, numpy.ones((5, 7), dtype='d', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s, numpy.ones((5, 7), dtype='d', order='F'))
    return (tree,)
Exemple #5
0
def makeStTree(vertexsize, cellsize):
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, '{Base}', 3, 3)
    z = CGL.newZone(b, '{Zone}', NPY.array(
        [[vertexsize[0], cellsize[0], 0], [vertexsize[1], cellsize[1], 0], [vertexsize[2], cellsize[2], 0]], order='F'))
    g = CGL.newGridCoordinates(z, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s, NPY.ones(tuple(vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s, NPY.ones(tuple(vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s, NPY.ones(tuple(vertexsize), dtype='float64', order='F'))
    return (T, b, z)
Exemple #6
0
 def edit(self):
     self._T('edit new')
     tree = CGL.newCGNSTree()
     tc = self.newtreecount
     self.busyCursor()
     fgprint = Q7FingerPrint(self, '.', 'new#%.3d.hdf' % tc, tree, [], [])
     child = self.loadQ7Tree(fgprint)
     fgprint._status = [Q7FingerPrint.STATUS_MODIFIED]
     self.readyCursor()
     self.newtreecount += 1
     child.show()
Exemple #7
0
def makeUnstTree(vertexsize, cellsize):
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, 'Base', 3, 3)
    s = NPY.array([[vertexsize, cellsize, 0]], dtype='int32', order='F')
    z = CGL.newZone(b, 'Zone', s, CGK.Unstructured_s)
    g = CGL.newGridCoordinates(z, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s, NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s, NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s, NPY.ones((vertexsize), dtype='float64', order='F'))
    tetras = CGL.newElements(z, 'TETRAS', CGK.TETRA_4_s, NPY.ones((cellsize * 4), dtype='int32'),
                             NPY.array([[1, cellsize]], 'i', order='F'))
    return (T, b, z)
Exemple #8
0
def makeCorrectTree(vertexsize, cellsize):
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, 'Base', 3, 3)
    s = NPY.array([[vertexsize, cellsize, 0]], dtype='int32', order='F')
    z = CGL.newZone(b, 'Zone', s, CGK.Unstructured_s)
    g = CGL.newGridCoordinates(z, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s,
                         NPY.ones((vertexsize), dtype='float64', order='F'))
    return (T, b, z)
Exemple #9
0
def makeCorrectTree():
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, 'Base', 3, 3)
    z1 = CGL.newZone(b, 'Zone1', NPY.array([[5, 4, 0], [7, 6, 0], [5, 4, 0]], order='F'))
    g = CGL.newGridCoordinates(z1, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s, NPY.ones((5, 7, 5), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s, NPY.ones((5, 7, 5), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s, NPY.ones((5, 7, 5), dtype='float64', order='F'))
    s = NPY.array([[vertexsize, cellsize, 0]], dtype='int32', order='F')
    z2 = CGU.copyNode(z1, 'Zone2')
    b[2].append(z2)
    z = [z1, z2]
    return (T, b, z)
Exemple #10
0
 def mergeAB(self):
     idx_a = int(self.cTreeA.currentText())
     idx_b = int(self.cTreeB.currentText())
     fpa = self._fgprint.getFingerPrint(idx_a)
     fpb = self._fgprint.getFingerPrint(idx_b)
     pfx_a = self.ePrefixA.text()
     pfx_b = self.ePrefixB.text()
     tree = CGL.newCGNSTree()
     tc = fpa.control.newtreecount
     fpc = Q7FingerPrint(fpa.control, '.', 'new#%.3d.hdf' % tc, tree, [], [])
     Q7TreeMergeModel(fpc)
     self.merge = Q7Tree(fpa.control, '/', fpc)
     fpc._status = [Q7FingerPrint.STATUS_MODIFIED]
     fpa.control.newtreecount += 1
     diag = {}
     diffAB(fpa.tree, fpb.tree, '', 'A', diag, False)
     fpc.tree = mergeAB(fpa.tree, fpb.tree, fpc.tree, 'C', diag, pfx_a, pfx_b)
     fpc.model.modelReset()
     dw = Q7Merge(self._control, fpc, diag)
     dw.show()
     self.merge.hide()
Exemple #11
0
#  -------------------------------------------------------------------------
#  pyCGNS - Python package for CFD General Notation System -
#  See license.txt file in the root directory of this Python module source
#  -------------------------------------------------------------------------
#
import CGNS.PAT.cgnslib as CGL
import CGNS.PAT.cgnsutils as CGU
import CGNS.PAT.cgnskeywords as CGK
import numpy as NPY

TESTS = []

#  -------------------------------------------------------------------------
tag = 'flow equation set'
diag = True
T = CGL.newCGNSTree()
b = CGL.newBase(T, '{Base#001}', 3, 3)
f = CGL.newFlowEquationSet(b)
TESTS.append((tag, T, diag))

#  -------------------------------------------------------------------------
tag = 'governing equations'
diag = True
T = CGL.newCGNSTree()
b = CGL.newBase(T, '{Base#001}', 3, 3)
f = CGL.newFlowEquationSet(b)
g = CGL.newGoverningEquations(f)
TESTS.append((tag, T, diag))

#  -------------------------------------------------------------------------
tag = 'diffusion model'
Exemple #12
0
def makeStTree():
    T = CGL.newCGNSTree()
    b = CGL.newBase(T, '{Base}', 3, 3)
    z1 = CGL.newZone(b, '{Zone1}',
                     NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F'))
    g = CGL.newGridCoordinates(z1, 'GridCoordinates')
    d = CGL.newDataArray(g, CGK.CoordinateX_s,
                         NPY.ones((5, 7, 9), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateY_s,
                         NPY.ones((5, 7, 9), dtype='float64', order='F'))
    d = CGL.newDataArray(g, CGK.CoordinateZ_s,
                         NPY.ones((5, 7, 9), dtype='float64', order='F'))
    z2 = CGU.copyNode(z1, '{Zone2}')
    b[2].append(z2)
    zgc = CGL.newZoneGridConnectivity(z1)
    gc = CGL.newGridConnectivity1to1(zgc, 'join1_2', '{Zone2}',
                                     NPY.array([[1, 1], [1, 4], [1, 9]]),
                                     NPY.array([[5, 5], [3, 7], [1, 9]]),
                                     NPY.array([-1, +2, +3]))
    zgc = CGL.newZoneGridConnectivity(z2)
    gc = CGL.newGridConnectivity1to1(zgc, 'join2_1', '{Zone1}',
                                     NPY.array([[5, 5], [3, 7], [1, 9]]),
                                     NPY.array([[1, 1], [1, 4], [1, 9]]),
                                     NPY.array([-1, +2, +3]))
    zbc = CGL.newZoneBC(z1)
    n = CGL.newBoundary(zbc,
                        '{BC1_1}', [[5, 5], [1, 7], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC1_2}', [[1, 5], [1, 1], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC1_3}', [[1, 5], [7, 7], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC1_4}', [[1, 5], [1, 7], [1, 1]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC1_5}', [[1, 5], [1, 7], [9, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC1_6}', [[1, 1], [4, 7], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    zbc = CGL.newZoneBC(z2)
    n = CGL.newBoundary(zbc,
                        '{BC2_1}', [[1, 1], [1, 7], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC2_2}', [[1, 5], [1, 1], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC2_3}', [[1, 5], [7, 7], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC2_4}', [[1, 5], [1, 7], [1, 1]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC2_5}', [[1, 5], [1, 7], [9, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    n = CGL.newBoundary(zbc,
                        '{BC2_6}', [[5, 5], [1, 3], [1, 9]],
                        btype=CGK.Null_s,
                        family=None,
                        pttype=CGK.PointRange_s)
    g = CGL.newGridLocation(n, value=CGK.FaceCenter_s)
    z = [z1, z2]
    return (T, b, z)