# On the boundary condition resembling Robin boundary condition

**URL:** https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145
**Category:** General Discussion
**Created:** [November 27, 2022, 2:23pm UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145 "2022-11-27T14:23:53Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [November 27, 2022, 2:23pm UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/1 "2022-11-27T14:23:53Z")

</div>

I am trying to solve a problem resembling

\Delta \mathbf{u} = 0, \;\;\Delta c = 0, with the boundary condition \mathbf{u} = \nabla c and \mathbf{n} \cdot \nabla c =0,

where \mathbf{n} is the normal vector of the boundary. The vector \mathbf{u} has two components u and v.

I want to solve \mathbf{u} and c in a coupling way.

This boundary condition is analogous to the classical Robin boundary condition. I know how to implement the Robin boundary condition in FreeFEM++, but I have no idea how to implement this boundary condition.

I would appreciate it greatly if anyone can give me some suggestions or hints.

---

<div class="post-metadata">

### Author: ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)
#### Post date: [November 28, 2022, 10:47am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/2 "2022-11-28T10:47:10Z")

</div>

Since your problem is vectorial, you should write the Robin boundary condition in a vector-matrix form. As it is now, it is incomplete (as far as I understand, of course). Can you write another equation for \mathbf{n} \cdot \nabla u depending on (u,v)?

---

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [November 28, 2022, 1:48pm UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/3 "2022-11-28T13:48:32Z")

</div>

Hi Prof. Vincent Laude,

Thanks for your kind reply. You are right, the minimum problem I raised before is incomplete. I just update the question (see the above-updated question). What really confuses me is the boundary condition \mathbf{u} = \nabla c. Thank you in advance.

Best,

Guangpu

---

<div class="post-metadata">

### Author: ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)
#### Post date: [December 8, 2022, 9:57am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/4 "2022-12-08T09:57:36Z")

</div>

Sorry for the late reply,  
Actually your variable is the vector (u,c) and the boundary term involves both \textbf{n} \cdot \nabla u and \textbf{n} \cdot \nabla c. Right now you are not specifying anything about \textbf{n} \cdot \nabla u.  
The boundary condition \nabla c = \textbf{u} doesn’t make much sense in this context. Are you sure of it?

---

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [December 9, 2022, 5:28am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/5 "2022-12-09T05:28:06Z")

</div>

Sorry, the minimum problem I simplified is incomplete, so I will give the original problem:

I want to perform a linear stability analysis. The following is the linearized perturbation equation. I try to use the shift-invert method to find eigenvalues.

I learned several example codes solving eigenvalues and found that we can only construct the matrix \mathbf{A} (\mathbf{A}u=\lambda\mathbf{B}u) in a coupling way.

So, when I implemented this problem in FreeFEM++, the boundary condition marked in blue stopped me.

I would greatly appreciate it if you could give me some suggestions on how to deal with this boundary condition. Can the FreeFEM++ solves eigenvalues in a decoupled way?

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/622e83fff2e8188318c6d8542314e1776380a629.png)

---

<div class="post-metadata">

### Author: ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)
#### Post date: [December 9, 2022, 9:03am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/6 "2022-12-09T09:03:33Z")

</div>

You should try to write down a weak form and precise a few things: 2D or 3D problem (though I guess 2D)? What is p in line 1 (it looks like the Stokes problem)? Divergence of \mathbf{u} is zero: how do you enforce that property, by a particular type of finite element?  
Your equation in blue, if correct, suggests \mathbf{u} is tangential on C1.

---

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [December 10, 2022, 11:18am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/7 "2022-12-10T11:18:24Z")

</div>

Hi Prof. Vincent Laude,

This is 2D eigenvalue problem.

We write down the weak form of the linearized governing equation (As you said, the first equation is the classical Stokes equation) and try to implement them in FreeFEM. But I fail to obtain eigenvalues because **I do not know how to implement the coupling equation marked in blue**.

Do you have any suggestions for the implementation of this tangential boundary condition?

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/5/5168284eed8dac44c3d7cd90c3555cd73be6999d.png)

---

<div class="post-metadata">

### Author: ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)
#### Post date: [December 10, 2022, 1:49pm UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/8 "2022-12-10T13:49:47Z")

</div>

We should try to write a small FreeFem++ script from your equations. For that:  
You have variables (p,\mathbf{u},c). What finite elements did you choose? Do you add a stabilization term? (see [FreeFEM - Stokes](https://modules.freefem.org/modules/stokes/)) It also seems a boundary term is missing in the first equation.  
The boundary conditions are incomplete: no equation for p and the two equations for C1 are self-contradicting (or we can simplify the blue one on the boundary).  
Finally: what is the eigenvalue in these equations?

---

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [December 13, 2022, 8:27am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/9 "2022-12-13T08:27:41Z")

</div>

Hi Prof. Vincent Laude,

(1) \sigma in the above equation is the eigenvalue value, c = c\_b + \hat{c}e^{\sigma t} .

(2) I choose P2 and P1 for (\mathbf{u}, c) and p, repectively. Due to the absence of reference pressure, I add a stabilization term just as you suggested.

(3) The velocity boundary condition on C1 can be further simplified as \hat{\mathbf{u}} |\_{C1} = \nabla c, using the concentration boundary condition \mathbf{n}\cdot\nabla c = 0.

(4) I try to implement the velocity boundary condition in FreeFEM++

> varf bstd( [u, v, p, c], [uu, vv, pp, cc] ) = on(1, u=dx(c), v=dy(c)) + on(2, u=0, v=0);

It doesn’t work since c is also variable.

Professor, do you have any ideas or suggestions on implementing this boundary condition?

---

<div class="post-metadata">

### Author: ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)
#### Post date: [December 13, 2022, 9:36am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/10 "2022-12-13T09:36:38Z")

</div>

As I wrote before, the first line of your variational formulation misses a boundary term: \int\_{\partial \Omega} (\frac{\partial \mathbf{u}}{\partial \mathbf{n}} - p \mathbf{n}) \cdot \mathbf{v}.  
The boundary condition for \mathbf{u} cannot be simply replaced in this boundary term, it seems.  
You must specify a boundary condition for pressure p as well.  
The eigenvalue equation you obtain has a rather singular right-hand-side (matrix B would have non-zero elements only for the dofs corresponding to concentration c).  
My suggestion would be to try an iterative solution where you solve in sequence the Stokes problem (with the velocity BC working because now the concentration is fixed at every iteration step) then the concentration equation (with fixed velocity at every step). But I don’t know if it would converge or not.

---

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [December 14, 2022, 4:04am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/11 "2022-12-14T04:04:17Z")

</div>

Hi Prof. Vincent Laude,

(1) We drop \int \left ( \frac{\partial \bar{\mathbf{u}}}{\partial \mathbf{n}} -\bar{ p}\mathbf{n} \right) since \mathbf{v} = 0 on a Dirchlet boundary condition for \bar{\mathbf{u}}.

(2) Do you know any FreeFEM example that solves the eigenvalue iteratively?

Thank you.

---

<div class="post-metadata">

### Author: ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)
#### Post date: [December 14, 2022, 8:16am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/12 "2022-12-14T08:16:07Z")

</div>

(1) Then you cannot at the same time impose \mathbf{u}=0 and the BC in blue, can you?  
(2) No, I don’t no a specific example in FreeFem++. As a remark, the power iteration method ([Power iteration - Wikipedia](https://en.wikipedia.org/wiki/Power_iteration)) or the Rayleigh quotient iteration ([Rayleigh quotient iteration - Wikipedia](https://en.wikipedia.org/wiki/Rayleigh_quotient_iteration)) are classical examples.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [December 14, 2022, 8:23am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/13 "2022-12-14T08:23:28Z")

</div>

Do not implement any of these methods. They are all available out of the box in SLEPc, look at [FreeFem-sources/examples/hpddm at master · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/tree/master/examples/hpddm#eigenvalue-problems).

---

<div class="post-metadata">

### Author: ![zhugp123](https://avatars.discourse-cdn.com/v4/letter/z/71e660/32.png) [@zhugp123](https://community.freefem.org/u/zhugp123)
#### Post date: [December 14, 2022, 11:08am UTC](https://community.freefem.org/t/on-the-boundary-condition-resembling-robin-boundary-condition/2145/14 "2022-12-14T11:08:18Z")

</div>

Thanks for you kind suggestions
