Re: [MeshPy] Quadratic elements using Triangle
by Andreas Kloeckner

Aravind Alwan <aravindalwan(a)gmail.com> writes:
> Hi Andreas,
>
> Thanks for the getting back on this. I had managed to get the desired
> behaviour by patching the code locally with the changes I had
> described. I implemented an ugly hack where I changed the unit of the
> Elements array in wrap_triangle.cpp from 3 to 6 (I only use quadratic
> meshes in my work). Your solution is definitely more elegant.
>
> I tested the changes that you made and it seems to be working fine for
> me. I've included the code I used to test the mesh. Note that the
> plotting portion of the code uses matplotlib's Triangulation package,
> which can handle only linear elements. I don't have a simple example
> that demonstrates the use of quadratic elements. I use quadratic
> meshes in my custom finite element analysis code, which is too big to
> reproduce here.
Thanks for checking and for the demo, I've added your it to the repository:
https://github.com/inducer/meshpy/blob/master/test/test_tri_quadratic.py
Andreas
6 years, 5 months

Re: [MeshPy] Quadratic elements using Triangle
by Andreas Kloeckner

Hi Aravind,
Aravind Alwan <aravindalwan(a)gmail.com> writes:
> I've been trying to use MeshPy to generate triangular meshes with
> quadratic elements (6 nodes per triangle : 3 vertices + 3 at the
> mid-points of the edges). Using the stock Triangle program, this can
> be done by passing the -o2 switch
> (http://www.cs.cmu.edu/~quake/triangle.highorder.html) when the
> program is called. However, when I looked at the options listed in the
> "build" function in triangle.py, "o2" is not among them.
>
> I tried to add this functionality by writing my own "build" function.
> Basically I copied the existing code and added a boolean argument
> called "quadratic_mesh" to the function. I then added the following
> lines in the middle of the function:
>
> if quadratic_mesh:
> opts += "o2"
I've just changed a few things in git. Pass mesh_order=2 to
build(). mesh.elements should now automatically be sized correctly. Let
me know if this works. It would also be great if you could contribute a
small demo of how to use the second-order meshing.
Andreas
6 years, 5 months

Quadratic elements using Triangle
by Aravind Alwan

Hi,
I've been trying to use MeshPy to generate triangular meshes with
quadratic elements (6 nodes per triangle : 3 vertices + 3 at the
mid-points of the edges). Using the stock Triangle program, this can
be done by passing the -o2 switch
(http://www.cs.cmu.edu/~quake/triangle.highorder.html) when the
program is called. However, when I looked at the options listed in the
"build" function in triangle.py, "o2" is not among them.
I tried to add this functionality by writing my own "build" function.
Basically I copied the existing code and added a boolean argument
called "quadratic_mesh" to the function. I then added the following
lines in the middle of the function:
if quadratic_mesh:
opts += "o2"
The modified function works and I'm able to generate a quadratic mesh.
I verified this by plotting the faces and the points to ensure that
additional points were indeed being placed at the mid-points of the
faces. However, when I looked at mesh.elements to get the connectivity
information, it still shows up as an array of 3-tuples, meaning that
each element in the array has only 3 nodes corresponding to the 3
vertices and not 6 nodes as one might expect.
I suspect that this is because the number of columns in the Elements
array (in the tMeshInfo structure defined in wrap_triangle.cpp) is
hard-coded to be 3 (line 45 in wrap_triangle.cpp). Can someone guide
me on how I can extract the complete connectivity information in
addition to the list of points and faces?
Thanks,
Aravind
6 years, 5 months