neperfepx / neper

Polycrystal generation and meshing
http://neper.info
GNU General Public License v3.0
205 stars 53 forks source link

Add element interpolation for tetrahedral elements #372

Open rquey opened 2 years ago

rquey commented 2 years ago

The ability to interpolate nodal values inside (tetrahedral) elements is needed to add some capabilities to Neper, see e.g. #373.

This is already somewhat implemented for triangle (2D) elements (code) and is now needed for tetrahedral (3D) elements. We consider linear interpolation. What we need:

xshang93 commented 2 years ago

I'd like to try and work on this. I might need to do it for my project anyways. Can you point me to where nodal interpolation is done in the script so I can start to look into it?

rquey commented 2 years ago

Interpolation is currently only done for nodal data transport over 2D meshes. This is handled by nem_transport_node, which on this line calls the shape function neut_elt_tri_shapefct.

Here is an example of use:

# Generate a 2D tess
neper -T -n 1 -dim 2

# Mesh the 2D tess and export the y positions of the nodes
neper -M n1-id1.tess -o old -cl 1.0 -statnode y

# Remesh the 2D mesh into a finer mesh and transport the y positions onto this mesh,
# also export the y positions of the nodes
neper -M n1-id1.tess,old.msh -cl 0.2 -loadmesh new.msh -transport node:real1:old.stnode -statnode y

# Check that the data resulting from transport and the actual y positions are the same
diff old.stnode.rem new.stnode > /dev/null
if [ "$?" == 0 ]
then
  echo "success!"
fi

Adding interpolation for tetrahedral elements can be done through a new function, neut_elt_tet_shapefct, similar to neut_elt_tri_shapefct. nem_transport_node can be generalized to accept 3D meshes, and the implementation could be tested using a similar example of use.

It may not be easy to write a simple neut_elt_tet_shapefct function and may be preferable to include more FEM-related code, which would be very fine.