How to impose Dirichlet boundary conditions by Lagrange multipliers

Hi, I want to impose Dirichlet boundary conditions by using the Lagrange multiplier method.

The governing equation for heat transfer is \Delta T = 0, where T is the temperature. The boundary conditions are shown in the following picture.

I know how to solve this problem in FreeFEM. However, I try to impose constant temperature on the top and bottom boundaries by using a Lagrange multiplier method, and the weak form is shown below:

\Biggl\{ \begin{array} -\int \nabla T \cdot \nabla w \; \text{d} \Gamma+\int w \mathbf{n} \cdot \nabla T \text{d} \Gamma + \int \lambda w \; \text{d} \Gamma &= 0, \\ \int \hat{\lambda} \left( T - T_c \right) \; \text{d} \Gamma &= 0, \end{array}

where w and \hat{\lambda} is the test function for temperature T and Lagrange multiplier \lambda. Note that here \lambda is a scalar field defined on the top and bottom boundaries.

The FreeFEM provides a Lagrange multiplier example (Poisson equation with a global constraint). In this example, we only need to introduce a scalar to enforce the global constraint, which is different from our case.

Does FreeFEM have a similar case that enforces boundary constraints by introducing a Lagrange multiplier?

Can FreeFEM define a finite element space for the Lagrange multiplier defined on the specific boundary ?

Thanks in advance.

image

Theoretically you can do that with 2 finite element one on Th (the 2 d mesh) and one one 1d mesh of the border, if we miss no operator.

Dear Profeesor,
I checked the whole FreeFEM document and only found 2D and 3D finite space defined on Th. On possible operator for 1d mesh is emptymesh. Could you kindly give me some advice on how to define finite element space on 1d mesh of the border. Thanks in advance.

Best

I think for the 1D at the border, you just do int1d(Th,\Gamma). That should do it.