Exemplo n.º 1
0
    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)


vertexsize = 20
cellsize = 7
(T, b, z) = makeUnstTree(vertexsize, cellsize)
sol1 = CGL.newFlowSolution(z, name='sol1', gridlocation=CGK.Vertex_s)
CGL.newDataArray(sol1,
                 'var',
                 value=NPY.ones(vertexsize, dtype='float64', order='F'))
sol2 = CGL.newFlowSolution(z, name='sol2', gridlocation=CGK.CellCenter_s)
CGL.newDataArray(sol2,
                 'var',
                 value=NPY.ones(cellsize, dtype='float64', order='F'))
TESTS.append((tag, T, diag))

#  -------------------------------------------------------------------------
tag = 'flowsolution bad dataarray dim'
diag = False
(T, b, z) = makeUnstTree(vertexsize, cellsize)
sol1 = CGL.newFlowSolution(z, name='sol1', gridlocation=CGK.Vertex_s)
CGL.newDataArray(sol1,
Exemplo n.º 2
0
#  ---------------------------------------------------------------------------
#  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.newFlowSolution(None)
C.newDataArray(data, '{DataArray}')
C.newRind(data, N.array([0, 0, 0, 0, 1, 1]))
C.newGridLocation(data)
C.newDataClass(data)
C.newDimensionalUnits(data)
C.newUserDefinedData(data, '{UserDefinedData}')
C.newDescriptor(data, '{Descriptor}')
#
status = '7.7'
comment = 'Full SIDS with all optionals'
pattern = [data, status, comment]
#
Exemplo n.º 3
0
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,
                     '{DataArray}',
                     value=NPY.ones((4, 6, 8), dtype='float64', order='F'))
d = CGL.newDataClass(a, CGK.NondimensionalParameter_s)
n = CGL.newZoneBC(z)
d = CGL.newDataClass(n, CGK.NondimensionalParameter_s)
q = CGL.newBC(n, '{BC}', family='{Family}')
d = CGL.newDataClass(q, CGK.NondimensionalParameter_s)
s = CGL.newBCDataSet(q, '{Set#01}')
d = CGL.newDataClass(s, CGK.NondimensionalParameter_s)
c = CGL.newBCData(s, CGK.Dirichlet_s)
d = CGL.newDataClass(c, CGK.NondimensionalParameter_s)
r = CGL.newReferenceState(b)
d = CGL.newDataClass(r, CGK.NondimensionalParameter_s)
Exemplo n.º 4
0
#  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.newZone(None, '{Zone}',
                 N.array([[5, 4, 0], [7, 7, 0], [9, 8, 0]], order='F'))

g1 = C.newGridCoordinates(data, "GridCoordinates")
C.newRigidGridMotion(data, "{RigidGridMotion}")
C.newArbitraryGridMotion(data, "{ArbitraryGridMotion}")
C.newFlowSolution(data, "{FlowSolution}")
C.newDiscreteData(data, "{DiscreteData}")
C.newIntegralData(data, "{IntegralData}")
C.newZoneGridConnectivity(data, "{GridConnectivity}")
C.newBoundary(data, "{BC}", N.array([[0, 0, 0], [0, 0, 0]]))
C.newZoneIterativeData(data, "{ZoneIterativeData}")
C.newReferenceState(data)
C.newRotatingCoordinates(data)
C.newDataClass(data)
C.newDimensionalUnits(data)
C.newFlowEquationSet(data)
C.newConvergenceHistory(data, K.ZoneConvergenceHistory_s)
C.newUserDefinedData(data, '{UserDefinedData}')
C.newDescriptor(data, '{Descriptor}')
C.newOrdinal(data)
Exemplo n.º 5
0
p_arr = var_mat[:,8]

# For now, skip the elem connectivity section. Because I do not need it.

##############################
# Write to CGNS file
##############################
import CGNS.PAT.cgnsutils as CGU
import CGNS.PAT.cgnslib as CGL
import CGNS.PAT.cgnskeywords as CK
import CGNS.MAP as CGM

T=CGL.newCGNSTree()
B=CGL.newBase(T,'hpMusic_base',2,2)
# The shape (3,1) is critical
zone_size = np.array([[n_node, n_elem, 0]])
Z=CGL.newZone(B,'Solution',zone_size,CK.Unstructured_s,'')
GC=CGL.newGridCoordinates(Z,name='GridCoordinates')
FS=CGL.newFlowSolution(Z,name='FlowSolution',gridlocation='Vertex')
GL=CGU.getNodeByPath(FS,'GridLocation')
CGU.nodeDelete(FS,GL)

coordinatex_node = CGL.newDataArray(GC,'CoordinateX',value=x_arr)
coordinatey_node = CGL.newDataArray(GC,'CoordinateY',value=y_arr)
density_node = CGL.newDataArray(FS,'Density',value=rho_arr)
velocityx_node = CGL.newDataArray(FS,'VelocityX',value=u_arr)
velocityy_node = CGL.newDataArray(FS,'VelocityY',value=v_arr)
p_node = CGL.newDataArray(FS,'Pressure',value=p_arr)

CGM.save("sol_tec.cgns",T)