# How to control on a specific part of domain

**URL:** <https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372>\
**Category:** General Discussion\
**Created:** [December 7, 2021, 6:10pm UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372 "2021-12-07T18:10:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)\
**Post date:** [December 7, 2021, 6:10pm UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372/1 "2021-12-07T18:10:16Z")

</div>

Dear All

How can we update a solution on a part of a domain?

For example: in an edge (right vertical) of a unit square, how could we take control.

---

<div class="post-metadata">

**Author:** ![Pitagoras1](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@Pitagoras1](https://community.freefem.org/u/Pitagoras1)\
**Post date:** [December 8, 2021, 10:07am UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372/2 "2021-12-08T10:07:01Z")

</div>

Hello,

1. Have you tried using the **chi** function in the desired restriction?

**Another possibility:**

Or create the domain restriction at the desired range. Below I send an example. Hope to help.

Yours sincerely,

Pitágoras.

[DOMAIN.edp](https://community.freefem.org/uploads/short-url/hrV7NlRyFwbjMWgWHL5lgRNpSQV.edp) (1.5 KB)

//=======================================================  
load “medit”  
//=======================================================  
// NUMERICAL VALUES  
//=======================================================  
int NInt=0, NSigma=99, NBase=98, NSigma1=97; // labels  
int N1=10; // Points in border

//=============== DOMAIN DATES ================  
real x0=0., xF=1., x1=xF, a=(x0+xF)/4., b= xF-a;  
real T=1.;

//=======================================================  
// THE DOMAIN  
//=======================================================  
border C1(s=x0, a){x=s; y=0.; label=NBase;}  
border C3p(s=a, b){x=s; y=0.; label=NBase;}  
border C3(s=b, x1){x=s; y=0.; label=NBase;}  
border C4(s=0., T){x=x1; y=s; label=NSigma;}  
border C5(s=x1, b){x=s; y=T; label=NSigma;}  
border C5p(s=b, a){x=s; y=T; label=NSigma;}  
border C7(s=a,0.){x=s; y=T; label=NSigma;}  
border C8(s=T,0.){x=x0; y=s; label=NSigma;}

//=================PLOT DOMAIN=========================  
plot ( C1(2_N1) + C3p(4_N1) + C3(2_N1)  
+ C4(8_N1)  
+ C5(2_N1) + C5p(4_N1) + C7(2_N1)  
+ C8(8_N1),  
wait=true);

//=================PLOT MESH========================  
mesh Th=buildmesh( C1(2_N1) + C3p(4_N1) + C3(2_N1)  
+ C4(8_N1)  
+ C5(2_N1) + C5p(4_N1) + C7(2_N1)  
+ C8(8_N1));  
plot(Th, wait=true, cmm=“MESH”);

//===========THE RESTRICTION==========

real one=1.;  
func restri=one\*(x\>=a)\*(x\<=b);

---

<div class="post-metadata">

**Author:** ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)\
**Post date:** [December 8, 2021, 10:50am UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372/3 "2021-12-08T10:50:01Z")

</div>

Dear @Pitagoras1 Sir,  
Thanks for your prompt response with the code.

actually, my problem was a sub-part of an interface boundary problem.

I am trying to solve the Poissons equation on two subdomains having a single interface boundary.

u1\_xx + u1\_yy = x on domain1 with u1 = 0 on Ddomain1  
u2\_xx + u2\_yy = x on domain2 with u1 = 0 on Ddomain2

on interface: u1 = u2 and u1\_n = u2\_n

while solving it I am trying to update a solution of the variable at the interface in each iteration (Like in [Schwarz scheme](https://doc.freefem.org/models/domain-decomposition.html#schwarz-non-overlapping-scheme) )

It would be helpful for me if any freefem sample code including an interface boundary is available.

---

<div class="post-metadata">

**Author:** ![Pitagoras1](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@Pitagoras1](https://community.freefem.org/u/Pitagoras1)\
**Post date:** [December 10, 2021, 8:53am UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372/4 "2021-12-10T08:53:34Z")

</div>

Dear @sumantkr ,

I’m not sure I understand your question correctly:

But if you have a domain-wide acting problem, but you need to constrain the action to one part of the domain, you can parameterize the region in two parts:

This is, \Omega = \Omega1 \ cup \Omega2.

Therefore, you can generate two characteristic functions:

chi (x1, y1) for \Omega1  
and  
chi (x2, y2) for \Omega2.

The chi (x, y) function generates the characteristic function of the parameterized region, taking only two internal points to it.

or, construct the mesh Th (for the 2D case)

mesh Th1= \Omega1 ;  
mesh Th2= \Omega2 ;  
mesh Th=Th1+Th2;

// and insert the chi functions:

func chi1= chi(Th1);  
func chi2= chi(Th2);

To consider u1 in Th1 (restrict only in Th1), consider  
u1_chi1. The same for u2 in Th2 (u2_chi2).

Hence the importance of parameterizing \Omega as \Omega1 \ cup \Omega2.

If I didn’t answer your question, can you rephrase it?

Best regards,

Pitágoras Carvalho.

---

<div class="post-metadata">

**Author:** ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)\
**Post date:** [December 10, 2021, 1:07pm UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372/5 "2021-12-10T13:07:05Z")

</div>

Thanks @Pitagoras1 Sir,

I think we are on the same path but here I have followed the generalized Schwarz non-overlapping algorithm for solving the interface boundary problem.

I have attached the iterative scheme and code script for the pseudo steps.

However, I am getting a good results agreement but It would help me if you can validate my steps.

Poissons equation defined as:

![eqn](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/5984045d119145642aa310a13b0fc07bc69f1ae5.png)

![intfbc](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/c457d746dddd5c4b974bde32fd5bcd2a107bb62a.png)

Solution steps for Schwarz algorithm for interface BCS is:

initialize u2 = 0,

![steps](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/a74de34bf749b51e5c87c4bfabff52a9e01e6a89.png)

Freefem code:  
[rsirpoisson.edp](https://community.freefem.org/uploads/short-url/aRbprFwBDZICGInz2yMWbMyyADc.edp) (1.9 KB)

Results obtained for above code is:

 ![schwarz1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/505a5f65ef9bce9b103a0a719c32d222a02f6ae1.png)

The only thing I am confused about is that whether I am going in the right direction while implementing the FREEFEM code here or not.

Waiting for your response Sir!!!

---

<div class="post-metadata">

**Author:** ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)\
**Post date:** [December 19, 2021, 1:03pm UTC](https://community.freefem.org/t/how-to-control-on-a-specific-part-of-domain/1372/6 "2021-12-19T13:03:07Z")

</div>

I have got this point for accessing the specific part of a domain. Apart from this, I am no clue for

a) How to make a finite element space for an intersecting side ( interface edge) of two domains.

Kindly, comment on it.

Thanks, @Pitagoras1
