# Convert Unstructured Mesh to Structured

I have solved a simple problem on Openfoam, which is a 3D rectangular parallelopiped, filled with rectangular hexahedrons as mesh elements. The structured, mapped mesh was made in ICEM and solved in OF. But the mesh and data, are in unstructured format i.e. they are represented with connectivity. I now want to convert the unstructured data to a structured data w/o connectivity i.e. the mesh should be represented with loop like

for(k=0;k<znocells;k++)
for(j=0;j<ynocells;j++)
for(i=0;i<xnocells;i++)
{
//access elements...
}


I have tried to write a code for the same, but have failed. A simple workaround involved involved sorting the array of elements, but that won't work for geometries like bifurcation and stuff. Is there a code available, or a software to import the OF mesh and spit out a structured mesh?

• In general you are going to need a general 3D interpolation algorithm the simplest of which would be a nearest neighbor search. The basic idea would be to represent your previous grid as a point cloud. Python (numpy and scipy) can provide you something to do this. – Kyle Mandli Oct 14 '17 at 2:53