40 use,
intrinsic :: iso_c_binding, only : c_ptr
51 class(
bc_ptr_t),
allocatable,
private :: items(:)
53 integer,
private :: size_ = 0
56 integer,
private :: capacity
80 generic :: apply => apply_scalar, apply_vector, &
81 apply_scalar_device, apply_vector_device, &
82 apply_scalar_field, apply_vector_field
102 class(
bc_list_t),
intent(inout),
target :: this
103 integer,
optional :: capacity
109 if (
present(capacity)) n = capacity
111 allocate(this%items(n))
125 if (
allocated(this%items))
then
127 this%items(i)%ptr => null()
130 deallocate(this%items)
142 class(
bc_t),
intent(inout),
target :: bc
143 type(
bc_ptr_t),
allocatable :: tmp(:)
145 if (this%size_ .ge. this%capacity)
then
146 this%capacity = this%capacity * 2
147 allocate(tmp(this%capacity))
148 tmp(1:this%size_) = this%items
149 call move_alloc(tmp, this%items)
152 this%size_ = this%size_ + 1
153 this%items(this%size_)%ptr =>
bc
162 class(
bc_t),
pointer ::
bc
163 integer,
intent(in) :: i
165 if (i .lt. 1 .or. i .gt. this%size_)
then
166 call neko_error(
"Index out of bounds in bc_list_get")
169 bc => this%items(i)%ptr
178 class(
bc_t),
pointer ::
bc
179 character(len=*),
intent(in) :: name
183 if (this%items(i)%ptr%name .eq. trim(name))
then
184 bc => this%items(i)%ptr
199 class(
bc_t),
pointer ::
bc
200 integer,
intent(in) :: zone_index
204 do j = 1,
size(this%items(i)%ptr%zone_indices)
205 if (this%items(i)%ptr%zone_indices(j) == zone_index)
then
206 bc => this%items(i)%ptr
213 call neko_error(
"Zone index not found in bc_list")
226 integer,
intent(in) :: n
227 real(kind=
rp),
intent(inout),
dimension(n) :: x
229 logical,
intent(in),
optional :: strong
230 type(c_ptr),
intent(inout),
optional :: strm
239 call this%apply_scalar_device(x_d, time = time, &
240 strong = strong, strm = strm)
250 if (
present(strong)) strong_ = strong
252 if (
present(time))
then
255 call this%items(i)%ptr%apply_scalar(x, n, time = time, &
262 call this%items(i)%ptr%apply_scalar(x, n, strong = strong_)
280 integer,
intent(in) :: n
281 real(kind=
rp),
intent(inout),
dimension(n) :: x
282 real(kind=
rp),
intent(inout),
dimension(n) :: y
283 real(kind=
rp),
intent(inout),
dimension(n) :: z
285 logical,
intent(in),
optional :: strong
286 type(c_ptr),
intent(inout),
optional :: strm
299 call this%apply_vector_device(x_d, y_d, z_d, time = time, &
300 strong = strong, strm = strm)
310 if (
present(strong)) strong_ = strong
312 if (
present(time))
then
315 call this%items(i)%ptr%apply_vector(x, y, z, n, time = time, &
322 call this%items(i)%ptr%apply_vector(x, y, z, n, strong = strong_)
338 type(c_ptr),
intent(inout) :: x_d
340 logical,
intent(in),
optional :: strong
341 type(c_ptr),
intent(inout),
optional :: strm
345 if (
present(strm))
then
352 call this%items(i)%ptr%apply_scalar_dev(x_d, time = time, &
353 strong = strong, strm = strm_)
369 type(c_ptr),
intent(inout) :: x_d
370 type(c_ptr),
intent(inout) :: y_d
371 type(c_ptr),
intent(inout) :: z_d
373 logical,
intent(in),
optional :: strong
374 type(c_ptr),
intent(inout),
optional :: strm
378 if (
present(strm))
then
385 call this%items(i)%ptr%apply_vector_dev(x_d, y_d, z_d, time = time, &
386 strong = strong, strm = strm_)
399 type(
field_t),
intent(inout) :: x
401 logical,
intent(in),
optional :: strong
402 type(c_ptr),
intent(inout),
optional :: strm
415 if (
present(strong)) strong_ = strong
417 if (
present(strm)) strm_ = strm
419 if (
present(time))
then
422 call this%items(i)%ptr%apply_scalar_generic(x, time = time, &
423 strong = strong_, strm = strm_)
429 call this%items(i)%ptr%apply_scalar_generic(x, &
430 strong = strong_, strm = strm_)
447 type(
field_t),
intent(inout) :: x
448 type(
field_t),
intent(inout) :: y
449 type(
field_t),
intent(inout) :: z
451 logical,
intent(in),
optional :: strong
452 type(c_ptr),
intent(inout),
optional :: strm
465 if (
present(strong)) strong_ = strong
467 if (
present(strm)) strm_ = strm
469 if (
present(time))
then
472 call this%items(i)%ptr%apply_vector_generic(x, y, z, time = time, &
473 strong = strong_, strm = strm_)
479 call this%items(i)%ptr%apply_vector_generic(x, y, z, &
480 strong = strong_, strm = strm_)
489 class(
bc_list_t),
intent(in),
target :: this
490 integer,
intent(in) :: i
493 strong = this%items(i)%ptr%strong
498 class(
bc_list_t),
intent(in),
target :: this
505 if (.not.
allocated(this%items(i)%ptr%msk))
then
506 call neko_error(
"bc not finalized, error in bc_list%is_empty")
509 if (this%items(i)%ptr%msk(0) > 0) is_empty = .false.
516 class(
bc_list_t),
intent(in),
target :: this
Return the device pointer for an associated Fortran array.
pure logical function bc_list_strong(this, i)
Return whether the bc is strong or not.
subroutine bc_list_apply_vector_array(this, x, y, z, n, time, strong, strm)
Apply a list of boundary conditions to a vector field.
subroutine bc_list_apply_vector_device(this, x_d, y_d, z_d, time, strong, strm)
Apply a list of boundary conditions to a vector field on the device.
class(bc_t) function, pointer bc_list_get(this, i)
Get the item at the given index.
subroutine bc_list_apply_scalar_array(this, x, n, time, strong, strm)
Apply a list of boundary conditions to a scalar field.
subroutine bc_list_apply_scalar_device(this, x_d, time, strong, strm)
Apply a list of boundary conditions to a scalar field on the device.
pure integer function bc_list_size(this)
Return the number of items in the list.
subroutine bc_list_append(this, bc)
Append a condition to the end of the list.
subroutine bc_list_init(this, capacity)
Constructor.
class(bc_t) function, pointer bc_list_get_by_name(this, name)
Get the item from a given name.
subroutine bc_list_apply_vector_field(this, x, y, z, time, strong, strm)
Apply a list of boundary conditions to a vector field.
subroutine bc_list_free(this)
Destructor.
class(bc_t) function, pointer bc_list_get_by_zone_index(this, zone_index)
Get the item from zone_index.
subroutine bc_list_apply_scalar_field(this, x, time, strong, strm)
Apply a list of boundary conditions to a scalar field.
logical function bc_list_is_empty(this)
Return whether the list is empty.
Defines a boundary condition.
Device abstraction, common interface for various accelerators.
type(c_ptr), bind(C), public glb_cmd_queue
Global command queue.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Module with things related to the simulation time.
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
A struct that contains all info about the time, expand as needed.