1 | function length=GetCharacteristicLength(index,x,y,varargin)
|
---|
2 | %GETCHARACTERISTICLENGTH - compute characteristic length for a mesh
|
---|
3 | %
|
---|
4 | % compute characteristic lengths of every element of a mesh.
|
---|
5 | %
|
---|
6 | % Usage:
|
---|
7 | % length =GetCharacteristicLength(index,x,y);
|
---|
8 | % length =GetCharacteristicLength(index,x,y,z);
|
---|
9 | %
|
---|
10 | % Examples:
|
---|
11 | % length =GetCharacteristicLength(md.mesh.elements,md.x,md.y);
|
---|
12 | % length =GetCharacteristicLength(md.mesh.elements,md.x,md.y,md.z);
|
---|
13 |
|
---|
14 |
|
---|
15 | %get number of elements and number of nodes
|
---|
16 | nels=size(index,1);
|
---|
17 | nods=numel(x);
|
---|
18 |
|
---|
19 | %some checks
|
---|
20 | if nargout~=1 | (nargin~=3 & nargin~=4),
|
---|
21 | help GetCharacteristicLength
|
---|
22 | error('GetCharacteristicLength error message: bad usage')
|
---|
23 | end
|
---|
24 | if ((numel(y)~=nods) | (nargin==4 & numel(z)~=nods)),
|
---|
25 | error('GetCharacteristicLength error message: x,y and z do not have the same length')
|
---|
26 | end
|
---|
27 | if max(index(:))>nods,
|
---|
28 | error(['GetCharacteristicLength error message: index should not have values above ' num2str(nods) ])
|
---|
29 | end
|
---|
30 | if (nargin==3 & size(index,2)~=3),
|
---|
31 | error('GetCharacteristicLength error message: index should have 3 columns for 2d meshes.')
|
---|
32 | end
|
---|
33 | if (nargin==4 & size(index,2)~=6),
|
---|
34 | error('GetCharacteristicLength error message: index should have 6 columns for 3d meshes.')
|
---|
35 | end
|
---|
36 |
|
---|
37 | %get areas or volumes.
|
---|
38 | areas=GetAreas(index,x,y,varargin{:});
|
---|
39 |
|
---|
40 | %for a 2d mesh:
|
---|
41 | if nargin==3,
|
---|
42 | length=sqrt(2*areas);
|
---|
43 | else
|
---|
44 | error('not supported yet');
|
---|
45 | end
|
---|