예제 #1
0
    finally:
        if status != 0:
            sys.exit(status)


#  max size of meshname : med.MED_NAME_SIZE+1
meshname = "2D unstructured mesh"
spacedim = 2
meshdim = 2
#  max size of axisname and unitname : 2*med.MED_SNAME_SIZE+1
#           12345678901234561234567890123456
axisname = "x               y               "
unitname = "cm              cm              "
#  ten nodes with two of them shared by the two polygons
coordinates = med.MEDFLOAT([
    0.5, 0., 1.5, 0., 0., 0.5, 1., 0.5, 2., 0.5, 0., 1., 1., 1., 2., 1., 0.5,
    2., 1.5, 2.
])
nnodes = 10
indexsize = 3
index = med.MEDINT([1, 7, 13])
#  connectivity : 2 hexagons
connectivity = med.MEDINT([1, 4, 7, 9, 6, 3, 2, 5, 8, 10, 7, 4])

#  MED file creation
try:
    fid = med.MEDfileOpen("UsesCase_MEDmesh_13.med", med.MED_ACC_CREAT)
except RuntimeError as ex:
    print("ERROR : file creation ...\n%s" % ex)
    sys.exit(-1)

#  write a comment in the file
예제 #2
0
        status = -1
    finally:
        if status != 0:
            sys.exit(status)


#  max size of meshname : med.MED_NAME_SIZE+1
meshname = "2D unstructured mesh"
spacedim = 2
meshdim = 2
#  max size of axisname and unitname : 2*med.MED_SNAME_SIZE+1
#           12345678901234561234567890123456
axisname = "x               y               "
unitname = "cm              cm              "
coordinates = med.MEDFLOAT([
    2., 1., 7., 1., 12., 1., 17., 1., 22., 1., 2., 6., 7., 6., 12., 6., 17.,
    6., 22., 6., 2., 11., 7., 11., 12., 11., 17., 11., 22., 11.
])
nnodes = 15
triaconnectivity = med.MEDINT([
    1, 7, 6, 2, 7, 1, 3, 7, 2, 8, 7, 3, 13, 7, 8, 12, 7, 13, 11, 7, 12, 6, 7,
    11
])
ntria3 = 8
quadconnectivity = med.MEDINT(
    [3, 4, 9, 8, 4, 5, 10, 9, 15, 14, 9, 10, 13, 8, 9, 14])
nquad4 = 4

#  MED file creation
try:
    fid = med.MEDfileOpen("UsesCase_MEDmesh_1.med", med.MED_ACC_CREAT)
except RuntimeError as ex:
예제 #3
0
		print("ERROR : no mesh info created from MEDmeshInfo")
		doCleanup(fid, -1)
	else :
		meshname,spacedim,meshdim,meshtype,description,dtunit,sortingtype,nstep,axistype,axisname,axisunit=meshinfo

	#  read how many nodes in the mesh
	try :
		nnodes, chgt, trsf = med.MEDmeshnEntity(fid, meshname, med.MED_NO_DT,
							med.MED_NO_IT, med.MED_NODE, med.MED_NO_GEOTYPE,
							med.MED_COORDINATE, med.MED_NO_CMODE)
	except RuntimeError as ex :
		print("ERROR : number of nodes ...\n%s" % ex)
		doCleanup(fid, -1)

	#  read mesh nodes coordinates
	coordinates = med.MEDFLOAT([0.] * nnodes * spacedim)
	try :
		med.MEDmeshNodeCoordinateRd(fid, meshname, med.MED_NO_DT, med.MED_NO_IT,
									med.MED_FULL_INTERLACE, coordinates)
	except RuntimeError as ex :
		print("ERROR : nodes coordinates ...\n%s" % ex)
		doCleanup(fid, -1)

	#  read number of geometrical types for cells
	try:
		ngeo, chgt2, trsf2 = med.MEDmeshnEntity(fid, meshname, med.MED_NO_DT,
							med.MED_NO_IT, med.MED_CELL, med.MED_GEO_ALL,
							med.MED_CONNECTIVITY, med.MED_NODAL)
	except RuntimeError as ex :
		print("ERROR : number of geo types ...\n%s" % ex)
		doCleanup(fid, -1)
예제 #4
0
        print("ERROR : close file ...\n%s" % ex)
        status = -1
    finally:
        if status != 0:
            sys.exit(status)


#  max size of meshname : med.MED_NAME_SIZE+1
meshname = "2D structured mesh"
spacedim = 2
meshdim = 2
#  max size of axisname and unitname : 2*med.MED_SNAME_SIZE+1
#           12345678901234561234567890123456
axisname = "x               y               "
unitname = "cm              cm              "
cooXaxis = med.MEDFLOAT([1., 2., 3., 4., 5.])
cooYaxis = med.MEDFLOAT([1., 2., 3.])
nquad4 = 8
#  max size of cellsname : 8*med.MED_SNAME_SIZE+1
#                         12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456
cellsnames = med.MEDCHAR(
    "CELL_1          CELL_2          CELL_3          CELL_4          CELL_5          CELL_6          CELL_7          CELL_8          "
)
#  max size of familyname : med.MED_NAME_SIZE+1
familyname = "CART_GRID_QUAD_FAMILY"
#  max size of groupname : med.MED_LNAME_SIZE+1
groupname = med.MEDCHAR("CART_GRID_GROUP")
familynumbers = med.MEDINT([-1, -1, -1, -1, -1, -1, -1, -1])

#  MED file creation
try:
예제 #5
0
        status = -1
    finally:
        if status != 0:
            sys.exit(status)


#  max size of meshname : med.MED_NAME_SIZE+1
meshname = "2D unstructured mesh"
spacedim = 2
meshdim = 2
#  max size of axisname and unitname : 2*med.MED_SNAME_SIZE+1
#           12345678901234561234567890123456
axisname = "x               y               "
unitname = "cm              cm              "
initial_coordinates = med.MEDFLOAT([
    2., 1., 7., 1., 12., 1., 17., 1., 22., 1., 2., 6., 7., 6., 12., 6., 17.,
    6., 22., 6., 2., 11., 7., 11., 12., 11., 17., 11., 22., 11.
])
nnodes = 15
triaconnectivity = med.MEDINT([
    1, 7, 6, 2, 7, 1, 3, 7, 2, 8, 7, 3, 13, 7, 8, 12, 7, 13, 11, 7, 12, 6, 7,
    11
])
ntria3 = 8
quadconnectivity = med.MEDINT(
    [3, 4, 9, 8, 4, 5, 10, 9, 15, 14, 9, 10, 13, 8, 9, 14])
nquad4 = 4
#  new coordinates (step 1) for nodes 13, 14 and 15
new_coordinates_step1 = med.MEDFLOAT([12., 15., 17., 15., 22., 15.])
#  max size of profile1name : med.MED_NAME_SIZE+1
profile1name = "UPPER_QUAD4_PROFILE"
profile1 = med.MEDINT([13, 14, 15])
예제 #6
0
#  a real code would check ...

#  read the axis coordinates (MED_CARTESIAN coordinates system)
#  X
axis = 1
try:
    size, chgt, trsf = med.MEDmeshnEntity(fid, meshname, med.MED_NO_DT,
                                          med.MED_NO_IT, med.MED_NODE,
                                          med.MED_NONE,
                                          med.MED_COORDINATE_AXIS1,
                                          med.MED_NO_CMODE)
except RuntimeError as ex:
    print("ERROR : number of coordinates on X axis ...\n%s" % ex)
    doCleanup(fid, -1)
ncell = size - 1
cooXaxis = med.MEDFLOAT([0.] * size)

try:
    med.MEDmeshGridIndexCoordinateRd(fid, meshname, med.MED_NO_DT,
                                     med.MED_NO_IT, axis, cooXaxis)
except RuntimeError as ex:
    print("ERROR : read axis X coordinates ...\n%s" % ex)
    doCleanup(fid, -1)

#  Y
axis = 2
try:
    size2, chgt2, trsf2 = med.MEDmeshnEntity(fid, meshname, med.MED_NO_DT,
                                             med.MED_NO_IT, med.MED_NODE,
                                             med.MED_NONE,
                                             med.MED_COORDINATE_AXIS2,
예제 #7
0
        status = -1
    finally:
        if status != 0:
            sys.exit(status)


#  max size of meshname : med.MED_NAME_SIZE+1
meshname = "2D unstructured mesh"
spacedim = 2
meshdim = 2
#  max size of axisname and unitname : 2*med.MED_SNAME_SIZE+1
#           12345678901234561234567890123456
axisname = "x               y               "
unitname = "cm              cm              "
initial_coordinates = med.MEDFLOAT([
    2., 1., 7., 1., 12., 1., 17., 1., 22., 1., 2., 6., 7., 6., 12., 6., 17.,
    6., 22., 6., 2., 11., 7., 11., 12., 11., 17., 11., 22., 11.
])
nnodes = 15
triaconnectivity = med.MEDINT([
    1, 7, 6, 2, 7, 1, 3, 7, 2, 8, 7, 3, 13, 7, 8, 12, 7, 13, 11, 7, 12, 6, 7,
    11
])
ntria3 = 8
quadconnectivity = med.MEDINT(
    [3, 4, 9, 8, 4, 5, 10, 9, 15, 14, 9, 10, 13, 8, 9, 14])
nquad4 = 4
#  matrix transformation (step 1) : rotation about the Y-axis : 45 degrees
transfMatrix_step1 = med.MEDFLOAT([0.0, 0.0, 0.0, 0.92388, 0.0, 0.38268, 0.0])
#  matrix transformation (step 2) : rotation about the Y-axis : 90 degrees
transfMatrix_step2 = med.MEDFLOAT([0.0, 0.0, 0.0, 0.707, 0.0, 0.707, 0.0])
예제 #8
0
coordinates = med.MEDFLOAT([
    -10.0,
    -10.0,
    +0.0,  # [ 1]
    -10.0,
    -10.0,
    +10.,  # [ 2]
    -10.0,
    +10.0,
    +10.,  # [ 3]
    -10.0,
    +10.0,
    +0.0,  # [ 4]
    +10.0,
    -10.0,
    +0.0,  # [ 5]
    +10.0,
    -10.0,
    +10.,  # [ 6]
    +10.0,
    +10.0,
    +10.,  # [ 7]
    +10.0,
    +10.0,
    +0.0,  # [ 8]
    -10.0,
    +0.0,
    +10.0,  # [ 9]
    -10.0,
    +0.0,
    +0.0,  # [10]
    +0.0,
    -10.0,
    +10.0,  # [11]
    +0.0,
    -10.0,
    +0.0,  # [12]
    +0.0,
    +10.0,
    +10.0,  # [13]
    +10.0,
    +0.0,
    +10.0,  # [14]
    +0.0,
    +10.0,
    +0.0,  # [15]
    +10.0,
    +0.0,
    +0.0  # [16]
])