57 use precon,
only :
pc_t, precon_factory, precon_destroy
69 use json_module,
only : json_file, json_core, json_value
87 class(
ksp_t),
allocatable :: ksp_vel
88 class(
ksp_t),
allocatable :: ksp_prs
89 class(
pc_t),
allocatable :: pc_vel
90 class(
pc_t),
allocatable :: pc_prs
91 integer :: vel_projection_dim
92 integer :: pr_projection_dim
93 integer :: vel_projection_activ_step
94 integer :: pr_projection_activ_step
95 logical :: strict_convergence
97 logical :: if_gradient_jump_penalty
109 logical :: forced_flow_rate = .false.
112 character(len=:),
allocatable :: nut_field_name
115 integer(kind=i8) :: glb_n_points
117 integer(kind=i8) :: glb_unique_points
132 procedure, pass(this) :: set_material_properties => &
146 module subroutine fluid_scheme_factory(object, type_name)
148 character(len=*) :: type_name
149 end subroutine fluid_scheme_factory
152 public :: fluid_scheme_incompressible_t, fluid_scheme_factory
157 subroutine fluid_scheme_init_base(this, msh, lx, params, scheme, user, &
160 class(fluid_scheme_incompressible_t),
target,
intent(inout) :: this
161 type(
mesh_t),
target,
intent(inout) :: msh
162 integer,
intent(in) :: lx
163 character(len=*),
intent(in) :: scheme
164 type(json_file),
target,
intent(inout) :: params
165 type(
user_t),
target,
intent(in) :: user
166 logical,
intent(in) :: kspv_init
168 character(len=LOG_SIZE) :: log_buf
169 real(kind=
rp),
allocatable :: real_vec(:)
170 real(kind=
rp) :: real_val, kappa, b, z0
171 logical :: logical_val
172 integer :: integer_val, ierr
173 type(json_file) :: wm_json
174 character(len=:),
allocatable :: string_val1, string_val2
175 real(kind=
rp) :: gjp_param_a, gjp_param_b
183 if (msh%gdim .eq. 2)
then
184 call this%Xh%init(
gll, lx, lx)
186 call this%Xh%init(
gll, lx, lx, lx)
189 call this%dm_Xh%init(msh, this%Xh)
191 call this%gs_Xh%init(this%dm_Xh)
193 call this%c_Xh%init(this%gs_Xh)
206 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
208 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
214 call this%set_material_properties(params, user)
219 if (params%valid_path(
'case.fluid.nut_field'))
then
220 call json_get(params,
'case.fluid.nut_field', this%nut_field_name)
221 this%variable_material_properties = .true.
223 this%nut_field_name =
""
228 call this%mu_field%init(this%dm_Xh,
"mu")
229 call this%rho_field%init(this%dm_Xh,
"rho")
230 call field_cfill(this%mu_field, this%mu, this%mu_field%size())
231 call field_cfill(this%rho_field, this%rho, this%mu_field%size())
237 call cfill(this%mu_field%x, this%mu, this%mu_field%size())
238 call cfill(this%rho_field%x, this%rho, this%rho_field%size())
244 'case.fluid.velocity_solver.projection_space_size', &
245 this%vel_projection_dim, 0)
247 'case.fluid.pressure_solver.projection_space_size', &
248 this%pr_projection_dim, 0)
250 'case.fluid.velocity_solver.projection_hold_steps', &
251 this%vel_projection_activ_step, 5)
253 'case.fluid.pressure_solver.projection_hold_steps', &
254 this%pr_projection_activ_step, 5)
259 if (params%valid_path(
"case.fluid.flow_rate_force"))
then
260 this%forced_flow_rate = .true.
265 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
266 else if (lx .ge. 10)
then
267 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
269 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
272 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
273 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
275 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
277 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
280 write(log_buf,
'(A,ES13.6)')
'rho :', this%rho
282 write(log_buf,
'(A,ES13.6)')
'mu :', this%mu
285 call json_get(params,
'case.numerics.dealias', logical_val)
286 write(log_buf,
'(A, L1)')
'Dealias : ', logical_val
289 write(log_buf,
'(A, L1)')
'LES : ', this%variable_material_properties
294 write(log_buf,
'(A, L1)')
'Save bdry : ', logical_val
303 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
304 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
305 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
308 call this%source_term%init(this%f_x, this%f_y, this%f_z, this%c_Xh, user)
309 call this%source_term%add(params,
'case.fluid.source_terms')
313 call neko_log%section(
"Velocity solver")
315 'case.fluid.velocity_solver.max_iterations', &
317 call json_get(params,
'case.fluid.velocity_solver.type', string_val1)
318 call json_get(params,
'case.fluid.velocity_solver.preconditioner', &
320 call json_get(params,
'case.fluid.velocity_solver.absolute_tolerance', &
323 'case.fluid.velocity_solver.monitor', &
324 logical_val, .false.)
326 call neko_log%message(
'Type : ('// trim(string_val1) // &
327 ', ' // trim(string_val2) //
')')
329 write(log_buf,
'(A,ES13.6)')
'Abs tol :', real_val
331 call this%solver_factory(this%ksp_vel, this%dm_Xh%size(), &
332 string_val1, integer_val, real_val, logical_val)
333 call this%precon_factory_(this%pc_vel, this%ksp_vel, &
334 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs_vel, string_val2)
340 this%strict_convergence, .false.)
351 call this%ulag%init(this%u, 2)
352 call this%vlag%init(this%v, 2)
353 call this%wlag%init(this%w, 2)
357 'case.fluid.gradient_jump_penalty.enabled',&
358 this%if_gradient_jump_penalty, .false.)
360 if (this%if_gradient_jump_penalty .eqv. .true.)
then
361 if ((this%dm_Xh%xh%lx - 1) .eq. 1)
then
363 'case.fluid.gradient_jump_penalty.tau',&
364 gjp_param_a, 0.02_rp)
368 'case.fluid.gradient_jump_penalty.scaling_factor',&
371 'case.fluid.gradient_jump_penalty.scaling_exponent',&
374 call this%gradient_jump_penalty_u%init(params, this%dm_Xh, this%c_Xh, &
375 gjp_param_a, gjp_param_b)
376 call this%gradient_jump_penalty_v%init(params, this%dm_Xh, this%c_Xh, &
377 gjp_param_a, gjp_param_b)
378 call this%gradient_jump_penalty_w%init(params, this%dm_Xh, this%c_Xh, &
379 gjp_param_a, gjp_param_b)
157 subroutine fluid_scheme_init_base(this, msh, lx, params, scheme, user, &
…
391 end subroutine fluid_scheme_init_base
393 subroutine fluid_scheme_free(this)
394 class(fluid_scheme_incompressible_t),
intent(inout) :: this
398 if (
allocated(this%ksp_vel))
then
399 call this%ksp_vel%free()
400 deallocate(this%ksp_vel)
403 if (
allocated(this%ksp_prs))
then
404 call this%ksp_prs%free()
405 deallocate(this%ksp_prs)
408 if (
allocated(this%pc_vel))
then
409 call precon_destroy(this%pc_vel)
410 deallocate(this%pc_vel)
413 if (
allocated(this%pc_prs))
then
414 call precon_destroy(this%pc_prs)
415 deallocate(this%pc_prs)
418 call this%source_term%free()
420 call this%gs_Xh%free()
422 call this%c_Xh%free()
424 call this%scratch%free()
431 if (this%variable_material_properties)
then
437 call this%ulag%free()
438 call this%vlag%free()
439 call this%wlag%free()
442 if (
associated(this%f_x))
then
446 if (
associated(this%f_y))
then
450 if (
associated(this%f_z))
then
458 call this%rho_field%free()
459 call this%mu_field%free()
462 if (this%if_gradient_jump_penalty .eqv. .true.)
then
463 call this%gradient_jump_penalty_u%free()
464 call this%gradient_jump_penalty_v%free()
465 call this%gradient_jump_penalty_w%free()
393 subroutine fluid_scheme_free(this)
…
468 end subroutine fluid_scheme_free
472 subroutine fluid_scheme_validate(this)
473 class(fluid_scheme_incompressible_t),
target,
intent(inout) :: this
475 logical :: logical_val
477 if ( (.not.
associated(this%u)) .or. &
478 (.not.
associated(this%v)) .or. &
479 (.not.
associated(this%w)) .or. &
480 (.not.
associated(this%p)))
then
484 if ( (.not.
allocated(this%u%x)) .or. &
485 (.not.
allocated(this%v%x)) .or. &
486 (.not.
allocated(this%w%x)) .or. &
487 (.not.
allocated(this%p%x)))
then
491 if (.not.
allocated(this%ksp_vel))
then
492 call neko_error(
'No Krylov solver for velocity defined')
495 if (.not.
allocated(this%ksp_prs))
then
496 call neko_error(
'No Krylov solver for pressure defined')
472 subroutine fluid_scheme_validate(this)
…
499 end subroutine fluid_scheme_validate
505 subroutine fluid_scheme_bc_apply_vel(this, t, tstep, strong)
506 class(fluid_scheme_incompressible_t),
intent(inout) :: this
507 real(kind=
rp),
intent(in) :: t
508 integer,
intent(in) :: tstep
509 logical,
intent(in) :: strong
512 class(
bc_t),
pointer :: b
515 call this%bcs_vel%apply_vector(&
516 this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), t, tstep, strong)
525 call this%bcs_vel%apply_vector(&
526 this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), t, tstep, strong)
534 do i = 1, this%bcs_vel%size()
535 b => this%bcs_vel%get(i)
505 subroutine fluid_scheme_bc_apply_vel(this, t, tstep, strong)
…
540 end subroutine fluid_scheme_bc_apply_vel
544 subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
545 class(fluid_scheme_incompressible_t),
intent(inout) :: this
546 real(kind=
rp),
intent(in) :: t
547 integer,
intent(in) :: tstep
550 class(
bc_t),
pointer :: b
553 call this%bcs_prs%apply(this%p, t, tstep)
557 call this%bcs_prs%apply(this%p, t, tstep)
561 do i = 1, this%bcs_prs%size()
562 b => this%bcs_prs%get(i)
544 subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
…
567 end subroutine fluid_scheme_bc_apply_prs
571 subroutine fluid_scheme_solver_factory(ksp, n, solver, &
572 max_iter, abstol, monitor)
573 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
574 integer,
intent(in),
value :: n
575 character(len=*),
intent(in) :: solver
576 integer,
intent(in) :: max_iter
577 real(kind=
rp),
intent(in) :: abstol
578 logical,
intent(in) :: monitor
580 call krylov_solver_factory(ksp, n, solver, max_iter, abstol, &
571 subroutine fluid_scheme_solver_factory(ksp, n, solver, &
…
583 end subroutine fluid_scheme_solver_factory
586 subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, &
588 class(fluid_scheme_incompressible_t),
intent(inout) :: this
589 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
590 class(
ksp_t),
target,
intent(inout) :: ksp
591 type(
coef_t),
target,
intent(in) :: coef
592 type(
dofmap_t),
target,
intent(in) :: dof
593 type(
gs_t),
target,
intent(inout) :: gs
594 type(
bc_list_t),
target,
intent(inout) :: bclst
595 character(len=*) :: pctype
597 call precon_factory(pc, pctype)
599 select type (pcp => pc)
601 call pcp%init(coef, dof, gs)
603 call pcp%init(coef, dof, gs)
605 call pcp%init(coef, dof, gs)
607 if (len_trim(pctype) .gt. 4)
then
608 if (index(pctype,
'+') .eq. 5)
then
609 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst, &
615 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
618 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
586 subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, &
…
623 end subroutine fluid_scheme_precon_factory
626 function fluid_compute_cfl(this, dt)
result(c)
627 class(fluid_scheme_incompressible_t),
intent(in) :: this
628 real(kind=
rp),
intent(in) :: dt
631 c =
cfl(dt, this%u%x, this%v%x, this%w%x, &
632 this%Xh, this%c_Xh, this%msh%nelv, this%msh%gdim)
626 function fluid_compute_cfl(this, dt)
result(c)
…
634 end function fluid_compute_cfl
638 subroutine fluid_scheme_update_material_properties(this)
639 class(fluid_scheme_incompressible_t),
intent(inout) :: this
643 this%mu_field = this%mu
644 if (this%variable_material_properties)
then
638 subroutine fluid_scheme_update_material_properties(this)
…
649 end subroutine fluid_scheme_update_material_properties
654 subroutine fluid_scheme_set_material_properties(this, params, user)
655 class(fluid_scheme_incompressible_t),
intent(inout) :: this
656 type(json_file),
intent(inout) :: params
657 type(
user_t),
target,
intent(in) :: user
658 character(len=LOG_SIZE) :: log_buf
661 logical :: nondimensional
662 real(kind=
rp) :: dummy_lambda, dummy_cp
666 if (.not.
associated(user%material_properties, dummy_mp_ptr))
then
668 write(log_buf,
'(A)')
"Material properties must be set in the user&
671 call user%material_properties(0.0_rp, 0, this%rho, this%mu, &
672 dummy_cp, dummy_lambda, params)
675 if (params%valid_path(
'case.fluid.Re') .and. &
676 (params%valid_path(
'case.fluid.mu') .or. &
677 params%valid_path(
'case.fluid.rho')))
then
678 call neko_error(
"To set the material properties for the fluid," // &
679 " either provide Re OR mu and rho in the case file.")
682 else if (params%valid_path(
'case.fluid.Re'))
then
684 write(log_buf,
'(A)')
'Non-dimensional fluid material properties &
687 write(log_buf,
'(A)')
'Density will be set to 1, dynamic viscosity to&
692 call json_get(params,
'case.fluid.Re', this%mu)
693 write(log_buf,
'(A)')
'Read non-dimensional material properties'
695 write(log_buf,
'(A,ES13.6)')
'Re :', this%mu
701 this%mu = 1.0_rp/this%mu
704 call json_get(params,
'case.fluid.mu', this%mu)
705 call json_get(params,
'case.fluid.rho', this%rho)
654 subroutine fluid_scheme_set_material_properties(this, params, user)
…
709 end subroutine fluid_scheme_set_material_properties
Abstract interface to sets rho and mu.
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.
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 .
Device abstraction, common interface for various accelerators.
subroutine, public device_event_sync(event)
Synchronize an event.
type(c_ptr), bind(C), public glb_cmd_event
Event for the global command queue.
Defines a dirichlet boundary condition.
Defines a mapping of the degrees of freedom.
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
subroutine, public field_add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
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)
subroutine fluid_scheme_validate(this)
Validate that all fields, solvers etc necessary for performing time-stepping are defined.
real(kind=rp) function fluid_compute_cfl(this, dt)
Compute CFL.
subroutine fluid_scheme_solver_factory(ksp, n, solver, max_iter, abstol, monitor)
Initialize a linear solver.
subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
Apply all boundary conditions defined for pressure.
subroutine fluid_scheme_bc_apply_vel(this, t, tstep, strong)
Apply all boundary conditions defined for velocity Here we perform additional gs operations to take c...
subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, pctype)
Initialize a Krylov preconditioner.
subroutine fluid_scheme_update_material_properties(this)
Update the values of mu_field if necessary.
subroutine fluid_scheme_init_base(this, msh, lx, params, scheme, user, kspv_init)
Initialise a fluid scheme.
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.
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...
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.
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 a zero-valued Dirichlet boundary condition.
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
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 .
Base type of all fluid formulations.
Base type of all fluid formulations.
Wrapper contaning and executing the fluid source terms.
Implements the gradient jump penalty.
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.
Provides a tool to set time step dt.
A type collecting all the overridable user routines.
User defined dirichlet condition for velocity.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...