73 class(LeastSquaresGradientType) :: this
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
85 number_connections = number_connected_faces(this%dis, n)
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)
100 dnm = node_distance(this%dis, n, m)
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)