SCOREC / core

parallel finite element unstructured meshes
Other
183 stars 62 forks source link

Modifying existing mesh to account for alternate boundary position #103

Open KennethEJansen opened 7 years ago

KennethEJansen commented 7 years ago

I have a mesh that was created for CFD assuming a far-field boundary. The mesh was given to me as a ugrid mesh from NASA. I want to try to use the same near-field mesh but would like to replace the far-field mesh with boundary points that lie on the wind tunnel walls instead. I can think of two ways to do this: 1) deform the far-field to the shape of the wind tunnel (probably bad because it is deforming a 500m box to a O(10)m box 2) delete all the elements from the ugrid file that are have a centroid outside of the wind tunnel walls and then move the new boundary points to the nearest actual wind tunnel wall (perhaps combined with some sort of mesh deformation tool so that the movement was absorbed nicely)?

Our current workflow is to load the ugrid mesh into SimModeler to create a discrete model for these cases so, presumably this needs to be done before that step. So in some sense, I guess this is not really a SCOREC/core question other than I know there is a ugrid reader code in the test tool that brings the mesh into mds format. If I started from there, the new question would be, if I found SCOREC/core tools to do the surgery, would I be able to export it back out as a ugrid file or would I need to do that painful process I used to do of using render to create a VTK file, use paraview to load the VTK file, and then save an Ensight (I think that is the one) file that Simmetrix could read and then make a mesh model of.

Advice from the experts on how to proceed?

KennethEJansen commented 7 years ago

Looking over the code a bit, I am thinking of the following (but could use tips on the best functions to do the psuedo-code steps) 1) hijack ugrid.cc to read the mesh and load it into mds 2) set up a series of clip planes to define points that are outside of the wind tunnel walls. 3) loop over all the elements of the mesh, test all vertices for inside and count.
If count=n_elm_vert, skip element as it is in the final mesh else if count=0 delete element and all entities on its closure else the element and some of its entities will need to be deleted. Here is the algorithm to decide what gets deleted. a) element always gets deleted but since we need for queries, I guess we do that last or create a marker for later deletion, b) loop over that element's faces and test each face's verts and count those inside, if count is nface_verts then face and its closure are kept (skip to next face of the element) else if count is 0 then this face and its closure are deleted (or marked for deletion?)
else the face straddles one of the clips so we figure out what gets deleted A) mark the face for deletion B) loop over the element's edges i) if both of its vertices are outside, delete edge, and both vertices ii) if both of its vertices are inside, keep edge and vertices iii) if one in and one out, delete edge and outside vertex. iv) for the cut edges, compute the closest point on the collection of cut planes v) for the first generation of the code, just move that vertex to the closest point vi) for future versions, compute that displacement vector and attach it to vertex for later use with a mesh deformation code as an applied displacement that will distribute this deformation throughout the mesh for better element quality. 4) write out the mesh in vtk format (would prefer to write in something SimModeler could directly read).

KennethEJansen commented 7 years ago

Alternative to step 3) above that might be simpler/faster to code iterate over elements and delete elements that don't have all verts inside of the clips iterate over faces and delete faces that don't have all verts inside of the clips iterate over the edges a) delete all edges that have both verts outside b) delete all edges that have one in and one out and move vertex that is "in" along the edge until it pierces the cut plane (or store the required deformation to do so attached to the vert) c) iterate over the vertices and delete those strictly outside (noting that b just moved points onto plane