# Running failure of an additive Schwarz method in two overlapping non-matching grids

**URL:** <https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789>\
**Category:** General Discussion\
**Created:** [May 30, 2022, 6:07am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789 "2022-05-30T06:07:38Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [May 30, 2022, 6:07am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/1 "2022-05-30T06:07:39Z")

</div>

Hi there,  
I wrote an additive Schwarz method code to solve a semi-linear elliptic problem. It seems fine but when I come to run it does not work properly. I guess the failure from the function _uh_ that the code seems does not recognize it or something like that. I am looking for someone to adjust it as soon as possible.  
Here is the algorithm of additive Schwarz method in the context of two overlapping nonmatching subdomains i=1,2.

-Δu\_{i}ⁿ+cu\_{i}ⁿ=f(u\_{i}ⁿ⁻¹) in Ω\_{i}  
u\_{i}ⁿ=uⁿ⁻¹ on γ\_{i}  
u\_{i}ⁿ=0 on Γ\_{i}

where  
uⁿ(x)=maxu\_{i}ⁿ(x), x∈Ω.

The freefem code is as follows

[Additive Schwarz method for semilinear PDEs.edp](https://community.freefem.org/uploads/short-url/uFoF3aEkrQ8VYNJBsFfsjxsL38Q.edp) (2.6 KB)

---

<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:** [June 7, 2022, 3:08pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/2 "2022-06-07T15:08:49Z")

</div>

You code is wrong because uh is a number not a function

```auto
Vh1 uh ; 

```

and set a each iteration uh ,

```auto
the Boundary condition with max(uold1,uold2); 

```

So my solution is

[Additive Schwarz method for semilinear PDEs.edp](https://community.freefem.org/uploads/short-url/5iNmekRLHZafcKd3KegmEKFCoxx.edp) (2.6 KB)

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [June 8, 2022, 11:40am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/3 "2022-06-08T11:40:53Z")

</div>

This finally solves my problem.  
Thanks a lot for your help Dr. Hecht. 👏

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [June 8, 2022, 11:43am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/4 "2022-06-08T11:43:00Z")

</div>

Dr. Hecht  
Could I ask you one more question please?  
What do i have to do to reduce the number of iterations?  
This makes it more reliable.

---

<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:** [June 8, 2022, 12:55pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/5 "2022-06-08T12:55:22Z")

</div>

You get a error because the number of node on central piece in not compatible in angle (not 16)  
and in vertical direction !!!  
And after be careful on vertical surface mesh , the orientation of the split quad face must be se same, ( this is no easy).

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [June 8, 2022, 6:03pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/6 "2022-06-08T18:03:24Z")

</div>

Thank you for your fast reply Dr. Hecht.  
However, I am sorry I did not understand your meaning with the saying ‘’ not compatible in angle (not 16)’’. To your information, the discretization of both subdomains is in the context of overlapping non-matching grids. So it is natural that the number of nodes for both subdomains on the intersection area is not the same. Could you explain that much more please? And since you are well-experienced in this field (consider me as your student), I need your solution if possible.

Also, what is the fault regarding the orientation? According to my understanding of the mesh, I applied the same as what is in your FreeFEM documentation in this regard, unless you meant something else.

Your help is appreciated.

---

<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:** [June 15, 2022, 12:55pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/7 "2022-06-15T12:55:44Z")

</div>

See on the graphic you see the point do not coincide on both mesh.

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [August 10, 2022, 8:10am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/8 "2022-08-10T08:10:58Z")

</div>

Thank you Prof. Hecht for your valuable notes.  
I have one more question if you do not mind. It can be noticed that some elements angles of both subdomains are equal to 90 degrees  
What I want is to build the above meshing in the sense that the angles of all elements are less than 90 degrees. This is so important as it satisfies what we call it " Discrete Maximum Principle".  
Your help is appreciated.

---

<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:** [August 10, 2022, 12:04pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/9 "2022-08-10T12:04:20Z")

</div>

This problem to build a acute mesh is very hard, you can read work of Jean-Marie Mirebeau from Orsay universty in France.

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [August 12, 2022, 1:18pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/10 "2022-08-12T13:18:09Z")

</div>

Great Prof.  
For the sake of time, could you tell me which work of Jean-Marie Mirebeau exactly?

---

<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:** [August 12, 2022, 2:05pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/11 "2022-08-12T14:05:30Z")

</div>

It do this in this tests,  
and in

[  
Adaptive and anisotropic finite element approximation: Theory and algorithms  
 ](https://www.semanticscholar.org/paper/Adaptive-and-anisotropic-finite-element-Theory-and-Mirebeau/3be9b226822f4bb04a6737b3643a6b60f482c345)

- [J. Mirebeau](https://www.semanticscholar.org/author/J.-Mirebeau/3205922)

- Computer Science, Mathematics

- 2010

TLDR

This paper addresses the problem of optimal mesh adaptation, as minimizing the approximation error over all (possibly anisotropic) triangulations of prescribed cardinality, given a norm X of interest and a function f to be approximated.Expand

- [  
10  
 ](https://www.semanticscholar.org/paper/3be9b226822f4bb04a6737b3643a6b60f482c345#citing-papers)

- [  
PDF  
 ](https://www.semanticscholar.org/paper/3be9b226822f4bb04a6737b3643a6b60f482c345)

- View 2 excerpts, cites background

Save

Alert

[  
Greedy bisection generates optimally adapted triangulations  
 ](https://www.semanticscholar.org/paper/Greedy-bisection-generates-optimally-adapted-Mirebeau-Cohen/da189202379d2a60fe6e9ef35fb166221a0415fe)

- [J. Mirebeau](https://www.semanticscholar.org/author/J.-Mirebeau/3205922), [A. Cohen](https://www.semanticscholar.org/author/A.-Cohen/145509578)
- Computer Science, Mathematics

Math. Comput.

- 2012

TLDR

It is proved that as the algorithm progresses, the triangles tend to adopt an optimal aspect ratio which is dictated by the local hessian of f, which means that the adaptive triangulations satisfy a convergence bound which is known to be asymptotically optimal among all possible triangulation.Expand

- [  
23  
 ](https://www.semanticscholar.org/paper/da189202379d2a60fe6e9ef35fb166221a0415fe#citing-papers)

- [  
PDF  
 ](https://www.semanticscholar.org/paper/da189202379d2a60fe6e9ef35fb166221a0415fe)

- View 3 excerpts, cites background

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [August 15, 2022, 5:53pm UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/12 "2022-08-15T17:53:37Z")

</div>

Thank you Prof. Hecht for the two attached theoretical works, which are great to read after my graduation. But I am looking for some numerical examples that solve my numerical work at this limited time if possible. I found a numerical reference in the personal page of the author in the bibliography, but it is not working.  
So, could you guide me with some acute triangulation examples, if possible? That would be a great help for me.

---

<div class="post-metadata">

**Author:** ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)\
**Post date:** [October 7, 2022, 10:20am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/13 "2022-10-07T10:20:10Z")

</div>

Dear Prof. Hecht

According to the code, ‘‘uold1’’ and ‘‘uold2’’ are two vectors. But as you know, we can not compare and take the maximum of two vectors unless all similar components of them are well compared in appropriate way. For example, we can say that uold1 \< uold2 if uold1(i) \< uold2(i) for all i components on the boundary. My question is, Does FreeFem++ automatically compare between all components of the two vectors? If yes, then we are in the safe side. If no, then could you suggest me how to do that please?  
I appreciate your help.

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [October 13, 2022, 10:38am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/14 "2022-10-13T10:38:45Z")

</div>

Dear professor,

I faced a problem. Maybe only you can help me.  
I want to simulate the propagation of elastic wave in a 2D model. By the obtained displacement of a specify point with time (i.e., the waveform), I could judge the correctness of the simulation results. I have successfully obtain the correct results using “solve or problem”. However, the results obtained based on “varf” is obvious wrong. The code in “varf. file” is written according to the examples from your homepage I have tried to debug this code, while the results still is wrong. Therefore, I am asking for your help.  
The two codes with “solve” and “varf” are attached to this post, respectively.  
[Sequential\_2D\_Solve.edp](https://community.freefem.org/uploads/short-url/bMtYfnSqLFffCfMdt6uacdLUrwg.edp) (2.2 KB)  
[Sequential\_2D\_varf.edp](https://community.freefem.org/uploads/short-url/vSFRA1rPwX5dnmlpKnHpxFuvTNc.edp) (2.3 KB)

Please give me some advice.

Best wishes,  
Liu

---

<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:** [October 19, 2022, 9:00am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/15 "2022-10-19T09:00:58Z")

</div>

If I have make no mistake the solution is:  
[Sequential\_2D\_Solve-FH.edp](https://community.freefem.org/uploads/short-url/af1Cp8qNzpecUnhT3bCCfi33XhR.edp) (3.0 KB)

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [October 19, 2022, 9:33am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/16 "2022-10-19T09:33:39Z")

</div>

Dear Professor,

Thank you so much for your considerate help.  
However, The values and trends of the results from the code modified by you are not same with the results from the simple code with only Solve (I uploaded in the last post), which had been confirmed right.  
On the other hand, I want to solve the elastic problem in a 3D model. So, my goal is to use PETSC to solve this elastic problem in parallel mode.Now, I first tried to switch the code with “solve” of the two-dimensional problems into the code of using “varf”. Therefore, “solve” should be not existence, and only use “varf” to solve the problem. Could you give me more advice?  
Best,  
Liu

---

<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:** [October 19, 2022, 9:48am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/17 "2022-10-19T09:48:11Z")

</div>

They is no problem build petsc Mat and do the same !

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [October 19, 2022, 10:05am UTC](https://community.freefem.org/t/running-failure-of-an-additive-schwarz-method-in-two-overlapping-non-matching-grids/1789/18 "2022-10-19T10:05:45Z")

</div>

Ok, I will try according to your help.  
However, the key problem is that the values and trends of the results from the code modified by you are not same with the results from the simple code with only Solve (I uploaded in the last post), which had been confirmed right.  
Do you have any other advice?
