244 subroutine fluid_pnpn_init(this, msh, lx, params, user, chkp)
245 class(fluid_pnpn_t),
target,
intent(inout) :: this
246 type(
mesh_t),
target,
intent(inout) :: msh
247 integer,
intent(in) :: lx
248 type(json_file),
target,
intent(inout) :: params
249 type(
user_t),
target,
intent(in) :: user
250 type(
chkp_t),
target,
intent(inout) :: chkp
251 character(len=15),
parameter :: scheme =
'Modular (Pn/Pn)'
253 class(
bc_t),
pointer :: bc_i, vel_bc
254 real(kind=
rp) :: abs_tol
255 character(len=LOG_SIZE) :: log_buf
256 integer :: ierr, integer_val, solver_maxiter
257 character(len=:),
allocatable :: solver_type, precon_type
258 logical :: monitor, found
260 type(json_file) :: numerics_params, precon_params
262 real(kind=
dp),
pointer :: tlag(:), dtlag(:)
267 call this%init_base(msh, lx, params, scheme,
user, .true.)
279 allocate(this%ext_bdf)
280 call this%ext_bdf%init(integer_val)
283 this%full_stress_formulation, .false.)
287 call this%c_Xh%generate_cyclic_bc()
290 call fluid_pnpn_ax_vel_factory(this)
292 if (this%full_stress_formulation)
then
294 call pnpn_prs_res_stress_factory(this%prs_res)
297 call pnpn_vel_res_stress_factory(this%vel_res)
303 call pnpn_prs_res_factory(this%prs_res)
306 call pnpn_vel_res_factory(this%vel_res)
313 call this%bcs_vel_projector%init(this%c_Xh)
315 if (params%valid_path(
'case.fluid.nut_field'))
then
316 if (.not. this%full_stress_formulation)
then
317 call neko_error(
"You need to set full_stress_formulation to " // &
318 "true for the fluid to have a spatially varying " // &
321 call json_get(params,
'case.fluid.nut_field', this%nut_field_name)
323 this%nut_field_name =
""
327 call ax_helm_allocator(this%Ax_prs, type_name =
"standard")
331 call rhs_maker_sumab_fctry(this%sumab)
334 call rhs_maker_ext_fctry(this%makeabf)
337 call rhs_maker_bdf_fctry(this%makebdf)
340 call rhs_maker_oifs_fctry(this%makeoifs)
343 associate(xh_lx => this%Xh%lx, xh_ly => this%Xh%ly, xh_lz => this%Xh%lz, &
344 dm_xh => this%dm_Xh, nelv => this%msh%nelv)
346 call this%p_res%init(dm_xh,
"p_res")
347 call this%u_res%init(dm_xh,
"u_res")
348 call this%v_res%init(dm_xh,
"v_res")
349 call this%w_res%init(dm_xh,
"w_res")
350 call this%abx1%init(dm_xh,
"abx1")
351 call this%aby1%init(dm_xh,
"aby1")
352 call this%abz1%init(dm_xh,
"abz1")
353 call this%abx2%init(dm_xh,
"abx2")
354 call this%aby2%init(dm_xh,
"aby2")
355 call this%abz2%init(dm_xh,
"abz2")
356 call this%advx%init(dm_xh,
"advx")
357 call this%advy%init(dm_xh,
"advy")
358 call this%advz%init(dm_xh,
"advz")
361 call this%du%init(this%dm_Xh,
'du')
362 call this%dv%init(this%dm_Xh,
'dv')
363 call this%dw%init(this%dm_Xh,
'dw')
364 call this%dp%init(this%dm_Xh,
'dp')
366 call this%ale%init(this%c_Xh, params,
user, chkp)
368 call neko_log%section(
"Fluid boundary conditions")
370 call this%setup_bcs(
user, params)
374 if (found)
call this%write_boundary_conditions()
377 call this%proj_prs%init(this%dm_Xh%size(), this%pr_projection_dim, &
378 this%pr_projection_activ_step, &
379 this%pr_projection_reorthogonalize_basis)
381 call this%proj_vel%init(this%dm_Xh%size(), this%vel_projection_dim, &
382 this%vel_projection_activ_step)
388 if (params%valid_path(
'case.fluid.flow_rate_force'))
then
389 call this%vol_flow%init(this%dm_Xh, params)
393 call neko_log%section(
"Pressure solver")
396 'case.fluid.pressure_solver.max_iterations', &
398 call json_get(params,
'case.fluid.pressure_solver.type', solver_type)
399 call json_get(params,
'case.fluid.pressure_solver.preconditioner.type', &
402 'case.fluid.pressure_solver.preconditioner', precon_params)
404 'case.fluid.pressure_solver.absolute_tolerance', &
408 call neko_log%message(
'Type : ('// trim(solver_type) // &
409 ', ' // trim(precon_type) //
')')
410 write(log_buf,
'(A,ES13.6)')
'Abs tol :', abs_tol
413 call this%solver_factory(this%ksp_prs, this%dm_Xh%size(), &
414 solver_type, solver_maxiter, abs_tol, monitor)
415 call this%precon_factory_(this%pc_prs, this%ksp_prs, &
416 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs_prs, &
417 precon_type, precon_params)
425 call json_get(params,
'case.numerics', numerics_params)
426 call chkp%get_time_history(tlag, dtlag)
427 call advection_factory(this%adv, numerics_params, this%c_Xh, &
428 this%ulag, this%vlag, this%wlag, &
429 dtlag, tlag, this%ext_bdf, &
434 payload => this%chkp%add_payload(
"fluid")
435 call payload%add_field(this%u)
436 call payload%add_field(this%v)
437 call payload%add_field(this%w)
438 call payload%add_field(this%p)
439 call payload%add_field(this%abx1)
440 call payload%add_field(this%abx2)
441 call payload%add_field(this%aby1)
442 call payload%add_field(this%aby2)
443 call payload%add_field(this%abz1)
444 call payload%add_field(this%abz2)
445 call payload%add_series(this%ulag)
446 call payload%add_series(this%vlag)
447 call payload%add_series(this%wlag)
451 this%schwarz_iterations, 0)
455 nullify(bc_i, vel_bc)
488 subroutine fluid_pnpn_restart(this, chkp)
489 class(fluid_pnpn_t),
target,
intent(inout) :: this
490 type(chkp_t),
intent(inout) :: chkp
492 class(bc_t),
pointer :: bc_i
494 n = this%u%dof%size()
495 if (
allocated(chkp%previous_mesh%elements) .or. &
496 chkp%previous_Xh%lx .ne. this%Xh%lx)
then
497 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
498 c_xh => this%c_Xh, ulag => this%ulag, vlag => this%vlag, &
500 do concurrent(j = 1:n)
501 u%x(j,1,1,1) = u%x(j,1,1,1) * c_xh%mult(j,1,1,1)
502 v%x(j,1,1,1) = v%x(j,1,1,1) * c_xh%mult(j,1,1,1)
503 w%x(j,1,1,1) = w%x(j,1,1,1) * c_xh%mult(j,1,1,1)
504 p%x(j,1,1,1) = p%x(j,1,1,1) * c_xh%mult(j,1,1,1)
506 do i = 1, this%ulag%size()
507 do concurrent(j = 1:n)
508 ulag%lf(i)%x(j,1,1,1) = ulag%lf(i)%x(j,1,1,1) &
510 vlag%lf(i)%x(j,1,1,1) = vlag%lf(i)%x(j,1,1,1) &
512 wlag%lf(i)%x(j,1,1,1) = wlag%lf(i)%x(j,1,1,1) &
519 if (neko_bcknd_device .eq. 1)
then
520 associate(u => this%u, v => this%v, w => this%w, &
521 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag,&
523 call device_memcpy(u%x, u%x_d, u%dof%size(), &
524 host_to_device, sync = .false.)
525 call device_memcpy(v%x, v%x_d, v%dof%size(), &
526 host_to_device, sync = .false.)
527 call device_memcpy(w%x, w%x_d, w%dof%size(), &
528 host_to_device, sync = .false.)
529 call device_memcpy(p%x, p%x_d, p%dof%size(), &
530 host_to_device, sync = .false.)
531 call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, &
532 u%dof%size(), host_to_device, sync = .false.)
533 call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, &
534 u%dof%size(), host_to_device, sync = .false.)
536 call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, &
537 v%dof%size(), host_to_device, sync = .false.)
538 call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, &
539 v%dof%size(), host_to_device, sync = .false.)
541 call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, &
542 w%dof%size(), host_to_device, sync = .false.)
543 call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, &
544 w%dof%size(), host_to_device, sync = .false.)
545 call device_memcpy(this%abx1%x, this%abx1%x_d, &
546 w%dof%size(), host_to_device, sync = .false.)
547 call device_memcpy(this%abx2%x, this%abx2%x_d, &
548 w%dof%size(), host_to_device, sync = .false.)
549 call device_memcpy(this%aby1%x, this%aby1%x_d, &
550 w%dof%size(), host_to_device, sync = .false.)
551 call device_memcpy(this%aby2%x, this%aby2%x_d, &
552 w%dof%size(), host_to_device, sync = .false.)
553 call device_memcpy(this%abz1%x, this%abz1%x_d, &
554 w%dof%size(), host_to_device, sync = .false.)
555 call device_memcpy(this%abz2%x, this%abz2%x_d, &
556 w%dof%size(), host_to_device, sync = .false.)
557 call device_memcpy(this%advx%x, this%advx%x_d, &
558 w%dof%size(), host_to_device, sync = .false.)
559 call device_memcpy(this%advy%x, this%advy%x_d, &
560 w%dof%size(), host_to_device, sync = .false.)
561 call device_memcpy(this%advz%x, this%advz%x_d, &
562 w%dof%size(), host_to_device, sync = .false.)
569 if (
allocated(chkp%previous_mesh%elements) &
570 .or. chkp%previous_Xh%lx .ne. this%Xh%lx)
then
572 call rotate_cyc(this%u, this%v, this%w, 1, this%c_Xh)
573 call this%gs_Xh%op(this%u, gs_op_add)
574 call this%gs_Xh%op(this%v, gs_op_add)
575 call this%gs_Xh%op(this%w, gs_op_add)
576 call this%gs_Xh%op(this%p, gs_op_add)
577 call rotate_cyc(this%u, this%v, this%w, 0, this%c_Xh)
579 do i = 1, this%ulag%size()
580 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
581 this%wlag%lf(i), 1, this%c_Xh)
582 call this%gs_Xh%op(this%ulag%lf(i), gs_op_add)
583 call this%gs_Xh%op(this%vlag%lf(i), gs_op_add)
584 call this%gs_Xh%op(this%wlag%lf(i), gs_op_add)
585 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
586 this%wlag%lf(i), 0, this%c_Xh)
590 call this%ale%sync_chkp(this%c_Xh, this%Xh, this%adv, chkp, this%gs_Xh)
591 if (this%ale%active)
then
592 call this%bc_prs_surface%recompute_normals()
593 call this%bc_sym_surface%recompute_normals()
597 do i = 1, this%bcs_vel%size()
598 bc_i => this%bcs_vel%get(i)
599 call bc_i%restart(this%u, this%v, this%w, &
600 this%ulag, this%vlag, this%wlag)
604 do i = 1, this%bcs_prs%size()
605 bc_i => this%bcs_prs%get(i)
606 call bc_i%restart(this%p)
711 subroutine fluid_pnpn_step(this, time, dt_controller)
712 class(fluid_pnpn_t),
target,
intent(inout) :: this
713 type(time_state_t),
intent(in) :: time
714 type(time_step_controller_t),
intent(in) :: dt_controller
718 type(ksp_monitor_t) :: ksp_results(4)
721 type(file_t) :: dump_file
722 class(bc_t),
pointer :: bc_i
724 if (this%freeze)
return
726 n = this%dm_Xh%size()
728 call profiler_start_region(
'Fluid', 1)
729 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
730 u_e => this%u_e, v_e => this%v_e, w_e => this%w_e, &
731 du => this%du, dv => this%dv, dw => this%dw, dp => this%dp, &
732 u_res => this%u_res, v_res => this%v_res, w_res => this%w_res, &
733 p_res => this%p_res, ax_vel => this%Ax_vel, ax_prs => this%Ax_prs, &
735 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
736 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
737 msh => this%msh, prs_res => this%prs_res, &
738 source_term => this%source_term, vel_res => this%vel_res, &
739 sumab => this%sumab, makeoifs => this%makeoifs, &
740 makeabf => this%makeabf, makebdf => this%makebdf, &
741 vel_projection_dim => this%vel_projection_dim, &
742 pr_projection_dim => this%pr_projection_dim, &
744 rho => this%rho, mu_tot => this%mu_tot, &
745 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
746 t => time%t, tstep => time%tstep, dt => time%dt, &
747 ext_bdf => this%ext_bdf, event => glb_cmd_event, &
751 call sumab%compute_fluid(u_e, v_e, w_e, u, v, w, &
752 ulag, vlag, wlag, ext_bdf%advection_coeffs%x, ext_bdf%nadv)
755 call this%source_term%compute(time)
758 call this%bcs_vel%apply_vector(f_x%x, f_y%x, f_z%x, &
759 this%dm_Xh%size(), time, strong = .false.)
761 if (this%ale%active)
then
763 call neko_error(
"ALE is not yet supported " // &
764 "with OIFS time integration.")
767 call this%adv%compute_ale(u, v, w, &
768 ale%wm_x, ale%wm_y, ale%wm_z, &
770 xh, c_xh, dm_xh%size())
776 call this%adv%compute(u, v, w, &
777 this%advx, this%advy, this%advz, &
778 xh, this%c_Xh, dm_xh%size(),
real(dt, kind=rp))
785 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
786 this%abx2, this%aby2, this%abz2, &
787 f_x%x, f_y%x, f_z%x, &
788 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
792 call makeoifs%compute_fluid(this%advx%x, this%advy%x, this%advz%x, &
793 f_x%x, f_y%x, f_z%x, &
794 rho%x(1,1,1,1),
real(dt, kind=rp), n)
797 call this%adv%compute(u, v, w, &
799 xh, this%c_Xh, dm_xh%size())
806 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
807 this%abx2, this%aby2, this%abz2, &
808 f_x%x, f_y%x, f_z%x, &
809 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
815 call makebdf%compute_fluid(ulag, vlag, wlag, f_x%x, f_y%x, f_z%x, &
816 u, v, w, c_xh%B, c_xh%Blag, c_xh%Blaglag, rho%x(1,1,1,1), &
818 ext_bdf%diffusion_coeffs%x, ext_bdf%ndiff, n)
822 if (this%ale%active)
then
824 call this%ale%advance_mesh(c_xh, time, ext_bdf%nadv)
826 call profiler_start_region(
'ALE recompute metrics')
828 call c_xh%recompute_metrics()
831 call this%adv%recompute_metrics(c_xh, .true.)
833 call this%bc_prs_surface%recompute_normals()
834 call this%bc_sym_surface%recompute_normals()
835 call profiler_end_region(
'ALE recompute metrics')
843 call this%update_material_properties(time)
846 if (this%svv_enabled)
then
847 call this%svv%update(rho, tstep)
850 do iter = 1, 1 + this%schwarz_iterations
852 call this%bc_apply_vel(time, strong = .true.)
853 call this%bc_apply_prs(time)
856 call profiler_start_region(
'Pressure_residual', 18)
857 call prs_res%compute(p, p_res,&
862 this%bc_prs_surface, this%bc_sym_surface,&
863 ax_prs, ext_bdf%diffusion_coeffs%x(1),
real(dt, kind=rp), &
868 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1)
then
869 call device_ortho(p_res%x_d, this%glb_n_points, n)
870 else if (.not. this%prs_dirichlet)
then
871 call ortho(p_res%x, this%glb_n_points, n)
874 call gs_xh%op(p_res, gs_op_add, event)
875 call device_event_sync(event)
878 call this%bcs_prs_projector%apply(p_res%x, p%dof%size())
881 call profiler_end_region(
'Pressure_residual', 18)
885 if (iter .eq. 1)
then
886 call this%proj_prs%pre_solving(p_res%x, tstep, c_xh, n, &
887 dt_controller, ax = ax_prs, gs_h = gs_xh, &
888 bclst = this%bcs_prs_projector, string =
'Pressure')
891 call this%pc_prs%update()
893 call profiler_start_region(
'Pressure_solve', 3)
897 this%ksp_prs%solve(ax_prs, dp, p_res%x, n, c_xh, &
898 this%bcs_prs_projector, gs_xh)
899 ksp_results(1)%name =
'Pressure'
902 call profiler_end_region(
'Pressure_solve', 3)
904 if (iter .eq. 1)
then
905 call this%proj_prs%post_solving(dp%x, ax_prs, c_xh, &
906 this%bcs_prs_projector, gs_xh, n, tstep, dt_controller)
910 call field_add2(p, dp, n)
911 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1)
then
912 call device_ortho(p%x_d, this%glb_n_points, n)
913 else if (.not. this%prs_dirichlet)
then
914 call ortho(p%x, this%glb_n_points, n)
918 call profiler_start_region(
'Velocity_residual', 19)
919 call vel_res%compute(ax_vel, u, v, w, &
920 u_res, v_res, w_res, &
924 mu_tot, rho, ext_bdf%diffusion_coeffs%x(1), &
925 real(dt, kind=rp), dm_xh%size())
927 call rotate_cyc(u_res, v_res, w_res, 1, c_xh)
928 call gs_xh%op(u_res%x, v_res%x, w_res%x, dm_xh%size(), &
930 call device_event_sync(event)
931 call rotate_cyc(u_res, v_res, w_res, 0, c_xh)
934 call this%bcs_vel_projector%apply(u_res%x, v_res%x, w_res%x, &
938 call profiler_end_region(
'Velocity_residual', 19)
940 if (iter .eq. 1)
then
941 call this%proj_vel%pre_solving(u_res%x, v_res%x, w_res%x, &
942 tstep, c_xh, n, dt_controller,
'Velocity')
945 call this%pc_vel%update()
947 call profiler_start_region(
"Velocity_solve", 4)
948 ksp_results(2:4) = this%ksp_vel%solve_coupled(ax_vel, du, dv, dw, &
949 u_res%x, v_res%x, w_res%x, n, c_xh, &
950 this%bcs_vel_projector, gs_xh, &
951 this%ksp_vel%max_iter)
952 call profiler_end_region(
"Velocity_solve", 4)
953 if (this%full_stress_formulation)
then
954 ksp_results(2)%name =
'Momentum'
956 ksp_results(2)%name =
'X-Velocity'
957 ksp_results(3)%name =
'Y-Velocity'
958 ksp_results(4)%name =
'Z-Velocity'
961 if (iter .eq. 1)
then
962 call this%proj_vel%post_solving(du%x, dv%x, dw%x, ax_vel, c_xh, &
963 this%bcs_vel_projector, gs_xh, n, tstep, &
967 if (neko_bcknd_device .eq. 1)
then
968 call device_opadd2cm(u%x_d, v%x_d, w%x_d, &
969 du%x_d, dv%x_d, dw%x_d, 1.0_rp, n, msh%gdim)
971 call opadd2cm(u%x, v%x, w%x, du%x, dv%x, dw%x, 1.0_rp, n, msh%gdim)
974 call fluid_step_info(time, ksp_results, &
975 this%full_stress_formulation, this%strict_convergence, &
976 this%allow_stabilization, iter)
980 if (this%forced_flow_rate)
then
982 call this%vol_flow%adjust( u, v, w, p, u_res, v_res, w_res, p_res, &
983 c_xh, gs_xh, ext_bdf, rho%x(1,1,1,1), mu_tot, &
984 real(dt, kind=rp), time, this%bcs_prs_projector, &
985 this%bcs_vel_projector, ax_vel, ax_prs, this%ksp_prs, &
986 this%ksp_vel, this%pc_prs, this%pc_vel, this%ksp_prs%max_iter, &
987 this%ksp_vel%max_iter)
993 call this%ale%update_mesh_velocity(c_xh, time)
999 call profiler_end_region(
'Fluid', 1)
1004 subroutine fluid_pnpn_setup_bcs(this, user, params)
1005 class(fluid_pnpn_t),
target,
intent(inout) :: this
1006 type(user_t),
target,
intent(in) :: user
1007 type(json_file),
intent(inout) :: params
1008 integer :: i, n_bcs, zone_index, j, zone_size, global_zone_size, ierr
1009 class(bc_t),
pointer :: bc_i
1010 type(json_core) :: core
1011 type(json_value),
pointer :: bc_object
1012 type(json_file) :: bc_subdict
1013 logical :: ale_active_local, any_moving_wall, moving_
1016 logical,
allocatable :: marked_zones(:)
1017 integer,
allocatable :: zone_indices(:)
1018 character(len=256) :: error_msg
1021 character(len=:),
allocatable :: bc_type_str
1022 this%ale%has_moving_boundary = .false.
1023 any_moving_wall = .false.
1024 ale_active_local = .false.
1025 call json_get_or_default(params,
'case.fluid.ale.enabled', &
1026 ale_active_local, .false.)
1029 call this%bc_prs_surface%init_from_components(this%c_Xh)
1030 call this%bc_sym_surface%init_from_components(this%c_Xh)
1033 if (params%valid_path(
'case.fluid.boundary_conditions'))
then
1034 call params%info(
'case.fluid.boundary_conditions', n_children = n_bcs)
1035 call params%get_core(core)
1036 call params%get(
'case.fluid.boundary_conditions', bc_object, found)
1041 call this%bcs_vel%init(n_bcs)
1043 allocate(marked_zones(
size(this%msh%labeled_zones)))
1044 marked_zones = .false.
1048 call json_extract_item(core, bc_object, i, bc_subdict)
1050 call json_get_or_lookup(bc_subdict,
"zone_indices", zone_indices)
1053 call json_get(bc_subdict,
"type", bc_type_str)
1055 if (trim(bc_type_str) .eq.
"no_slip")
then
1056 call json_get_or_default(bc_subdict,
"moving", moving_, .false.)
1059 this%ale%has_moving_boundary = .true.
1065 do j = 1,
size(zone_indices)
1066 zone_size = this%msh%labeled_zones(zone_indices(j))%size
1067 call mpi_allreduce(zone_size, global_zone_size, 1, &
1068 mpi_integer, mpi_max, neko_comm, ierr)
1070 if (global_zone_size .eq. 0)
then
1071 write(error_msg,
'(A, I0, A, A, I0, A)') &
1072 "Zone index ", zone_indices(j), &
1073 " is invalid as this zone has 0 size, meaning it ", &
1074 "is not in the mesh. Check fluid boundary condition ", &
1076 call neko_error(error_msg)
1079 if (marked_zones(zone_indices(j)))
then
1080 write(error_msg,
'(A, I0, A, A, A, A)') &
1081 "Zone with index ", zone_indices(j), &
1082 " has already been assigned a boundary condition. ", &
1083 "Please check your boundary_conditions entry for the ", &
1084 "fluid and make sure that each zone index appears only ", &
1085 "in a single boundary condition."
1086 call neko_error(error_msg)
1088 marked_zones(zone_indices(j)) = .true.
1093 call velocity_bc_factory(bc_i, this, bc_subdict, this%c_Xh,
user)
1097 if (
associated(bc_i))
then
1100 type is (symmetry_aligned_t)
1105 call this%bcs_vel_projector%mark(bc_i%bc_x, component =
'x')
1106 call this%bcs_vel_projector%mark(bc_i%bc_y, component =
'y')
1107 call this%bcs_vel_projector%mark(bc_i%bc_z, component =
'z')
1108 call this%bcs_vel%append(bc_i)
1109 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1110 type is (symmetry_t)
1113 if (.not. this%full_stress_formulation)
then
1114 call neko_error(
"The symmetry boundary condition " // &
1115 "requires the full stress formulation to be enabled.")
1117 call this%bcs_vel_projector%mark(bc_i)
1118 call this%bcs_vel%append(bc_i)
1119 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1120 type is (non_normal_aligned_t)
1122 call this%bcs_vel_projector%mark(bc_i%bc_x, component =
'x')
1123 call this%bcs_vel_projector%mark(bc_i%bc_y, component =
'y')
1124 call this%bcs_vel_projector%mark(bc_i%bc_z, component =
'z')
1125 call this%bcs_vel%append(bc_i)
1126 type is (non_normal_t)
1127 call this%bcs_vel_projector%mark(bc_i)
1128 call this%bcs_vel%append(bc_i)
1129 type is (shear_stress_t)
1130 if (.not. this%full_stress_formulation)
then
1131 call neko_error(
"The shear_stress boundary condition " // &
1132 "requires the full stress formulation to be enabled.")
1134 call this%bcs_vel_projector%mark(bc_i)
1135 call this%bcs_vel%append(bc_i)
1136 type is (wall_model_bc_t)
1137 if (.not. this%full_stress_formulation)
then
1138 call neko_error(
"The wall_model boundary condition " // &
1139 "requires the full stress formulation to be enabled.")
1141 call this%bcs_vel_projector%mark(bc_i)
1142 call this%bcs_vel%append(bc_i)
1146 if (bc_i%bc_type .eq. bc_dirichlet)
then
1147 call this%bc_prs_surface%mark_labeled_zones( &
1149 if (this%full_stress_formulation)
then
1150 call this%bcs_vel_projector%mark(bc_i)
1152 call this%bcs_vel_projector%mark(bc_i, component =
'x')
1153 call this%bcs_vel_projector%mark(bc_i, component =
'y')
1154 call this%bcs_vel_projector%mark(bc_i, component =
'z')
1158 call this%bcs_vel%append(bc_i)
1163 if (this%ale%active .and. (.not. this%ale%has_moving_boundary))
then
1164 call neko_error(
"Case file error: ALE is active, " // &
1165 "but no moving wall was found. " // &
1166 "Use type = 'no_slip' with 'moving': true in case file.")
1170 do i = 1,
size(this%msh%labeled_zones)
1171 if ((this%msh%labeled_zones(i)%size .gt. 0) .and. &
1172 (.not. marked_zones(i)))
then
1173 write(error_msg,
'(A, I0)') &
1174 "No fluid boundary condition assigned to zone ", i
1175 call neko_error(error_msg)
1182 call this%bcs_prs%init(n_bcs)
1186 call json_extract_item(core, bc_object, i, bc_subdict)
1188 call pressure_bc_factory(bc_i, this, bc_subdict, this%c_Xh,
user)
1192 if (
associated(bc_i))
then
1193 call this%bcs_prs%append(bc_i)
1196 if (bc_i%bc_type .eq. bc_dirichlet)
then
1197 call this%bcs_prs_projector%mark(bc_i)
1205 do i = 1,
size(this%msh%labeled_zones)
1206 if (this%msh%labeled_zones(i)%size .gt. 0)
then
1207 call neko_error(
"No boundary_conditions entry in the case file!")
1213 call this%bcs_vel%init()
1214 call this%bcs_prs%init()
1218 call this%bc_prs_surface%finalize()
1219 call this%bc_sym_surface%finalize()
1220 call this%bcs_vel_projector%finalize(rebuild_mask = .true.)
1223 this%prs_dirichlet = this%bcs_prs_projector%dof_mask%is_set()
1224 call mpi_allreduce(mpi_in_place, this%prs_dirichlet, 1, &
1225 mpi_logical, mpi_lor, neko_comm)
1228 if (
allocated(marked_zones))
then
1229 deallocate(marked_zones)
1232 if (
allocated(zone_indices))
then
1233 deallocate(zone_indices)
1236 nullify(bc_i, bc_object)
1241 subroutine fluid_pnpn_write_boundary_conditions(this)
1248 class(fluid_pnpn_t),
target,
intent(inout) :: this
1249 type(dirichlet_t) :: bdry_mask
1250 type(field_t),
pointer :: bdry_field
1251 type(file_t) :: bdry_file
1252 integer :: temp_index, i
1253 class(bc_t),
pointer :: bci
1254 character(len=LOG_SIZE) :: log_buf
1256 write(log_buf,
'(A)')
'Marking using integer keys in bdry0.f00000'
1257 call neko_log%message(log_buf)
1258 write(log_buf,
'(A)')
'Condition-value pairs: '
1259 call neko_log%message(log_buf)
1260 write(log_buf,
'(A)')
' no_slip (stationary wall) = 1'
1261 call neko_log%message(log_buf)
1262 write(log_buf,
'(A)')
' velocity_value = 2'
1263 call neko_log%message(log_buf)
1264 write(log_buf,
'(A)')
' outflow, normal_outflow (+dong) = 3'
1265 call neko_log%message(log_buf)
1266 write(log_buf,
'(A)')
' symmetry = 4'
1267 call neko_log%message(log_buf)
1268 write(log_buf,
'(A)')
' periodic = 6'
1269 call neko_log%message(log_buf)
1270 write(log_buf,
'(A)')
' user_velocity = 7'
1271 call neko_log%message(log_buf)
1272 write(log_buf,
'(A)')
' user_pressure = 8'
1273 call neko_log%message(log_buf)
1274 write(log_buf,
'(A)')
' shear_stress = 9'
1275 call neko_log%message(log_buf)
1276 write(log_buf,
'(A)')
' wall_modelling = 10'
1277 call neko_log%message(log_buf)
1278 write(log_buf,
'(A)')
' blasius_profile = 11'
1279 call neko_log%message(log_buf)
1280 write(log_buf,
'(A)')
' no_slip (moving wall) = 12'
1281 call neko_log%message(log_buf)
1283 call neko_scratch_registry%request_field(bdry_field, temp_index, .true.)
1287 call bdry_mask%init_from_components(this%c_Xh, 6.0_rp)
1288 call bdry_mask%mark_zone(this%msh%periodic)
1289 call bdry_mask%finalize()
1290 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1291 call bdry_mask%free()
1293 do i = 1, this%bcs_prs%size()
1294 bci => this%bcs_prs%get(i)
1295 select type (
bc => bci)
1296 type is (zero_dirichlet_t)
1297 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1298 call bdry_mask%mark_facets(bci%marked_facet)
1299 call bdry_mask%finalize()
1300 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1301 call bdry_mask%free()
1303 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1304 call bdry_mask%mark_facets(bci%marked_facet)
1305 call bdry_mask%finalize()
1306 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1307 call bdry_mask%free()
1309 call bdry_mask%init_from_components(this%c_Xh, 8.0_rp)
1310 call bdry_mask%mark_facets(bci%marked_facet)
1311 call bdry_mask%finalize()
1312 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1313 call bdry_mask%free()
1317 do i = 1, this%bcs_vel%size()
1318 bci => this%bcs_vel%get(i)
1319 select type (
bc => bci)
1321 if (
bc%is_moving)
then
1323 call bdry_mask%init_from_components(this%c_Xh, 12.0_rp)
1326 call bdry_mask%init_from_components(this%c_Xh, 1.0_rp)
1328 call bdry_mask%mark_facets(bci%marked_facet)
1329 call bdry_mask%finalize()
1330 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1331 call bdry_mask%free()
1333 call bdry_mask%init_from_components(this%c_Xh, 2.0_rp)
1334 call bdry_mask%mark_facets(bci%marked_facet)
1335 call bdry_mask%finalize()
1336 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1337 call bdry_mask%free()
1338 type is (symmetry_aligned_t)
1339 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1340 call bdry_mask%mark_facets(bci%marked_facet)
1341 call bdry_mask%finalize()
1342 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1343 call bdry_mask%free()
1344 type is (symmetry_t)
1345 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1346 call bdry_mask%mark_facets(bci%marked_facet)
1347 call bdry_mask%finalize()
1348 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1349 call bdry_mask%free()
1351 call bdry_mask%init_from_components(this%c_Xh, 7.0_rp)
1352 call bdry_mask%mark_facets(bci%marked_facet)
1353 call bdry_mask%finalize()
1354 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1355 call bdry_mask%free()
1356 type is (shear_stress_t)
1357 call bdry_mask%init_from_components(this%c_Xh, 9.0_rp)
1358 call bdry_mask%mark_facets(bci%marked_facet)
1359 call bdry_mask%finalize()
1360 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1361 call bdry_mask%free()
1362 type is (wall_model_bc_t)
1363 call bdry_mask%init_from_components(this%c_Xh, 10.0_rp)
1364 call bdry_mask%mark_facets(bci%marked_facet)
1365 call bdry_mask%finalize()
1366 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1367 call bdry_mask%free()
1369 call bdry_mask%init_from_components(this%c_Xh, 11.0_rp)
1370 call bdry_mask%mark_facets(bci%marked_facet)
1371 call bdry_mask%finalize()
1372 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1373 call bdry_mask%free()
1378 call bdry_file%init(
'bdry.fld')
1379 call bdry_file%write(bdry_field)
1381 call neko_scratch_registry%relinquish_field(temp_index)
1383 nullify(bdry_field, bci)