52  use precon, 
only : 
pc_t, precon_factory, precon_destroy
 
   62  use json_module, 
only : json_file
 
   78     class(
ksp_t), 
allocatable :: ksp_vel
 
   79     class(
ksp_t), 
allocatable :: ksp_prs
 
   80     class(
pc_t), 
allocatable :: pc_vel
 
   81     class(
pc_t), 
allocatable :: pc_prs
 
   82     integer :: vel_projection_dim
 
   83     integer :: pr_projection_dim
 
   84     integer :: vel_projection_activ_step
 
   85     integer :: pr_projection_activ_step
 
   86     logical :: strict_convergence
 
   93     logical :: forced_flow_rate = .false. 
 
   96     character(len=:), 
allocatable :: nut_field_name
 
   99     type(
field_t), 
pointer :: mu_tot => null()
 
  102     integer(kind=i8) :: glb_n_points
 
  104     integer(kind=i8) :: glb_unique_points
 
  119     procedure, pass(this) :: set_material_properties => &
 
 
  133     module subroutine fluid_scheme_factory(object, type_name)
 
  135       character(len=*) :: type_name
 
  136     end subroutine fluid_scheme_factory
 
  139  public :: fluid_scheme_incompressible_t, fluid_scheme_factory
 
  144  subroutine fluid_scheme_init_base(this, msh, lx, params, scheme, user, &
 
  147    class(fluid_scheme_incompressible_t), 
target, 
intent(inout) :: this
 
  148    type(
mesh_t), 
target, 
intent(inout) :: msh
 
  149    integer, 
intent(in) :: lx
 
  150    character(len=*), 
intent(in) :: scheme
 
  151    type(json_file), 
target, 
intent(inout) :: params
 
  152    type(
user_t), 
target, 
intent(in) :: user
 
  153    logical, 
intent(in) :: kspv_init
 
  155    character(len=LOG_SIZE) :: log_buf
 
  156    real(kind=
rp), 
allocatable :: real_vec(:)
 
  157    real(kind=
rp) :: real_val, kappa, b, z0
 
  158    logical :: logical_val
 
  159    integer :: integer_val, ierr
 
  160    type(json_file) :: wm_json
 
  161    character(len=:), 
allocatable :: string_val1, string_val2
 
  162    real(kind=
rp) :: gjp_param_a, gjp_param_b
 
  163    type(json_file) :: json_subdict
 
  171    if (msh%gdim .eq. 2) 
then 
  172       call this%Xh%init(
gll, lx, lx)
 
  174       call this%Xh%init(
gll, lx, lx, lx)
 
  177    call this%dm_Xh%init(msh, this%Xh)
 
  179    call this%gs_Xh%init(this%dm_Xh)
 
  181    call this%c_Xh%init(this%gs_Xh)
 
  184    call this%scratch%init(this%dm_Xh, 10, 2)
 
  194    write(log_buf, 
'(A, A)') 
'Type       : ', trim(scheme)
 
  196    write(log_buf, 
'(A, A)') 
'Name       : ', trim(this%name)
 
  210    call this%set_material_properties(params, 
user)
 
  214         'case.fluid.velocity_solver.projection_space_size', &
 
  215         this%vel_projection_dim, 0)
 
  217         'case.fluid.pressure_solver.projection_space_size', &
 
  218         this%pr_projection_dim, 0)
 
  220         'case.fluid.velocity_solver.projection_hold_steps', &
 
  221         this%vel_projection_activ_step, 5)
 
  223         'case.fluid.pressure_solver.projection_hold_steps', &
 
  224         this%pr_projection_activ_step, 5)
 
  229    if (params%valid_path(
"case.fluid.flow_rate_force")) 
then 
  230       this%forced_flow_rate = .true.
 
  235       write(log_buf, 
'(A, I1)') 
'Poly order : ', lx-1
 
  236    else if (lx .ge. 10) 
then 
  237       write(log_buf, 
'(A, I2)') 
'Poly order : ', lx-1
 
  239       write(log_buf, 
'(A, I3)') 
'Poly order : ', lx-1
 
  242    this%glb_n_points = int(this%msh%glb_nelv, 
i8)*int(this%Xh%lxyz, 
i8)
 
  243    this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()), 
i8)
 
  245    write(log_buf, 
'(A, I0)') 
'GLL points : ', this%glb_n_points
 
  247    write(log_buf, 
'(A, I0)') 
'Unique pts.: ', this%glb_unique_points
 
  251    call json_get(params, 
'case.numerics.dealias', logical_val)
 
  252    write(log_buf, 
'(A, L1)') 
'Dealias    : ', logical_val
 
  258    write(log_buf, 
'(A, L1)') 
'Save bdry  : ', logical_val
 
  262         logical_val, .false.)
 
  263    write(log_buf, 
'(A, L1)') 
'Full stress: ', logical_val
 
  273    call this%f_x%init(this%dm_Xh, fld_name = 
"fluid_rhs_x")
 
  274    call this%f_y%init(this%dm_Xh, fld_name = 
"fluid_rhs_y")
 
  275    call this%f_z%init(this%dm_Xh, fld_name = 
"fluid_rhs_z")
 
  279       call neko_log%section(
"Velocity solver")
 
  281            'case.fluid.velocity_solver.max_iterations', &
 
  283       call json_get(params, 
'case.fluid.velocity_solver.type', string_val1)
 
  284       call json_get(params, 
'case.fluid.velocity_solver.preconditioner.type', &
 
  287            'case.fluid.velocity_solver.preconditioner', json_subdict)
 
  288       call json_get(params, 
'case.fluid.velocity_solver.absolute_tolerance', &
 
  291            'case.fluid.velocity_solver.monitor', &
 
  292            logical_val, .false.)
 
  294       call neko_log%message(
'Type       : ('// trim(string_val1) // &
 
  295            ', ' // trim(string_val2) // 
')')
 
  297       write(log_buf, 
'(A,ES13.6)') 
'Abs tol    :', real_val
 
  299       call this%solver_factory(this%ksp_vel, this%dm_Xh%size(), &
 
  300            string_val1, integer_val, real_val, logical_val)
 
  301       call this%precon_factory_(this%pc_vel, this%ksp_vel, &
 
  302            this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs_vel, &
 
  303            string_val2, json_subdict)
 
  309         this%strict_convergence, .false.)
 
  313    call this%ulag%init(this%u, 2)
 
  314    call this%vlag%init(this%v, 2)
 
  315    call this%wlag%init(this%w, 2)
 
  325    call neko_log%section(
'Fluid Source term')
 
  326    call this%source_term%init(this%f_x, this%f_y, this%f_z, this%c_Xh, 
user, &
 
  328    call this%source_term%add(params, 
'case.fluid.source_terms')
 
 
  331  end subroutine fluid_scheme_init_base
 
  333  subroutine fluid_scheme_free(this)
 
  334    class(fluid_scheme_incompressible_t), 
intent(inout) :: this
 
  338    if (
allocated(this%ksp_vel)) 
then 
  339       call this%ksp_vel%free()
 
  340       deallocate(this%ksp_vel)
 
  343    if (
allocated(this%ksp_prs)) 
then 
  344       call this%ksp_prs%free()
 
  345       deallocate(this%ksp_prs)
 
  348    if (
allocated(this%pc_vel)) 
then 
  349       call precon_destroy(this%pc_vel)
 
  350       deallocate(this%pc_vel)
 
  353    if (
allocated(this%pc_prs)) 
then 
  354       call precon_destroy(this%pc_prs)
 
  355       deallocate(this%pc_prs)
 
  358    call this%source_term%free()
 
  360    call this%gs_Xh%free()
 
  362    call this%c_Xh%free()
 
  364    call this%scratch%free()
 
  375    call this%ulag%free()
 
  376    call this%vlag%free()
 
  377    call this%wlag%free()
 
  380    if (
associated(this%f_x)) 
then 
  384    if (
associated(this%f_y)) 
then 
  388    if (
associated(this%f_z)) 
then 
  399    call this%dm_Xh%free()
 
 
  402  end subroutine fluid_scheme_free
 
  406  subroutine fluid_scheme_validate(this)
 
  407    class(fluid_scheme_incompressible_t), 
target, 
intent(inout) :: this
 
  409    logical :: logical_val
 
  411    if ( (.not. 
associated(this%u)) .or. &
 
  412         (.not. 
associated(this%v)) .or. &
 
  413         (.not. 
associated(this%w)) .or. &
 
  414         (.not. 
associated(this%p))) 
then 
  418    if ( (.not. 
allocated(this%u%x)) .or. &
 
  419         (.not. 
allocated(this%v%x)) .or. &
 
  420         (.not. 
allocated(this%w%x)) .or. &
 
  421         (.not. 
allocated(this%p%x))) 
then 
  425    if (.not. 
allocated(this%ksp_vel)) 
then 
  426       call neko_error(
'No Krylov solver for velocity defined')
 
  429    if (.not. 
allocated(this%ksp_prs)) 
then 
  430       call neko_error(
'No Krylov solver for pressure defined')
 
 
  433  end subroutine fluid_scheme_validate
 
  439  subroutine fluid_scheme_bc_apply_vel(this, time, strong)
 
  440    class(fluid_scheme_incompressible_t), 
intent(inout) :: this
 
  442    logical, 
intent(in) :: strong
 
  444    class(
bc_t), 
pointer :: b
 
  447    call this%bcs_vel%apply_vector(&
 
  448         this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), time, strong)
 
  457    call this%bcs_vel%apply_vector(&
 
  458         this%u%x, this%v%x, this%w%x, this%dm_Xh%size(), time, strong)
 
  466    do i = 1, this%bcs_vel%size()
 
  467       b => this%bcs_vel%get(i)
 
 
  472  end subroutine fluid_scheme_bc_apply_vel
 
  476  subroutine fluid_scheme_bc_apply_prs(this, time)
 
  477    class(fluid_scheme_incompressible_t), 
intent(inout) :: this
 
  481    class(
bc_t), 
pointer :: b
 
  484    call this%bcs_prs%apply(this%p, time)
 
  488    call this%bcs_prs%apply(this%p, time)
 
  492    do i = 1, this%bcs_prs%size()
 
  493       b => this%bcs_prs%get(i)
 
 
  498  end subroutine fluid_scheme_bc_apply_prs
 
  502  subroutine fluid_scheme_solver_factory(ksp, n, solver, &
 
  503       max_iter, abstol, monitor)
 
  504    class(
ksp_t), 
allocatable, 
target, 
intent(inout) :: ksp
 
  505    integer, 
intent(in), 
value :: n
 
  506    character(len=*), 
intent(in) :: solver
 
  507    integer, 
intent(in) :: max_iter
 
  508    real(kind=
rp), 
intent(in) :: abstol
 
  509    logical, 
intent(in) :: monitor
 
  511    call krylov_solver_factory(ksp, n, solver, max_iter, abstol, &
 
 
  514  end subroutine fluid_scheme_solver_factory
 
  517  subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, &
 
  519    class(fluid_scheme_incompressible_t), 
intent(inout) :: this
 
  520    class(
pc_t), 
allocatable, 
target, 
intent(inout) :: pc
 
  521    class(
ksp_t), 
target, 
intent(inout) :: ksp
 
  522    type(
coef_t), 
target, 
intent(in) :: coef
 
  523    type(
dofmap_t), 
target, 
intent(in) :: dof
 
  524    type(
gs_t), 
target, 
intent(inout) :: gs
 
  525    type(
bc_list_t), 
target, 
intent(inout) :: bclst
 
  526    character(len=*) :: pctype
 
  527    type(json_file), 
intent(inout) :: pcparams
 
  529    call precon_factory(pc, pctype)
 
  531    select type (pcp => pc)
 
  533       call pcp%init(coef, dof, gs)
 
  535       call pcp%init(coef, dof, gs)
 
  537       call pcp%init(coef, dof, gs)
 
  539       call pcp%init(coef, bclst, pcparams)
 
  541       call pcp%init(coef, bclst, pcparams)
 
 
  546  end subroutine fluid_scheme_precon_factory
 
  549  function fluid_compute_cfl(this, dt) 
result(c)
 
  550    class(fluid_scheme_incompressible_t), 
intent(in) :: this
 
  551    real(kind=
rp), 
intent(in) :: dt
 
  554    c = 
cfl(dt, this%u%x, this%v%x, this%w%x, &
 
  555         this%Xh, this%c_Xh, this%msh%nelv, this%msh%gdim)
 
 
  557  end function fluid_compute_cfl
 
  564  subroutine fluid_scheme_update_material_properties(this, time)
 
  565    class(fluid_scheme_incompressible_t), 
intent(inout) :: this
 
  569    call this%user_material_properties(this%name, this%material_properties, &
 
  572    if (len(trim(this%nut_field_name)) > 0) 
then 
  585       call device_memcpy(this%rho%x, this%rho%x_d, this%rho%size(), &
 
 
  588  end subroutine fluid_scheme_update_material_properties
 
  593  subroutine fluid_scheme_set_material_properties(this, params, user)
 
  594    class(fluid_scheme_incompressible_t), 
target, 
intent(inout) :: this
 
  595    type(json_file), 
intent(inout) :: params
 
  596    type(
user_t), 
target, 
intent(in) :: user
 
  597    character(len=LOG_SIZE) :: log_buf
 
  600    logical :: nondimensional
 
  601    real(kind=
rp) :: dummy_lambda, dummy_cp
 
  602    real(kind=
rp) :: const_mu, const_rho
 
  615    call this%material_properties%init(2)
 
  616    call this%material_properties%assign(1, this%rho)
 
  617    call this%material_properties%assign(2, this%mu)
 
  619    if (.not. 
associated(
user%material_properties, dummy_mp_ptr)) 
then 
  621       write(log_buf, 
'(A)') 
'Material properties must be set in the user' // &
 
  624       this%user_material_properties => 
user%material_properties
 
  626       call user%material_properties(this%name, this%material_properties, &
 
  632       if (params%valid_path(
'case.fluid.Re') .and. &
 
  633            (params%valid_path(
'case.fluid.mu') .or. &
 
  634            params%valid_path(
'case.fluid.rho'))) 
then 
  635          call neko_error(
"To set the material properties for the fluid, " // &
 
  636               "either provide Re OR mu and rho in the case file.")
 
  638       else if (params%valid_path(
'case.fluid.Re')) 
then 
  640          write(log_buf, 
'(A)') 
'Non-dimensional fluid material properties & 
  643          write(log_buf, 
'(A)') 
'Density will be set to 1, dynamic viscosity to& 
  648          call json_get(params, 
'case.fluid.Re', const_mu)
 
  649          write(log_buf, 
'(A)') 
'Read non-dimensional material properties' 
  651          write(log_buf, 
'(A,ES13.6)') 
'Re         :', const_mu
 
  657          const_mu = 1.0_rp/const_mu
 
  660          call json_get(params, 
'case.fluid.mu', const_mu)
 
  661          call json_get(params, 
'case.fluid.rho', const_rho)
 
  667    if (
associated(
user%material_properties, dummy_mp_ptr)) 
then 
  674       write(log_buf, 
'(A,ES13.6)') 
'rho        :', const_rho
 
  676       write(log_buf, 
'(A,ES13.6)') 
'mu         :', const_mu
 
  688       call device_memcpy(this%rho%x, this%rho%x_d, this%rho%size(), &
 
  692       call device_memcpy(this%mu_tot%x, this%mu_tot%x_d, this%mu%size(), &
 
 
  695  end subroutine fluid_scheme_set_material_properties
 
Copy data between host and device (or device and device)
 
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.
 
Defines a boundary condition.
 
Jacobi preconditioner accelerator backend.
 
Device abstraction, common interface for various accelerators.
 
subroutine, public device_event_sync(event)
Synchronize an event.
 
integer, parameter, public device_to_host
 
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_addcol3(a, b, c, n)
Returns .
 
subroutine, public field_copy(a, b, n)
Copy a vector .
 
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_update_material_properties(this, time)
Call user material properties routine and update the values of mu if necessary.
 
subroutine fluid_scheme_precon_factory(this, pc, ksp, coef, dof, gs, bclst, pctype, pcparams)
Initialize a Krylov preconditioner.
 
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_bc_apply_vel(this, time, strong)
Apply all boundary conditions defined for velocity Here we perform additional gs operations to take c...
 
subroutine fluid_scheme_solver_factory(ksp, n, solver, max_iter, abstol, monitor)
Initialize a linear solver.
 
subroutine fluid_scheme_bc_apply_prs(this, time)
Apply all boundary conditions defined for pressure.
 
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 =  ...
 
Utilities for retrieving parameters from the case files.
 
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.
 
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...
 
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.
 
Module with things related to the simulation time.
 
Interfaces for user interaction with NEKO.
 
subroutine, public dummy_user_material_properties(scheme_name, properties, time)
 
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.
 
Defines a jacobi preconditioner.
 
Base abstract type for a canonical Krylov method, solving .
 
Defines a canonical Krylov preconditioner.
 
Defines a jacobi preconditioner for SX-Aurora.
 
A struct that contains all info about the time, expand as needed.
 
A type collecting all the overridable user routines and flag to suppress type injection from custom m...