1
! Copyright (C) 2009 Imperial College London and others.
3
! Please see the AUTHORS file in the main source directory for a full list
4
! of copyright holders.
7
! Applied Modelling and Computation Group
8
! Department of Earth Science and Engineering
9
! Imperial College London
11
! amcgsoftware@imperial.ac.uk
13
! This library is free software; you can redistribute it and/or
14
! modify it under the terms of the GNU Lesser General Public
15
! License as published by the Free Software Foundation,
16
! version 2.1 of the License.
18
! This library is distributed in the hope that it will be useful,
19
! but WITHOUT ANY WARRANTY; without even the implied warranty of
20
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
! Lesser General Public License for more details.
23
! You should have received a copy of the GNU Lesser General Public
24
! License along with this library; if not, write to the Free Software
25
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30
subroutine test_length_scale_tensor
36
use global_parameters, only : pi
39
type(vector_field) :: positions
40
type(element_type) :: shape
42
real, dimension(:,:,:), allocatable :: dshape
43
real, dimension(:), allocatable :: detwei
44
real, dimension(:,:,:), allocatable :: computed_result
45
real, dimension(:,:), allocatable :: expected_result
48
positions = read_triangle_files("data/structured", quad_degree=3)
52
shape = ele_shape(positions,1)
53
allocate(computed_result(positions%dim, positions%dim, ele_ngi(positions, 1)))
54
allocate(expected_result(positions%dim, positions%dim))
55
allocate(detwei(ele_ngi(positions, 1)))
56
allocate(dshape(ele_loc(positions, 1), ele_ngi(positions, 1), positions%dim))
58
call transform_to_physical(positions, 1, shape, dshape=dshape, detwei=detwei)
59
! We'll just choose the first element here - each of them should have the same area
60
computed_result = length_scale_tensor(dshape, shape)
62
! This is only correct for regular right-angled triangles
64
expected_result = reshape(&
66
& -edge, edge*5. /),(/2,2/))
68
fail = .not.fequals(computed_result(:,:,1), expected_result, 1.0e-9)
69
call report_test("[length_scale_tensor]", fail, .false., "Result from length_scale_tensor is incorrect.")
71
deallocate(computed_result)
72
deallocate(expected_result)
76
end subroutine test_length_scale_tensor