Propagate the segments for the solver's current x, and send the trajectory
(joined in time order) to the solver's iteration_callback.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(my_solver_type), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x |
the solver's (scaled) opt vars for this iteration |
|
| integer, | intent(in) | :: | iter |
iteration number |
subroutine iteration_trajectory(me,x,iter) implicit none class(my_solver_type),intent(inout) :: me real(wp),dimension(:),intent(in) :: x !! the solver's (scaled) opt vars for this iteration integer,intent(in) :: iter !! iteration number integer :: iseg, i, n, ntot, istart, iend, istep, nseg real(wp),dimension(:),allocatable :: et real(wp),dimension(:,:),allocatable :: r_rot, r_inr, r_se real(wp),dimension(:,:),allocatable :: seg_et !! (2,nseg) each segment's start and end times real(wp),dimension(:,:,:),allocatable :: seg_rot, seg_inr, seg_se !! (3,2,nseg) and positions real(wp),dimension(:,:),allocatable :: defects !! (2,nseg/2) |dr|, |dv| at each interface real(wp),dimension(6) :: dx associate (segs => me%mission%segs) call me%mission%put_x_in_segments(x) ! (the segments' initial states for this iteration) !$OMP PARALLEL DO do iseg = 1, size(segs) call segs(iseg)%traj_inertial%destroy() call segs(iseg)%traj_rotating%destroy() call segs(iseg)%traj_se_rotating%destroy() call segs(iseg)%propagate(mode=2) ! [export points] end do !$OMP END PARALLEL DO nseg = size(segs) n = 0 do iseg = 1, nseg n = n + size(segs(iseg)%traj_inertial%et) end do allocate(et(n), r_rot(3,n), r_inr(3,n), r_se(3,n)) allocate(seg_et(2,nseg), seg_rot(3,2,nseg), seg_inr(3,2,nseg), seg_se(3,2,nseg)) seg_et = 0.0_wp; seg_rot = 0.0_wp; seg_inr = 0.0_wp; seg_se = 0.0_wp ntot = 0 do iseg = 1, size(segs) associate (ti => segs(iseg)%traj_inertial, tr => segs(iseg)%traj_rotating, & ts => segs(iseg)%traj_se_rotating) n = size(ti%et) if (n == 0) cycle ! the segment's start and end (as propagated): seg_et(1,iseg) = ti%et(1) seg_et(2,iseg) = ti%et(n) seg_inr(:,1,iseg) = [ti%x(1), ti%y(1), ti%z(1)] seg_inr(:,2,iseg) = [ti%x(n), ti%y(n), ti%z(n)] seg_rot(:,1,iseg) = [tr%x(1), tr%y(1), tr%z(1)] seg_rot(:,2,iseg) = [tr%x(n), tr%y(n), tr%z(n)] seg_se(:,1,iseg) = [ts%x(1), ts%y(1), ts%z(1)] seg_se(:,2,iseg) = [ts%x(n), ts%y(n), ts%z(n)] ! the joined trajectory: if (ti%et(n) >= ti%et(1)) then istart = 1; iend = n; istep = 1 ! forward propagated else istart = n; iend = 1; istep = -1 ! backward propagated end if do i = istart, iend, istep if (ntot > 0) then if (ti%et(i) <= et(ntot)) cycle ! (the segments' shared ends) end if ntot = ntot + 1 et(ntot) = ti%et(i) r_inr(:,ntot) = [ti%x(i), ti%y(i), ti%z(i)] r_rot(:,ntot) = [tr%x(i), tr%y(i), tr%z(i)] r_se(:,ntot) = [ts%x(i), ts%y(i), ts%z(i)] end do end associate end do do iseg = 1, size(segs) call segs(iseg)%traj_inertial%destroy() call segs(iseg)%traj_rotating%destroy() call segs(iseg)%traj_se_rotating%destroy() end do ! the defects: segments 2k-1 and 2k end at the same point (when solved) allocate(defects(2, nseg/2)) do i = 1, nseg/2 dx = segs(2*i-1)%data%xf_rotating - segs(2*i)%data%xf_rotating defects(1,i) = norm2(dx(1:3)) defects(2,i) = norm2(dx(4:6)) end do end associate call me%iteration_callback(iter, et(1:ntot), r_rot(:,1:ntot), r_inr(:,1:ntot), r_se(:,1:ntot), & seg_et, seg_rot, seg_inr, seg_se, defects) end subroutine iteration_trajectory