[Hedge] hedge mesh
Andreas Kloeckner
lists at informa.tiker.net
Sun Dec 12 22:05:57 PST 2010
Hi Islam,
On Thu, 09 Dec 2010 10:45:06 +0100, "Islam El Salawi" <islamelsalawi at gmx.de> wrote:
> 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()
>
> [snip]
>
> #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.
Right--you need to generate a list of
hedge.mesh.element.Triangle/Tetrahedron instances for 'elements'. For
the case of a Cartesian structured mesh, you'd need to split each
quadrilateral in two.
HTH,
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/hedge/attachments/20101213/c915773f/attachment.pgp>
More information about the Hedge
mailing list