~fluidity-core/fluidity/bug_1183080

« back to all changes in this revision

Viewing changes to femtools/tests/test_length_scale_tensor.F90

  • Committer: Tim Greaves
  • Date: 2013-04-19 11:53:43 UTC
  • mfrom: (3463.2.94 turbulence-clean)
  • Revision ID: tim.greaves@imperial.ac.uk-20130419115343-qq0m21v905aachuy
This merge is a replay of a previous merge which was reviewed in detail by
Christian Jacobs. There have been no changes since this was approved, hence I'm
fast-tracking this through as the concerns that led to the previous uncommit
have been resolved.

This merge brings in general updates from Jonathan Bull to his turbulence codes
and updates the BFS examples and various related tests to reflect this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!    Copyright (C) 2009 Imperial College London and others.
 
2
!    
 
3
!    Please see the AUTHORS file in the main source directory for a full list
 
4
!    of copyright holders.
 
5
!
 
6
!    Prof. C Pain
 
7
!    Applied Modelling and Computation Group
 
8
!    Department of Earth Science and Engineering
 
9
!    Imperial College London
 
10
!
 
11
!    amcgsoftware@imperial.ac.uk
 
12
!    
 
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.
 
17
!
 
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.
 
22
!
 
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
 
26
!    USA
 
27
 
 
28
#include "fdebug.h"
 
29
 
 
30
subroutine test_length_scale_tensor
 
31
 
 
32
   use unittest_tools
 
33
   use read_triangle
 
34
   use fields
 
35
   use smoothing_module
 
36
   use global_parameters, only : pi
 
37
   implicit none
 
38
   
 
39
   type(vector_field) :: positions
 
40
   type(element_type) :: shape
 
41
   real :: edge
 
42
   real, dimension(:,:,:), allocatable :: dshape
 
43
   real, dimension(:), allocatable :: detwei
 
44
   real, dimension(:,:,:), allocatable :: computed_result
 
45
   real, dimension(:,:), allocatable :: expected_result
 
46
   logical :: fail
 
47
   
 
48
   positions = read_triangle_files("data/structured", quad_degree=3)
 
49
   ! Edge length in mesh
 
50
   edge = pi/8.
 
51
 
 
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))
 
57
 
 
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)
 
61
 
 
62
   ! This is only correct for regular right-angled triangles
 
63
   edge = edge**2/4.
 
64
   expected_result = reshape(&
 
65
               (/ edge*5., -edge,&
 
66
               & -edge, edge*5. /),(/2,2/))
 
67
 
 
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.")
 
70
   
 
71
   deallocate(computed_result)
 
72
   deallocate(expected_result)
 
73
   deallocate(detwei)
 
74
   deallocate(dshape)
 
75
 
 
76
end subroutine test_length_scale_tensor
 
77