Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
steepest_descent_math.f90
Go to the documentation of this file.
1
34
43 use num_types, only: rp
44 use vector, only: vector_t
45 use neko_config, only: neko_bcknd_device
50 implicit none
51 private
52
54
55contains
56
65 subroutine sd_direction(s, x, xmin, xmax, n)
66 type(vector_t), intent(inout) :: s
67 type(vector_t), intent(in) :: x
68 real(kind=rp), intent(in) :: xmin, xmax
69 integer, intent(in), optional :: n
70 integer :: n_local
71
72 if (present(n)) then
73 n_local = n
74 else
75 n_local = s%size()
76 end if
77
78 ! An empty range has nothing to do, and its host array may be unallocated
79 if (n_local .lt. 1) return
80
81 if (neko_bcknd_device .eq. 1) then
82 call device_sd_direction(s%x_d, x%x_d, xmin, xmax, n_local)
83 else
84 call sd_direction_cpu(s%x, x%x, xmin, xmax, n_local)
85 end if
86
87 end subroutine sd_direction
88
103 subroutine sd_update_move_limits(delta, x, x1, x2, dec, inc, dmin, dmax, n)
104 type(vector_t), intent(inout) :: delta
105 type(vector_t), intent(in) :: x, x1, x2
106 real(kind=rp), intent(in) :: dec, inc, dmin, dmax
107 integer, intent(in), optional :: n
108 integer :: n_local
109
110 if (present(n)) then
111 n_local = n
112 else
113 n_local = delta%size()
114 end if
115
116 ! An empty range has nothing to do, and its host array may be unallocated
117 if (n_local .lt. 1) return
118
119 if (neko_bcknd_device .eq. 1) then
120 call device_sd_update_move_limits(delta%x_d, x%x_d, x1%x_d, x2%x_d, &
121 dec, inc, dmin, dmax, n_local)
122 else
123 call sd_update_move_limits_cpu(delta%x, x%x, x1%x, x2%x, &
124 dec, inc, dmin, dmax, n_local)
125 end if
126
127 end subroutine sd_update_move_limits
128
145 subroutine sd_update_design(x_new, x, s, delta, psi, smax, xmin, xmax, n)
146 type(vector_t), intent(inout) :: x_new
147 type(vector_t), intent(in) :: x, s, delta
148 real(kind=rp), intent(in) :: psi, smax, xmin, xmax
149 integer, intent(in), optional :: n
150 integer :: n_local
151
152 if (present(n)) then
153 n_local = n
154 else
155 n_local = x_new%size()
156 end if
157
158 ! An empty range has nothing to do, and its host array may be unallocated
159 if (n_local .lt. 1) return
160
161 if (neko_bcknd_device .eq. 1) then
162 call device_sd_update_design(x_new%x_d, x%x_d, s%x_d, delta%x_d, &
163 psi, smax, xmin, xmax, n_local)
164 else
165 call sd_update_design_cpu(x_new%x, x%x, s%x, delta%x, &
166 psi, smax, xmin, xmax, n_local)
167 end if
168
169 end subroutine sd_update_design
170
171end module steepest_descent_math
Device backend dispatch for the steepest-descent optimizer kernels.
subroutine, public device_sd_update_move_limits(delta_d, x_d, x1_d, x2_d, dec, inc, dmin, dmax, n)
Adapt the move limits on the device (Eq. D23).
subroutine, public device_sd_update_design(x_new_d, x_d, s_d, delta_d, psi, smax, xmin, xmax, n)
Move-limited, box-constrained design update on the device (Eq. D24).
subroutine, public device_sd_direction(s_d, x_d, xmin, xmax, n)
Bound-projected steepest-descent direction on the device (Eq. D22).
CPU backend for the steepest-descent optimizer kernels.
subroutine, public sd_direction_cpu(s, x, xmin, xmax, n)
Bound-projected steepest-descent direction on CPU (Eq. D22).
subroutine, public sd_update_move_limits_cpu(delta, x, x1, x2, dec, inc, dmin, dmax, n)
Adapt the move limits on CPU (Eq. D23).
subroutine, public sd_update_design_cpu(x_new, x, s, delta, psi, smax, xmin, xmax, n)
Move-limited, box-constrained design update on CPU (Eq. D24).
Vector-level kernels of the steepest-descent optimizer.
subroutine, public sd_update_move_limits(delta, x, x1, x2, dec, inc, dmin, dmax, n)
Adapt the move limits (Eq. D23).
subroutine, public sd_update_design(x_new, x, s, delta, psi, smax, xmin, xmax, n)
Move-limited, box-constrained design update (Eq. D24).
subroutine, public sd_direction(s, x, xmin, xmax, n)
Bound-projected steepest-descent direction (Eq. D22).