Calculating the maximum and minimum values of the difference between two consecutive iterations

Hi community
My problem is to find the extreme values of the difference between two consecutive iterations u^{n+1}_{ih_i} and u^{n}_{ih_i} of a Schwarz algorithm. For a certain purpose, this is done by excluding the values of internal border segments 1 and 4 on both subdomains, respectively. I am facing a problem on how to define the border segments and how to subtract the solution vectors on the internal border nodes from the solution vectors on the remaining subdomains regions. Could I have any help on that?
Thanks a lot.

Linear Schwarz alternating method_semilinear elliptic problem_monotone convergence analysis.edp (6.0 KB)

If you your finite element V_h if Lagrange type then the value of dot is a value of your unknown a dog point point.

Vh u, up; // $u^{n+1}$, $u^{n}$  
... computation .of u and up 
real[int] diff= u[]-up[]; 
diff= abs(diff); 
int idof = maxi(diff); //  get index of Max value 


Thank you, dear Hecht, for your fast reply.
However, it is not exactly what I need. I found the maximum values of the difference between two consecutive iterations of a Schwarz algorithm through the process

diff1 = abs(uh1-uold1);
norm1=diff1.max;
diff2 = abs(uh2-uold2);
norm2=diff2.max;

What I need is the following, according to my code:

  1. How to exclude the nodes values vectors uh11 and uh22 of internal border segment no.2 of the first subdomain and internal border segment no.4 of the second subdomain from all the two solution values vectors uh1 and uh2?
    ,then
  2. How to subtract the solution vectors on the internal border nodes from the solution vectors on the remaining sub-domains regions?
    ,and lastly
  3. Find the maximum and minimum values (maxdif1, mindif1, maxdif2, mindif2) of the difference between two consecutive iterations on both subdomains.
    I hope it is clear now and you correct me with my code.
    Thanks

SO you have just to remove of internal node

varf  vBC(u,v) = on(1,u=1); // the boundary where you have Boundary condition
real[int] bc=vBC(0,Vh,tgv=1);; // build a vector with 0 internal and 1 on BC node 

 diff1 = abs(uh1-uold1);
norm1=diff1.max;
diff2 = abs(uh2-uold2)
diff2 .*= bc;;// remove internal node !!!
norm2=diff2.max;

Thank you again for your appreciated and helpful answer, Dr. Hecht.
I successfully printed out the differences vectors: diff1=abs(uh1-uold1) and diff2=abs(uh2-uold2) on the internal boundary conditions as follows:

int j;
varf vBC1(uh1, vh1) = on(2, uh1 = 2.); // variational formulation to set the solution values at label no. 2
real[int] bc1vec = vBC1(0,Vh1,tgv=1); // build a vector with 0 internal and 1 on boundary condition nodes at label no. 2
for(j=0; j< bc1vec.n; j++) {
real xv1= Th1(j).x , yv1= Th1(j).y;
if(abs(bc1vec[j]-2)<1e-10)
cout << " At "<< j << " : " << xv1 << " , " << yv1 << " , " << diff1[j] << endl;
diff11=diff1[j];
};
varf vDA2(uh2, vh2) = on(4, uh2 = 4.); // variational formulation to set the solution values at label no. 4
real[int] da2vec = vDA2(0,Vh2,tgv=1); // build a vector with 0 internal and 1 on boundary condition nodes at label no. 4
for(int j=0; j< da2vec.n; j++) {
real xv2= Th2(j).x , yv2= Th2(j).y;
if(abs(da2vec[j]-4)<1e-10)
cout << " At "<< j << " : " << xv2 << " , " << yv2 << " , " << diff2[j] << endl;
diff22=diff2[j];
};

Now, I only need to get diff1 and diff2 on all internal and remaining boundary nodes of both subdomains as one more step. My failure attempt to do that is as follows:

dif1.=diff1-diff11;
dif2.
=diff2-diff22;

I think the failure reason is attributed to mismatched dimensions. Can you kindly help me to do this mission, please?
With thanks.

Remark diff22 os not defined so I am lose, soory

I finally succeeded in achieving my goal. Here is my final attempt to get the minimum difference values on both subdomains.

// This procces is to find min. difference values on both subdomains.
int j;
int NbVertices1=Th1.nv;
for (int j = 0; j < NbVertices1; j++){
int L1 = Th1(j).label;
real xv1= Th1(j).x , yv1= Th1(j).y;
if (L1 == 2){
diff1[j];
//cout << " At j= "<< j << " : " << xv1 << " , " << yv1 << " , " << diff1[j] << endl;
}
else if (L1 != 2){
diff1[j]=0;
//cout << " At j= "<< j << " : " << xv1 << " , " << yv1 << " , " << diff1[j] << endl;
}

diff11=diff1[j];
//cout << " At node no."<< j << ": the difference is " << diff11 << endl;
};

int NbVertices2=Th2.nv;
for (int j = 0; j < NbVertices2; j++){
int L2 = Th2(j).label;
real xv2= Th2(j).x , yv2= Th2(j).y;
if (L2 == 4) {
diff2[j];
//cout << " At j= "<< j << " : " << xv2 << " , " << yv2 << " , " << diff2[j] << endl;
}
else if (L2 != 4){
diff2[j]=0;
//cout << " At j= “<< j << " : " << xv2 << " , " << yv2 << " , " << diff2[j] << endl;
}
diff22=diff2[j];
//cout << " At node no.”<< j << ": the difference is " << diff22 << endl;
};

for (int j = 0; j < NbVertices1; j++){
dif1[j]=diff1[j]-diff11[j];
//cout << " At node j = "<< j << " on 1st subdomain, the difference is " << dif1[j] << endl;
//maxdif1 = dif1.max;
if (dif1[j] != 0){
//cout << " For min.value, At node j = "<< j << " on 1st subdomain, the difference is " << dif1[j] << endl;
mininorm1 = dif1[j];
mindif1 = mininorm1.min;
}
};
for (int j = 0; j < NbVertices2; j++){
dif2[j]=diff2[j]-diff22[j];
//cout << " At node j = "<< j << " on 2nd subdomain, the difference is " << dif2[j] << endl;
//maxdif2 = dif2.max;
if (dif2[j] != 0){
//cout << " For min.value, At node j = "<< j << " on 1st subdomain, the difference is " << dif1[j] << endl;
mininorm2 = dif2[j];
mindif2 = mininorm2.min;
}
};

I am glad to hear from you if any comments or another method to achieve the goal.
Thank you.