~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to misc/utils/matlab/meshindex.m

  • Committer: Johannes Ring
  • Date: 2008-03-05 22:43:06 UTC
  • Revision ID: johannr@simula.no-20080305224306-2npsdyhfdpl2esji
The BIG commit!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function index = meshindex(p, t)
 
2
 
 
3
% MESHINDEX - COMPUTE APPROXIMATE MULTI-ADAPTIVE EFFICIENCY INDEX FOR MESH
 
4
%
 
5
% Usage: index = meshindex(p, t)
 
6
%
 
7
%   p - points    (exported from PDE Toolbox)
 
8
%   t - triangles (exported from PDE Toolbox)
 
9
%       
 
10
% Copyright (C) 2005 Anders Logg.
 
11
% Licensed under the GNU LGPL Version 2.1.
 
12
 
 
13
hmin = 1.0;
 
14
hlist = hmin*ones(size(p, 2), 1);
 
15
 
 
16
for triangle = t
 
17
 
 
18
  i0 = triangle(1);
 
19
  i1 = triangle(2);
 
20
  i2 = triangle(3);
 
21
 
 
22
  p0 = p(:, i0);
 
23
  p1 = p(:, i1);
 
24
  p2 = p(:, i2);
 
25
 
 
26
  h0 = norm(p1 - p0);
 
27
  h1 = norm(p2 - p1);
 
28
  h2 = norm(p0 - p2);
 
29
 
 
30
  h = min([h0, h1, h2]);
 
31
 
 
32
  hlist(i0) = min(hlist(i0), h);
 
33
  hlist(i1) = min(hlist(i1), h);
 
34
  hlist(i2) = min(hlist(i2), h);
 
35
 
 
36
  hmin = min(h, hmin);
 
37
 
 
38
end
 
39
 
 
40
index = (length(hlist) / hmin) / sum(1.0 ./ hlist);