~airpollution/fluidity/fluidity_airpollution

« back to all changes in this revision

Viewing changes to femtools/tests/test_pe_number_1d.F90

  • Committer: ziyouzhj
  • Date: 2013-12-09 16:51:29 UTC
  • Revision ID: ziyouzhj@gmail.com-20131209165129-ucoetc3u0atyy05c
airpolution

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!    Copyright (C) 2006 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; either
 
16
!    version 2.1 of the License, or (at your option) any later version.
 
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_pe_number_1d
 
31
 
 
32
  use diagnostic_fields
 
33
  use fields
 
34
  use fldebug
 
35
  use spud
 
36
  use state_module
 
37
  use unittest_tools
 
38
  use field_options
 
39
 
 
40
  implicit none
 
41
 
 
42
  integer :: stat
 
43
  type(element_type) :: shape
 
44
  type(quadrature_type) :: quad
 
45
  type(mesh_type) :: coordinate_mesh, velocity_mesh
 
46
  type(scalar_field) :: pe_no, phi
 
47
  type(state_type) :: state
 
48
  type(tensor_field) :: diffusivity
 
49
  type(vector_field) :: positions, velocity
 
50
    
 
51
  quad = make_quadrature(vertices = 2, dim  = 1, degree = 2)
 
52
  shape = make_element_shape(vertices = 2, dim  = 1, degree = 1, quad = quad)
 
53
  call deallocate(quad)
 
54
  
 
55
  call allocate(coordinate_mesh, nodes = 4, elements = 3, shape = shape, name = "CoordinateMesh")
 
56
  call deallocate(shape)
 
57
  
 
58
  call set_ele_nodes(coordinate_mesh, 1, (/1, 2/))
 
59
  call set_ele_nodes(coordinate_mesh, 2, (/2, 3/))
 
60
  call set_ele_nodes(coordinate_mesh, 3, (/3, 4/))
 
61
  
 
62
  velocity_mesh = piecewise_constant_mesh(coordinate_mesh, name = "PeNumberMesh")
 
63
  
 
64
  call allocate(positions, 1, coordinate_mesh, name = "Coordinate")
 
65
  call allocate(velocity, 1, velocity_mesh, name = "Velocity")
 
66
  call allocate(diffusivity, velocity_mesh, name = "PhiDiffusivity")
 
67
  call allocate(phi, velocity_mesh, name = "Phi")
 
68
  call allocate(pe_no, velocity_mesh, name = "PeNumber")
 
69
  
 
70
  call deallocate(coordinate_mesh)
 
71
  call deallocate(velocity_mesh)
 
72
    
 
73
  call set(positions, (/1, 2, 3, 4/), spread((/0.0, 1.0, 11.0, 111.0/), 1, 1))
 
74
  call set(velocity, (/1, 2, 3/), spread((/1.0, 1.0, 5.0/), 1, 1))
 
75
  
 
76
  call insert(state, positions, name = positions%name)
 
77
  call insert(state, velocity, name = velocity%name)
 
78
  call insert(state, diffusivity, name = diffusivity%name)
 
79
  call insert(state, phi, name = phi%name)
 
80
  call deallocate(positions)
 
81
  call deallocate(velocity)
 
82
  call deallocate(phi)
 
83
  
 
84
  pe_no%option_path = "/material_phase::Fluid/scalar_field::GridPecletNumber"
 
85
  call add_option(trim(pe_no%option_path) // "/diagnostic", stat = stat)
 
86
  assert(stat == SPUD_NEW_KEY_WARNING)
 
87
  call set_option(trim(complete_field_path(pe_no%option_path)) // "/field_name", "Phi", stat = stat)
 
88
  assert(stat == SPUD_NEW_KEY_WARNING)
 
89
  
 
90
  call set(diffusivity, (/1, 2, 3/), spread(spread((/1.0, 1.0, 1.0/), 1, 1), 1, 1))
 
91
  
 
92
  call calculate_diagnostic_variable(state, "GridPecletNumber", pe_no)
 
93
  call report_test("[pe no]", node_val(pe_no, (/1, 2, 3/)) .fne. (/1.0, 10.0, 500.0/), .false., "Incorrect pe number")
 
94
      
 
95
  call set(diffusivity, (/1, 2, 3/), spread(spread((/2.0, 5.0, 10.0/), 1, 1), 1, 1))
 
96
  
 
97
  call calculate_diagnostic_variable(state, "GridPecletNumber", pe_no)
 
98
  call report_test("[pe no]", node_val(pe_no, (/1, 2, 3/)) .fne. (/0.5, 2.0, 50.0/), .false., "Incorrect pe number")
 
99
    
 
100
  call deallocate(state)
 
101
  call deallocate(diffusivity)
 
102
  call deallocate(pe_no)
 
103
  
 
104
  call report_test_no_references()
 
105
 
 
106
end subroutine test_pe_number_1d