1 function res = check_consistency(grid)
2 %
function res = check_consistency(grid)
4 %
function checking the consistency of a
cubegrid, i.e. checking, whether
5 % - all elements have axis parallel edges
6 % - the volume of the
leaf-elements corresponds to the level-0 elements
9 % res: This is 1
if OK, 0
if error
11 % @note The check is slow, as all edges
for all elements are determined in
14 % perhaps later further extensions
16 % Bernard Haasdonk 27.3.2007
18 %
for all elements check that all edges are axis-parallel
22 for gid = 1:grid.nelements;
23 [p0,p1] = get_edges(grid,gid);
25 % only one entry may relevantly differ from zero
26 nonzeros = sum(abs(diff)>1e-10);
27 if (min(nonzeros)<1) || (max(nonzeros)>1)
28 disp(
'edge not axis parallel, please check!');
33 % check the volume of the
leaf-elements corresponds to the level-0 elements
35 macrogids = find(grid.level==0);
36 leafgids = get_leafgids(grid);
38 macrovol = get_volume(grid,macrogids);
39 leafvol = get_volume(grid,leafgids);
41 ratio = abs(sum(macrovol)-sum(leafvol))/sum(macrovol);
43 disp(
'volume ratio of leaf and macrogrid differing, please check!');
A hierarchical cubegrid of arbitrary dimension.