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
238 call this%apply_scalar_device(x_d, time = time, &
239 strong = strong, strm = strm)
243 call this%items(i)%ptr%apply_scalar(x, n, time = time, &
261 integer,
intent(in) :: n
262 real(kind=
rp),
intent(inout),
dimension(n) :: x
263 real(kind=
rp),
intent(inout),
dimension(n) :: y
264 real(kind=
rp),
intent(inout),
dimension(n) :: z
266 logical,
intent(in),
optional :: strong
267 type(c_ptr),
intent(inout),
optional :: strm
279 call this%apply_vector_device(x_d, y_d, z_d, time = time, &
280 strong = strong, strm = strm)
284 call this%items(i)%ptr%apply_vector(x, y, z, n, time = time, &
300 type(c_ptr),
intent(inout) :: x_d
302 logical,
intent(in),
optional :: strong
303 type(c_ptr),
intent(inout),
optional :: strm
307 if (
present(strm))
then
314 call this%items(i)%ptr%apply_scalar_dev(x_d, time = time, &
315 strong = strong, strm = strm_)
331 type(c_ptr),
intent(inout) :: x_d
332 type(c_ptr),
intent(inout) :: y_d
333 type(c_ptr),
intent(inout) :: z_d
335 logical,
intent(in),
optional :: strong
336 type(c_ptr),
intent(inout),
optional :: strm
340 if (
present(strm))
then
347 call this%items(i)%ptr%apply_vector_dev(x_d, y_d, z_d, time = time, &
348 strong = strong, strm = strm_)
361 type(
field_t),
intent(inout) :: x
363 logical,
intent(in),
optional :: strong
364 type(c_ptr),
intent(inout),
optional :: strm
369 call this%items(i)%ptr%apply_scalar_generic(x, time = time, &
370 strong = strong, strm = strm)
386 type(
field_t),
intent(inout) :: x
387 type(
field_t),
intent(inout) :: y
388 type(
field_t),
intent(inout) :: z
390 logical,
intent(in),
optional :: strong
391 type(c_ptr),
intent(inout),
optional :: strm
396 call this%items(i)%ptr%apply_vector_generic(x, y, z, time = time, &
397 strong = strong, strm = strm)
405 class(
bc_list_t),
intent(in),
target :: this
406 integer,
intent(in) :: i
409 strong = this%items(i)%ptr%strong
414 class(
bc_list_t),
intent(in),
target :: this
421 if (.not.
allocated(this%items(i)%ptr%msk))
then
422 call neko_error(
"bc not finalized, error in bc_list%is_empty")
425 if (this%items(i)%ptr%msk(0) > 0) is_empty = .false.
432 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.