# How to apply an integrated constrain condition in FEM?

I'm running some simulation using FEM. In my model I need to apply a constraint condition to the governing equation. My governing equation similar to the diffusion equation as below:

$$\frac{\partial c}{\partial t}=\nabla(D\nabla c)\quad\text{on}\quad\Omega$$

and the flux is defined as follow:

$$-D\nabla c\cdot n=J$$

And the constraint condition is an integral. For short, I need to constrain the total flux alone the specific surface equals to a constant, which means:

$$\int_{\partial\Omega_{1}}(-D\nabla c\cdot n)d\Gamma=\text{Constant}$$ where $$\partial\Omega_{1}$$ is part of my domain's surface, not the total surface.

I can write out the weak form for the governing equation(based on N-R method) as follow: $$R_{c}^{I}=\int_{\Omega}\dot{c}N^{I}d\Omega+\int_{\Omega}D\nabla c\nabla N^{I}d\Omega-\int_{\partial\Omega}D\nabla c\cdot n N^{I}d\Gamma$$ and the related stiffness matrix: $$K_{c\dot{c}}^{IJ}=-\frac{\partial R_{c}^{I}}{\partial\dot{c}^{J}}=-\int_{\Omega}N^{J}N^{I}d\Omega$$ $$K_{cc}^{IJ}=-\frac{\partial R_{c}^{I}}{\partial c^{J}}=-\int_{\Omega}D\nabla N^{J}\nabla N^{I}d\Omega+\int_{\partial\Omega_{1}}D\nabla N\cdot n N^{I}d\Omega$$

How can I apply $$\int_{\partial\Omega_{1}}(-D\nabla c\cdot n)d\Gamma=\text{Constant}$$ to my FEM system?

Someone told me that Lagrange multiplier can solve this problem, but I still don't know how to do it. I'm a newbie of FEM, so any details are helpful for me.

• Jan 4 '18 at 20:19
• @BiswajitBanerjee: Hi Biswajit, thank you so much for the reply. I see the webpage you give me. Just one question, if I want to constraint all the node's grad(c)*n=Constant, then the formula list on that page is ok, but what I want is the total (or the integrated ) flux equals to a constant. So will the formula still correct to use? Sorry for my poor FEM knowledge. Jan 5 '18 at 8:34
• Think of the integral as a sum over nodal quantities (you can use some sort of quadrature to compute that sum), e.g. $\sum_n J_i - C = 0$. Then the minimization problem will have the extra regularization term $\lambda (\sum_n J_i - C)$ instead of terms for each node, e.g., $\lambda_i (J_i - C)$ . You can then use the standard process. Jan 5 '18 at 21:43
• Similar questions have been asked before, see e.g. this question.
– knl
Jan 6 '18 at 9:42
• I wrote a simple Python example for you, see it here. Lines 19 and 24 are about augmenting the system with a Lagrange multiplier.
– knl
Jan 6 '18 at 10:36