44 use krylov,
only :
ksp_t, krylov_solver_factory, krylov_solver_destroy, &
53 use precon,
only :
pc_t, precon_factory, precon_destroy
64 use json_module,
only : json_file
94 type(
gs_t),
pointer :: gs_xh
104 integer :: ksp_maxiter
106 integer :: projection_dim
108 integer :: projection_activ_step
122 integer :: n_dir_bcs = 0
124 integer :: n_neumann_bcs = 0
130 type(json_file),
pointer :: params
136 real(kind=
rp),
pointer :: lambda
140 character(len=:),
allocatable :: nut_field_name
142 real(kind=
rp),
pointer :: rho
144 real(kind=
rp),
pointer :: cp
146 real(kind=
rp) :: pr_turb
148 logical :: variable_material_properties = .false.
150 character(len=NEKO_MSH_MAX_ZLBL_LEN),
allocatable :: bc_labels(:)
161 procedure, pass(this) :: update_material_properties => &
176 material_properties, &
177 ulag, vlag, wlag, time_scheme)
188 type(
mesh_t),
target,
intent(inout) :: msh
189 type(
coef_t),
target,
intent(inout) :: coef
190 type(
gs_t),
target,
intent(inout) :: gs
191 type(json_file),
target,
intent(inout) :: params
192 type(
user_t),
target,
intent(in) :: user
206 real(kind=
rp) :: dtlag(10), tlag(10)
227 real(kind=
rp),
intent(inout) :: t
228 integer,
intent(inout) :: tstep
229 real(kind=
rp),
intent(in) :: dt
243 type(
facet_zone_t),
intent(inout) :: zones(NEKO_MSH_MAX_ZLBLS)
244 character(len=NEKO_MSH_MAX_ZLBL_LEN),
intent(in) :: bc_labels(:)
245 character(len=NEKO_MSH_MAX_ZLBL_LEN) :: bc_label
247 real(kind=
rp) :: dir_value, flux
250 do i = 1,
size(bc_labels)
251 bc_label = trim(bc_labels(i))
252 if (bc_label(1:2) .eq.
'd=')
then
268 this%n_dir_bcs = this%n_dir_bcs + 1
269 call this%dir_bcs(this%n_dir_bcs)%init_base(this%c_Xh)
270 call this%dir_bcs(this%n_dir_bcs)%mark_zone(zones(i))
271 read(bc_label(3:), *) dir_value
272 call this%dir_bcs(this%n_dir_bcs)%set_g(dir_value)
273 call this%dir_bcs(this%n_dir_bcs)%finalize()
276 if (bc_label(1:2) .eq.
'n=')
then
277 this%n_neumann_bcs = this%n_neumann_bcs + 1
278 call this%neumann_bcs(this%n_neumann_bcs)%init_base(this%c_Xh)
279 call this%neumann_bcs(this%n_neumann_bcs)%mark_zone(zones(i))
280 read(bc_label(3:), *) flux
281 call this%neumann_bcs(this%n_neumann_bcs)%finalize_neumann(flux)
285 if (bc_label(1:4) .eq.
'user')
then
286 call this%user_bc%mark_zone(zones(i))
291 do i = 1, this%n_dir_bcs
292 call bc_list_add(this%bclst_dirichlet, this%dir_bcs(i))
296 call bc_list_init(this%bclst_neumann, this%n_neumann_bcs)
297 do i = 1, this%n_neumann_bcs
298 call bc_list_add(this%bclst_neumann, this%neumann_bcs(i))
313 type(
mesh_t),
target,
intent(inout) :: msh
314 type(
coef_t),
target,
intent(inout) :: c_Xh
315 type(
gs_t),
target,
intent(inout) :: gs_Xh
316 type(json_file),
target,
intent(inout) :: params
317 character(len=*),
intent(in) :: scheme
318 type(
user_t),
target,
intent(in) :: user
321 character(len=LOG_SIZE) :: log_buf
323 logical :: logical_val
324 real(kind=
rp) :: real_val, solver_abstol
325 integer :: integer_val, ierr
326 character(len=:),
allocatable :: solver_type, solver_precon
333 call json_get(params,
'case.fluid.velocity_solver.type', solver_type)
334 call json_get(params,
'case.fluid.velocity_solver.preconditioner', &
336 call json_get(params,
'case.fluid.velocity_solver.absolute_tolerance', &
340 'case.fluid.velocity_solver.projection_space_size', &
341 this%projection_dim, 20)
343 'case.fluid.velocity_solver.projection_hold_steps', &
344 this%projection_activ_step, 5)
347 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
349 call neko_log%message(
'Ksp scalar : ('// trim(solver_type) // &
350 ', ' // trim(solver_precon) //
')')
351 write(log_buf,
'(A,ES13.6)')
' `-abs tol :', solver_abstol
355 this%dm_Xh => this%u%dof
356 this%params => params
363 call this%slag%init(this%s, 2)
375 write(log_buf,
'(A,ES13.6)')
'rho :', this%rho
377 write(log_buf,
'(A,ES13.6)')
'lambda :', this%lambda
379 write(log_buf,
'(A,ES13.6)')
'cp :', this%cp
385 if (params%valid_path(
'case.scalar.nut_field'))
then
386 call json_get(params,
'case.scalar.Pr_t', this%pr_turb)
387 call json_get(params,
'case.scalar.nut_field', this%nut_field_name)
388 this%variable_material_properties = .true.
390 this%nut_field_name =
""
394 call this%lambda_field%init(this%dm_Xh,
"lambda")
397 this%lambda_field%size())
399 call cfill(this%lambda_field%x, this%lambda, this%lambda_field%size())
406 call this%user_bc%init_base(this%c_Xh)
412 this%bc_labels =
"not"
414 if (params%valid_path(
'case.scalar.boundary_types'))
then
415 call json_get(params,
'case.scalar.boundary_types', this%bc_labels, &
423 call this%f_Xh%init(this%dm_Xh, fld_name =
"scalar_rhs")
426 call this%source_term%init(this%f_Xh, this%c_Xh, user)
427 call this%source_term%add(params,
'case.scalar.source_terms')
432 call this%user_bc%mark_zone(msh%wall)
433 call this%user_bc%mark_zone(msh%inlet)
434 call this%user_bc%mark_zone(msh%outlet)
435 call this%user_bc%mark_zone(msh%outlet_normal)
436 call this%user_bc%mark_zone(msh%sympln)
437 call this%user_bc%finalize()
438 if (this%user_bc%msk(0) .gt. 0)
call bc_list_add(this%bclst_dirichlet, &
442 call this%field_dir_bc%init_base(this%c_Xh)
443 call this%field_dir_bc%mark_zones_from_list(msh%labeled_zones, &
444 'd_s', this%bc_labels)
445 call this%field_dir_bc%finalize()
446 call mpi_allreduce(this%field_dir_bc%msk(0), integer_val, 1, &
448 if (integer_val .gt. 0)
call this%field_dir_bc%init_field(
'd_s')
450 call bc_list_add(this%bclst_dirichlet, this%field_dir_bc)
455 this%field_dir_bc%update => user%user_dirichlet_update
458 call bc_list_add(this%field_dirichlet_bcs, this%field_dir_bc)
463 'case.fluid.velocity_solver.max_iterations', &
466 'case.fluid.velocity_solver.monitor', &
467 logical_val, .false.)
469 solver_type, integer_val, solver_abstol, logical_val)
471 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bclst_dirichlet, solver_precon)
488 if (
allocated(this%ksp))
then
489 call krylov_solver_destroy(this%ksp)
493 if (
allocated(this%pc))
then
494 call precon_destroy(this%pc)
498 if (
allocated(this%bc_labels))
then
499 deallocate(this%bc_labels)
502 call this%source_term%free()
507 call this%lambda_field%free()
508 call this%slag%free()
512 call this%field_dir_bc%free()
521 if ( (.not.
allocated(this%u%x)) .or. &
522 (.not.
allocated(this%v%x)) .or. &
523 (.not.
allocated(this%w%x)) .or. &
524 (.not.
allocated(this%s%x)))
then
528 if (.not.
allocated(this%ksp))
then
529 call neko_error(
'No Krylov solver for velocity defined')
532 if (.not.
associated(this%Xh))
then
536 if (.not.
associated(this%dm_Xh))
then
540 if (.not.
associated(this%c_Xh))
then
544 if (.not.
associated(this%f_Xh))
then
548 if (.not.
associated(this%params))
then
564 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
565 integer,
intent(in),
value :: n
566 integer,
intent(in) :: max_iter
567 character(len=*),
intent(in) :: solver
568 real(kind=
rp) :: abstol
569 logical,
intent(in) :: monitor
571 call krylov_solver_factory(ksp, n, solver, max_iter, &
572 abstol, monitor = monitor)
579 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
580 class(
ksp_t),
target,
intent(inout) :: ksp
581 type(
coef_t),
target,
intent(inout) :: coef
582 type(
dofmap_t),
target,
intent(inout) :: dof
583 type(
gs_t),
target,
intent(inout) :: gs
584 type(
bc_list_t),
target,
intent(inout) :: bclst
585 character(len=*) :: pctype
587 call precon_factory(pc, pctype)
589 select type (pcp => pc)
591 call pcp%init(coef, dof, gs)
593 call pcp%init(coef, dof, gs)
595 call pcp%init(coef, dof, gs)
597 if (len_trim(pctype) .gt. 4)
then
598 if (index(pctype,
'+') .eq. 5)
then
599 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst, &
605 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
619 call this%user_bc%set_eval(usr_eval)
629 real(kind=
rp) :: lambda_factor
631 lambda_factor = this%rho*this%cp/this%pr_turb
633 if (this%variable_material_properties)
then
637 call device_cfill(this%lambda_field%x_d, this%lambda, n)
638 call device_add2s2(this%lambda_field%x_d, nut%x_d, lambda_factor, n)
640 call cfill(this%lambda_field%x, this%lambda, n)
641 call add2s2(this%lambda_field%x, nut%x, lambda_factor, n)
Abstract interface defining a dirichlet condition on a list of fields.
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 to dealocate a scalar formulation.
Abstract interface to initialize a scalar formulation.
Abstract interface to restart a scalar formulation.
Abstract interface to compute a time-step.
Abstract interface defining a user defined scalar boundary condition (pointwise) Just imitating inflo...
Defines a boundary condition.
subroutine, public bc_list_add(bclst, bc)
Add a condition to a list of boundary conditions.
subroutine, public bc_list_init(bclst, size)
Constructor for a list of boundary conditions.
subroutine, public bc_list_free(bclst)
Destructor for a list of boundary conditions.
subroutine, public bc_list_apply_scalar(bclst, x, n, t, tstep)
Apply a list of boundary conditions to a scalar field.
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 zone as a subset of facets in a mesh.
Defines inflow dirichlet conditions.
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
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.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
Implements material_properties_t type.
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)
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
Defines a Neumann boundary condition.
integer, parameter, public rp
Global precision used in computations.
Contains the scalar_scheme_t type.
subroutine scalar_scheme_init(this, msh, c_Xh, gs_Xh, params, scheme, user, material_properties)
Initialize all related components of the current scheme.
subroutine scalar_scheme_add_bcs(this, zones, bc_labels)
Initialize boundary conditions.
subroutine scalar_scheme_free(this)
Deallocate a scalar formulation.
subroutine scalar_scheme_solver_factory(ksp, n, solver, max_iter, abstol, monitor)
Initialize a linear solver.
subroutine scalar_scheme_set_user_bc(this, usr_eval)
Initialize a user defined scalar bc.
subroutine scalar_scheme_validate(this)
Validate that all fields, solvers etc necessary for performing time-stepping are defined.
subroutine scalar_scheme_update_material_properties(this)
Update the values of lambda_field if necessary.
subroutine scalar_scheme_precon_factory(pc, ksp, coef, dof, gs, bclst, pctype)
Initialize a Krylov preconditioner.
Implements the scalar_source_term_t type.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Defines a function space.
Jacobi preconditioner SX-Aurora backend.
Compound scheme for the advection and diffusion operators in a transport equation.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
Defines dirichlet conditions for scalars.
A list of boundary conditions.
Base type for a boundary condition.
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....
field_list_t, To be able to group fields together
Defines a jacobi preconditioner.
Base abstract type for a canonical Krylov method, solving .
Contains all the material properties necessary in the simulation.
Generic Neumann boundary condition. This sets the flux of the field to the chosen value.
Defines a canonical Krylov preconditioner.
Base type for a scalar advection-diffusion solver.
Wrapper contaning and executing the scalar source terms.
The function space for the SEM solution fields.
Defines a jacobi preconditioner for SX-Aurora.
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 scalars.