# How to implement an operator at the boundary?

**URL:** <https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862>\
**Category:** General Discussion\
**Created:** [January 2, 2024, 2:06pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862 "2024-01-02T14:06:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![C98](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@C98](https://community.freefem.org/u/C98)\
**Post date:** [January 2, 2024, 2:06pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/1 "2024-01-02T14:06:41Z")

</div>

Hi,

I am considering the heat equation u\_t = \Delta u on a plate [0,1]\times [0,1]. I would like to impose, in FreeFem, the following type of boundary condition

u(x,0) = F\bigg(\int\_{0}^{1}u(x,y)dy \bigg) for x\in (0,1),

where F is a given function (we can suppose for now that F is just the identity map). What is the syntax to implement such a boundary condition?

My intuition is to write something like on(border, u=w), and w= int2d(myMesh, y)(u\_previous), to mean integration with respect to y, and here u\_previous is the u at the previous time step (here, I initialize w as an element object). I don’t get an error when I try this on Freefem, but I’m not sure if it’s giving me the right answer, so I wanted to check here.

Thank you in advance for your answers

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [January 2, 2024, 2:54pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/2 "2024-01-02T14:54:24Z")

</div>

A first idea:

Use a explicite schema to compute u(x,0)) put in 1d mesh  
Be careful to compute the interpolation of \int\_0^1 u(x,y) dy due to  
fixe name x for coordinate in integration and in interpolation  
so I do a function to compute X \mapsto F(\int\_0^1 u(X,x)) dx

the code is  
[boundary-Op.edp](https://community.freefem.org/uploads/short-url/1L9ni33iSzPWabPPhnh0JDdoGl5.edp) (567 Bytes)

---

<div class="post-metadata">

**Author:** ![C98](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@C98](https://community.freefem.org/u/C98)\
**Post date:** [January 5, 2024, 3:30pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/3 "2024-01-05T15:30:10Z")

</div>

Thank you very much for your answer! I think I am starting to understand how it works.

So, let’s say I want to impose the (constant in space) boundary condition

u(x,0) = -\int\_{0}^{1}\int\_{0}^{1} u^2(x,y)\ dxdy

So here, I just need to define a function to integrate over y, and then I use int1d again in the loop, like in this code?

[boundary-Op\_energy.edp](https://community.freefem.org/uploads/short-url/3yHBX8MTe3ZgziUbeGUu8N7kTUW.edp) (639 Bytes)

---

<div class="post-metadata">

**Author:** ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)\
**Post date:** [January 14, 2024, 3:56am UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/4 "2024-01-14T03:56:54Z")

</div>

Dear developer：  
I would like to ask you a question. for layermesh , through :  
mesh3 Th3 = buildlayers(Th, MaxLayer, zbound=[zmin,zmax],labelmid, labelup , labeldown );  
we can get the label of the surface grid. Is there any method to set the label for each internal layer grid?  
for example: MaxLayer=5,Is there any way to obtain the label of the second layer grid？

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [January 14, 2024, 3:21pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/5 "2024-01-14T15:21:45Z")

</div>

Not to day  
Remark why you need this

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [January 14, 2024, 3:41pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/6 "2024-01-14T15:41:06Z")

</div>

to impose u = int u^2 dx hase a bounday condition it is very simple

just add a real

```auto
real intu2 = int2d(Th)(u*u); 
Fu[] = intu2; 

```

in the script

---

<div class="post-metadata">

**Author:** ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)\
**Post date:** [January 14, 2024, 3:44pm UTC](https://community.freefem.org/t/how-to-implement-an-operator-at-the-boundary/2862/7 "2024-01-14T15:44:51Z")

</div>

Thank you for your reply.  
What I want to do is treat each layer mesh as a floating conductor, where the unknowns in this layer are same value, and replace this layer unknowns with one degree of freedom,so i can reduce the computational scale.  
thanks again.
