rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
check_consistency.m
1 function res = check_consistency(grid)
2 %function res = check_consistency(grid)
3 % function checking the consistency of a polygonal grid, i.e. checking, whether
4 % the edge centroids correspond (implicit neighbour-index test)
5 %
6 % @todo: perhaps later further extensions
7 %
8 % return values:
9 % res: boolean value which is 'true' if the check succeeds, or 'false' if it
10 % fails.
11 %
12 
13 % Bernard Haasdonk 9.5.2007
14 
15  res = 1;
16 
17 % check neighbour indices corresponding across edges
18 % must satisfy NBI(NBI(i,j), INB(i,j)) = i;
19 % works for general grids, but uses loops...
20 %disp('checking neighbour-edge relations');
21 %disp('and neighbour-edge-centroid consistency:');
22 for i=1:grid.nelements
23  for di=1:grid.nneigh
24  if (grid.NBI(i,di)>0)
25  if grid.NBI(grid.NBI(i,di), grid.INB(i,di))~=i
26  disp('neighbour relations are inconsistent!!');
27  res = 0;
28  end;
29  if (abs(grid.ECX(grid.NBI(i,di), grid.INB(i,di))-grid.ECX(i,di))>eps)
30  disp('edge ECX are inconsistent!!');
31  res = 0;
32  end;
33  if (abs(grid.ECY(grid.NBI(i,di), grid.INB(i,di))-grid.ECY(i,di))>eps)
34  disp('edge ECY are inconsistent!!');
35  res = 0;
36  end;
37  end;
38  end,
39 end;
40