Implementation Crouzeix-Raviart Element


I’m working on the implementation of the Crouzeix-Raviart Element (at the moment the linear case, but I would like to also do that for higher order) with Dirichlet boundary conditions for the Laplacian eigenvalue problem. I followed the tutorial on how to implement new spaces and I was able to obtain something, but I’m having trouble in implementing the boundary conditions. Do you have any advice on how to do that? Or in general any code that could be useful in order to implement Crouzeix-Raviart?

Thank you,


Hi Melanie,

the (lowest-order) Crouzeix-Raviart FESpace is implemented in NGSolve

fes = FESpace(“nonconforming”,mesh, dirichlet=”…”)

if you like to compare with your implementation. In the source code it is in comp/fespace.hpp, comp/fespace.cpp with class name NonconformingFESpace.

Normally the Dirichlet data is handled in the base class FESpace and you only have to specify the Dirichlet flag when calling your FESpace class in Python. What kind of problem appears if you try to use Dirichlet boundary conditions?



since I wasn’t able to adjust my code, I started to use the Crouzeix-Raviart FESpace already implemented. I’m currently working with the eigenvalue solver from the documentation with the nonconforming space (2.2 Programming an eigenvalue solver — NGS-Py 6.2.2102-284-gd0f4626b4 documentation).
By using it I observed that something is not working right, since around the meshisize of h=0.1 the L2-error of the eigenvectors begin to grow again (instead of converging) and also the eigenvalue “explodes” (with h= 0.01 I get an eigenvalue of 132.68, while the exact one is 19.74). I tried to use the eigenvalue solver with the H1 space and with that the eigenvalue converges to the exact one and the L2-error of the eigenvectors converges. So I’m guessing that something is not working right when using the nonconforming space with the eigenvalue solver.

Has anyone noticed something similar to that or has an idea why this happens?