# Lagrange multiplier for Dirichlet boundary condition

**URL:** <https://community.freefem.org/t/lagrange-multiplier-for-dirichlet-boundary-condition/2402>\
**Category:** General Discussion\
**Created:** [April 18, 2023, 7:06am UTC](https://community.freefem.org/t/lagrange-multiplier-for-dirichlet-boundary-condition/2402 "2023-04-18T07:06:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [April 27, 2023, 8:28pm UTC](https://community.freefem.org/t/lagrange-multiplier-for-dirichlet-boundary-condition/2402/7 "2023-04-27T20:28:13Z")

</div>

Dear @cmd @marchywka , thank you both for your previous help and I have made good process about using Lagrange multiplier to implement Dirichlet BC. However, there are problems when I try to parallelise my code.  
It seems **FreeFemm++** and **ff-mpirun -n 1 …** compile code differently. I found the fowllowing three operations are not allowed using **ff-mpirun -n 1…** , while it works well for **FreeFem++**

```auto
1. int[int] labs = [1];
    ThS = extract(ThG, label=labs);
2. matrix UAtemp = ua(Vh,Sh);
3. createMat(ThS, UU, Pk)

```

it seem `createMat(ThS UU, Pk)` does not work for a surface mesh `ThS` ? also it seems the second command is illegal if `Vh` and `Sh` are in two different FE spaces defined on two different meshes?

Can you please help me have a look? the sequential code works well.  
[stokes\_lagrange\_parallel.edp](https://community.freefem.org/uploads/short-url/ee18j945hlDYrjhXqKGptr2IdzA.edp) (2.2 KB)  
[stokes\_lagrange.edp](https://community.freefem.org/uploads/short-url/ywuAA7Tc14AMkfGpFhfcOKDwj4m.edp) (1.5 KB)

---

_[View the full topic](https://community.freefem.org/t/lagrange-multiplier-for-dirichlet-boundary-condition/2402)._
