40 use,
intrinsic :: iso_c_binding, only : c_ptr
50 class(
bc_ptr_t),
allocatable,
private :: items(:)
52 integer,
private :: size_ = 0
55 integer,
private :: capacity
79 generic :: apply => apply_scalar, apply_vector, &
80 apply_scalar_device, apply_vector_device, &
81 apply_scalar_field, apply_vector_field
101 class(
bc_list_t),
intent(inout),
target :: this
102 integer,
optional :: capacity
108 if (
present(capacity)) n = capacity
110 allocate(this%items(n))
124 if (
allocated(this%items))
then
126 this%items(i)%ptr => null()
129 deallocate(this%items)
141 class(
bc_t),
intent(inout),
target :: bc
142 type(
bc_ptr_t),
allocatable :: tmp(:)
144 if (this%size_ .ge. this%capacity)
then
145 this%capacity = this%capacity * 2
146 allocate(tmp(this%capacity))
147 tmp(1:this%size_) = this%items
148 call move_alloc(tmp, this%items)
151 this%size_ = this%size_ + 1
152 this%items(this%size_)%ptr =>
bc
161 class(
bc_t),
pointer ::
bc
162 integer,
intent(in) :: i
164 if (i .lt. 1 .or. i .gt. this%size_)
then
165 call neko_error(
"Index out of bounds in bc_list_get")
168 bc => this%items(i)%ptr
177 class(
bc_t),
pointer ::
bc
178 character(len=*),
intent(in) :: name
182 if (this%items(i)%ptr%name .eq. trim(name))
then
183 bc => this%items(i)%ptr
198 class(
bc_t),
pointer ::
bc
199 integer,
intent(in) :: zone_index
203 do j = 1,
size(this%items(i)%ptr%zone_indices)
204 if (this%items(i)%ptr%zone_indices(j) == zone_index)
then
205 bc => this%items(i)%ptr
212 call neko_error(
"Zone index not found in bc_list")
225 integer,
intent(in) :: n
226 real(kind=
rp),
intent(inout),
dimension(n) :: x
228 logical,
intent(in),
optional :: strong
229 type(c_ptr),
intent(inout),
optional :: strm
237 call this%apply_scalar_device(x_d, time = time, &
238 strong = strong, strm = strm)
241 call this%items(i)%ptr%apply_scalar(x, n, time = time, &
258 integer,
intent(in) :: n
259 real(kind=
rp),
intent(inout),
dimension(n) :: x
260 real(kind=
rp),
intent(inout),
dimension(n) :: y
261 real(kind=
rp),
intent(inout),
dimension(n) :: z
263 logical,
intent(in),
optional :: strong
264 type(c_ptr),
intent(inout),
optional :: strm
276 call this%apply_vector_device(x_d, y_d, z_d, time = time, &
277 strong = strong, strm = strm)
280 call this%items(i)%ptr%apply_vector(x, y, z, n, time = time, &
295 type(c_ptr),
intent(inout) :: x_d
297 logical,
intent(in),
optional :: strong
298 type(c_ptr),
intent(inout),
optional :: strm
302 if (
present(strm))
then
309 call this%items(i)%ptr%apply_scalar_dev(x_d, time = time, &
310 strong = strong, strm = strm_)
326 type(c_ptr),
intent(inout) :: x_d
327 type(c_ptr),
intent(inout) :: y_d
328 type(c_ptr),
intent(inout) :: z_d
330 logical,
intent(in),
optional :: strong
331 type(c_ptr),
intent(inout),
optional :: strm
335 if (
present(strm))
then
342 call this%items(i)%ptr%apply_vector_dev(x_d, y_d, z_d, time = time, &
343 strong = strong, strm = strm_)
356 type(
field_t),
intent(inout) :: x
358 logical,
intent(in),
optional :: strong
359 type(c_ptr),
intent(inout),
optional :: strm
363 call this%items(i)%ptr%apply_scalar_generic(x, time = time, &
364 strong = strong, strm = strm)
379 type(
field_t),
intent(inout) :: x
380 type(
field_t),
intent(inout) :: y
381 type(
field_t),
intent(inout) :: z
383 logical,
intent(in),
optional :: strong
384 type(c_ptr),
intent(inout),
optional :: strm
388 call this%items(i)%ptr%apply_vector_generic(x, y, z, time = time, &
389 strong = strong, strm = strm)
396 class(
bc_list_t),
intent(in),
target :: this
397 integer,
intent(in) :: i
400 strong = this%items(i)%ptr%strong
405 class(
bc_list_t),
intent(in),
target :: this
412 if (.not.
allocated(this%items(i)%ptr%msk))
then
413 call neko_error(
"bc not finalized, error in bc_list%is_empty")
416 if (this%items(i)%ptr%msk(0) > 0) is_empty = .false.
423 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.