Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
steepest_descent_cpu.f90
Go to the documentation of this file.
1
34
41 use num_types, only: rp
42 implicit none
43 private
44
46
47contains
48
58 subroutine sd_direction_cpu(s, x, xmin, xmax, n)
59 integer, intent(in) :: n
60 real(kind=rp), dimension(n), intent(inout) :: s
61 real(kind=rp), dimension(n), intent(in) :: x
62 real(kind=rp), intent(in) :: xmin, xmax
63 integer :: i
64
65 do i = 1, n
66 s(i) = -s(i)
67 if ((x(i) .ge. xmax .and. s(i) .gt. 0.0_rp) .or. &
68 (x(i) .le. xmin .and. s(i) .lt. 0.0_rp)) then
69 s(i) = 0.0_rp
70 end if
71 end do
72
73 end subroutine sd_direction_cpu
74
88 subroutine sd_update_move_limits_cpu(delta, x, x1, x2, dec, inc, dmin, &
89 dmax, n)
90 integer, intent(in) :: n
91 real(kind=rp), dimension(n), intent(inout) :: delta
92 real(kind=rp), dimension(n), intent(in) :: x, x1, x2
93 real(kind=rp), intent(in) :: dec, inc, dmin, dmax
94 real(kind=rp) :: d
95 integer :: i
96
97 do i = 1, n
98 d = (x(i) - x1(i)) * (x1(i) - x2(i))
99 if (d .lt. 0.0_rp) then
100 delta(i) = dec * delta(i)
101 else if (d .gt. 0.0_rp) then
102 delta(i) = inc * delta(i)
103 end if
104 delta(i) = min(dmax, max(dmin, delta(i)))
105 end do
106
107 end subroutine sd_update_move_limits_cpu
108
124 subroutine sd_update_design_cpu(x_new, x, s, delta, psi, smax, xmin, xmax, &
125 n)
126 integer, intent(in) :: n
127 real(kind=rp), dimension(n), intent(out) :: x_new
128 real(kind=rp), dimension(n), intent(in) :: x, s, delta
129 real(kind=rp), intent(in) :: psi, smax, xmin, xmax
130 integer :: i
131
132 do i = 1, n
133 x_new(i) = min(xmax, max(xmin, min(x(i) + delta(i), &
134 max(x(i) - delta(i), x(i) + psi * (s(i) / smax)))))
135 end do
136
137 end subroutine sd_update_design_cpu
138
139end module steepest_descent_cpu
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).