350 subroutine fluid_pnpn_init(this, msh, lx, params, user, chkp)
351 class(fluid_pnpn_t),
target,
intent(inout) :: this
352 type(
mesh_t),
target,
intent(inout) :: msh
353 integer,
intent(in) :: lx
354 type(json_file),
target,
intent(inout) :: params
355 type(
user_t),
target,
intent(in) :: user
356 type(
chkp_t),
target,
intent(inout) :: chkp
357 character(len=15),
parameter :: scheme =
'Modular (Pn/Pn)'
359 class(
bc_t),
pointer :: bc_i, vel_bc
360 real(kind=
rp) :: abs_tol
361 character(len=LOG_SIZE) :: log_buf
362 integer :: ierr, integer_val
363 character(len=:),
allocatable :: solver_type, precon_type
366 type(json_file) :: numerics_params, precon_params, solver_params
368 real(kind=
dp),
pointer :: tlag(:), dtlag(:)
373 call this%init_base(msh, lx, params, scheme,
user, .true.)
385 allocate(this%ext_bdf)
386 call this%ext_bdf%init(integer_val)
389 this%full_stress_formulation, .false.)
393 call this%c_Xh%generate_cyclic_bc()
396 call fluid_pnpn_ax_vel_factory(this)
398 if (this%full_stress_formulation)
then
400 call pnpn_prs_res_stress_factory(this%prs_res)
403 call pnpn_vel_res_stress_factory(this%vel_res)
409 call pnpn_prs_res_factory(this%prs_res)
412 call pnpn_vel_res_factory(this%vel_res)
419 call this%bcs_vel_projector%init(this%c_Xh)
421 if (params%valid_path(
'case.fluid.nut_field'))
then
422 if (.not. this%full_stress_formulation)
then
423 call neko_error(
"You need to set full_stress_formulation to " // &
424 "true for the fluid to have a spatially varying " // &
427 call json_get(params,
'case.fluid.nut_field', this%nut_field_name)
429 this%nut_field_name =
""
433 if (this%c_Xh%geo_compression)
then
434 call ax_helm_allocator(this%Ax_prs, type_name =
"standard_compr")
436 call ax_helm_allocator(this%Ax_prs, type_name =
"standard")
441 call rhs_maker_sumab_fctry(this%sumab)
444 call rhs_maker_ext_fctry(this%makeabf)
447 call rhs_maker_bdf_fctry(this%makebdf)
450 call rhs_maker_oifs_fctry(this%makeoifs)
453 associate(xh_lx => this%Xh%lx, xh_ly => this%Xh%ly, xh_lz => this%Xh%lz, &
454 dm_xh => this%dm_Xh, nelv => this%msh%nelv)
456 call this%p_res%init(dm_xh,
"p_res")
457 call this%u_res%init(dm_xh,
"u_res")
458 call this%v_res%init(dm_xh,
"v_res")
459 call this%w_res%init(dm_xh,
"w_res")
460 call this%abx1%init(dm_xh,
"abx1")
461 call this%aby1%init(dm_xh,
"aby1")
462 call this%abz1%init(dm_xh,
"abz1")
463 call this%abx2%init(dm_xh,
"abx2")
464 call this%aby2%init(dm_xh,
"aby2")
465 call this%abz2%init(dm_xh,
"abz2")
466 call this%advx%init(dm_xh,
"advx")
467 call this%advy%init(dm_xh,
"advy")
468 call this%advz%init(dm_xh,
"advz")
471 call this%du%init(this%dm_Xh,
'du')
472 call this%dv%init(this%dm_Xh,
'dv')
473 call this%dw%init(this%dm_Xh,
'dw')
474 call this%dp%init(this%dm_Xh,
'dp')
476 call this%ale%init(this%c_Xh, params,
user, chkp)
478 call neko_log%section(
"Fluid boundary conditions")
480 call this%setup_bcs(
user, params)
484 if (found)
call this%write_boundary_conditions()
487 call this%proj_prs%init(this%dm_Xh%size(), this%pr_projection_dim, &
488 this%pr_projection_activ_step, &
489 this%pr_projection_reorthogonalize_basis)
491 call this%proj_vel%init(this%dm_Xh%size(), this%vel_projection_dim, &
492 this%vel_projection_activ_step)
498 if (params%valid_path(
'case.fluid.flow_rate_force'))
then
499 call this%vol_flow%init(this%dm_Xh, params)
503 call neko_log%section(
"Pressure solver")
505 call json_get(params,
'case.fluid.pressure_solver', solver_params)
506 call json_get(params,
'case.fluid.pressure_solver.type', solver_type)
507 call json_get(params,
'case.fluid.pressure_solver.preconditioner.type', &
510 'case.fluid.pressure_solver.preconditioner', precon_params)
512 'case.fluid.pressure_solver.absolute_tolerance', &
514 call neko_log%message(
'Type : ('// trim(solver_type) // &
515 ', ' // trim(precon_type) //
')')
516 write(log_buf,
'(A,ES13.6)')
'Abs tol :', abs_tol
519 call this%solver_factory(this%ksp_prs, this%dm_Xh%size(), solver_params)
520 call this%precon_factory_(this%pc_prs, this%ksp_prs, &
521 this%c_Xh, this%bcs_prs, &
522 precon_type, precon_params)
530 call json_get(params,
'case.numerics', numerics_params)
531 call chkp%get_time_history(tlag, dtlag)
532 call advection_factory(this%adv, numerics_params, this%c_Xh, &
533 this%ulag, this%vlag, this%wlag, &
534 dtlag, tlag, this%ext_bdf, &
539 payload => this%chkp%add_payload(
"fluid")
540 call payload%add_field(this%u)
541 call payload%add_field(this%v)
542 call payload%add_field(this%w)
543 call payload%add_field(this%p)
544 call payload%add_field(this%abx1)
545 call payload%add_field(this%abx2)
546 call payload%add_field(this%aby1)
547 call payload%add_field(this%aby2)
548 call payload%add_field(this%abz1)
549 call payload%add_field(this%abz2)
550 call payload%add_series(this%ulag)
551 call payload%add_series(this%vlag)
552 call payload%add_series(this%wlag)
556 this%schwarz_iterations, 0)
560 nullify(bc_i, vel_bc)
596 subroutine fluid_pnpn_restart(this, chkp)
597 class(fluid_pnpn_t),
target,
intent(inout) :: this
598 type(chkp_t),
intent(inout) :: chkp
600 class(bc_t),
pointer :: bc_i
602 n = this%u%dof%size()
603 if (
allocated(chkp%previous_mesh%elements) .or. &
604 chkp%previous_Xh%lx .ne. this%Xh%lx)
then
605 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
606 c_xh => this%c_Xh, ulag => this%ulag, vlag => this%vlag, &
608 do concurrent(j = 1:n)
609 u%x(j,1,1,1) = u%x(j,1,1,1) * c_xh%mult(j,1,1,1)
610 v%x(j,1,1,1) = v%x(j,1,1,1) * c_xh%mult(j,1,1,1)
611 w%x(j,1,1,1) = w%x(j,1,1,1) * c_xh%mult(j,1,1,1)
612 p%x(j,1,1,1) = p%x(j,1,1,1) * c_xh%mult(j,1,1,1)
614 do i = 1, this%ulag%size()
615 do concurrent(j = 1:n)
616 ulag%lf(i)%x(j,1,1,1) = ulag%lf(i)%x(j,1,1,1) &
618 vlag%lf(i)%x(j,1,1,1) = vlag%lf(i)%x(j,1,1,1) &
620 wlag%lf(i)%x(j,1,1,1) = wlag%lf(i)%x(j,1,1,1) &
627 if (neko_bcknd_device .eq. 1)
then
628 associate(u => this%u, v => this%v, w => this%w, &
629 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag,&
631 call device_memcpy(u%x, u%x_d, u%dof%size(), &
632 host_to_device, sync = .false.)
633 call device_memcpy(v%x, v%x_d, v%dof%size(), &
634 host_to_device, sync = .false.)
635 call device_memcpy(w%x, w%x_d, w%dof%size(), &
636 host_to_device, sync = .false.)
637 call device_memcpy(p%x, p%x_d, p%dof%size(), &
638 host_to_device, sync = .false.)
639 call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, &
640 u%dof%size(), host_to_device, sync = .false.)
641 call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, &
642 u%dof%size(), host_to_device, sync = .false.)
644 call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, &
645 v%dof%size(), host_to_device, sync = .false.)
646 call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, &
647 v%dof%size(), host_to_device, sync = .false.)
649 call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, &
650 w%dof%size(), host_to_device, sync = .false.)
651 call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, &
652 w%dof%size(), host_to_device, sync = .false.)
653 call device_memcpy(this%abx1%x, this%abx1%x_d, &
654 w%dof%size(), host_to_device, sync = .false.)
655 call device_memcpy(this%abx2%x, this%abx2%x_d, &
656 w%dof%size(), host_to_device, sync = .false.)
657 call device_memcpy(this%aby1%x, this%aby1%x_d, &
658 w%dof%size(), host_to_device, sync = .false.)
659 call device_memcpy(this%aby2%x, this%aby2%x_d, &
660 w%dof%size(), host_to_device, sync = .false.)
661 call device_memcpy(this%abz1%x, this%abz1%x_d, &
662 w%dof%size(), host_to_device, sync = .false.)
663 call device_memcpy(this%abz2%x, this%abz2%x_d, &
664 w%dof%size(), host_to_device, sync = .false.)
665 call device_memcpy(this%advx%x, this%advx%x_d, &
666 w%dof%size(), host_to_device, sync = .false.)
667 call device_memcpy(this%advy%x, this%advy%x_d, &
668 w%dof%size(), host_to_device, sync = .false.)
669 call device_memcpy(this%advz%x, this%advz%x_d, &
670 w%dof%size(), host_to_device, sync = .false.)
677 if (
allocated(chkp%previous_mesh%elements) &
678 .or. chkp%previous_Xh%lx .ne. this%Xh%lx)
then
680 call rotate_cyc(this%u, this%v, this%w, 1, this%c_Xh)
681 call this%gs_Xh%op(this%u, gs_op_add)
682 call this%gs_Xh%op(this%v, gs_op_add)
683 call this%gs_Xh%op(this%w, gs_op_add)
684 call this%gs_Xh%op(this%p, gs_op_add)
685 call rotate_cyc(this%u, this%v, this%w, 0, this%c_Xh)
687 do i = 1, this%ulag%size()
688 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
689 this%wlag%lf(i), 1, this%c_Xh)
690 call this%gs_Xh%op(this%ulag%lf(i), gs_op_add)
691 call this%gs_Xh%op(this%vlag%lf(i), gs_op_add)
692 call this%gs_Xh%op(this%wlag%lf(i), gs_op_add)
693 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
694 this%wlag%lf(i), 0, this%c_Xh)
698 call this%ale%sync_chkp(this%c_Xh, this%Xh, this%adv, chkp, this%gs_Xh)
699 if (this%ale%active)
then
700 call this%bc_prs_surface%recompute_normals()
701 call this%bc_sym_surface%recompute_normals()
705 do i = 1, this%bcs_vel%size()
706 bc_i => this%bcs_vel%get(i)
707 call bc_i%restart(this%u, this%v, this%w, &
708 this%ulag, this%vlag, this%wlag)
712 do i = 1, this%bcs_prs%size()
713 bc_i => this%bcs_prs%get(i)
714 call bc_i%restart(this%p)
721 select type (adv => this%adv)
851 subroutine fluid_pnpn_step(this, time, dt_controller)
852 class(fluid_pnpn_t),
target,
intent(inout) :: this
853 type(time_state_t),
intent(in) :: time
854 type(time_step_controller_t),
intent(in) :: dt_controller
858 type(ksp_monitor_t) :: ksp_results(4)
861 type(file_t) :: dump_file
862 class(bc_t),
pointer :: bc_i
864 if (this%freeze)
return
866 n = this%dm_Xh%size()
868 call profiler_start_region(
'Fluid', 1)
869 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
870 u_e => this%u_e, v_e => this%v_e, w_e => this%w_e, &
871 du => this%du, dv => this%dv, dw => this%dw, dp => this%dp, &
872 u_res => this%u_res, v_res => this%v_res, w_res => this%w_res, &
873 p_res => this%p_res, ax_vel => this%Ax_vel, ax_prs => this%Ax_prs, &
875 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
876 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
877 msh => this%msh, prs_res => this%prs_res, &
878 source_term => this%source_term, vel_res => this%vel_res, &
879 sumab => this%sumab, makeoifs => this%makeoifs, &
880 makeabf => this%makeabf, makebdf => this%makebdf, &
881 vel_projection_dim => this%vel_projection_dim, &
882 pr_projection_dim => this%pr_projection_dim, &
884 rho => this%rho, mu_tot => this%mu_tot, &
885 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
886 t => time%t, tstep => time%tstep, dt => time%dt, &
887 ext_bdf => this%ext_bdf, event => glb_cmd_event, &
891 call sumab%compute_fluid(u_e, v_e, w_e, u, v, w, &
892 ulag, vlag, wlag, ext_bdf%advection_coeffs%x, ext_bdf%nadv)
895 call this%source_term%compute(time, extrapolate = .true.)
898 call this%bcs_vel%apply_vector(f_x%x, f_y%x, f_z%x, &
899 this%dm_Xh%size(), time, strong = .false.)
901 if (this%ale%active)
then
903 call neko_error(
"ALE is not yet supported " // &
904 "with OIFS time integration.")
907 call this%adv%compute_ale(u, v, w, &
908 ale%wm_x, ale%wm_y, ale%wm_z, &
910 xh, c_xh, dm_xh%size())
916 call this%adv%compute(u, v, w, &
917 this%advx, this%advy, this%advz, &
918 xh, this%c_Xh, dm_xh%size(),
real(dt, kind=rp))
925 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
926 this%abx2, this%aby2, this%abz2, &
927 f_x%x, f_y%x, f_z%x, &
928 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
932 call makeoifs%compute_fluid(this%advx%x, this%advy%x, this%advz%x, &
933 f_x%x, f_y%x, f_z%x, &
934 rho%x(1,1,1,1),
real(dt, kind=rp), n)
937 call this%adv%compute(u, v, w, &
939 xh, this%c_Xh, dm_xh%size())
946 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
947 this%abx2, this%aby2, this%abz2, &
948 f_x%x, f_y%x, f_z%x, &
949 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
955 call makebdf%compute_fluid(ulag, vlag, wlag, f_x%x, f_y%x, f_z%x, &
956 u, v, w, c_xh%B, c_xh%Blag, c_xh%Blaglag, rho%x(1,1,1,1), &
958 ext_bdf%diffusion_coeffs%x, ext_bdf%ndiff, n)
965 call this%source_term%compute(time, extrapolate = .false., scale = rho)
967 if (this%ale%active)
then
969 call this%ale%advance_mesh(c_xh, time, ext_bdf%nadv)
971 call profiler_start_region(
'ALE recompute metrics')
973 call c_xh%recompute_metrics()
976 call this%adv%recompute_metrics(c_xh, .true.)
978 call this%bc_prs_surface%recompute_normals()
979 call this%bc_sym_surface%recompute_normals()
980 call profiler_end_region(
'ALE recompute metrics')
988 call this%update_material_properties(time)
991 if (this%svv_enabled)
then
992 call this%svv%update(rho, tstep)
995 do iter = 1, 1 + this%schwarz_iterations
997 call this%bc_apply_vel(time, strong = .true.)
998 call this%bc_apply_prs(time)
1001 call profiler_start_region(
'Pressure_residual', 18)
1002 call prs_res%compute(p, p_res,&
1007 this%bc_prs_surface, this%bc_sym_surface,&
1008 ax_prs, ext_bdf%diffusion_coeffs%x(1),
real(dt, kind=rp), &
1013 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1)
then
1014 call device_ortho(p_res%x_d, this%glb_n_points, n)
1015 else if (.not. this%prs_dirichlet)
then
1016 call ortho(p_res%x, this%glb_n_points, n)
1019 call gs_xh%op(p_res, gs_op_add, event)
1022 call this%bcs_prs_projector%apply(p_res%x, p%dof%size())
1025 call profiler_end_region(
'Pressure_residual', 18)
1029 if (iter .eq. 1)
then
1030 call this%proj_prs%pre_solving(p_res%x, tstep, c_xh, n, &
1031 dt_controller, ax = ax_prs, gs_h = gs_xh, &
1032 bclst = this%bcs_prs_projector, string =
'Pressure')
1035 call this%pc_prs%update()
1037 call profiler_start_region(
'Pressure_solve', 3)
1041 this%ksp_prs%solve(ax_prs, dp, p_res%x, n, c_xh, &
1042 this%bcs_prs_projector, gs_xh)
1043 ksp_results(1)%name =
'Pressure'
1046 call profiler_end_region(
'Pressure_solve', 3)
1048 if (iter .eq. 1)
then
1049 call this%proj_prs%post_solving(dp%x, ax_prs, c_xh, &
1050 this%bcs_prs_projector, gs_xh, n, tstep, dt_controller)
1054 call field_add2(p, dp, n)
1055 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1)
then
1056 call device_ortho(p%x_d, this%glb_n_points, n)
1057 else if (.not. this%prs_dirichlet)
then
1058 call ortho(p%x, this%glb_n_points, n)
1062 call profiler_start_region(
'Velocity_residual', 19)
1063 call vel_res%compute(ax_vel, u, v, w, &
1064 u_res, v_res, w_res, &
1068 mu_tot, rho, ext_bdf%diffusion_coeffs%x(1), &
1069 real(dt, kind=rp), dm_xh%size())
1071 call rotate_cyc(u_res, v_res, w_res, 1, c_xh)
1072 call gs_xh%op(u_res%x, v_res%x, w_res%x, dm_xh%size(), &
1074 call rotate_cyc(u_res, v_res, w_res, 0, c_xh)
1077 call this%bcs_vel_projector%apply(u_res%x, v_res%x, w_res%x, &
1081 call profiler_end_region(
'Velocity_residual', 19)
1083 if (iter .eq. 1)
then
1084 call this%proj_vel%pre_solving(u_res%x, v_res%x, w_res%x, &
1085 tstep, c_xh, n, dt_controller,
'Velocity')
1088 call this%pc_vel%update()
1090 call profiler_start_region(
"Velocity_solve", 4)
1091 ksp_results(2:4) = this%ksp_vel%solve_coupled(ax_vel, du, dv, dw, &
1092 u_res%x, v_res%x, w_res%x, n, c_xh, &
1093 this%bcs_vel_projector, gs_xh, &
1094 this%ksp_vel%max_iter)
1095 call profiler_end_region(
"Velocity_solve", 4)
1096 if (this%full_stress_formulation)
then
1097 ksp_results(2)%name =
'Momentum'
1099 ksp_results(2)%name =
'X-Velocity'
1100 ksp_results(3)%name =
'Y-Velocity'
1101 ksp_results(4)%name =
'Z-Velocity'
1104 if (iter .eq. 1)
then
1105 call this%proj_vel%post_solving(du%x, dv%x, dw%x, ax_vel, c_xh, &
1106 this%bcs_vel_projector, gs_xh, n, tstep, &
1110 if (neko_bcknd_device .eq. 1)
then
1111 call device_opadd2cm(u%x_d, v%x_d, w%x_d, &
1112 du%x_d, dv%x_d, dw%x_d, 1.0_rp, n, msh%gdim)
1114 call opadd2cm(u%x, v%x, w%x, du%x, dv%x, dw%x, 1.0_rp, n, msh%gdim)
1117 call fluid_step_info(time, ksp_results, &
1118 this%full_stress_formulation, this%strict_convergence, &
1119 this%allow_stabilization, iter)
1123 if (this%forced_flow_rate)
then
1125 call this%vol_flow%adjust( u, v, w, p, u_res, v_res, w_res, p_res, &
1126 c_xh, gs_xh, ext_bdf, rho%x(1,1,1,1), mu_tot, &
1127 real(dt, kind=rp), time, this%bcs_prs_projector, &
1128 this%bcs_vel_projector, ax_vel, ax_prs, this%ksp_prs, &
1129 this%ksp_vel, this%pc_prs, this%pc_vel, this%ksp_prs%max_iter, &
1130 this%ksp_vel%max_iter)
1136 call this%ale%update_mesh_velocity(c_xh, time)
1142 call profiler_end_region(
'Fluid', 1)
1155 subroutine fluid_pnpn_setup_bcs(this, user, params)
1156 class(fluid_pnpn_t),
target,
intent(inout) :: this
1157 type(user_t),
target,
intent(in) :: user
1158 type(json_file),
intent(inout) :: params
1159 integer :: i, n_bcs, j, k, l, zone_size, global_zone_size, ierr
1160 integer :: facet_value
1161 class(bc_t),
pointer :: bc_i
1162 type(json_core) :: core
1163 type(json_value),
pointer :: bc_object
1164 type(json_file) :: bc_subdict, velocity_subdict, pressure_subdict
1165 logical :: moving_, has_velocity, has_pressure, pressure_dirichlet
1168 logical,
allocatable :: marked_zones(:)
1169 integer,
allocatable :: zone_indices(:)
1170 character(len=256) :: error_msg
1171 character(len=:),
allocatable :: bc_type_str
1173 this%ale%has_moving_boundary = .false.
1176 call this%bc_prs_surface%init_from_components(this%c_Xh)
1177 call this%bc_sym_surface%init_from_components(this%c_Xh)
1180 if (params%valid_path(
'case.fluid.boundary_conditions'))
then
1181 call params%info(
'case.fluid.boundary_conditions', n_children = n_bcs)
1182 call params%get_core(core)
1183 call params%get(
'case.fluid.boundary_conditions', bc_object, found)
1185 call this%bcs_vel%init(n_bcs)
1186 call this%bcs_prs%init(n_bcs)
1188 allocate(marked_zones(
size(this%msh%labeled_zones)))
1189 marked_zones = .false.
1193 call json_extract_item(core, bc_object, i, bc_subdict)
1195 call json_get_or_lookup(bc_subdict,
"zone_indices", zone_indices)
1200 do j = 1,
size(zone_indices)
1201 zone_size = this%msh%labeled_zones(zone_indices(j))%size
1202 call mpi_allreduce(zone_size, global_zone_size, 1, &
1203 mpi_integer, mpi_max, neko_comm, ierr)
1205 if (global_zone_size .eq. 0)
then
1206 write(error_msg,
'(A, I0, A, A, I0, A)') &
1207 "Zone index ", zone_indices(j), &
1208 " is invalid as this zone has 0 size, meaning it ", &
1209 "is not in the mesh. Check fluid boundary condition ", &
1211 call neko_error(error_msg)
1214 if (marked_zones(zone_indices(j)))
then
1215 write(error_msg,
'(A, I0, A, A, A, A)') &
1216 "Zone with index ", zone_indices(j), &
1217 " has already been assigned a boundary condition. ", &
1218 "Please check your boundary_conditions entry for the ", &
1219 "fluid and make sure that each zone index appears only ", &
1220 "in a single boundary condition."
1221 call neko_error(error_msg)
1223 marked_zones(zone_indices(j)) = .true.
1227 call fluid_pnpn_bc_split(bc_subdict, velocity_subdict, &
1228 pressure_subdict, has_velocity, has_pressure)
1234 if (has_velocity)
then
1236 call json_get(velocity_subdict,
"type", bc_type_str)
1237 if (trim(bc_type_str) .eq.
"no_slip")
then
1238 call json_get_or_default(velocity_subdict,
"moving", moving_, &
1240 if (moving_) this%ale%has_moving_boundary = .true.
1243 call velocity_bc_factory(bc_i, this, velocity_subdict, &
1249 if (
associated(bc_i))
then
1252 type is (symmetry_aligned_t)
1257 call this%bcs_vel_projector%mark(bc_i%bc_x, component =
'x')
1258 call this%bcs_vel_projector%mark(bc_i%bc_y, component =
'y')
1259 call this%bcs_vel_projector%mark(bc_i%bc_z, component =
'z')
1260 call this%bcs_vel%append(bc_i)
1261 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1262 type is (symmetry_t)
1265 if (.not. this%full_stress_formulation)
then
1266 call neko_error(
"The symmetry boundary condition " // &
1267 "requires the full stress formulation to be enabled.")
1269 call this%bcs_vel_projector%mark(bc_i)
1270 call this%bcs_vel%append(bc_i)
1271 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1272 type is (non_normal_aligned_t)
1274 call this%bcs_vel_projector%mark(bc_i%bc_x, component =
'x')
1275 call this%bcs_vel_projector%mark(bc_i%bc_y, component =
'y')
1276 call this%bcs_vel_projector%mark(bc_i%bc_z, component =
'z')
1277 call this%bcs_vel%append(bc_i)
1278 type is (non_normal_t)
1279 call this%bcs_vel_projector%mark(bc_i)
1280 call this%bcs_vel%append(bc_i)
1281 type is (shear_stress_t)
1282 if (.not. this%full_stress_formulation)
then
1283 call neko_error(
"The shear_stress boundary condition " // &
1284 "requires the full stress formulation to be enabled.")
1286 call this%bcs_vel_projector%mark(bc_i)
1287 call this%bcs_vel%append(bc_i)
1288 type is (wall_model_bc_t)
1289 if (.not. this%full_stress_formulation)
then
1290 call neko_error(
"The wall_model boundary condition " // &
1291 "requires the full stress formulation to be enabled.")
1293 call this%bcs_vel_projector%mark(bc_i)
1294 call this%bcs_vel%append(bc_i)
1295 class is (mixed_bc_t)
1298 if (.not. this%full_stress_formulation)
then
1299 call neko_error(
"The " // trim(bc_i%name) // &
1300 " boundary condition is a mixed condition and " // &
1301 "requires the full stress formulation to be enabled.")
1303 call this%bcs_vel_projector%mark(bc_i)
1304 call this%bcs_vel%append(bc_i)
1308 if (bc_i%bc_type .eq. bc_dirichlet)
then
1309 call this%bc_prs_surface%mark_labeled_zones( &
1311 if (this%full_stress_formulation)
then
1312 call this%bcs_vel_projector%mark(bc_i)
1314 call this%bcs_vel_projector%mark(bc_i, component =
'x')
1315 call this%bcs_vel_projector%mark(bc_i, component =
'y')
1316 call this%bcs_vel_projector%mark(bc_i, component =
'z')
1320 call this%bcs_vel%append(bc_i)
1328 pressure_dirichlet = .false.
1329 if (has_pressure)
then
1330 call pressure_bc_factory(bc_i, this, pressure_subdict, &
1336 if (
associated(bc_i))
then
1337 call this%bcs_prs%append(bc_i)
1340 if (bc_i%bc_type .eq. bc_dirichlet)
then
1341 call this%bcs_prs_projector%mark(bc_i)
1342 pressure_dirichlet = .true.
1348 if (pressure_dirichlet)
then
1354 do j = 1,
size(zone_indices)
1355 do k = 1, this%msh%nelv
1356 do l = 1, 2 * this%msh%gdim
1357 if (this%msh%facet_type(l, k) .eq. -zone_indices(j))
then
1358 this%msh%facet_type(l, k) = facet_value
1365 call velocity_subdict%destroy()
1366 call pressure_subdict%destroy()
1368 if (this%ale%active .and. (.not. this%ale%has_moving_boundary))
then
1369 call neko_error(
"Case file error: ALE is active, " // &
1370 "but no moving wall was found. " // &
1371 "Use type = 'no_slip' with 'moving': true in case file.")
1375 do i = 1,
size(this%msh%labeled_zones)
1376 if ((this%msh%labeled_zones(i)%size .gt. 0) .and. &
1377 (.not. marked_zones(i)))
then
1378 write(error_msg,
'(A, I0)') &
1379 "No fluid boundary condition assigned to zone ", i
1380 call neko_error(error_msg)
1385 do i = 1,
size(this%msh%labeled_zones)
1386 if (this%msh%labeled_zones(i)%size .gt. 0)
then
1387 call neko_error(
"No boundary_conditions entry in the case file!")
1393 call this%bcs_vel%init()
1394 call this%bcs_prs%init()
1398 call this%bc_prs_surface%finalize()
1399 call this%bc_sym_surface%finalize()
1400 call this%bcs_vel_projector%finalize(rebuild_mask = .true.)
1403 this%prs_dirichlet = this%bcs_prs_projector%dof_mask%is_set()
1404 call mpi_allreduce(mpi_in_place, this%prs_dirichlet, 1, &
1405 mpi_logical, mpi_lor, neko_comm)
1407 if (
allocated(marked_zones))
then
1408 deallocate(marked_zones)
1411 if (
allocated(zone_indices))
then
1412 deallocate(zone_indices)
1415 nullify(bc_i, bc_object)
1420 subroutine fluid_pnpn_write_boundary_conditions(this)
1427 class(fluid_pnpn_t),
target,
intent(inout) :: this
1428 type(dirichlet_t) :: bdry_mask
1429 type(field_t),
pointer :: bdry_field
1430 type(file_t) :: bdry_file
1431 integer :: temp_index, i
1432 class(bc_t),
pointer :: bci
1433 character(len=LOG_SIZE) :: log_buf
1435 write(log_buf,
'(A)')
'Marking using integer keys in bdry0.f00000'
1436 call neko_log%message(log_buf)
1437 write(log_buf,
'(A)')
'Condition-value pairs: '
1438 call neko_log%message(log_buf)
1439 write(log_buf,
'(A)')
' no_slip (stationary wall) = 1'
1440 call neko_log%message(log_buf)
1441 write(log_buf,
'(A)')
' velocity_value = 2'
1442 call neko_log%message(log_buf)
1443 write(log_buf,
'(A)')
' outflow, normal_outflow (+dong) = 3'
1444 call neko_log%message(log_buf)
1445 write(log_buf,
'(A)')
' symmetry = 4'
1446 call neko_log%message(log_buf)
1447 write(log_buf,
'(A)')
' periodic = 6'
1448 call neko_log%message(log_buf)
1449 write(log_buf,
'(A)')
' user_velocity = 7'
1450 call neko_log%message(log_buf)
1451 write(log_buf,
'(A)')
' user_pressure = 8'
1452 call neko_log%message(log_buf)
1453 write(log_buf,
'(A)')
' shear_stress = 9'
1454 call neko_log%message(log_buf)
1455 write(log_buf,
'(A)')
' wall_modelling = 10'
1456 call neko_log%message(log_buf)
1457 write(log_buf,
'(A)')
' blasius_profile = 11'
1458 call neko_log%message(log_buf)
1459 write(log_buf,
'(A)')
' no_slip (moving wall) = 12'
1460 call neko_log%message(log_buf)
1462 call neko_scratch_registry%request_field(bdry_field, temp_index, .true.)
1466 call bdry_mask%init_from_components(this%c_Xh, 6.0_rp)
1467 call bdry_mask%mark_zone(this%msh%periodic)
1468 call bdry_mask%finalize()
1469 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1470 call bdry_mask%free()
1472 do i = 1, this%bcs_prs%size()
1473 bci => this%bcs_prs%get(i)
1474 select type (
bc => bci)
1475 type is (zero_dirichlet_t)
1476 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1477 call bdry_mask%mark_facets(bci%marked_facet)
1478 call bdry_mask%finalize()
1479 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1480 call bdry_mask%free()
1482 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1483 call bdry_mask%mark_facets(bci%marked_facet)
1484 call bdry_mask%finalize()
1485 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1486 call bdry_mask%free()
1488 call bdry_mask%init_from_components(this%c_Xh, 8.0_rp)
1489 call bdry_mask%mark_facets(bci%marked_facet)
1490 call bdry_mask%finalize()
1491 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1492 call bdry_mask%free()
1496 do i = 1, this%bcs_vel%size()
1497 bci => this%bcs_vel%get(i)
1498 select type (
bc => bci)
1500 if (
bc%is_moving)
then
1502 call bdry_mask%init_from_components(this%c_Xh, 12.0_rp)
1505 call bdry_mask%init_from_components(this%c_Xh, 1.0_rp)
1507 call bdry_mask%mark_facets(bci%marked_facet)
1508 call bdry_mask%finalize()
1509 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1510 call bdry_mask%free()
1512 call bdry_mask%init_from_components(this%c_Xh, 2.0_rp)
1513 call bdry_mask%mark_facets(bci%marked_facet)
1514 call bdry_mask%finalize()
1515 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1516 call bdry_mask%free()
1517 type is (symmetry_aligned_t)
1518 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1519 call bdry_mask%mark_facets(bci%marked_facet)
1520 call bdry_mask%finalize()
1521 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1522 call bdry_mask%free()
1523 type is (symmetry_t)
1524 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1525 call bdry_mask%mark_facets(bci%marked_facet)
1526 call bdry_mask%finalize()
1527 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1528 call bdry_mask%free()
1530 call bdry_mask%init_from_components(this%c_Xh, 7.0_rp)
1531 call bdry_mask%mark_facets(bci%marked_facet)
1532 call bdry_mask%finalize()
1533 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1534 call bdry_mask%free()
1535 type is (shear_stress_t)
1536 call bdry_mask%init_from_components(this%c_Xh, 9.0_rp)
1537 call bdry_mask%mark_facets(bci%marked_facet)
1538 call bdry_mask%finalize()
1539 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1540 call bdry_mask%free()
1541 type is (wall_model_bc_t)
1542 call bdry_mask%init_from_components(this%c_Xh, 10.0_rp)
1543 call bdry_mask%mark_facets(bci%marked_facet)
1544 call bdry_mask%finalize()
1545 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1546 call bdry_mask%free()
1548 call bdry_mask%init_from_components(this%c_Xh, 11.0_rp)
1549 call bdry_mask%mark_facets(bci%marked_facet)
1550 call bdry_mask%finalize()
1551 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1552 call bdry_mask%free()
1557 call bdry_file%init(
'bdry.fld')
1558 call bdry_file%write(bdry_field)
1560 call neko_scratch_registry%relinquish_field(temp_index)
1562 nullify(bdry_field, bci)