16 real(dp),
dimension(:, :),
allocatable :: data
39 type(
array2d),
allocatable,
dimension(:) :: r
58 integer(I4B) :: n, nodes
65 allocate (gradient%R(dis%nodes))
67 gradient%R(n)%data = gradient%create_gradient_reconstruction_matrix(n)
74 integer(I4B),
intent(in) :: n
75 real(dp),
dimension(:, :),
allocatable :: r
77 integer(I4B) :: number_connections
78 integer(I4B) :: ipos, local_pos, m
80 real(dp),
dimension(3) :: dnm
81 real(dp),
dimension(:, :),
allocatable :: d
82 real(dp),
dimension(:, :),
allocatable :: grad_scale
87 allocate (d(number_connections, 3))
88 allocate (r(3, number_connections))
89 allocate (grad_scale(number_connections, number_connections))
97 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
98 m = this%dis%con%ja(ipos)
103 d(local_pos, :) = dnm / length
104 grad_scale(local_pos, local_pos) = 1.0_dp / length
106 local_pos = local_pos + 1
110 r = matmul(
pinv(d), grad_scale)
114 function get(this, n, c)
result(grad_c)
117 integer(I4B),
intent(in) :: n
118 real(dp),
dimension(:),
intent(in) :: c
120 real(dp),
dimension(3) :: grad_c
122 grad_c = this%compute_cell_gradient(n, c)
127 real(dp),
dimension(3) :: grad_c
130 integer(I4B),
intent(in) :: n
131 real(dp),
dimension(:),
intent(in) :: phi_new
133 real(dp),
dimension(:, :),
pointer :: r
134 integer(I4B) :: ipos, local_pos
135 integer(I4B) :: number_connections
138 real(dp),
dimension(:),
allocatable :: dc
142 allocate (dc(number_connections))
144 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
145 m = this%dis%con%ja(ipos)
146 dc(local_pos) = phi_new(m) - phi_new(n)
147 local_pos = local_pos + 1
152 grad_c = matmul(r, dc)
This module contains simulation constants.
real(dp), parameter done
real constant 1
integer(i4b) function, public number_connected_faces(dis, n)
Returns the number of connected faces for a given cell.
real(dp) function, dimension(3), public node_distance(dis, n, m)
Returns the vector distance from cell n to cell m.
This module defines variable data types.
real(dp) function, dimension(:, :), allocatable create_gradient_reconstruction_matrix(this, n)
real(dp) function, dimension(3) get(this, n, c)
real(dp) function, dimension(3) compute_cell_gradient(this, n, phi_new)
type(leastsquaresgradienttype) function constructor(dis)
real(dp) function, dimension(size(a, dim=2), size(a, dim=1)), public pinv(A)
Abstract interface for cell-based gradient computation.
Weighted least-squares gradient method for structured and unstructured grids.