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
# pyCGNS - Python package for CFD General Notation System - # See license.txt file in the root directory of this Python module source # ------------------------------------------------------------------------- # from __future__ import unicode_literals import CGNS.PAT.cgnslib as CGL import CGNS.PAT.cgnsutils as CGU import CGNS.PAT.cgnskeywords as CGK import numpy as NPY TESTS = [] # ------------------------------------------------------------------------- tag = 'base level family #1' diag = True T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base#001}', 3, 3) CGL.newFamily(b, '{Family#001}') TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'family elsewhere than base' diag = False T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base#001}', 3, 3) u = CGL.newUserDefinedData(b, '{UD#001}') CGL.newFamily(u, '{Family#001}') TESTS.append((tag, T, diag)) # -------------------------------------------------------------------------
TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bad struct #2' diag = False T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base#1}', 3, 3) b[2] = {} TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bad name #1' diag = False T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base}', 3, 3) d = CGL.newFamily(b, '{Family#1}') d[0] = None TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bad name #2' diag = False T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base}', 3, 3) d = CGL.newFamily(b, '{Family#1}') d = CGL.newFamily(b, '{Family#2}') d[0] = '{Family#1}' TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bad name #3'
# ------------------------------------------------------------------------- tag = 'base dataclass #3' diag = False T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base}', 3, 3) d = CGL.newDataClass(b, CGK.NormalizedByDimensional_s) d[1] = CGU.setStringAsArray("NormalizedByDimensionnal") TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'all levels dataclass' diag = True T = CGL.newCGNSTree() b = CGL.newBase(T, '{Base}', 3, 3) d = CGL.newFamily(b, '{Family}') d = CGL.newDataClass(b, CGK.NondimensionalParameter_s) z = CGL.newZone(b, '{Zone}', NPY.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F')) d = CGL.newDataClass(z, CGK.NondimensionalParameter_s) g = CGL.newGridCoordinates(z, CGK.GridCoordinates_s) w = CGL.newDataArray(g, CGK.CoordinateX_s, NPY.ones((5, 7, 9), dtype='float64', order='F')) w = CGL.newDataArray(g, CGK.CoordinateY_s, NPY.ones((5, 7, 9), dtype='float64', order='F')) w = CGL.newDataArray(g, CGK.CoordinateZ_s, NPY.ones((5, 7, 9), dtype='float64', order='F')) d = CGL.newDataClass(g, CGK.NondimensionalParameter_s) f = CGL.newFlowSolution(z) d = CGL.newDataClass(f, CGK.NondimensionalParameter_s) a = CGL.newDataArray(f,
# 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 C import CGNS.PAT.cgnserrors as E import CGNS.PAT.cgnskeywords as K import numpy as N data = C.newBase(None, '{Base}', 3, 3) C.newZone(data, '{Zone}', N.array([[5, 4, 0], [7, 6, 0], [9, 8, 0]], order='F')) C.newSimulationType(data) C.newIntegralData(data, '{IntegralData}') C.newBaseIterativeData(data, '{BaseIterativeData}') C.newConvergenceHistory(data) C.newFamily(data, '{Family}') C.newFlowEquationSet(data) C.newReferenceState(data) C.newAxisymmetry(data) C.newRotatingCoordinates(data) C.newGravity(data) C.newDataClass(data) C.newDimensionalUnits(data) C.newUserDefinedData(data, '{UserDefinedData}') C.newDescriptor(data, '{Descriptor}') status = '6.2' comment = 'Full SIDS with all optionals children' pattern = [data, status, comment]
# --------------------------------------------------------------------------- # pyCGNS - Python package for CFD General Notation System - # See license.txt file in the root directory of this Python module source # --------------------------------------------------------------------------- # from __future__ import unicode_literals import CGNS.PAT.cgnslib as C import CGNS.PAT.cgnserrors as E import CGNS.PAT.cgnskeywords as K import numpy as N # data = C.newFamily(None, '{Family}') C.newGeometryReference(data, '{GeometryReference}') C.newRotatingCoordinates(data) C.newUserDefinedData(data, '{UserDefinedData}') C.newDescriptor(data, '{Descriptor}') C.newOrdinal(data) # status = '12.6' comment = 'Full SIDS with all optionals' pattern = [data, status, comment] #