56 use json_module,
only : json_file
79 type(
field_t) :: p_res, u_res, v_res, w_res
83 class(
ax_t),
allocatable :: ax
139 type(
mesh_t),
target,
intent(inout) :: msh
140 integer,
intent(inout) :: lx
141 type(json_file),
target,
intent(inout) :: params
142 type(
user_t),
intent(in) :: user
144 character(len=15),
parameter :: scheme =
'Modular (Pn/Pn)'
145 logical :: found, logical_val
146 integer :: integer_val
147 real(kind=
rp) :: real_val
152 call this%scheme_init(msh, lx, params, .true., .true., scheme, user, &
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%p_res%init(dm_xh,
"p_res")
178 call this%u_res%init(dm_xh,
"u_res")
179 call this%v_res%init(dm_xh,
"v_res")
180 call this%w_res%init(dm_xh,
"w_res")
181 call this%abx1%init(dm_xh,
"abx1")
182 call this%aby1%init(dm_xh,
"aby1")
183 call this%abz1%init(dm_xh,
"abz1")
184 call this%abx2%init(dm_xh,
"abx2")
185 call this%aby2%init(dm_xh,
"aby2")
186 call this%abz2%init(dm_xh,
"abz2")
194 call this%du%init(dm_xh,
'du')
195 call this%dv%init(dm_xh,
'dv')
196 call this%dw%init(dm_xh,
'dw')
197 call this%dp%init(dm_xh,
'dp')
202 call this%bc_prs_surface%init(this%c_Xh)
203 call this%bc_prs_surface%mark_zone(msh%inlet)
204 call this%bc_prs_surface%mark_zones_from_list(msh%labeled_zones,&
207 call this%bc_prs_surface%mark_zones_from_list(msh%labeled_zones,&
208 'd_vel_u', this%bc_labels)
209 call this%bc_prs_surface%mark_zones_from_list(msh%labeled_zones,&
210 'd_vel_v', this%bc_labels)
211 call this%bc_prs_surface%mark_zones_from_list(msh%labeled_zones,&
212 'd_vel_w', this%bc_labels)
213 call this%bc_prs_surface%finalize()
215 call this%bc_sym_surface%init(this%c_Xh)
216 call this%bc_sym_surface%mark_zone(msh%sympln)
217 call this%bc_sym_surface%mark_zones_from_list(msh%labeled_zones,&
218 'sym', this%bc_labels)
220 call this%bc_sym_surface%finalize()
222 call this%bc_vel_res_non_normal%init(this%c_Xh)
223 call this%bc_vel_res_non_normal%mark_zone(msh%outlet_normal)
224 call this%bc_vel_res_non_normal%mark_zones_from_list(msh%labeled_zones,&
225 'on', this%bc_labels)
226 call this%bc_vel_res_non_normal%mark_zones_from_list(msh%labeled_zones,&
229 call this%bc_vel_res_non_normal%finalize()
230 call this%bc_vel_res_non_normal%init_msk()
232 call this%bc_field_dirichlet_p%init(this%c_Xh)
233 call this%bc_field_dirichlet_p%mark_zones_from_list(msh%labeled_zones,
'on+dong', &
235 call this%bc_field_dirichlet_p%mark_zones_from_list(msh%labeled_zones, &
236 'o+dong', this%bc_labels)
237 call this%bc_field_dirichlet_p%mark_zones_from_list(msh%labeled_zones,
'd_pres', &
239 call this%bc_field_dirichlet_p%finalize()
240 call this%bc_field_dirichlet_p%set_g(0.0_rp)
242 call bc_list_add(this%bclst_dp, this%bc_field_dirichlet_p)
246 call this%bc_field_dirichlet_u%init(this%c_Xh)
247 call this%bc_field_dirichlet_u%mark_zones_from_list(msh%labeled_zones,
'd_vel_u', &
249 call this%bc_field_dirichlet_u%finalize()
250 call this%bc_field_dirichlet_u%set_g(0.0_rp)
252 call this%bc_field_dirichlet_v%init(this%c_Xh)
253 call this%bc_field_dirichlet_v%mark_zones_from_list(msh%labeled_zones,
'd_vel_v', &
255 call this%bc_field_dirichlet_v%finalize()
256 call this%bc_field_dirichlet_v%set_g(0.0_rp)
258 call this%bc_field_dirichlet_w%init(this%c_Xh)
259 call this%bc_field_dirichlet_w%mark_zones_from_list(msh%labeled_zones,
'd_vel_w', &
261 call this%bc_field_dirichlet_w%finalize()
262 call this%bc_field_dirichlet_w%set_g(0.0_rp)
264 call this%bc_vel_res%init(this%c_Xh)
265 call this%bc_vel_res%mark_zone(msh%inlet)
266 call this%bc_vel_res%mark_zone(msh%wall)
267 call this%bc_vel_res%mark_zones_from_list(msh%labeled_zones, &
269 call this%bc_vel_res%mark_zones_from_list(msh%labeled_zones, &
271 call this%bc_vel_res%finalize()
272 call this%bc_vel_res%set_g(0.0_rp)
274 call bc_list_add(this%bclst_vel_res, this%bc_vel_res)
275 call bc_list_add(this%bclst_vel_res, this%bc_vel_res_non_normal)
281 call bc_list_add(this%bclst_du,this%bc_vel_res_non_normal%bc_x)
283 call bc_list_add(this%bclst_du, this%bc_field_dirichlet_u)
287 call bc_list_add(this%bclst_dv,this%bc_vel_res_non_normal%bc_y)
289 call bc_list_add(this%bclst_dv, this%bc_field_dirichlet_v)
293 call bc_list_add(this%bclst_dw,this%bc_vel_res_non_normal%bc_z)
295 call bc_list_add(this%bclst_dw, this%bc_field_dirichlet_w)
298 call this%proj_prs%init(this%dm_Xh%size(), this%pr_projection_dim, &
299 this%pr_projection_activ_step)
301 call this%proj_u%init(this%dm_Xh%size(), this%vel_projection_dim, &
302 this%vel_projection_activ_step)
303 call this%proj_v%init(this%dm_Xh%size(), this%vel_projection_dim, &
304 this%vel_projection_activ_step)
305 call this%proj_w%init(this%dm_Xh%size(), this%vel_projection_dim, &
306 this%vel_projection_activ_step)
310 call this%chkp%add_lag(this%ulag, this%vlag, this%wlag)
314 if (params%valid_path(
'case.fluid.flow_rate_force'))
then
315 call this%vol_flow%init(this%dm_Xh, params)
322 real(kind=rp) :: dtlag(10), tlag(10)
323 type(field_t) :: u_temp, v_temp, w_temp
326 n = this%u%dof%size()
330 call col2(this%u%x,this%c_Xh%mult,this%u%dof%size())
331 call col2(this%v%x,this%c_Xh%mult,this%u%dof%size())
332 call col2(this%w%x,this%c_Xh%mult,this%u%dof%size())
333 call col2(this%p%x,this%c_Xh%mult,this%u%dof%size())
334 do i = 1, this%ulag%size()
335 call col2(this%ulag%lf(i)%x,this%c_Xh%mult,this%u%dof%size())
336 call col2(this%vlag%lf(i)%x,this%c_Xh%mult,this%u%dof%size())
337 call col2(this%wlag%lf(i)%x,this%c_Xh%mult,this%u%dof%size())
341 if (neko_bcknd_device .eq. 1)
then
342 associate(u=>this%u, v=>this%v, w=>this%w, &
343 ulag=>this%ulag, vlag=>this%vlag, wlag=>this%wlag,&
345 call device_memcpy(u%x, u%x_d, u%dof%size(), &
346 host_to_device, sync=.false.)
347 call device_memcpy(v%x, v%x_d, v%dof%size(), &
348 host_to_device, sync=.false.)
349 call device_memcpy(w%x, w%x_d, w%dof%size(), &
350 host_to_device, sync=.false.)
351 call device_memcpy(p%x, p%x_d, p%dof%size(), &
352 host_to_device, sync=.false.)
353 call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, &
354 u%dof%size(), host_to_device, sync=.false.)
355 call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, &
356 u%dof%size(), host_to_device, sync=.false.)
358 call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, &
359 v%dof%size(), host_to_device, sync=.false.)
360 call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, &
361 v%dof%size(), host_to_device, sync=.false.)
363 call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, &
364 w%dof%size(), host_to_device, sync=.false.)
365 call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, &
366 w%dof%size(), host_to_device, sync=.false.)
367 call device_memcpy(this%abx1%x, this%abx1%x_d, &
368 w%dof%size(), host_to_device, sync=.false.)
369 call device_memcpy(this%abx2%x, this%abx2%x_d, &
370 w%dof%size(), host_to_device, sync=.false.)
371 call device_memcpy(this%aby1%x, this%aby1%x_d, &
372 w%dof%size(), host_to_device, sync=.false.)
373 call device_memcpy(this%aby2%x, this%aby2%x_d, &
374 w%dof%size(), host_to_device, sync=.false.)
375 call device_memcpy(this%abz1%x, this%abz1%x_d, &
376 w%dof%size(), host_to_device, sync=.false.)
377 call device_memcpy(this%abz2%x, this%abz2%x_d, &
378 w%dof%size(), host_to_device, sync=.false.)
383 call this%gs_Xh%op(this%u,gs_op_add)
384 call this%gs_Xh%op(this%v,gs_op_add)
385 call this%gs_Xh%op(this%w,gs_op_add)
386 call this%gs_Xh%op(this%p,gs_op_add)
388 do i = 1, this%ulag%size()
389 call this%gs_Xh%op(this%ulag%lf(i),gs_op_add)
390 call this%gs_Xh%op(this%vlag%lf(i),gs_op_add)
391 call this%gs_Xh%op(this%wlag%lf(i),gs_op_add)
450 call this%scheme_free()
452 call this%bc_prs_surface%free()
453 call this%bc_sym_surface%free()
454 call bc_list_free(this%bclst_vel_res)
455 call bc_list_free(this%bclst_dp)
456 call this%proj_prs%free()
457 call this%proj_u%free()
458 call this%proj_v%free()
459 call this%proj_w%free()
461 call this%p_res%free()
462 call this%u_res%free()
463 call this%v_res%free()
464 call this%w_res%free()
471 call this%abx1%free()
472 call this%aby1%free()
473 call this%abz1%free()
475 call this%abx2%free()
476 call this%aby2%free()
477 call this%abz2%free()
479 if (
allocated(this%Ax))
then
483 if (
allocated(this%prs_res))
then
484 deallocate(this%prs_res)
487 if (
allocated(this%vel_res))
then
488 deallocate(this%vel_res)
491 if (
allocated(this%sumab))
then
492 deallocate(this%sumab)
495 if (
allocated(this%makeabf))
then
496 deallocate(this%makeabf)
499 if (
allocated(this%makebdf))
then
500 deallocate(this%makebdf)
503 call this%vol_flow%free()
515 real(kind=rp),
intent(inout) :: t
516 integer,
intent(inout) :: tstep
517 real(kind=rp),
intent(in) :: dt
518 type(time_scheme_controller_t),
intent(inout) :: ext_bdf
519 type(time_step_controller_t),
intent(in) :: dt_controller
523 type(ksp_monitor_t) :: ksp_results(4)
525 type(field_t),
pointer :: u_e, v_e, w_e
527 integer :: temp_indices(3)
531 if (this%freeze)
return
533 n = this%dm_Xh%size()
535 call profiler_start_region(
'Fluid', 1)
536 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
537 du => this%du, dv => this%dv, dw => this%dw, dp => this%dp, &
538 u_res =>this%u_res, v_res => this%v_res, w_res => this%w_res, &
539 p_res => this%p_res, ax => this%Ax, xh => this%Xh, &
540 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
541 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
542 msh => this%msh, prs_res => this%prs_res, &
544 vel_res => this%vel_res, sumab => this%sumab, &
545 makeabf => this%makeabf, makebdf => this%makebdf, &
546 vel_projection_dim => this%vel_projection_dim, &
547 pr_projection_dim => this%pr_projection_dim, &
548 rho => this%rho, mu => this%mu, &
549 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
550 if_variable_dt => dt_controller%if_variable_dt, &
551 dt_last_change => dt_controller%dt_last_change)
554 call this%scratch%request_field(u_e, temp_indices(1))
555 call this%scratch%request_field(v_e, temp_indices(2))
556 call this%scratch%request_field(w_e, temp_indices(3))
557 call sumab%compute_fluid(u_e, v_e, w_e, u, v, w, &
558 ulag, vlag, wlag, ext_bdf%advection_coeffs, ext_bdf%nadv)
561 call this%source_term%compute(t, tstep)
564 if (neko_bcknd_device .eq. 1)
then
565 call device_opcolv(f_x%x_d, f_y%x_d, f_z%x_d, c_xh%B_d, msh%gdim, n)
567 call opcolv(f_x%x, f_y%x, f_z%x, c_xh%B, msh%gdim, n)
571 call this%adv%compute(u, v, w, &
572 f_x%x, f_y%x, f_z%x, &
573 xh, this%c_Xh, dm_xh%size())
579 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
580 this%abx2, this%aby2, this%abz2, &
581 f_x%x, f_y%x, f_z%x, &
582 rho, ext_bdf%advection_coeffs, n)
585 call makebdf%compute_fluid(ulag, vlag, wlag, f_x%x, f_y%x, f_z%x, &
586 u, v, w, c_xh%B, rho, dt, &
587 ext_bdf%diffusion_coeffs, ext_bdf%ndiff, n)
596 call this%dirichlet_update_(this%field_dirichlet_fields, &
597 this%field_dirichlet_bcs, this%c_Xh, t, tstep,
"fluid")
599 call this%bc_apply_vel(t, tstep)
600 call this%bc_apply_prs(t, tstep)
603 call profiler_start_region(
'Pressure residual', 18)
604 call prs_res%compute(p, p_res, u, v, w, u_e, v_e, w_e, &
605 f_x, f_y, f_z, c_xh, gs_xh, this%bc_prs_surface, &
606 this%bc_sym_surface, ax, ext_bdf%diffusion_coeffs(1), &
609 call gs_xh%op(p_res, gs_op_add)
610 call bc_list_apply_scalar(this%bclst_dp, p_res%x, p%dof%size(), t, tstep)
611 call profiler_end_region
613 call this%proj_prs%pre_solving(p_res%x, tstep, c_xh, n, dt_controller,
'Pressure')
615 call this%pc_prs%update()
616 call profiler_start_region(
'Pressure solve', 3)
618 this%ksp_prs%solve(ax, dp, p_res%x, n, c_xh, this%bclst_dp, gs_xh)
620 call profiler_end_region
622 call this%proj_prs%post_solving(dp%x, ax, c_xh, &
623 this%bclst_dp, gs_xh, n, tstep, dt_controller)
625 if (neko_bcknd_device .eq. 1)
then
626 call device_add2(p%x_d, dp%x_d,n)
628 call add2(p%x, dp%x,n)
633 call profiler_start_region(
'Velocity residual', 19)
634 call vel_res%compute(ax, u, v, w, &
635 u_res, v_res, w_res, &
639 mu, rho, ext_bdf%diffusion_coeffs(1), &
642 call gs_xh%op(u_res, gs_op_add)
643 call gs_xh%op(v_res, gs_op_add)
644 call gs_xh%op(w_res, gs_op_add)
646 call bc_list_apply_vector(this%bclst_vel_res,&
647 u_res%x, v_res%x, w_res%x, dm_xh%size(),&
651 if (neko_bcknd_device .eq. 1)
then
652 call this%bc_field_dirichlet_u%apply_scalar_dev(u_res%x_d, t, tstep)
653 call this%bc_field_dirichlet_v%apply_scalar_dev(v_res%x_d, t, tstep)
654 call this%bc_field_dirichlet_w%apply_scalar_dev(w_res%x_d, t, tstep)
656 call this%bc_field_dirichlet_u%apply_scalar(u_res%x, this%dm_Xh%size(), t, tstep)
657 call this%bc_field_dirichlet_v%apply_scalar(v_res%x, this%dm_Xh%size(), t, tstep)
658 call this%bc_field_dirichlet_w%apply_scalar(w_res%x, this%dm_Xh%size(), t, tstep)
661 call profiler_end_region
663 call this%proj_u%pre_solving(u_res%x, tstep, c_xh, n, dt_controller)
664 call this%proj_v%pre_solving(v_res%x, tstep, c_xh, n, dt_controller)
665 call this%proj_w%pre_solving(w_res%x, tstep, c_xh, n, dt_controller)
667 call this%pc_vel%update()
669 call profiler_start_region(
"Velocity solve", 4)
670 ksp_results(2) = this%ksp_vel%solve(ax, du, u_res%x, n, &
671 c_xh, this%bclst_du, gs_xh)
672 ksp_results(3) = this%ksp_vel%solve(ax, dv, v_res%x, n, &
673 c_xh, this%bclst_dv, gs_xh)
674 ksp_results(4) = this%ksp_vel%solve(ax, dw, w_res%x, n, &
675 c_xh, this%bclst_dw, gs_xh)
676 call profiler_end_region
678 call this%proj_u%post_solving(du%x, ax, c_xh, &
679 this%bclst_du, gs_xh, n, tstep, dt_controller)
680 call this%proj_v%post_solving(dv%x, ax, c_xh, &
681 this%bclst_dv, gs_xh, n, tstep, dt_controller)
682 call this%proj_w%post_solving(dw%x, ax, c_xh, &
683 this%bclst_dw, gs_xh, n, tstep, dt_controller)
685 if (neko_bcknd_device .eq. 1)
then
686 call device_opadd2cm(u%x_d, v%x_d, w%x_d, &
687 du%x_d, dv%x_d, dw%x_d, 1.0_rp, n, msh%gdim)
689 call opadd2cm(u%x, v%x, w%x, du%x, dv%x, dw%x, 1.0_rp, n, msh%gdim)
692 if (this%forced_flow_rate)
then
693 call this%vol_flow%adjust( u, v, w, p, u_res, v_res, w_res, p_res, &
694 c_xh, gs_xh, ext_bdf, rho, mu,&
695 dt, this%bclst_dp, this%bclst_du, this%bclst_dv, &
696 this%bclst_dw, this%bclst_vel_res, ax, this%ksp_prs, &
697 this%ksp_vel, this%pc_prs, this%pc_vel, this%ksp_prs%max_iter, &
698 this%ksp_vel%max_iter)
701 call fluid_step_info(tstep, t, dt, ksp_results)
703 call this%scratch%relinquish_field(temp_indices)
706 call profiler_end_region
Copy data between host and device (or device and device)
Retrieves a parameter by name or throws an error.
Contains the factory routine for advection_t children.
subroutine, public advection_factory(this, json, coef)
A factory for advection_t decendants.
Subroutines to add advection terms to the RHS of a transport equation.
subroutine, public ax_helm_factory(Ax)
Factory routine for the a Helmholtz problem matrix-vector product. The selection is based on the comp...
Defines a Matrix-vector product.
Defines a boundary condition.
subroutine, public bc_list_add(bclst, bc)
Add a condition to a list of boundary conditions.
subroutine, public bc_list_apply_vector(bclst, x, y, z, n, t, tstep)
Apply a list of boundary conditions to a vector field.
subroutine, public bc_list_init(bclst, size)
Constructor for a list of boundary conditions.
subroutine, public bc_list_free(bclst)
Destructor for a list of boundary conditions.
subroutine, public bc_list_apply_scalar(bclst, x, n, t, tstep)
Apply a list of boundary conditions to a scalar field.
subroutine, public device_add2(a_d, b_d, n)
subroutine, public device_col2(a_d, b_d, n)
subroutine, public device_opadd2cm(a1_d, a2_d, a3_d, b1_d, b2_d, b3_d, c, n, gdim)
subroutine, public device_opcolv(a1_d, a2_d, a3_d, c_d, gdim, n)
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Defines a dirichlet boundary condition.
Dirichlet condition applied in the facet normal direction.
Auxiliary routines for fluid solvers.
subroutine, public fluid_step_info(step, t, dt, ksp_results)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
Modular version of the Classic Nek5000 Pn/Pn formulation for fluids.
subroutine fluid_pnpn_init(this, msh, lx, params, user, material_properties)
subroutine fluid_pnpn_step(this, t, tstep, dt, ext_bdf, dt_controller)
Advance fluid simulation in time.
subroutine fluid_pnpn_free(this)
subroutine fluid_pnpn_restart(this, dtlag, tlag)
Utilities for retrieving parameters from the case files.
Implements the base abstract type for Krylov solvers plus helper types.
type(log_t), public neko_log
Global log stream.
Implements material_properties_t type.
subroutine, public add2(a, b, n)
Vector addition .
subroutine, public col2(a, b, n)
Vector multiplication .
Collection of vector field operations operating on and . Note that in general the indices and ....
subroutine opcolv(a1, a2, a3, c, gdim, n)
subroutine opadd2cm(a1, a2, a3, b1, b2, b3, c, n, gdim)
integer, parameter neko_bcknd_device
Dirichlet condition on axis aligned plane in the non normal direction.
integer, parameter, public rp
Global precision used in computations.
Defines Pressure residual factory for the Pn-Pn formulation.
subroutine, public pnpn_prs_res_factory(prs_res)
subroutine, public pnpn_vel_res_factory(vel_res)
Defines Pressure and velocity residuals in the Pn-Pn formulation.
subroutine, public profiler_end_region
End the most recently started profiler region.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
Project x onto X, the space of old solutions and back again.
Fluid abbdf factory for the Pn-Pn formulation.
subroutine, public rhs_maker_ext_fctry(makeabf)
subroutine, public rhs_maker_sumab_fctry(sumab)
subroutine, public rhs_maker_bdf_fctry(makebdf)
Routines to generate the right-hand sides for the convection-diffusion equation. Employs the EXT/BDF ...
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Compound scheme for the advection and diffusion operators in a transport equation.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
Base abstract type for computing the advection operator.
Base type for a matrix-vector product providing .
A list of boundary conditions.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Generic Dirichlet boundary condition on .
Dirichlet condition in facet normal direction.
Base type of all fluid formulations.
Type for storing initial and final residuals in a Krylov solver.
Contains all the material properties necessary in the simulation.
Dirichlet condition in non normal direction of a plane.
Abstract type to compute pressure residual.
Abstract type to compute velocity residual.
Abstract type to add contributions to F from lagged BD terms.
Abstract type to sum up contributions to kth order extrapolation scheme.
Abstract type to compute extrapolated velocity field for the pressure equation.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
Provides a tool to set time step dt.