1237
1243
if iformat == "abaqus":
1238
1244
handler.close()
1246
def starcd2xml(ifilename, ofilename):
1247
"Convert from Star-CD tetrahedral grid format to DOLFIN XML."
1249
print starcd2xml.__doc__
1251
if not path.isfile(ifilename[:-3] + "vrt") or not path.isfile(ifilename[:-3] + "cel"):
1252
print "StarCD format requires one .vrt file and one .cel file"
1257
ofile = open(ofilename, "w")
1259
# Open file, the vertices are in a .vrt file
1260
ifile = open(ifilename[:-3] + "vrt", "r")
1262
write_header_mesh(ofile, "tetrahedron", 3)
1265
# Read & write vertices
1267
# first, read all lines (need to sweep to times through the file)
1268
lines = ifile.readlines()
1270
# second, find the number of vertices
1273
nodenr = int(line[0:15])
1274
if nodenr > num_vertices: num_vertices = nodenr
1277
# third, run over all vertices
1278
write_header_vertices(ofile, num_vertices)
1280
nodenr = int(line[0:15])
1281
vertex0 = float(line[15:31])
1282
vertex1 = float(line[31:47])
1283
vertex2 = float(line[47:63])
1284
write_vertex(ofile, int(nodenr)-1, float(vertex0), float(vertex1), float(vertex2))
1285
write_footer_vertices(ofile)
1290
# Open file, the cells are in a .cel file
1291
ifile = open(ifilename[:-3] + "cel", "r")
1293
# Read & write cells
1295
# first, read all lines (need to sweep to times through the file)
1296
lines = ifile.readlines()
1298
# second, find the number of cells
1302
l = [int(a) for a in line.split()]
1303
cellnr, node0, node1, node2, node3, node4, node5, node6, node7, tmp1, tmp2 = l
1305
if node2 == node3 and node4 == node5 and node5 == node6 and node6 == node7: # these nodes should be equal
1308
print "The file does contain cells that are not tetraheders. The cell number is ", cellnr, " the line read was ", line
1310
print "The file does contain cells that are not tetraheders node4==0. The cell number is ", cellnr, " the line read was ", line
1315
# third, run over all cells
1316
write_header_cells(ofile, num_cells )
1319
l = [int(a) for a in line.split()]
1320
cellnr, node0, node1, node2, node3, node4, node5, node6, node7, tmp1, tmp2 = l
1322
if node2 == node3 and node4 == node5 and node5 == node6 and node6 == node7: # these nodes should be equal
1324
write_cell_tetrahedron(ofile, counter, node0-1, node1-1, node2-1, node4-1)
1328
write_footer_cells(ofile)
1329
write_footer_mesh(ofile)