Application of Dirichlet BCs

Hello FreeFem community,

I started using FreeFEM. I find it very easy to understand and use. I started liking it and considering to integrate it into my research workflow. I am looking for some clarification regarding the application of boundary conditions.

I read in the FreeFEM documentation that Dirichlet boundary conditions are imposed using the penalty method using a very high value (10^30) for the penalty constant.

My experience indicates that such an approach results in ill-conditioned matrices and poses many issues in the modal analysis (eigenvalue problems) and buckling analysis due to the sensitivity of results to the penalty constant.

I am wondering you have any plans for implementing the elimination approach for imposing Dirichlet BCs in FreeFEM in the future.


Hello Chenna,
Please have a look at these slides. You can do unsymmetric elimination (tgv = -1) or symmetric elimination (tgv = -2) for homogenous Dirichlet boundary conditions.

Hello prj,
Thank you! Very much appreciate your prompt response!


when you compute generalize eigen value problem
the problem this find smallest eigen value (not all) of
A u = lambda B u
if you use generalize inverse mode you compute eigen value
of compute eigen value of
A^-1 B u = lambda^-1 u

to remove this problem you just put
tgv trick on A and no boundary condition on B then you get correct results with non problem.

if you add tgv=-2 on both matrix A, B then you get a lot of eigen values 1 form boundary part,
and so you have to remove value.

Form me, the tgv technique is very simple and in fact they do not change the condition number a level of
floating point number.

That is not correct to put tgv = -2 on B, I think. If you put tgv = -20 on B, then you won’t have spurious eigenvalues.
Reminder: tgv = -20 => put the complete row and column to 0 (dangerous, singular symmetric system), tgv = -10 => put the complete row to 0 (dangerous, singular nonsymmetric system).

Also, if you solve block systems iteratively, e.g., [[A, B]; [C, D]], and don’t impose Dirichlet boundary conditions exactly, it’s a nightmare with penalization. If you put tgv = -1 on A and D, and tgv = -10 on B and C, then no problem.

Hello @frederichecht and @prj ,
Thank you very much for your comments!

I must say that this increased my confusion. I will go through the presentation to understand how these different options work.

I think a cleaner implementation in which only the unknown DOFs are solved would be good idea. Having said that, I can understand that you might have your reasons for following the approach you have implemented now.

Don’t worry, if you want to do elimination, just use tgv = -1. The issue raised by Frédéric can be bypassed by some other tgv values, but this is really for power-user.

Just a small remark, Dirichlet unknowns are actual unknowns. If you are referring to an implementation where we’d actually remove the associated rows/columns from the coefficient matrix, then this is usually a bad idea. It requires a lot of bookkeeping (because you need to modify the sparsity pattern of the systems, which is sparse, and operations on sparse matrices are usually slow), for almost zero advantages.