48 use krylov,
only :
ksp_t, krylov_solver_factory, krylov_solver_destroy, &
60 use precon,
only :
pc_t, precon_factory, precon_destroy
72 use json_module,
only : json_file, json_core, json_value
91 class(
ksp_t),
allocatable :: ksp_vel
92 class(
ksp_t),
allocatable :: ksp_prs
93 class(
pc_t),
allocatable :: pc_vel
94 class(
pc_t),
allocatable :: pc_prs
95 integer :: vel_projection_dim
96 integer :: pr_projection_dim
97 integer :: vel_projection_activ_step
98 integer :: pr_projection_activ_step
99 logical :: strict_convergence
101 logical :: if_gradient_jump_penalty
113 logical :: forced_flow_rate = .false.
116 character(len=:),
allocatable :: nut_field_name
119 integer(kind=i8) :: glb_n_points
121 integer(kind=i8) :: glb_unique_points
136 procedure, pass(this) :: set_material_properties => &
150 module subroutine fluid_scheme_factory(object, type_name)
152 character(len=*) :: type_name
153 end subroutine fluid_scheme_factory
156 public :: fluid_scheme_incompressible_t, fluid_scheme_factory
161 subroutine fluid_scheme_init_base(this, msh, lx, params, scheme, user, &
164 class(fluid_scheme_incompressible_t),
target,
intent(inout) :: this
165 type(
mesh_t),
target,
intent(inout) :: msh
166 integer,
intent(in) :: lx
167 character(len=*),
intent(in) :: scheme
168 type(json_file),
target,
intent(inout) :: params
169 type(
user_t),
target,
intent(in) :: user
170 logical,
intent(in) :: kspv_init
172 character(len=LOG_SIZE) :: log_buf
173 real(kind=
rp),
allocatable :: real_vec(:)
174 real(kind=
rp) :: real_val, kappa, b, z0
175 logical :: logical_val
176 integer :: integer_val, ierr
177 type(json_file) :: wm_json
178 character(len=:),
allocatable :: string_val1, string_val2
179 real(kind=
rp) :: gjp_param_a, gjp_param_b
187 if (msh%gdim .eq. 2)
then
188 call this%Xh%init(
gll, lx, lx)
190 call this%Xh%init(
gll, lx, lx, lx)
193 call this%dm_Xh%init(msh, this%Xh)
195 call this%gs_Xh%init(this%dm_Xh)
197 call this%c_Xh%init(this%gs_Xh)
207 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
213 call this%set_material_properties(params, user)
218 if (params%valid_path(
'case.fluid.nut_field'))
then
219 call json_get(params,
'case.fluid.nut_field', this%nut_field_name)
220 this%variable_material_properties = .true.
222 this%nut_field_name =
""
227 call this%mu_field%init(this%dm_Xh,
"mu")
228 call this%rho_field%init(this%dm_Xh,
"rho")
229 call field_cfill(this%mu_field, this%mu, this%mu_field%size())
230 call field_cfill(this%rho_field, this%rho, this%mu_field%size())
236 call cfill(this%mu_field%x, this%mu, this%mu_field%size())
237 call cfill(this%rho_field%x, this%rho, this%rho_field%size())
243 'case.fluid.velocity_solver.projection_space_size', &
244 this%vel_projection_dim, 20)
246 'case.fluid.pressure_solver.projection_space_size', &
247 this%pr_projection_dim, 20)
249 'case.fluid.velocity_solver.projection_hold_steps', &
250 this%vel_projection_activ_step, 5)
252 'case.fluid.pressure_solver.projection_hold_steps', &
253 this%pr_projection_activ_step, 5)
258 if (params%valid_path(
"case.fluid.flow_rate_force"))
then
259 this%forced_flow_rate = .true.
264 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
265 else if (lx .ge. 10)
then
266 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
268 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
271 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
272 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
274 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
276 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
279 write(log_buf,
'(A,ES13.6)')
'rho :', this%rho
281 write(log_buf,
'(A,ES13.6)')
'mu :', this%mu
284 call json_get(params,
'case.numerics.dealias', logical_val)
285 write(log_buf,
'(A, L1)')
'Dealias : ', logical_val
288 write(log_buf,
'(A, L1)')
'LES : ', this%variable_material_properties
293 write(log_buf,
'(A, L1)')
'Save bdry : ', logical_val
302 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
303 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
304 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
307 call this%source_term%init(this%f_x, this%f_y, this%f_z, this%c_Xh, user)
308 call this%source_term%add(params,
'case.fluid.source_terms')
312 call neko_log%section(
"Velocity solver")
314 'case.fluid.velocity_solver.max_iterations', &
316 call json_get(params,
'case.fluid.velocity_solver.type', string_val1)
317 call json_get(params,
'case.fluid.velocity_solver.preconditioner', &
319 call json_get(params,
'case.fluid.velocity_solver.absolute_tolerance', &
322 'case.fluid.velocity_solver.monitor', &
323 logical_val, .false.)
325 call neko_log%message(
'Type : ('// trim(string_val1) // &
326 ', ' // trim(string_val2) //
')')
328 write(log_buf,
'(A,ES13.6)')
'Abs tol :', real_val
330 call this%solver_factory(this%ksp_vel, this%dm_Xh%size(), &
331 string_val1, integer_val, real_val, logical_val)
332 call this%precon_factory_(this%pc_vel, this%ksp_vel, &
333 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs_vel, string_val2)
339 this%strict_convergence, .false.)
350 call this%ulag%init(this%u, 2)
351 call this%vlag%init(this%v, 2)
352 call this%wlag%init(this%w, 2)
356 'case.fluid.gradient_jump_penalty.enabled',&
357 this%if_gradient_jump_penalty, .false.)
359 if (this%if_gradient_jump_penalty .eqv. .true.)
then
360 if ((this%dm_Xh%xh%lx - 1) .eq. 1)
then
362 'case.fluid.gradient_jump_penalty.tau',&
363 gjp_param_a, 0.02_rp)
367 'case.fluid.gradient_jump_penalty.scaling_factor',&
370 'case.fluid.gradient_jump_penalty.scaling_exponent',&
373 call this%gradient_jump_penalty_u%init(params, this%dm_Xh, this%c_Xh, &
374 gjp_param_a, gjp_param_b)
375 call this%gradient_jump_penalty_v%init(params, this%dm_Xh, this%c_Xh, &
376 gjp_param_a, gjp_param_b)
377 call this%gradient_jump_penalty_w%init(params, this%dm_Xh, this%c_Xh, &
378 gjp_param_a, gjp_param_b)
161 subroutine fluid_scheme_init_base(this, msh, lx, params, scheme, user, &
…
390 end subroutine fluid_scheme_init_base
392 subroutine fluid_scheme_free(this)
393 class(fluid_scheme_incompressible_t),
intent(inout) :: this
401 if (
allocated(this%ksp_vel))
then
402 call krylov_solver_destroy(this%ksp_vel)
403 deallocate(this%ksp_vel)
406 if (
allocated(this%ksp_prs))
then
407 call krylov_solver_destroy(this%ksp_prs)
408 deallocate(this%ksp_prs)
411 if (
allocated(this%pc_vel))
then
412 call precon_destroy(this%pc_vel)
413 deallocate(this%pc_vel)
416 if (
allocated(this%pc_prs))
then
417 call precon_destroy(this%pc_prs)
418 deallocate(this%pc_prs)
421 call this%source_term%free()
423 call this%gs_Xh%free()
425 call this%c_Xh%free()
427 call this%scratch%free()
434 if (this%variable_material_properties)
then
440 call this%ulag%free()
441 call this%vlag%free()
442 call this%wlag%free()
445 if (
associated(this%f_x))
then
449 if (
associated(this%f_y))
then
453 if (
associated(this%f_z))
then
461 call this%rho_field%free()
462 call this%mu_field%free()
465 if (this%if_gradient_jump_penalty .eqv. .true.)
then
466 call this%gradient_jump_penalty_u%free()
467 call this%gradient_jump_penalty_v%free()
468 call this%gradient_jump_penalty_w%free()
392 subroutine fluid_scheme_free(this)
…
471 end subroutine fluid_scheme_free
475 subroutine fluid_scheme_validate(this)
476 class(fluid_scheme_incompressible_t),
target,
intent(inout) :: this
478 logical :: logical_val
480 if ( (.not.
associated(this%u)) .or. &
481 (.not.
associated(this%v)) .or. &
482 (.not.
associated(this%w)) .or. &
483 (.not.
associated(this%p)))
then
487 if ( (.not.
allocated(this%u%x)) .or. &
488 (.not.
allocated(this%v%x)) .or. &
489 (.not.
allocated(this%w%x)) .or. &
490 (.not.
allocated(this%p%x)))
then
494 if (.not.
allocated(this%ksp_vel))
then
495 call neko_error(
'No Krylov solver for velocity defined')
498 if (.not.
allocated(this%ksp_prs))
then
499 call neko_error(
'No Krylov solver for pressure defined')
505 call this%chkp%init(this%u, this%v, this%w, this%p)
475 subroutine fluid_scheme_validate(this)
…
507 end subroutine fluid_scheme_validate
513 subroutine fluid_scheme_bc_apply_vel(this, t, tstep, strong)
514 class(fluid_scheme_incompressible_t),
intent(inout) :: this
515 real(kind=
rp),
intent(in) :: t
516 integer,
intent(in) :: tstep
517 logical,
intent(in) :: strong
519 call this%bcs_vel%apply_vector(&
520 this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), t, tstep, strong)
528 call this%bcs_vel%apply_vector(&
529 this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), t, tstep, strong)
513 subroutine fluid_scheme_bc_apply_vel(this, t, tstep, strong)
…
537 end subroutine fluid_scheme_bc_apply_vel
541 subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
542 class(fluid_scheme_incompressible_t),
intent(inout) :: this
543 real(kind=
rp),
intent(in) :: t
544 integer,
intent(in) :: tstep
546 call this%bcs_prs%apply(this%p, t, tstep)
552 call this%bcs_prs%apply(this%p, t, tstep)
541 subroutine fluid_scheme_bc_apply_prs(this, t, tstep)
…
559 end subroutine fluid_scheme_bc_apply_prs
563 subroutine fluid_scheme_solver_factory(ksp, n, solver, &
564 max_iter, abstol, monitor)
565 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
566 integer,
intent(in),
value :: n
567 character(len=*),
intent(in) :: solver
568 integer,
intent(in) :: max_iter
569 real(kind=
rp),
intent(in) :: abstol
570 logical,
intent(in) :: monitor
572 call krylov_solver_factory(ksp, n, solver, max_iter, abstol, &
563 subroutine fluid_scheme_solver_factory(ksp, n, solver, &
…
575 end subroutine fluid_scheme_solver_factory
578 subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, &
580 class(fluid_scheme_incompressible_t),
intent(inout) :: this
581 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
582 class(
ksp_t),
target,
intent(inout) :: ksp
583 type(
coef_t),
target,
intent(in) :: coef
584 type(
dofmap_t),
target,
intent(in) :: dof
585 type(
gs_t),
target,
intent(inout) :: gs
586 type(
bc_list_t),
target,
intent(inout) :: bclst
587 character(len=*) :: pctype
589 call precon_factory(pc, pctype)
591 select type (pcp => pc)
593 call pcp%init(coef, dof, gs)
595 call pcp%init(coef, dof, gs)
597 call pcp%init(coef, dof, gs)
599 if (len_trim(pctype) .gt. 4)
then
600 if (index(pctype,
'+') .eq. 5)
then
601 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst, &
607 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
610 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
578 subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, &
…
615 end subroutine fluid_scheme_precon_factory
618 function fluid_compute_cfl(this, dt)
result(c)
619 class(fluid_scheme_incompressible_t),
intent(in) :: this
620 real(kind=
rp),
intent(in) :: dt
623 c =
cfl(dt, this%u%x, this%v%x, this%w%x, &
624 this%Xh, this%c_Xh, this%msh%nelv, this%msh%gdim)
618 function fluid_compute_cfl(this, dt)
result(c)
…
626 end function fluid_compute_cfl
630 subroutine fluid_scheme_update_material_properties(this)
631 class(fluid_scheme_incompressible_t),
intent(inout) :: this
635 this%mu_field = this%mu
636 if (this%variable_material_properties)
then
630 subroutine fluid_scheme_update_material_properties(this)
…
641 end subroutine fluid_scheme_update_material_properties
646 subroutine fluid_scheme_set_material_properties(this, params, user)
647 class(fluid_scheme_incompressible_t),
intent(inout) :: this
648 type(json_file),
intent(inout) :: params
649 type(
user_t),
target,
intent(in) :: user
650 character(len=LOG_SIZE) :: log_buf
653 logical :: nondimensional
654 real(kind=
rp) :: dummy_lambda, dummy_cp
658 if (.not.
associated(user%material_properties, dummy_mp_ptr))
then
660 write(log_buf,
'(A)')
"Material properties must be set in the user&
663 call user%material_properties(0.0_rp, 0, this%rho, this%mu, &
664 dummy_cp, dummy_lambda, params)
667 if (params%valid_path(
'case.fluid.Re') .and. &
668 (params%valid_path(
'case.fluid.mu') .or. &
669 params%valid_path(
'case.fluid.rho')))
then
670 call neko_error(
"To set the material properties for the fluid,&
671 & either provide Re OR mu and rho in the case file.")
674 else if (params%valid_path(
'case.fluid.Re'))
then
676 write(log_buf,
'(A)')
'Non-dimensional fluid material properties &
679 write(log_buf,
'(A)')
'Density will be set to 1, dynamic viscosity to&
684 call json_get(params,
'case.fluid.Re', this%mu)
685 write(log_buf,
'(A)')
'Read non-dimensional material properties'
687 write(log_buf,
'(A,ES13.6)')
'Re :', this%mu
693 this%mu = 1.0_rp/this%mu
696 call json_get(params,
'case.fluid.mu', this%mu)
697 call json_get(params,
'case.fluid.rho', this%rho)
646 subroutine fluid_scheme_set_material_properties(this, params, user)
…
701 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.
subroutine, public device_stream_wait_event(stream, event, flags)
Synchronize a device stream with an event.
type(c_ptr), bind(C), public glb_cmd_queue
Global command queue.
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.
Defines inflow dirichlet conditions.
Defines user dirichlet condition for a scalar field.
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 .
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.
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.
User defined dirichlet condition for velocity.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...