Actual source code: example1.edp
 1 /*******************************************************
 2  *  This file is part of the FreeFEM tutorial made by  *
 3  *      Pierre Jolivet <pierre@joliv.et>               *
 4  *                                                     *
 5  *  See https://joliv.et/FreeFem-tutorial for more     *
 6  *                                                     *
 7  *   Description: simple two-way domain decomposition  *
 8  *******************************************************/
  
10 include "macro_ddm_seq.idp"
 
12 int[int] l = [2, 2, 2, 2];
13 int interface = 10;
14 mesh T = square(5, 6, label = l, [5.0/6.0 * x, y]);
15 mesh Ttop = trunc(T, x < 0.3, label = 1);
16 Ttop = trunc(Ttop, y > 0.7, label = 10);
17 Ttop = movemesh(Ttop, [1.0/3.0 - x, y]);
18 mesh Tt = trunc(T, !(y > 0.7 || (x > 0.3 && y < 0.3)), label = 2);
19 mesh TtF = Ttop + Tt;
 
21 mesh[int] ThLocal(2);
22 matrix[int] D(2);
23 matrix[int] R(2);
 
25 partition(TtF, 2, ThLocal, 1, D, R, interface, P1);
26 plot(TtF, wait = 1);
27 fespace VhGlobal(TtF, P1);
28 VhGlobal u, v;
29 u = randreal1();
30 plot(u, wait = 1);
31 v = 0;
32 for(int i = 0; i < 2; ++i) {
33     fespace VhLocal(ThLocal[i], P1);
34     VhLocal uLocal;
35     uLocal[] = R[i] * u[];
36     real[int] diag = D[i].diag;
37     uLocal[] .*= diag;
38     v[] += R[i]' * uLocal[];
39     plot(v, wait = 1);
40 }
41 plot(v, wait = 1);
42 v[] -= u[];
43 plot(v, wait = 1);