46 use krylov,
only :
ksp_t, krylov_solver_factory, krylov_solver_destroy, &
63 use precon,
only :
pc_t, precon_factory, precon_destroy
75 use json_module,
only : json_file
110 class(
ksp_t),
allocatable :: ksp_vel
111 class(
ksp_t),
allocatable :: ksp_prs
112 class(
pc_t),
allocatable :: pc_vel
113 class(
pc_t),
allocatable :: pc_prs
114 integer :: vel_projection_dim
115 integer :: pr_projection_dim
116 integer :: vel_projection_activ_step
117 integer :: pr_projection_activ_step
118 logical :: strict_convergence
121 class(
bc_t),
allocatable :: bc_inflow
124 logical :: if_gradient_jump_penalty
140 type(json_file),
pointer :: params
146 logical :: forced_flow_rate = .false.
147 logical :: freeze = .false.
153 character(len=:),
allocatable :: nut_field_name
155 logical :: variable_material_properties = .false.
161 integer(kind=i8) :: glb_n_points
163 integer(kind=i8) :: glb_unique_points
166 character(len=NEKO_MSH_MAX_ZLBL_LEN),
allocatable :: bc_labels(:)
185 procedure, pass(this) :: set_material_properties => &
195 procedure,
private, pass(this) :: set_bc_type_output => &
198 procedure, pass(this) :: update_material_properties => &
212 type(
mesh_t),
target,
intent(inout) :: msh
213 integer,
intent(in) :: lx
214 type(json_file),
target,
intent(inout) :: params
215 type(
user_t),
target,
intent(in) :: user
237 real(kind=
rp),
intent(in) :: t
238 integer,
intent(in) :: tstep
239 real(kind=
rp),
intent(in) :: dt
251 real(kind=
rp) :: dtlag(10), tlag(10)
258 module subroutine fluid_scheme_factory(object, type_name)
259 class(fluid_scheme_t),
intent(inout),
allocatable :: object
260 character(len=*) :: type_name
261 end subroutine fluid_scheme_factory
264 public :: fluid_scheme_t, fluid_scheme_factory
269 subroutine fluid_scheme_init_common(this, msh, lx, params, scheme, user, &
272 class(fluid_scheme_t),
target,
intent(inout) :: this
273 type(
mesh_t),
target,
intent(inout) :: msh
274 integer,
intent(in) :: lx
275 character(len=*),
intent(in) :: scheme
276 type(json_file),
target,
intent(inout) :: params
277 type(
user_t),
target,
intent(in) :: user
278 logical,
intent(in) :: kspv_init
280 character(len=LOG_SIZE) :: log_buf
281 real(kind=
rp),
allocatable :: real_vec(:)
282 real(kind=
rp) :: real_val, kappa, b, z0
283 logical :: logical_val
284 integer :: integer_val, ierr
285 type(json_file) :: wm_json
286 character(len=:),
allocatable :: string_val1, string_val2
294 if (msh%gdim .eq. 2)
then
295 call this%Xh%init(
gll, lx, lx)
297 call this%Xh%init(
gll, lx, lx, lx)
300 call this%dm_Xh%init(msh, this%Xh)
302 call this%gs_Xh%init(this%dm_Xh)
304 call this%c_Xh%init(this%gs_Xh)
310 this%params => params
318 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
324 call this%set_material_properties(params, user)
329 if (params%valid_path(
'case.fluid.nut_field'))
then
330 call json_get(params,
'case.fluid.nut_field', this%nut_field_name)
331 this%variable_material_properties = .true.
333 this%nut_field_name =
""
338 call this%mu_field%init(this%dm_Xh,
"mu")
339 call this%rho_field%init(this%dm_Xh,
"mu")
340 call field_cfill(this%mu_field, this%mu, this%mu_field%size())
341 call field_cfill(this%rho_field, this%rho, this%mu_field%size())
347 call cfill(this%mu_field%x, this%mu, this%mu_field%size())
348 call cfill(this%rho_field%x, this%rho, this%rho_field%size())
354 'case.fluid.velocity_solver.projection_space_size', &
355 this%vel_projection_dim, 20)
357 'case.fluid.pressure_solver.projection_space_size', &
358 this%pr_projection_dim, 20)
360 'case.fluid.velocity_solver.projection_hold_steps', &
361 this%vel_projection_activ_step, 5)
363 'case.fluid.pressure_solver.projection_hold_steps', &
364 this%pr_projection_activ_step, 5)
369 if (params%valid_path(
"case.fluid.flow_rate_force"))
then
370 this%forced_flow_rate = .true.
375 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
376 else if (lx .ge. 10)
then
377 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
379 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
382 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
383 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
385 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
387 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
390 write(log_buf,
'(A,ES13.6)')
'rho :', this%rho
392 write(log_buf,
'(A,ES13.6)')
'mu :', this%mu
395 call json_get(params,
'case.numerics.dealias', logical_val)
396 write(log_buf,
'(A, L1)')
'Dealias : ', logical_val
399 write(log_buf,
'(A, L1)')
'LES : ', this%variable_material_properties
404 write(log_buf,
'(A, L1)')
'Save bdry : ', logical_val
406 if (logical_val)
then
407 write(log_buf,
'(A)')
'bdry keys: '
409 write(log_buf,
'(A)')
'No-slip wall ''w'' = 1'
411 write(log_buf,
'(A)')
'Inlet/velocity dirichlet ''v'' = 2'
413 write(log_buf,
'(A)')
'Outlet ''o'' = 3'
415 write(log_buf,
'(A)')
'Symmetry ''sym'' = 4'
417 write(log_buf,
'(A)')
'Outlet-normal ''on'' = 5'
419 write(log_buf,
'(A)')
'Periodic = 6'
421 write(log_buf,
'(A)')
'Dirichlet on velocity components: '
423 write(log_buf,
'(A)')
' ''d_vel_u, d_vel_v, d_vel_w'' = 7'
425 write(log_buf,
'(A)')
'Pressure dirichlet ''d_pres'' = 8'
427 write(log_buf,
'(A)')
'''d_vel_(u,v,w)'' and ''d_pres'' = 8'
429 write(log_buf,
'(A)')
'Shear stress ''sh'' = 9'
431 write(log_buf,
'(A)')
'Wall modelling ''wm'' = 10'
433 write(log_buf,
'(A)')
'No boundary condition set = 0'
442 this%bc_labels =
"not"
444 if (params%valid_path(
'case.fluid.boundary_types'))
then
446 'case.fluid.boundary_types', &
450 call this%bclst_vel%init()
452 call this%bc_sym%init_base(this%c_Xh)
453 call this%bc_sym%mark_zone(msh%sympln)
454 call this%bc_sym%mark_zones_from_list(msh%labeled_zones, &
455 'sym', this%bc_labels)
456 call this%bc_sym%finalize()
457 call this%bc_sym%init(this%c_Xh)
458 call this%bclst_vel%append(this%bc_sym)
461 call this%bc_sh%init_base(this%c_Xh)
462 call this%bc_sh%mark_zones_from_list(msh%labeled_zones, &
463 'sh', this%bc_labels)
464 call this%bc_sh%finalize()
467 call this%bc_sh%init_shear_stress(this%c_Xh)
469 call this%bclst_vel%append(this%bc_sh%symmetry)
472 if (this%bc_sh%msk(0) .gt. 0)
then
473 call params%get(
'case.fluid.shear_stress.value', real_vec, logical_val)
474 if (.not. logical_val .and. this%bc_sh%msk(0) .gt. 0)
then
475 call neko_warning(
"No stress values provided for sh boundaries, &
476 & defaulting to 0. Use fluid.shear_stress.value to set.")
477 allocate(real_vec(3))
479 else if (
size(real_vec) .ne. 3)
then
480 call neko_error (
"The shear stress vector provided in &
481 &fluid.shear_stress.value should have 3 components.")
483 call this%bc_sh%set_stress(real_vec(1), real_vec(2), real_vec(3))
486 call this%bclst_vel_neumann%init()
487 call this%bclst_vel_neumann%append(this%bc_sh)
492 if (params%valid_path(
'case.fluid.inflow_condition'))
then
493 call json_get(params,
'case.fluid.inflow_condition.type', string_val1)
494 if (trim(string_val1) .eq.
"uniform")
then
496 else if (trim(string_val1) .eq.
"blasius")
then
498 else if (trim(string_val1) .eq.
"user")
then
501 call neko_error(
'Invalid inflow condition '//string_val1)
504 call this%bc_inflow%init_base(this%c_Xh)
505 call this%bc_inflow%mark_zone(msh%inlet)
506 call this%bc_inflow%mark_zones_from_list(msh%labeled_zones, &
508 call this%bc_inflow%finalize()
509 call this%bclst_vel%append(this%bc_inflow)
511 if (trim(string_val1) .eq.
"uniform")
then
512 call json_get(params,
'case.fluid.inflow_condition.value', real_vec)
513 select type (bc_if => this%bc_inflow)
515 call bc_if%set_inflow(real_vec)
517 else if (trim(string_val1) .eq.
"blasius")
then
518 select type (bc_if => this%bc_inflow)
520 call json_get(params,
'case.fluid.blasius.delta', real_val)
521 call json_get(params,
'case.fluid.blasius.approximation', &
523 call json_get(params,
'case.fluid.blasius.freestream_velocity', &
526 call bc_if%set_params(real_vec, real_val, string_val2)
529 else if (trim(string_val1) .eq.
"user")
then
537 call this%bc_wallmodel%init_base(this%c_Xh)
538 call this%bc_wallmodel%mark_zones_from_list(msh%labeled_zones,&
539 'wm', this%bc_labels)
540 call this%bc_wallmodel%finalize()
542 if (this%bc_wallmodel%msk(0) .gt. 0)
then
544 call this%bc_wallmodel%init_wall_model_bc(wm_json, this%mu / this%rho)
546 call this%bc_wallmodel%shear_stress_t%init_shear_stress(this%c_Xh)
549 call this%bclst_vel%append(this%bc_wallmodel%symmetry)
550 call this%bclst_vel_neumann%append(this%bc_wallmodel)
552 call this%bc_wall%init_base(this%c_Xh)
553 call this%bc_wall%mark_zone(msh%wall)
554 call this%bc_wall%mark_zones_from_list(msh%labeled_zones, &
556 call this%bc_wall%finalize()
557 call this%bclst_vel%append(this%bc_wall)
560 call this%user_field_bc_vel%bc_u%init_base(this%c_Xh)
561 call this%user_field_bc_vel%bc_u%mark_zones_from_list(msh%labeled_zones, &
562 'd_vel_u', this%bc_labels)
563 call this%user_field_bc_vel%bc_u%finalize()
565 call mpi_allreduce(this%user_field_bc_vel%bc_u%msk(0), integer_val, 1, &
567 if (integer_val .gt. 0)
then
568 call this%user_field_bc_vel%bc_u%init_field(
'd_vel_u')
572 call this%user_field_bc_vel%bc_v%init_base(this%c_Xh)
573 call this%user_field_bc_vel%bc_v%mark_zones_from_list(msh%labeled_zones, &
574 'd_vel_v', this%bc_labels)
575 call this%user_field_bc_vel%bc_v%finalize()
577 call mpi_allreduce(this%user_field_bc_vel%bc_v%msk(0), integer_val, 1, &
579 if (integer_val .gt. 0)
then
580 call this%user_field_bc_vel%bc_v%init_field(
'd_vel_v')
584 call this%user_field_bc_vel%bc_w%init_base(this%c_Xh)
585 call this%user_field_bc_vel%bc_w%mark_zones_from_list(msh%labeled_zones, &
586 'd_vel_w', this%bc_labels)
587 call this%user_field_bc_vel%bc_w%finalize()
589 call mpi_allreduce(this%user_field_bc_vel%bc_w%msk(0), integer_val, 1, &
591 if (integer_val .gt. 0)
then
592 call this%user_field_bc_vel%bc_w%init_field(
'd_vel_w')
596 call this%user_field_bc_vel%init_base(this%c_Xh)
597 call this%user_field_bc_vel%mark_zones_from_list(msh%labeled_zones, &
598 'd_vel_u', this%bc_labels)
599 call this%user_field_bc_vel%mark_zones_from_list(msh%labeled_zones, &
600 'd_vel_v', this%bc_labels)
601 call this%user_field_bc_vel%mark_zones_from_list(msh%labeled_zones, &
602 'd_vel_w', this%bc_labels)
603 call this%user_field_bc_vel%finalize()
606 call this%bclst_vel%append(this%user_field_bc_vel)
611 this%user_field_bc_vel%update => user%user_dirichlet_update
618 call this%user_field_bc_vel%field_list%init(4)
619 call this%user_field_bc_vel%field_list%assign_to_field(1, &
620 this%user_field_bc_vel%bc_u%field_bc)
621 call this%user_field_bc_vel%field_list%assign_to_field(2, &
622 this%user_field_bc_vel%bc_v%field_bc)
623 call this%user_field_bc_vel%field_list%assign_to_field(3, &
624 this%user_field_bc_vel%bc_w%field_bc)
625 call this%user_field_bc_vel%field_list%assign_to_field(4, &
626 this%user_field_bc_prs%field_bc)
628 call this%user_field_bc_vel%bc_list%init(
size = 4)
630 call this%user_field_bc_vel%bc_list%append(this%user_field_bc_vel%bc_u)
631 call this%user_field_bc_vel%bc_list%append(this%user_field_bc_vel%bc_v)
632 call this%user_field_bc_vel%bc_list%append(this%user_field_bc_vel%bc_w)
636 call fluid_scheme_set_bc_type_output(this, params)
644 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
645 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
646 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
649 call this%source_term%init(this%f_x, this%f_y, this%f_z, this%c_Xh, user)
650 call this%source_term%add(params,
'case.fluid.source_terms')
654 call this%set_bc_type_output(params)
658 call neko_log%section(
"Velocity solver")
660 'case.fluid.velocity_solver.max_iterations', &
662 call json_get(params,
'case.fluid.velocity_solver.type', string_val1)
663 call json_get(params,
'case.fluid.velocity_solver.preconditioner', &
665 call json_get(params,
'case.fluid.velocity_solver.absolute_tolerance', &
668 'case.fluid.velocity_solver.monitor', &
669 logical_val, .false.)
671 call neko_log%message(
'Type : ('// trim(string_val1) // &
672 ', ' // trim(string_val2) //
')')
674 write(log_buf,
'(A,ES13.6)')
'Abs tol :', real_val
676 call fluid_scheme_solver_factory(this%ksp_vel, this%dm_Xh%size(), &
677 string_val1, integer_val, real_val, logical_val)
678 call fluid_scheme_precon_factory(this%pc_vel, this%ksp_vel, &
679 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bclst_vel, string_val2)
685 this%strict_convergence, .false.)
696 call this%ulag%init(this%u, 2)
697 call this%vlag%init(this%v, 2)
698 call this%wlag%init(this%w, 2)
701 end subroutine fluid_scheme_init_common
704 subroutine fluid_scheme_init_all(this, msh, lx, params, kspv_init, &
705 kspp_init, scheme, user)
707 class(fluid_scheme_t),
target,
intent(inout) :: this
708 type(
mesh_t),
target,
intent(inout) :: msh
709 integer,
intent(in) :: lx
710 type(json_file),
target,
intent(inout) :: params
711 type(
user_t),
target,
intent(in) :: user
714 character(len=*),
intent(in) :: scheme
715 real(kind=
rp) :: abs_tol
716 integer :: integer_val, ierr
717 logical :: logical_val
718 character(len=:),
allocatable :: solver_type, precon_type
719 character(len=LOG_SIZE) :: log_buf
720 real(kind=
rp) :: gjp_param_a, gjp_param_b
722 call fluid_scheme_init_common(this, msh, lx, params, scheme, user, &
731 call this%bclst_prs%init()
732 call this%bc_prs%init_base(this%c_Xh)
733 call this%bc_prs%mark_zones_from_list(msh%labeled_zones, &
735 call this%bc_prs%mark_zones_from_list(msh%labeled_zones, &
736 'on', this%bc_labels)
739 call this%user_field_bc_prs%init_base(this%c_Xh)
740 call this%user_field_bc_prs%mark_zones_from_list(msh%labeled_zones, &
741 'd_pres', this%bc_labels)
742 call this%user_field_bc_prs%finalize()
743 call mpi_allreduce(this%user_field_bc_prs%msk(0), integer_val, 1, &
746 if (integer_val .gt. 0)
call this%user_field_bc_prs%init_field(
'd_pres')
747 call this%bclst_prs%append(this%user_field_bc_prs)
748 call this%user_field_bc_vel%bc_list%append(this%user_field_bc_prs)
750 if (msh%outlet%size .gt. 0)
then
751 call this%bc_prs%mark_zone(msh%outlet)
753 if (msh%outlet_normal%size .gt. 0)
then
754 call this%bc_prs%mark_zone(msh%outlet_normal)
757 call this%bc_prs%finalize()
758 call this%bc_prs%set_g(0.0_rp)
759 call this%bclst_prs%append(this%bc_prs)
760 call this%bc_dong%init_base(this%c_Xh)
761 call this%bc_dong%mark_zones_from_list(msh%labeled_zones, &
762 'o+dong', this%bc_labels)
763 call this%bc_dong%mark_zones_from_list(msh%labeled_zones, &
764 'on+dong', this%bc_labels)
765 call this%bc_dong%finalize()
768 call this%bc_dong%init(this%c_Xh, params)
770 call this%bclst_prs%append(this%bc_dong)
774 call neko_log%section(
"Pressure solver")
777 'case.fluid.pressure_solver.max_iterations', &
779 call json_get(params,
'case.fluid.pressure_solver.type', solver_type)
780 call json_get(params,
'case.fluid.pressure_solver.preconditioner', &
782 call json_get(params,
'case.fluid.pressure_solver.absolute_tolerance', &
785 'case.fluid.pressure_solver.monitor', &
786 logical_val, .false.)
787 call neko_log%message(
'Type : ('// trim(solver_type) // &
788 ', ' // trim(precon_type) //
')')
789 write(log_buf,
'(A,ES13.6)')
'Abs tol :', abs_tol
792 call fluid_scheme_solver_factory(this%ksp_prs, this%dm_Xh%size(), &
793 solver_type, integer_val, abs_tol, logical_val)
794 call fluid_scheme_precon_factory(this%pc_prs, this%ksp_prs, &
795 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bclst_prs, precon_type)
803 'case.fluid.gradient_jump_penalty.enabled',&
804 this%if_gradient_jump_penalty, .false.)
806 if (this%if_gradient_jump_penalty .eqv. .true.)
then
807 if ((this%dm_Xh%xh%lx - 1) .eq. 1)
then
809 'case.fluid.gradient_jump_penalty.tau',&
810 gjp_param_a, 0.02_rp)
814 'case.fluid.gradient_jump_penalty.scaling_factor',&
817 'case.fluid.gradient_jump_penalty.scaling_exponent',&
820 call this%gradient_jump_penalty_u%init(params, this%dm_Xh, this%c_Xh, &
821 gjp_param_a, gjp_param_b)
822 call this%gradient_jump_penalty_v%init(params, this%dm_Xh, this%c_Xh, &
823 gjp_param_a, gjp_param_b)
824 call this%gradient_jump_penalty_w%init(params, this%dm_Xh, this%c_Xh, &
825 gjp_param_a, gjp_param_b)
830 end subroutine fluid_scheme_init_all
833 subroutine fluid_scheme_free(this)
834 class(fluid_scheme_t),
intent(inout) :: this
836 call this%bdry%free()
838 if (
allocated(this%bc_inflow))
then
839 call this%bc_inflow%free()
842 call this%bc_wall%free()
843 call this%bc_sym%free()
844 call this%bc_sh%free()
849 call this%user_field_bc_prs%field_bc%free()
850 call this%user_field_bc_prs%free()
851 call this%user_field_bc_vel%bc_u%field_bc%free()
852 call this%user_field_bc_vel%bc_v%field_bc%free()
853 call this%user_field_bc_vel%bc_w%field_bc%free()
854 call this%user_field_bc_vel%free()
858 if (
allocated(this%ksp_vel))
then
859 call krylov_solver_destroy(this%ksp_vel)
860 deallocate(this%ksp_vel)
863 if (
allocated(this%ksp_prs))
then
864 call krylov_solver_destroy(this%ksp_prs)
865 deallocate(this%ksp_prs)
868 if (
allocated(this%pc_vel))
then
869 call precon_destroy(this%pc_vel)
870 deallocate(this%pc_vel)
873 if (
allocated(this%pc_prs))
then
874 call precon_destroy(this%pc_prs)
875 deallocate(this%pc_prs)
878 if (
allocated(this%bc_labels))
then
879 deallocate(this%bc_labels)
882 call this%source_term%free()
884 call this%gs_Xh%free()
886 call this%c_Xh%free()
888 call this%bclst_vel%free()
890 call this%scratch%free()
899 call this%ulag%free()
900 call this%vlag%free()
901 call this%wlag%free()
904 if (
associated(this%f_x))
then
908 if (
associated(this%f_y))
then
912 if (
associated(this%f_z))
then
920 call this%mu_field%free()
923 if (this%if_gradient_jump_penalty .eqv. .true.)
then
924 call this%gradient_jump_penalty_u%free()
925 call this%gradient_jump_penalty_v%free()
926 call this%gradient_jump_penalty_w%free()
930 end subroutine fluid_scheme_free
934 subroutine fluid_scheme_validate(this)
935 class(fluid_scheme_t),
target,
intent(inout) :: this
937 logical :: logical_val
939 if ( (.not.
associated(this%u)) .or. &
940 (.not.
associated(this%v)) .or. &
941 (.not.
associated(this%w)) .or. &
942 (.not.
associated(this%p)))
then
946 if ( (.not.
allocated(this%u%x)) .or. &
947 (.not.
allocated(this%v%x)) .or. &
948 (.not.
allocated(this%w%x)) .or. &
949 (.not.
allocated(this%p%x)))
then
953 if (.not.
allocated(this%ksp_vel))
then
954 call neko_error(
'No Krylov solver for velocity defined')
957 if (.not.
allocated(this%ksp_prs))
then
958 call neko_error(
'No Krylov solver for pressure defined')
961 if (.not.
associated(this%params))
then
965 if (
allocated(this%bc_inflow))
then
966 select type (ip => this%bc_inflow)
975 call this%chkp%init(this%u, this%v, this%w, this%p)
977 end subroutine fluid_scheme_validate
983 subroutine fluid_scheme_bc_apply_vel(this, t, tstep)
984 class(fluid_scheme_t),
intent(inout) :: this
985 real(kind=
rp),
intent(in) :: t
986 integer,
intent(in) :: tstep
988 call this%bclst_vel%apply_vector( &
989 this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), t, tstep)
991 end subroutine fluid_scheme_bc_apply_vel
995 subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
996 class(fluid_scheme_t),
intent(inout) :: this
997 real(kind=
rp),
intent(in) :: t
998 integer,
intent(in) :: tstep
1000 call this%bclst_prs%apply_scalar(this%p%x, this%p%dof%size(), t, tstep)
1002 end subroutine fluid_scheme_bc_apply_prs
1006 subroutine fluid_scheme_solver_factory(ksp, n, solver, &
1007 max_iter, abstol, monitor)
1008 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
1009 integer,
intent(in),
value :: n
1010 character(len=*),
intent(in) :: solver
1011 integer,
intent(in) :: max_iter
1012 real(kind=
rp),
intent(in) :: abstol
1013 logical,
intent(in) :: monitor
1015 call krylov_solver_factory(ksp, n, solver, max_iter, abstol, &
1018 end subroutine fluid_scheme_solver_factory
1021 subroutine fluid_scheme_precon_factory(pc, ksp, coef, dof, gs, bclst, &
1023 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
1024 class(
ksp_t),
target,
intent(inout) :: ksp
1025 type(
coef_t),
target,
intent(in) :: coef
1026 type(
dofmap_t),
target,
intent(in) :: dof
1027 type(
gs_t),
target,
intent(inout) :: gs
1028 type(
bc_list_t),
target,
intent(inout) :: bclst
1029 character(len=*) :: pctype
1031 call precon_factory(pc, pctype)
1033 select type (pcp => pc)
1035 call pcp%init(coef, dof, gs)
1037 call pcp%init(coef, dof, gs)
1039 call pcp%init(coef, dof, gs)
1041 if (len_trim(pctype) .gt. 4)
then
1042 if (index(pctype,
'+') .eq. 5)
then
1043 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst, &
1046 call neko_error(
'Unknown coarse grid solver')
1049 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
1052 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
1057 end subroutine fluid_scheme_precon_factory
1060 subroutine fluid_scheme_set_usr_inflow(this, usr_eval)
1061 class(fluid_scheme_t),
intent(inout) :: this
1064 select type (bc_if => this%bc_inflow)
1066 call bc_if%set_eval(usr_eval)
1068 call neko_error(
"Not a user defined inflow condition")
1070 end subroutine fluid_scheme_set_usr_inflow
1073 function fluid_compute_cfl(this, dt)
result(c)
1074 class(fluid_scheme_t),
intent(in) :: this
1075 real(kind=
rp),
intent(in) :: dt
1078 c =
cfl(dt, this%u%x, this%v%x, this%w%x, &
1079 this%Xh, this%c_Xh, this%msh%nelv, this%msh%gdim)
1081 end function fluid_compute_cfl
1085 subroutine fluid_scheme_set_bc_type_output(this, params)
1086 class(fluid_scheme_t),
target,
intent(inout) :: this
1087 type(json_file),
intent(inout) :: params
1097 call this%bdry%init(this%dm_Xh,
'bdry')
1100 call bdry_mask%init_base(this%c_Xh)
1101 call bdry_mask%mark_zone(this%msh%wall)
1102 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1103 'w', this%bc_labels)
1104 call bdry_mask%finalize()
1105 call bdry_mask%set_g(1.0_rp)
1106 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1107 call bdry_mask%free()
1109 call bdry_mask%init_base(this%c_Xh)
1110 call bdry_mask%mark_zone(this%msh%inlet)
1111 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1112 'v', this%bc_labels)
1113 call bdry_mask%finalize()
1114 call bdry_mask%set_g(2.0_rp)
1115 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1116 call bdry_mask%free()
1118 call bdry_mask%init_base(this%c_Xh)
1119 call bdry_mask%mark_zone(this%msh%outlet)
1120 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1121 'o', this%bc_labels)
1122 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1123 'o+dong', this%bc_labels)
1124 call bdry_mask%finalize()
1125 call bdry_mask%set_g(3.0_rp)
1126 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1127 call bdry_mask%free()
1129 call bdry_mask%init_base(this%c_Xh)
1130 call bdry_mask%mark_zone(this%msh%sympln)
1131 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1132 'sym', this%bc_labels)
1133 call bdry_mask%finalize()
1134 call bdry_mask%set_g(4.0_rp)
1135 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1136 call bdry_mask%free()
1138 call bdry_mask%init_base(this%c_Xh)
1139 call bdry_mask%mark_zone(this%msh%outlet_normal)
1140 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1141 'on', this%bc_labels)
1142 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1143 'on+dong', this%bc_labels)
1144 call bdry_mask%finalize()
1145 call bdry_mask%set_g(5.0_rp)
1146 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1147 call bdry_mask%free()
1149 call bdry_mask%init_base(this%c_Xh)
1150 call bdry_mask%mark_zone(this%msh%periodic)
1151 call bdry_mask%finalize()
1152 call bdry_mask%set_g(6.0_rp)
1153 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1154 call bdry_mask%free()
1156 call bdry_mask%init_base(this%c_Xh)
1157 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1158 'd_vel_u', this%bc_labels)
1159 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1160 'd_vel_v', this%bc_labels)
1161 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1162 'd_vel_w', this%bc_labels)
1163 call bdry_mask%finalize()
1164 call bdry_mask%set_g(7.0_rp)
1165 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1166 call bdry_mask%free()
1168 call bdry_mask%init_base(this%c_Xh)
1169 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1170 'd_pres', this%bc_labels)
1171 call bdry_mask%finalize()
1172 call bdry_mask%set_g(8.0_rp)
1173 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1174 call bdry_mask%free()
1176 call bdry_mask%init_base(this%c_Xh)
1177 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1178 'sh', this%bc_labels)
1179 call bdry_mask%finalize()
1180 call bdry_mask%set_g(9.0_rp)
1181 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1182 call bdry_mask%free()
1184 call bdry_mask%init_base(this%c_Xh)
1185 call bdry_mask%mark_zones_from_list(this%msh%labeled_zones, &
1186 'wm', this%bc_labels)
1187 call bdry_mask%finalize()
1188 call bdry_mask%set_g(10.0_rp)
1189 call bdry_mask%apply_scalar(this%bdry%x, this%dm_Xh%size())
1190 call bdry_mask%free()
1194 end subroutine fluid_scheme_set_bc_type_output
1197 subroutine fluid_scheme_update_material_properties(this)
1198 class(fluid_scheme_t),
intent(inout) :: this
1202 if (this%variable_material_properties)
then
1210 call cfill(this%mu_field%x, this%mu, n)
1211 call add2s2(this%mu_field%x, nut%x, this%rho, n)
1215 end subroutine fluid_scheme_update_material_properties
1220 subroutine fluid_scheme_set_material_properties(this, params, user)
1221 class(fluid_scheme_t),
intent(inout) :: this
1222 type(json_file),
intent(inout) :: params
1223 type(
user_t),
target,
intent(in) :: user
1224 character(len=LOG_SIZE) :: log_buf
1227 logical :: nondimensional
1228 real(kind=
rp) :: dummy_lambda, dummy_cp
1232 if (.not.
associated(user%material_properties, dummy_mp_ptr))
then
1234 write(log_buf,
'(A)')
"Material properties must be set in the user&
1237 call user%material_properties(0.0_rp, 0, this%rho, this%mu, &
1238 dummy_cp, dummy_lambda, params)
1241 if (params%valid_path(
'case.fluid.Re') .and. &
1242 (params%valid_path(
'case.fluid.mu') .or. &
1243 params%valid_path(
'case.fluid.rho')))
then
1244 call neko_error(
"To set the material properties for the fluid,&
1245 & either provide Re OR mu and rho in the case file.")
1248 else if (params%valid_path(
'case.fluid.Re'))
then
1250 write(log_buf,
'(A)')
'Non-dimensional fluid material properties &
1253 write(log_buf,
'(A)')
'Density will be set to 1, dynamic viscosity to&
1258 call json_get(params,
'case.fluid.Re', this%mu)
1259 write(log_buf,
'(A)')
'Read non-dimensional material properties'
1261 write(log_buf,
'(A,ES13.6)')
'Re :', this%mu
1267 this%mu = 1.0_rp/this%mu
1270 call json_get(params,
'case.fluid.mu', this%mu)
1271 call json_get(params,
'case.fluid.rho', this%rho)
1275 end subroutine fluid_scheme_set_material_properties
Abstract interface to dealocate a fluid formulation.
Abstract interface to initialize a fluid formulation.
Abstract interface to restart a fluid scheme.
Abstract interface to compute a time-step.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Abstract interface for setting material properties.
Abstract interface defining a user defined inflow condition (pointwise)
Defines a boundary condition.
Defines a Blasius profile dirichlet condition.
type(mpi_comm) neko_comm
MPI communicator.
Jacobi preconditioner accelerator backend.
subroutine, public device_add2s2(a_d, b_d, c1, n)
Vector addition with scalar multiplication (multiplication on first argument)
subroutine, public device_cfill(a_d, c, n)
Set all elements to a constant c .
Defines a dirichlet boundary condition.
Defines a mapping of the degrees of freedom.
Defines a dong outflow condition.
Defines inflow dirichlet conditions.
Defines inflow dirichlet conditions.
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
subroutine fluid_scheme_set_material_properties(this, params, user)
Sets rho and mu.
subroutine fluid_scheme_free(this)
Deallocate a fluid formulation.
subroutine fluid_scheme_update_material_properties(this)
Update the values of mu_field if necessary.
subroutine fluid_scheme_set_bc_type_output(this, params)
Set boundary types for the diagnostic output.
real(kind=rp) function fluid_compute_cfl(this, dt)
Compute CFL.
subroutine fluid_scheme_init_all(this, msh, lx, params, kspv_init, kspp_init, scheme, user)
Initialize all components of the current scheme.
subroutine fluid_scheme_set_usr_inflow(this, usr_eval)
Initialize a user defined inflow condition.
subroutine fluid_scheme_init_common(this, msh, lx, params, scheme, user, kspv_init)
Initialise a fluid scheme.
subroutine fluid_scheme_bc_apply_vel(this, t, tstep)
Apply all boundary conditions defined for velocity Here we perform additional gs operations to take c...
subroutine fluid_scheme_validate(this)
Validate that all fields, solvers etc necessary for performing time-stepping are defined.
subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
Apply all boundary conditions defined for pressure.
Implements the fluid_source_term_t type.
Computes various statistics for the fluid fields. We use the Reynolds decomposition for a field u = ...
Implements gradient_jump_penalty_t.
Defines inflow dirichlet conditions.
Utilities for retrieving parameters from the case files.
subroutine, public json_extract_object(json, name, object)
Extract object as a separate JSON dictionary.
Implements the base abstract type for Krylov solvers plus helper types.
integer, parameter, public ksp_max_iter
Maximum number of iters.
integer, parameter, public neko_log_verbose
Verbose log level.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
real(kind=rp) function, public glsum(a, n)
Sum a vector of length n.
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
subroutine, public add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
Defines a mean flow field.
Defines a mean squared flow field.
integer, parameter, public neko_msh_max_zlbls
Max num. zone labels.
integer, parameter, public neko_msh_max_zlbl_len
Max length of a zone label.
integer, parameter neko_bcknd_device
integer, parameter, public i8
integer, parameter, public rp
Global precision used in computations.
real(kind=rp) function, public cfl(dt, u, v, w, xh, coef, nelv, gdim)
Hybrid ph-multigrid preconditioner.
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
type(scratch_registry_t) function init(dof, size, expansion_size)
Constructor, optionally taking initial registry and expansion size as argument.
Defines a shear stress boundary condition for a vector field. Maintainer: Timofey Mukha.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Defines a function space.
integer, parameter, public gll
Defines a container for all statistics.
Jacobi preconditioner SX-Aurora backend.
Mixed Dirichlet-Neumann axis aligned symmetry plane.
Compound scheme for the advection and diffusion operators in a transport equation.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
subroutine, public dummy_user_material_properties(t, tstep, rho, mu, cp, lambda, params)
Defines inflow dirichlet conditions.
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Defines the wall_model_bc_t type. Maintainer: Timofey Mukha.
Defines wall boundary conditions.
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
Blasius profile for inlet (vector valued)
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Defines a jacobi preconditioner.
Generic Dirichlet boundary condition on .
Dong outflow condition Follows "A Convective-like Energy-Stable Open Boundary Condition for Simulati...
User defined dirichlet condition, for which the user can work with an entire field....
Extension of the user defined dirichlet condition field_dirichlet
Base type of all fluid formulations.
Wrapper contaning and executing the fluid source terms.
Implements the gradient jump penalty.
Dirichlet condition for inlet (vector valued)
Defines a jacobi preconditioner.
Base abstract type for a canonical Krylov method, solving .
Defines a canonical Krylov preconditioner.
A shear stress boundary condition.
The function space for the SEM solution fields.
Defines a jacobi preconditioner for SX-Aurora.
Mixed Dirichlet-Neumann symmetry plane condition.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
Provides a tool to set time step dt.
User defined dirichlet condition for inlet (vector valued)
No-slip Wall boundary condition.
A shear stress boundary condition, computing the stress values using a wall model.