139 ulag, vlag, wlag, time_scheme, rho)
141 type(
mesh_t),
target,
intent(in) :: msh
142 type(
coef_t),
target,
intent(in) :: coef
143 type(
gs_t),
target,
intent(inout) :: gs
144 type(json_file),
target,
intent(inout) :: params
145 type(
user_t),
target,
intent(in) :: user
148 real(kind=
rp),
intent(in) :: rho
150 character(len=15),
parameter :: scheme =
'Modular (Pn/Pn)'
156 call this%scheme_init(msh, coef, gs, params, scheme, user, rho)
159 call ax_helm_factory(this%ax, full_formulation = .false.)
162 call scalar_residual_factory(this%res)
165 call rhs_maker_ext_fctry(this%makeext)
168 call rhs_maker_bdf_fctry(this%makebdf)
171 call rhs_maker_oifs_fctry(this%makeoifs)
174 associate(xh_lx => this%Xh%lx, xh_ly => this%Xh%ly, xh_lz => this%Xh%lz, &
175 dm_xh => this%dm_Xh, nelv => this%msh%nelv)
177 call this%s_res%init(dm_xh,
"s_res")
179 call this%abx1%init(dm_xh,
"abx1")
181 call this%abx2%init(dm_xh,
"abx2")
183 call this%advs%init(dm_xh,
"advs")
185 call this%ds%init(dm_xh,
'ds')
191 call this%bc_res%init_base(this%c_Xh)
192 do i = 1, this%n_dir_bcs
193 call this%bc_res%mark_facets(this%dir_bcs(i)%marked_facet)
197 if (this%user_bc%msk(0) .gt. 0)
then
198 call this%bc_res%mark_facets(this%user_bc%marked_facet)
201 call this%bc_res%mark_zones_from_list(msh%labeled_zones,
'd_s', &
203 call this%bc_res%finalize()
204 call this%bc_res%set_g(0.0_rp)
206 call this%bclst_ds%init()
207 call this%bclst_ds%append(this%bc_res)
211 call this%proj_s%init(this%dm_Xh%size(), this%projection_dim, &
212 this%projection_activ_step)
223 call advection_factory(this%adv, params, this%c_Xh, &
224 ulag, vlag, wlag, this%chkp%dtlag, &
232 real(kind=rp) :: dtlag(10), tlag(10)
236 n = this%s%dof%size()
238 call col2(this%s%x, this%c_Xh%mult, n)
239 call col2(this%slag%lf(1)%x, this%c_Xh%mult, n)
240 call col2(this%slag%lf(2)%x, this%c_Xh%mult, n)
241 if (neko_bcknd_device .eq. 1)
then
242 call device_memcpy(this%s%x, this%s%x_d, &
243 n, host_to_device, sync = .false.)
244 call device_memcpy(this%slag%lf(1)%x, this%slag%lf(1)%x_d, &
245 n, host_to_device, sync = .false.)
246 call device_memcpy(this%slag%lf(2)%x, this%slag%lf(2)%x_d, &
247 n, host_to_device, sync = .false.)
248 call device_memcpy(this%abx1%x, this%abx1%x_d, &
249 n, host_to_device, sync = .false.)
250 call device_memcpy(this%abx2%x, this%abx2%x_d, &
251 n, host_to_device, sync = .false.)
252 call device_memcpy(this%advs%x, this%advs%x_d, &
253 n, host_to_device, sync = .false.)
256 call this%gs_Xh%op(this%s, gs_op_add)
257 call this%gs_Xh%op(this%slag%lf(1), gs_op_add)
258 call this%gs_Xh%op(this%slag%lf(2), gs_op_add)
304 real(kind=rp),
intent(in) :: t
305 integer,
intent(in) :: tstep
306 real(kind=rp),
intent(in) :: dt
307 type(time_scheme_controller_t),
intent(in) :: ext_bdf
308 type(time_step_controller_t),
intent(in) :: dt_controller
312 type(ksp_monitor_t) :: ksp_results(1)
313 character(len=LOG_SIZE) :: log_buf
315 n = this%dm_Xh%size()
317 call profiler_start_region(
'Scalar', 2)
318 associate(u => this%u, v => this%v, w => this%w, s => this%s, &
319 cp => this%cp, rho => this%rho, &
321 s_res => this%s_res, &
322 ax => this%Ax, f_xh => this%f_Xh, xh => this%Xh, &
323 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
324 slag => this%slag, oifs => this%oifs, &
325 lambda_field => this%lambda_field, &
326 projection_dim => this%projection_dim, &
327 msh => this%msh, res => this%res, makeoifs => this%makeoifs, &
328 makeext => this%makeext, makebdf => this%makebdf, &
329 if_variable_dt => dt_controller%if_variable_dt, &
330 dt_last_change => dt_controller%dt_last_change)
332 if (neko_log%level_ .ge. neko_log_debug)
then
333 write(log_buf,
'(A,A,E15.7,A,E15.7,A,E15.7)')
'Scalar debug', &
334 ' l2norm s', glsc2(this%s%x, this%s%x, n), &
335 ' slag1', glsc2(this%slag%lf(1)%x, this%slag%lf(1)%x, n), &
336 ' slag2', glsc2(this%slag%lf(2)%x, this%slag%lf(2)%x, n)
337 call neko_log%message(log_buf)
338 write(log_buf,
'(A,A,E15.7,A,E15.7)')
'Scalar debug2', &
339 ' l2norm abx1', glsc2(this%abx1%x, this%abx1%x, n), &
340 ' abx2', glsc2(this%abx2%x, this%abx2%x, n)
341 call neko_log%message(log_buf)
345 call this%source_term%compute(t, tstep)
348 if (this%if_gradient_jump_penalty .eqv. .true.)
then
349 call this%gradient_jump_penalty%compute(u, v, w, s)
350 call this%gradient_jump_penalty%perform(f_xh)
354 call this%bclst_neumann%apply_scalar(this%f_Xh%x, dm_xh%size())
358 call this%adv%compute_scalar(u, v, w, s, this%advs, &
359 xh, this%c_Xh, dm_xh%size())
361 call makeext%compute_scalar(this%abx1, this%abx2, f_xh%x, rho, &
362 ext_bdf%advection_coeffs, n)
364 call makeoifs%compute_scalar(this%advs%x, f_xh%x, rho, dt, n)
367 call this%adv%compute_scalar(u, v, w, s, f_xh, &
368 xh, this%c_Xh, dm_xh%size())
374 call makeext%compute_scalar(this%abx1, this%abx2, f_xh%x, rho, &
375 ext_bdf%advection_coeffs, n)
378 call makebdf%compute_scalar(slag, f_xh%x, s, c_xh%B, rho, dt, &
379 ext_bdf%diffusion_coeffs, ext_bdf%ndiff, n)
387 call this%field_dir_bc%update(this%field_dir_bc%field_list, &
388 this%field_dirichlet_bcs, this%c_Xh, t, tstep,
"scalar")
389 call this%bclst_dirichlet%apply_scalar(this%s%x, this%dm_Xh%size())
393 call this%update_material_properties()
396 call profiler_start_region(
'Scalar_residual', 20)
397 call res%compute(ax, s, s_res, f_xh, c_xh, msh, xh, lambda_field, &
398 rho*cp, ext_bdf%diffusion_coeffs(1), dt, dm_xh%size())
400 call gs_xh%op(s_res, gs_op_add)
403 call this%bclst_ds%apply_scalar(s_res%x, dm_xh%size())
405 call profiler_end_region(
'Scalar_residual', 20)
407 call this%proj_s%pre_solving(s_res%x, tstep, c_xh, n, dt_controller)
409 call this%pc%update()
410 call profiler_start_region(
'Scalar_solve', 21)
411 ksp_results(1) = this%ksp%solve(ax, ds, s_res%x, n, &
412 c_xh, this%bclst_ds, gs_xh)
413 call profiler_end_region(
'Scalar_solve', 21)
415 call this%proj_s%post_solving(ds%x, ax, c_xh, &
416 this%bclst_ds, gs_xh, n, tstep, dt_controller)
419 if (neko_bcknd_device .eq. 1)
then
420 call device_add2s2(s%x_d, ds%x_d, 1.0_rp, n)
422 call add2s2(s%x, ds%x, 1.0_rp, n)
425 call scalar_step_info(tstep, t, dt, ksp_results)
428 call profiler_end_region(
'Scalar', 2)