242 subroutine fluid_pnpn_init(this, msh, lx, params, user, chkp)
243 class(fluid_pnpn_t),
target,
intent(inout) :: this
244 type(
mesh_t),
target,
intent(inout) :: msh
245 integer,
intent(in) :: lx
246 type(json_file),
target,
intent(inout) :: params
247 type(
user_t),
target,
intent(in) :: user
248 type(
chkp_t),
target,
intent(inout) :: chkp
249 character(len=15),
parameter :: scheme =
'Modular (Pn/Pn)'
251 class(
bc_t),
pointer :: bc_i, vel_bc
252 real(kind=
rp) :: abs_tol
253 character(len=LOG_SIZE) :: log_buf
254 integer :: ierr, integer_val, solver_maxiter
255 character(len=:),
allocatable :: solver_type, precon_type
256 logical :: monitor, found
258 type(json_file) :: numerics_params, precon_params
263 call this%init_base(msh, lx, params, scheme,
user, .true.)
275 allocate(this%ext_bdf)
276 call this%ext_bdf%init(integer_val)
279 this%full_stress_formulation, .false.)
283 call this%c_Xh%generate_cyclic_bc()
285 if (this%full_stress_formulation)
then
287 call ax_helm_allocator(this%Ax_vel, type_name =
"full")
290 call pnpn_prs_res_stress_factory(this%prs_res)
293 call pnpn_vel_res_stress_factory(this%vel_res)
299 call ax_helm_allocator(this%Ax_vel, type_name =
"standard")
302 call pnpn_prs_res_factory(this%prs_res)
305 call pnpn_vel_res_factory(this%vel_res)
312 call this%bcs_vel_projector%init(this%c_Xh)
314 if (params%valid_path(
'case.fluid.nut_field'))
then
315 if (.not. this%full_stress_formulation)
then
316 call neko_error(
"You need to set full_stress_formulation to " // &
317 "true for the fluid to have a spatially varying " // &
320 call json_get(params,
'case.fluid.nut_field', this%nut_field_name)
322 this%nut_field_name =
""
326 call ax_helm_allocator(this%Ax_prs, type_name =
"standard")
330 call rhs_maker_sumab_fctry(this%sumab)
333 call rhs_maker_ext_fctry(this%makeabf)
336 call rhs_maker_bdf_fctry(this%makebdf)
339 call rhs_maker_oifs_fctry(this%makeoifs)
342 associate(xh_lx => this%Xh%lx, xh_ly => this%Xh%ly, xh_lz => this%Xh%lz, &
343 dm_xh => this%dm_Xh, nelv => this%msh%nelv)
345 call this%p_res%init(dm_xh,
"p_res")
346 call this%u_res%init(dm_xh,
"u_res")
347 call this%v_res%init(dm_xh,
"v_res")
348 call this%w_res%init(dm_xh,
"w_res")
349 call this%abx1%init(dm_xh,
"abx1")
350 call this%aby1%init(dm_xh,
"aby1")
351 call this%abz1%init(dm_xh,
"abz1")
352 call this%abx2%init(dm_xh,
"abx2")
353 call this%aby2%init(dm_xh,
"aby2")
354 call this%abz2%init(dm_xh,
"abz2")
355 call this%advx%init(dm_xh,
"advx")
356 call this%advy%init(dm_xh,
"advy")
357 call this%advz%init(dm_xh,
"advz")
360 call this%du%init(this%dm_Xh,
'du')
361 call this%dv%init(this%dm_Xh,
'dv')
362 call this%dw%init(this%dm_Xh,
'dw')
363 call this%dp%init(this%dm_Xh,
'dp')
365 call this%ale%init(this%c_Xh, params,
user, chkp)
367 call neko_log%section(
"Fluid boundary conditions")
369 call this%setup_bcs(
user, params)
373 if (found)
call this%write_boundary_conditions()
376 call this%proj_prs%init(this%dm_Xh%size(), this%pr_projection_dim, &
377 this%pr_projection_activ_step, &
378 this%pr_projection_reorthogonalize_basis)
380 call this%proj_vel%init(this%dm_Xh%size(), this%vel_projection_dim, &
381 this%vel_projection_activ_step)
387 if (params%valid_path(
'case.fluid.flow_rate_force'))
then
388 call this%vol_flow%init(this%dm_Xh, params)
392 call neko_log%section(
"Pressure solver")
395 'case.fluid.pressure_solver.max_iterations', &
397 call json_get(params,
'case.fluid.pressure_solver.type', solver_type)
398 call json_get(params,
'case.fluid.pressure_solver.preconditioner.type', &
401 'case.fluid.pressure_solver.preconditioner', precon_params)
403 'case.fluid.pressure_solver.absolute_tolerance', &
407 call neko_log%message(
'Type : ('// trim(solver_type) // &
408 ', ' // trim(precon_type) //
')')
409 write(log_buf,
'(A,ES13.6)')
'Abs tol :', abs_tol
412 call this%solver_factory(this%ksp_prs, this%dm_Xh%size(), &
413 solver_type, solver_maxiter, abs_tol, monitor)
414 call this%precon_factory_(this%pc_prs, this%ksp_prs, &
415 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs_prs, &
416 precon_type, precon_params)
424 call json_get(params,
'case.numerics', numerics_params)
425 call advection_factory(this%adv, numerics_params, this%c_Xh, &
426 this%ulag, this%vlag, this%wlag, &
427 chkp%dtlag, chkp%tlag, this%ext_bdf, &
432 call this%chkp%add_fluid(this%u, this%v, this%w, this%p)
434 this%chkp%abx1 => this%abx1
435 this%chkp%abx2 => this%abx2
436 this%chkp%aby1 => this%aby1
437 this%chkp%aby2 => this%aby2
438 this%chkp%abz1 => this%abz1
439 this%chkp%abz2 => this%abz2
440 call this%chkp%add_lag(this%ulag, this%vlag, this%wlag)
444 this%schwarz_iterations, 0)
448 nullify(bc_i, vel_bc)
452 subroutine fluid_pnpn_restart(this, chkp)
453 class(fluid_pnpn_t),
target,
intent(inout) :: this
454 type(chkp_t),
intent(inout) :: chkp
455 real(kind=rp) :: dtlag(10), tlag(10)
461 n = this%u%dof%size()
462 if (
allocated(chkp%previous_mesh%elements) .or. &
463 chkp%previous_Xh%lx .ne. this%Xh%lx)
then
464 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
465 c_xh => this%c_Xh, ulag => this%ulag, vlag => this%vlag, &
467 do concurrent(j = 1:n)
468 u%x(j,1,1,1) = u%x(j,1,1,1) * c_xh%mult(j,1,1,1)
469 v%x(j,1,1,1) = v%x(j,1,1,1) * c_xh%mult(j,1,1,1)
470 w%x(j,1,1,1) = w%x(j,1,1,1) * c_xh%mult(j,1,1,1)
471 p%x(j,1,1,1) = p%x(j,1,1,1) * c_xh%mult(j,1,1,1)
473 do i = 1, this%ulag%size()
474 do concurrent(j = 1:n)
475 ulag%lf(i)%x(j,1,1,1) = ulag%lf(i)%x(j,1,1,1) &
477 vlag%lf(i)%x(j,1,1,1) = vlag%lf(i)%x(j,1,1,1) &
479 wlag%lf(i)%x(j,1,1,1) = wlag%lf(i)%x(j,1,1,1) &
486 if (neko_bcknd_device .eq. 1)
then
487 associate(u => this%u, v => this%v, w => this%w, &
488 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag,&
490 call device_memcpy(u%x, u%x_d, u%dof%size(), &
491 host_to_device, sync = .false.)
492 call device_memcpy(v%x, v%x_d, v%dof%size(), &
493 host_to_device, sync = .false.)
494 call device_memcpy(w%x, w%x_d, w%dof%size(), &
495 host_to_device, sync = .false.)
496 call device_memcpy(p%x, p%x_d, p%dof%size(), &
497 host_to_device, sync = .false.)
498 call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, &
499 u%dof%size(), host_to_device, sync = .false.)
500 call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, &
501 u%dof%size(), host_to_device, sync = .false.)
503 call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, &
504 v%dof%size(), host_to_device, sync = .false.)
505 call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, &
506 v%dof%size(), host_to_device, sync = .false.)
508 call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, &
509 w%dof%size(), host_to_device, sync = .false.)
510 call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, &
511 w%dof%size(), host_to_device, sync = .false.)
512 call device_memcpy(this%abx1%x, this%abx1%x_d, &
513 w%dof%size(), host_to_device, sync = .false.)
514 call device_memcpy(this%abx2%x, this%abx2%x_d, &
515 w%dof%size(), host_to_device, sync = .false.)
516 call device_memcpy(this%aby1%x, this%aby1%x_d, &
517 w%dof%size(), host_to_device, sync = .false.)
518 call device_memcpy(this%aby2%x, this%aby2%x_d, &
519 w%dof%size(), host_to_device, sync = .false.)
520 call device_memcpy(this%abz1%x, this%abz1%x_d, &
521 w%dof%size(), host_to_device, sync = .false.)
522 call device_memcpy(this%abz2%x, this%abz2%x_d, &
523 w%dof%size(), host_to_device, sync = .false.)
524 call device_memcpy(this%advx%x, this%advx%x_d, &
525 w%dof%size(), host_to_device, sync = .false.)
526 call device_memcpy(this%advy%x, this%advy%x_d, &
527 w%dof%size(), host_to_device, sync = .false.)
528 call device_memcpy(this%advz%x, this%advz%x_d, &
529 w%dof%size(), host_to_device, sync = .false.)
536 if (
allocated(chkp%previous_mesh%elements) &
537 .or. chkp%previous_Xh%lx .ne. this%Xh%lx)
then
539 call rotate_cyc(this%u, this%v, this%w, 1, this%c_Xh)
540 call this%gs_Xh%op(this%u, gs_op_add)
541 call this%gs_Xh%op(this%v, gs_op_add)
542 call this%gs_Xh%op(this%w, gs_op_add)
543 call this%gs_Xh%op(this%p, gs_op_add)
544 call rotate_cyc(this%u, this%v, this%w, 0, this%c_Xh)
546 do i = 1, this%ulag%size()
547 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
548 this%wlag%lf(i), 1, this%c_Xh)
549 call this%gs_Xh%op(this%ulag%lf(i), gs_op_add)
550 call this%gs_Xh%op(this%vlag%lf(i), gs_op_add)
551 call this%gs_Xh%op(this%wlag%lf(i), gs_op_add)
552 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
553 this%wlag%lf(i), 0, this%c_Xh)
557 call this%ale%sync_chkp(this%c_Xh, this%Xh, this%adv, chkp, this%gs_Xh)
558 if (this%ale%active)
then
559 call this%bc_prs_surface%recompute_normals()
560 call this%bc_sym_surface%recompute_normals()
661 subroutine fluid_pnpn_step(this, time, dt_controller)
662 class(fluid_pnpn_t),
target,
intent(inout) :: this
663 type(time_state_t),
intent(in) :: time
664 type(time_step_controller_t),
intent(in) :: dt_controller
668 type(ksp_monitor_t) :: ksp_results(4)
671 type(file_t) :: dump_file
672 class(bc_t),
pointer :: bc_i
674 if (this%freeze)
return
676 n = this%dm_Xh%size()
678 call profiler_start_region(
'Fluid', 1)
679 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
680 u_e => this%u_e, v_e => this%v_e, w_e => this%w_e, &
681 du => this%du, dv => this%dv, dw => this%dw, dp => this%dp, &
682 u_res => this%u_res, v_res => this%v_res, w_res => this%w_res, &
683 p_res => this%p_res, ax_vel => this%Ax_vel, ax_prs => this%Ax_prs, &
685 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
686 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
687 msh => this%msh, prs_res => this%prs_res, &
688 source_term => this%source_term, vel_res => this%vel_res, &
689 sumab => this%sumab, makeoifs => this%makeoifs, &
690 makeabf => this%makeabf, makebdf => this%makebdf, &
691 vel_projection_dim => this%vel_projection_dim, &
692 pr_projection_dim => this%pr_projection_dim, &
694 rho => this%rho, mu_tot => this%mu_tot, &
695 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
696 t => time%t, tstep => time%tstep, dt => time%dt, &
697 ext_bdf => this%ext_bdf, event => glb_cmd_event, &
701 call sumab%compute_fluid(u_e, v_e, w_e, u, v, w, &
702 ulag, vlag, wlag, ext_bdf%advection_coeffs%x, ext_bdf%nadv)
705 call this%source_term%compute(time)
708 call this%bcs_vel%apply_vector(f_x%x, f_y%x, f_z%x, &
709 this%dm_Xh%size(), time, strong = .false.)
711 if (this%ale%active)
then
713 call neko_error(
"ALE is not yet supported " // &
714 "with OIFS time integration.")
717 call this%adv%compute_ale(u, v, w, &
718 ale%wm_x, ale%wm_y, ale%wm_z, &
720 xh, c_xh, dm_xh%size())
726 call this%adv%compute(u, v, w, &
727 this%advx, this%advy, this%advz, &
728 xh, this%c_Xh, dm_xh%size(),
real(dt, kind=rp))
735 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
736 this%abx2, this%aby2, this%abz2, &
737 f_x%x, f_y%x, f_z%x, &
738 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
742 call makeoifs%compute_fluid(this%advx%x, this%advy%x, this%advz%x, &
743 f_x%x, f_y%x, f_z%x, &
744 rho%x(1,1,1,1),
real(dt, kind=rp), n)
747 call this%adv%compute(u, v, w, &
749 xh, this%c_Xh, dm_xh%size())
756 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
757 this%abx2, this%aby2, this%abz2, &
758 f_x%x, f_y%x, f_z%x, &
759 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
765 call makebdf%compute_fluid(ulag, vlag, wlag, f_x%x, f_y%x, f_z%x, &
766 u, v, w, c_xh%B, c_xh%Blag, c_xh%Blaglag, rho%x(1,1,1,1), &
768 ext_bdf%diffusion_coeffs%x, ext_bdf%ndiff, n)
772 if (this%ale%active)
then
774 call this%ale%advance_mesh(c_xh, time, ext_bdf%nadv)
776 call profiler_start_region(
'ALE recompute metrics')
778 call c_xh%recompute_metrics()
781 call this%adv%recompute_metrics(c_xh, .true.)
783 call this%bc_prs_surface%recompute_normals()
784 call this%bc_sym_surface%recompute_normals()
785 call profiler_end_region(
'ALE recompute metrics')
793 call this%update_material_properties(time)
795 do iter = 1, 1 + this%schwarz_iterations
797 call this%bc_apply_vel(time, strong = .true.)
798 call this%bc_apply_prs(time)
801 call profiler_start_region(
'Pressure_residual', 18)
802 call prs_res%compute(p, p_res,&
807 this%bc_prs_surface, this%bc_sym_surface,&
808 ax_prs, ext_bdf%diffusion_coeffs%x(1),
real(dt, kind=rp), &
813 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1)
then
814 call device_ortho(p_res%x_d, this%glb_n_points, n)
815 else if (.not. this%prs_dirichlet)
then
816 call ortho(p_res%x, this%glb_n_points, n)
819 call gs_xh%op(p_res, gs_op_add, event)
820 call device_event_sync(event)
823 call this%bcs_prs_projector%apply(p_res%x, p%dof%size())
826 call profiler_end_region(
'Pressure_residual', 18)
830 if (iter .eq. 1)
then
831 call this%proj_prs%pre_solving(p_res%x, tstep, c_xh, n, &
832 dt_controller, ax = ax_prs, gs_h = gs_xh, &
833 bclst = this%bcs_prs_projector, string =
'Pressure')
836 call this%pc_prs%update()
838 call profiler_start_region(
'Pressure_solve', 3)
842 this%ksp_prs%solve(ax_prs, dp, p_res%x, n, c_xh, &
843 this%bcs_prs_projector, gs_xh)
844 ksp_results(1)%name =
'Pressure'
847 call profiler_end_region(
'Pressure_solve', 3)
849 if (iter .eq. 1)
then
850 call this%proj_prs%post_solving(dp%x, ax_prs, c_xh, &
851 this%bcs_prs_projector, gs_xh, n, tstep, dt_controller)
855 call field_add2(p, dp, n)
856 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1)
then
857 call device_ortho(p%x_d, this%glb_n_points, n)
858 else if (.not. this%prs_dirichlet)
then
859 call ortho(p%x, this%glb_n_points, n)
863 call profiler_start_region(
'Velocity_residual', 19)
864 call vel_res%compute(ax_vel, u, v, w, &
865 u_res, v_res, w_res, &
869 mu_tot, rho, ext_bdf%diffusion_coeffs%x(1), &
870 real(dt, kind=rp), dm_xh%size())
872 call rotate_cyc(u_res, v_res, w_res, 1, c_xh)
873 call gs_xh%op(u_res%x, v_res%x, w_res%x, dm_xh%size(), &
875 call device_event_sync(event)
876 call rotate_cyc(u_res, v_res, w_res, 0, c_xh)
879 call this%bcs_vel_projector%apply(u_res%x, v_res%x, w_res%x, &
883 call profiler_end_region(
'Velocity_residual', 19)
885 if (iter .eq. 1)
then
886 call this%proj_vel%pre_solving(u_res%x, v_res%x, w_res%x, &
887 tstep, c_xh, n, dt_controller,
'Velocity')
890 call this%pc_vel%update()
892 call profiler_start_region(
"Velocity_solve", 4)
893 ksp_results(2:4) = this%ksp_vel%solve_coupled(ax_vel, du, dv, dw, &
894 u_res%x, v_res%x, w_res%x, n, c_xh, &
895 this%bcs_vel_projector, gs_xh, &
896 this%ksp_vel%max_iter)
897 call profiler_end_region(
"Velocity_solve", 4)
898 if (this%full_stress_formulation)
then
899 ksp_results(2)%name =
'Momentum'
901 ksp_results(2)%name =
'X-Velocity'
902 ksp_results(3)%name =
'Y-Velocity'
903 ksp_results(4)%name =
'Z-Velocity'
906 if (iter .eq. 1)
then
907 call this%proj_vel%post_solving(du%x, dv%x, dw%x, ax_vel, c_xh, &
908 this%bcs_vel_projector, gs_xh, n, tstep, &
912 if (neko_bcknd_device .eq. 1)
then
913 call device_opadd2cm(u%x_d, v%x_d, w%x_d, &
914 du%x_d, dv%x_d, dw%x_d, 1.0_rp, n, msh%gdim)
916 call opadd2cm(u%x, v%x, w%x, du%x, dv%x, dw%x, 1.0_rp, n, msh%gdim)
919 call fluid_step_info(time, ksp_results, &
920 this%full_stress_formulation, this%strict_convergence, &
921 this%allow_stabilization, iter)
925 if (this%forced_flow_rate)
then
927 call this%vol_flow%adjust( u, v, w, p, u_res, v_res, w_res, p_res, &
928 c_xh, gs_xh, ext_bdf, rho%x(1,1,1,1), mu_tot, &
929 real(dt, kind=rp), time, this%bcs_prs_projector, &
930 this%bcs_vel_projector, ax_vel, ax_prs, this%ksp_prs, &
931 this%ksp_vel, this%pc_prs, this%pc_vel, this%ksp_prs%max_iter, &
932 this%ksp_vel%max_iter)
938 call this%ale%update_mesh_velocity(c_xh, time)
944 call profiler_end_region(
'Fluid', 1)
949 subroutine fluid_pnpn_setup_bcs(this, user, params)
950 class(fluid_pnpn_t),
target,
intent(inout) :: this
951 type(user_t),
target,
intent(in) :: user
952 type(json_file),
intent(inout) :: params
953 integer :: i, n_bcs, zone_index, j, zone_size, global_zone_size, ierr
954 class(bc_t),
pointer :: bc_i
955 type(json_core) :: core
956 type(json_value),
pointer :: bc_object
957 type(json_file) :: bc_subdict
958 logical :: ale_active_local, any_moving_wall, moving_
961 logical,
allocatable :: marked_zones(:)
962 integer,
allocatable :: zone_indices(:)
965 character(len=:),
allocatable :: bc_type_str
966 this%ale%has_moving_boundary = .false.
967 any_moving_wall = .false.
968 ale_active_local = .false.
969 call json_get_or_default(params,
'case.fluid.ale.enabled', &
970 ale_active_local, .false.)
973 call this%bc_prs_surface%init_from_components(this%c_Xh)
974 call this%bc_sym_surface%init_from_components(this%c_Xh)
977 if (params%valid_path(
'case.fluid.boundary_conditions'))
then
978 call params%info(
'case.fluid.boundary_conditions', n_children = n_bcs)
979 call params%get_core(core)
980 call params%get(
'case.fluid.boundary_conditions', bc_object, found)
985 call this%bcs_vel%init(n_bcs)
987 allocate(marked_zones(
size(this%msh%labeled_zones)))
988 marked_zones = .false.
992 call json_extract_item(core, bc_object, i, bc_subdict)
994 call json_get_or_lookup(bc_subdict,
"zone_indices", zone_indices)
997 call json_get(bc_subdict,
"type", bc_type_str)
999 if (trim(bc_type_str) .eq.
"no_slip")
then
1000 call json_get_or_default(bc_subdict,
"moving", moving_, .false.)
1003 this%ale%has_moving_boundary = .true.
1009 do j = 1,
size(zone_indices)
1010 zone_size = this%msh%labeled_zones(zone_indices(j))%size
1011 call mpi_allreduce(zone_size, global_zone_size, 1, &
1012 mpi_integer, mpi_max, neko_comm, ierr)
1014 if (global_zone_size .eq. 0)
then
1015 write(error_unit,
'(A, A, I0, A, A, I0, A)')
"*** ERROR ***: ",&
1016 "Zone index ", zone_indices(j), &
1017 " is invalid as this zone has 0 size, meaning it ", &
1018 "is not in the mesh. Check fluid boundary condition ", &
1023 if (marked_zones(zone_indices(j)))
then
1024 write(error_unit,
'(A, A, I0, A, A, A, A)')
"*** ERROR ***: ", &
1025 "Zone with index ", zone_indices(j), &
1026 " has already been assigned a boundary condition. ", &
1027 "Please check your boundary_conditions entry for the ", &
1028 "fluid and make sure that each zone index appears only ", &
1029 "in a single boundary condition."
1032 marked_zones(zone_indices(j)) = .true.
1037 call velocity_bc_factory(bc_i, this, bc_subdict, this%c_Xh,
user)
1041 if (
associated(bc_i))
then
1044 type is (symmetry_aligned_t)
1049 call this%bcs_vel_projector%mark(bc_i%bc_x, component =
'x')
1050 call this%bcs_vel_projector%mark(bc_i%bc_y, component =
'y')
1051 call this%bcs_vel_projector%mark(bc_i%bc_z, component =
'z')
1052 call this%bcs_vel%append(bc_i)
1053 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1054 type is (symmetry_t)
1057 if (.not. this%full_stress_formulation)
then
1058 call neko_error(
"The symmetry boundary condition " // &
1059 "requires the full stress formulation to be enabled.")
1061 call this%bcs_vel_projector%mark(bc_i)
1062 call this%bcs_vel%append(bc_i)
1063 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1064 type is (non_normal_aligned_t)
1066 call this%bcs_vel_projector%mark(bc_i%bc_x, component =
'x')
1067 call this%bcs_vel_projector%mark(bc_i%bc_y, component =
'y')
1068 call this%bcs_vel_projector%mark(bc_i%bc_z, component =
'z')
1069 call this%bcs_vel%append(bc_i)
1070 type is (non_normal_t)
1071 call this%bcs_vel_projector%mark(bc_i)
1072 call this%bcs_vel%append(bc_i)
1073 type is (shear_stress_t)
1074 if (.not. this%full_stress_formulation)
then
1075 call neko_error(
"The shear_stress boundary condition " // &
1076 "requires the full stress formulation to be enabled.")
1078 call this%bcs_vel_projector%mark(bc_i)
1079 call this%bcs_vel%append(bc_i)
1080 type is (wall_model_bc_t)
1081 if (.not. this%full_stress_formulation)
then
1082 call neko_error(
"The wall_model boundary condition " // &
1083 "requires the full stress formulation to be enabled.")
1085 call this%bcs_vel_projector%mark(bc_i)
1086 call this%bcs_vel%append(bc_i)
1090 if (bc_i%bc_type .eq. bc_dirichlet)
then
1091 call this%bc_prs_surface%mark_labeled_zones( &
1093 if (this%full_stress_formulation)
then
1094 call this%bcs_vel_projector%mark(bc_i)
1096 call this%bcs_vel_projector%mark(bc_i, component =
'x')
1097 call this%bcs_vel_projector%mark(bc_i, component =
'y')
1098 call this%bcs_vel_projector%mark(bc_i, component =
'z')
1102 call this%bcs_vel%append(bc_i)
1107 if (this%ale%active .and. (.not. this%ale%has_moving_boundary))
then
1108 call neko_error(
"Case file error: ALE is active, " // &
1109 "but no moving wall was found. " // &
1110 "Use type = 'no_slip' with 'moving': true in case file.")
1114 do i = 1,
size(this%msh%labeled_zones)
1115 if ((this%msh%labeled_zones(i)%size .gt. 0) .and. &
1116 (.not. marked_zones(i)))
then
1117 write(error_unit,
'(A, A, I0)')
"*** ERROR ***: ", &
1118 "No fluid boundary condition assigned to zone ", i
1126 call this%bcs_prs%init(n_bcs)
1130 call json_extract_item(core, bc_object, i, bc_subdict)
1132 call pressure_bc_factory(bc_i, this, bc_subdict, this%c_Xh,
user)
1136 if (
associated(bc_i))
then
1137 call this%bcs_prs%append(bc_i)
1140 if (bc_i%bc_type .eq. bc_dirichlet)
then
1141 call this%bcs_prs_projector%mark(bc_i)
1149 do i = 1,
size(this%msh%labeled_zones)
1150 if (this%msh%labeled_zones(i)%size .gt. 0)
then
1151 call neko_error(
"No boundary_conditions entry in the case file!")
1157 call this%bcs_vel%init()
1158 call this%bcs_prs%init()
1162 call this%bc_prs_surface%finalize()
1163 call this%bc_sym_surface%finalize()
1164 call this%bcs_vel_projector%finalize(rebuild_mask = .true.)
1167 this%prs_dirichlet = this%bcs_prs_projector%dof_mask%is_set()
1168 call mpi_allreduce(mpi_in_place, this%prs_dirichlet, 1, &
1169 mpi_logical, mpi_lor, neko_comm)
1172 if (
allocated(marked_zones))
then
1173 deallocate(marked_zones)
1176 if (
allocated(zone_indices))
then
1177 deallocate(zone_indices)
1180 nullify(bc_i, bc_object)
1185 subroutine fluid_pnpn_write_boundary_conditions(this)
1192 class(fluid_pnpn_t),
target,
intent(inout) :: this
1193 type(dirichlet_t) :: bdry_mask
1194 type(field_t),
pointer :: bdry_field
1195 type(file_t) :: bdry_file
1196 integer :: temp_index, i
1197 class(bc_t),
pointer :: bci
1198 character(len=LOG_SIZE) :: log_buf
1200 write(log_buf,
'(A)')
'Marking using integer keys in bdry0.f00000'
1201 call neko_log%message(log_buf)
1202 write(log_buf,
'(A)')
'Condition-value pairs: '
1203 call neko_log%message(log_buf)
1204 write(log_buf,
'(A)')
' no_slip (stationary wall) = 1'
1205 call neko_log%message(log_buf)
1206 write(log_buf,
'(A)')
' velocity_value = 2'
1207 call neko_log%message(log_buf)
1208 write(log_buf,
'(A)')
' outflow, normal_outflow (+dong) = 3'
1209 call neko_log%message(log_buf)
1210 write(log_buf,
'(A)')
' symmetry = 4'
1211 call neko_log%message(log_buf)
1212 write(log_buf,
'(A)')
' periodic = 6'
1213 call neko_log%message(log_buf)
1214 write(log_buf,
'(A)')
' user_velocity = 7'
1215 call neko_log%message(log_buf)
1216 write(log_buf,
'(A)')
' user_pressure = 8'
1217 call neko_log%message(log_buf)
1218 write(log_buf,
'(A)')
' shear_stress = 9'
1219 call neko_log%message(log_buf)
1220 write(log_buf,
'(A)')
' wall_modelling = 10'
1221 call neko_log%message(log_buf)
1222 write(log_buf,
'(A)')
' blasius_profile = 11'
1223 call neko_log%message(log_buf)
1224 write(log_buf,
'(A)')
' no_slip (moving wall) = 12'
1225 call neko_log%message(log_buf)
1227 call neko_scratch_registry%request_field(bdry_field, temp_index, .true.)
1231 call bdry_mask%init_from_components(this%c_Xh, 6.0_rp)
1232 call bdry_mask%mark_zone(this%msh%periodic)
1233 call bdry_mask%finalize()
1234 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1235 call bdry_mask%free()
1237 do i = 1, this%bcs_prs%size()
1238 bci => this%bcs_prs%get(i)
1239 select type (
bc => bci)
1240 type is (zero_dirichlet_t)
1241 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1242 call bdry_mask%mark_facets(bci%marked_facet)
1243 call bdry_mask%finalize()
1244 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1245 call bdry_mask%free()
1247 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1248 call bdry_mask%mark_facets(bci%marked_facet)
1249 call bdry_mask%finalize()
1250 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1251 call bdry_mask%free()
1253 call bdry_mask%init_from_components(this%c_Xh, 8.0_rp)
1254 call bdry_mask%mark_facets(bci%marked_facet)
1255 call bdry_mask%finalize()
1256 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1257 call bdry_mask%free()
1261 do i = 1, this%bcs_vel%size()
1262 bci => this%bcs_vel%get(i)
1263 select type (
bc => bci)
1265 if (
bc%is_moving)
then
1267 call bdry_mask%init_from_components(this%c_Xh, 12.0_rp)
1270 call bdry_mask%init_from_components(this%c_Xh, 1.0_rp)
1272 call bdry_mask%mark_facets(bci%marked_facet)
1273 call bdry_mask%finalize()
1274 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1275 call bdry_mask%free()
1277 call bdry_mask%init_from_components(this%c_Xh, 2.0_rp)
1278 call bdry_mask%mark_facets(bci%marked_facet)
1279 call bdry_mask%finalize()
1280 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1281 call bdry_mask%free()
1282 type is (symmetry_aligned_t)
1283 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1284 call bdry_mask%mark_facets(bci%marked_facet)
1285 call bdry_mask%finalize()
1286 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1287 call bdry_mask%free()
1288 type is (symmetry_t)
1289 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1290 call bdry_mask%mark_facets(bci%marked_facet)
1291 call bdry_mask%finalize()
1292 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1293 call bdry_mask%free()
1295 call bdry_mask%init_from_components(this%c_Xh, 7.0_rp)
1296 call bdry_mask%mark_facets(bci%marked_facet)
1297 call bdry_mask%finalize()
1298 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1299 call bdry_mask%free()
1300 type is (shear_stress_t)
1301 call bdry_mask%init_from_components(this%c_Xh, 9.0_rp)
1302 call bdry_mask%mark_facets(bci%marked_facet)
1303 call bdry_mask%finalize()
1304 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1305 call bdry_mask%free()
1306 type is (wall_model_bc_t)
1307 call bdry_mask%init_from_components(this%c_Xh, 10.0_rp)
1308 call bdry_mask%mark_facets(bci%marked_facet)
1309 call bdry_mask%finalize()
1310 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1311 call bdry_mask%free()
1313 call bdry_mask%init_from_components(this%c_Xh, 11.0_rp)
1314 call bdry_mask%mark_facets(bci%marked_facet)
1315 call bdry_mask%finalize()
1316 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1317 call bdry_mask%free()
1322 call bdry_file%init(
'bdry.fld')
1323 call bdry_file%write(bdry_field)
1325 call neko_scratch_registry%relinquish_field(temp_index)
1327 nullify(bdry_field, bci)