1
! Copyright (C) 2006 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; either
16
! version 2.1 of the License, or (at your option) any later version.
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_pe_number_1d
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
51
quad = make_quadrature(vertices = 2, dim = 1, degree = 2)
52
shape = make_element_shape(vertices = 2, dim = 1, degree = 1, quad = quad)
55
call allocate(coordinate_mesh, nodes = 4, elements = 3, shape = shape, name = "CoordinateMesh")
56
call deallocate(shape)
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/))
62
velocity_mesh = piecewise_constant_mesh(coordinate_mesh, name = "PeNumberMesh")
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")
70
call deallocate(coordinate_mesh)
71
call deallocate(velocity_mesh)
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))
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)
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)
90
call set(diffusivity, (/1, 2, 3/), spread(spread((/1.0, 1.0, 1.0/), 1, 1), 1, 1))
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")
95
call set(diffusivity, (/1, 2, 3/), spread(spread((/2.0, 5.0, 10.0/), 1, 1), 1, 1))
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")
100
call deallocate(state)
101
call deallocate(diffusivity)
102
call deallocate(pe_no)
104
call report_test_no_references()
106
end subroutine test_pe_number_1d