[Hedge] hedge mesh
Islam El Salawi
islamelsalawi at gmx.de
Thu Dec 9 01:45:06 PST 2010
Hallo there,
I could figure out the last problem on my own. But now, I have another question.
I created a structured dummy 3d mesh of a cube with ICEM and converted the cgns file to ascii vtk. After that I wrote a short python script to read in the vtk data to hedge.
import numpy
def convertvtk2hedge(filename):
f=open(filename,'r')
vtkfile=f.readlines()
f.close()
splitfile=[]
mesh=[]
StartMeshData=False
StartPointData=False
CellTypeData=False
#find data for coordinates and mesh
for n,i in enumerate(vtkfile):
splitfile=vtkfile[n].split()
if splitfile[0]=='POINTS':
StartPointData=n
if splitfile[0]=='CELLS':
StartMeshData=n
if splitfile[0]=='CELL_TYPES':
CellTypeData=n
if StartMeshData:
StartMeshData
else:
StartMeshData=len(vtkfile)
if CellTypeData:
CellTypeData
else:
CellTypeData=len(vtkfile)
print 'CellTypeData',CellTypeData
print 'StartMeshData', StartMeshData
#add mesh data to list
#first add point coordinates
assistlist=[]
class mesh:
points=[]
elements=[]
for i in range(StartMeshData-StartPointData-1):
line=vtkfile[StartPointData+1+i].split()
assistlist.append(numpy.array([float(line[0]),float(line[1]),float(line[2])]))
mesh.points=numpy.array(assistlist,dtype=numpy.float64)
##add cell data
for i in range(CellTypeData-StartMeshData-1):
line=vtkfile[i+StartMeshData+1].split()
mesh.elements.append([line[1],line[2],line[3],line[4]])
return mesh
Then I use this function to convert the cube mesh:
mesh=convertvtk2hedge(filename='domain.00001.vtk')
Now I wanted to assign the correct type to the mesh by setting:
grid=make_conformal_mesh(mesh.points, mesh.elements)
I'm not sure if that's the right way, because actually the dummy mesh is a structured one but make_conformal_mesh delivers triangles or tetrahedrons.
Regards
Islam
-------- Original-Nachricht --------
> Datum: Wed, 08 Dec 2010 14:27:58 +0100
> Von: "Islam El Salawi" <islamelsalawi at gmx.de>
> An: hedge at tiker.net, lists at informa.tiker.net
> Betreff: [Hedge] hedge mesh
> Hi there,
>
> first I want to thank you for your help. What is a mesh for hedge supposed
> to look like? I assumed that it is a list and the list objects look like:
>
> Mesh_points:
> 0[1,2,3]
> 1[5,6,10]
> ...
>
> and so on, just like the example in the meshpy documentation homepage. Is
> this correct?
>
> Regards
> Islam
>
> --
> GRATIS! Movie-FLAT mit über 300 Videos.
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
>
> _______________________________________________
> Hedge mailing list
> Hedge at tiker.net
> http://lists.tiker.net/listinfo/hedge
--
Ihr GMX Postfach immer dabei: die kostenlose GMX Mail App für Android.
Komfortabel, sicher und schnell: www.gmx.de/android
-------------- next part --------------
A non-text attachment was scrubbed...
Name: domain.00001.vtk
Type: application/octet-stream
Size: 273216 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/hedge/attachments/20101209/0527ffe6/attachment-0001.obj>
More information about the Hedge
mailing list