61 real(kind=rp) :: t_adj
62 real(kind=dp) :: start_time_org, start_time, end_time
63 character(len=LOG_SIZE) :: log_buf
65 logical :: output_at_end
66 type(time_step_controller_t) :: dt_controller
79 call neko_log%section(
'Starting adjoint')
80 write(log_buf,
'(A,E15.7,A,E15.7,A)')
'T : [', 0d0,
', ', &
81 this%case%end_time,
')'
82 call neko_log%message(log_buf)
83 call dt_controller%init(this%case%params)
84 if (.not. dt_controller%if_variable_dt)
then
85 write(log_buf,
'(A, E15.7)')
'dt : ', this%case%dt
86 call neko_log%message(log_buf)
88 write(log_buf,
'(A, E15.7)')
'CFL : ', dt_controller%set_cfl
89 call neko_log%message(log_buf)
93 call neko_log%section(
'Postprocessing')
95 call this%output_controller%execute(t_adj, tstep_adj)
100 call this%case%usr%user_init_modules(t_adj, this%scheme%u_adj, &
101 this%scheme%v_adj, this%scheme%w_adj,&
102 this%scheme%p_adj, this%scheme%c_Xh, this%case%params)
103 call neko_log%end_section()
104 call neko_log%newline()
107 start_time_org = mpi_wtime()
109 do while (t_adj .lt. this%case%end_time .and. (.not. jobctrl_time_limit()))
110 call profiler_start_region(
'Time-Step')
111 tstep_adj = tstep_adj + 1
112 start_time = mpi_wtime()
114 call neko_log%status(t_adj, this%case%end_time)
115 write(log_buf,
'(A,I6)')
'Time-step: ', tstep_adj
116 call neko_log%message(log_buf)
117 call neko_log%begin()
120 call neko_log%message(log_buf)
122 this%case%tlag, this%case%dtlag, tstep_adj)
124 call neko_log%section(
'Adjoint fluid')
125 call this%scheme%step(t_adj, tstep_adj, this%case%dt, &
126 this%case%fluid%ext_bdf, dt_controller)
127 end_time = mpi_wtime()
128 write(log_buf,
'(A,E15.7,A,E15.7)') &
129 'Elapsed time (s):', end_time-start_time_org,
' Step time:', &
131 call neko_log%end_section(log_buf)
134 if (
allocated(this%case%scalar))
then
135 start_time = mpi_wtime()
136 call neko_log%section(
'Scalar')
137 call this%case%scalar%step(t_adj, tstep_adj, this%case%dt, &
138 this%case%fluid%ext_bdf, dt_controller)
139 end_time = mpi_wtime()
140 write(log_buf,
'(A,E15.7,A,E15.7)') &
141 'Elapsed time (s):', end_time-start_time_org,
' Step time:', &
143 call neko_log%end_section(log_buf)
146 call neko_log%section(
'Postprocessing')
149 call this%output_controller%execute(t_adj, tstep_adj)
152 call this%case%usr%material_properties(t, tstep, this%case%fluid%rho, &
153 this%case%fluid%mu, &
154 this%case%scalar%cp, &
155 this%case%scalar%lambda, &
158 call neko_log%end_section()
161 call profiler_end_region
165 call json_get_or_default(this%case%params,
'case.output_at_end',&
166 output_at_end, .true.)
167 call this%output_controller%execute(t_adj, tstep_adj, output_at_end)
169 if (.not. (output_at_end) .and. t_adj .lt. this%case%end_time)
then
173 call this%case%usr%user_finalize_modules(t_adj, this%case%params)
175 call neko_log%end_section(
'Normal end.')
209 type(case_t),
intent(inout) :: c
210 real(kind=rp),
intent(inout) :: t
212 type(file_t) :: chkpf, previous_meshf
213 character(len=LOG_SIZE) :: log_buf
214 character(len=:),
allocatable :: restart_file
215 character(len=:),
allocatable :: restart_mesh_file
219 call c%params%get(
'case.restart_file', restart_file, found)
220 call c%params%get(
'case.restart_mesh_file', restart_mesh_file, found)
223 previous_meshf = file_t(trim(restart_mesh_file))
224 call previous_meshf%read(c%fluid%chkp%previous_mesh)
227 call c%params%get(
'case.mesh2mesh_tolerance', tol,&
230 if (found) c%fluid%chkp%mesh2mesh_tol = tol
232 chkpf = file_t(trim(restart_file))
233 call chkpf%read(c%fluid%chkp)
234 c%dtlag = c%fluid%chkp%dtlag
235 c%tlag = c%fluid%chkp%tlag
238 call c%fluid%chkp%previous_mesh%free()
239 do i = 1,
size(c%dtlag)
240 call c%fluid%ext_bdf%set_coeffs(c%dtlag)
243 call c%fluid%restart(c%dtlag, c%tlag)
244 if (
allocated(c%scalar))
call c%scalar%restart(c%dtlag, c%tlag)
246 t = c%fluid%chkp%restart_time()
247 call neko_log%section(
'Restarting from checkpoint')
248 write(log_buf,
'(A,A)')
'File : ', trim(restart_file)
249 call neko_log%message(log_buf)
250 write(log_buf,
'(A,E15.7)')
'Time : ', t
251 call neko_log%message(log_buf)
252 call neko_log%end_section()
254 call c%output_controller%set_counter(t)