Demo: The 2-D Laplace equation: P2 Finite Element

In this demo we modify the previous one by replacing the P1 finite element by the P2 one. So we only comment the changes with respect to the previous code.

  • The mesh has to be modified by adding necessary nodes to use P2 interpolation. To do this we use the member function AddMidNodes of class Mesh. This function adds a node to each edge to mesh sides and enables then using 2nd order finite elements. For practical reasons, we save the modified mesh in a dedicated file.

       ms.AddMidNodes();
       ms.put("out.m");

  • The next modification consists in replacing class Laplace2DT3 by class Laplace2DT6 for 6-node (P2) triangles.

       Laplace2DT6 eq(ms,u);

  • Note that we do not store solution in a file, since postprocessing with P2 finite element solution is not yet implemented.