1
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – Kyle Mandli Oct 14 '17 at 2:53
1
$\begingroup$

I think you can do it in a fairly straightforward way, as I do in PETSc. You find all the faces between cells, which gives you the mesh topology. To find the faces, you loop over cells and each of the 6 faces uses the hash for the 4 vertices (i,j,k,l) in sorted order. Then you just read out the hash table at the end. My code is here

https://bitbucket.org/petsc/petsc/src/c99b676fdc4d0978b5621d138ceee2e1b7869aa6/src/dm/impls/plex/plexinterpolate.c?at=master&fileviewer=file-view-default#plexinterpolate.c-137

Its a little longer because I first count everything so I can statically allocate the structure to hold it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.