46 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
51 type,
public,
abstract ::
bc_t
53 integer,
allocatable :: msk(:)
55 integer,
allocatable :: facet(:)
67 type(c_ptr) :: msk_d = c_null_ptr
69 type(c_ptr) :: facet_d = c_null_ptr
121 class(
bc_t),
intent(inout) :: this
122 integer,
intent(in) :: n
123 real(kind=
rp),
intent(inout),
dimension(n) :: x
124 real(kind=
rp),
intent(in),
optional :: t
125 integer,
intent(in),
optional :: tstep
140 class(
bc_t),
intent(inout) :: this
141 integer,
intent(in) :: n
142 real(kind=
rp),
intent(inout),
dimension(n) :: x
143 real(kind=
rp),
intent(inout),
dimension(n) :: y
144 real(kind=
rp),
intent(inout),
dimension(n) :: z
145 real(kind=
rp),
intent(in),
optional :: t
146 integer,
intent(in),
optional :: tstep
154 class(
bc_t),
intent(inout),
target :: this
165 class(
bc_t),
intent(inout),
target :: this
167 real(kind=
rp),
intent(in),
optional :: t
168 integer,
intent(in),
optional :: tstep
181 class(
bc_t),
intent(inout),
target :: this
185 real(kind=
rp),
intent(in),
optional :: t
186 integer,
intent(in),
optional :: tstep
202 class(
bc_t),
intent(inout) :: this
203 type(
coef_t),
target,
intent(in) :: coef
209 this%Xh => this%dof%Xh
210 this%msh => this%dof%msh
212 call this%marked_facet%init()
218 class(
bc_t),
intent(inout) :: this
220 call this%marked_facet%free()
227 if (
allocated(this%msk))
then
231 if (
allocated(this%facet))
then
232 deallocate(this%facet)
235 if (c_associated(this%msk_d))
then
237 this%msk_d = c_null_ptr
240 if (c_associated(this%facet_d))
then
242 this%facet_d = c_null_ptr
251 class(
bc_t),
intent(inout) :: this
252 integer,
intent(in) :: facet
253 integer,
intent(in) :: el
257 call this%marked_facet%push(t)
264 class(
bc_t),
intent(inout) :: this
269 fp => facet_list%array()
270 do i = 1, facet_list%size()
271 call this%marked_facet%push(fp(i))
279 class(
bc_t),
intent(inout) :: this
282 do i = 1, bc_zone%size
283 call this%marked_facet%push(bc_zone%facet_el(i))
294 class(
bc_t),
intent(inout) :: this
296 character(len=*) :: bc_key
297 character(len=100),
allocatable :: split_key(:)
298 character(len=NEKO_MSH_MAX_ZLBL_LEN) :: bc_labels(:)
299 integer :: i, j, k, l, msh_bc_type
302 if(trim(bc_key) .eq.
'o' .or. trim(bc_key) .eq.
'on' &
303 .or. trim(bc_key) .eq.
'o+dong' .or. trim(bc_key) .eq.
'on+dong')
then
305 else if(trim(bc_key) .eq.
'd_pres')
then
307 else if(trim(bc_key) .eq.
'w')
then
309 else if(trim(bc_key) .eq.
'v')
then
311 else if(trim(bc_key) .eq.
'd_vel_u')
then
313 else if(trim(bc_key) .eq.
'd_vel_v')
then
315 else if(trim(bc_key) .eq.
'd_vel_w')
then
317 else if(trim(bc_key) .eq.
'sym')
then
319 else if(trim(bc_key) .eq.
'sh')
then
321 else if(trim(bc_key) .eq.
'wm')
then
325 do i = 1,
size(bc_labels)
328 if (index(trim(bc_labels(i)),
'/') .eq. 0)
then
329 if (trim(bc_key) .eq. trim(bc_labels(i)))
then
332 do j = 1,this%msh%nelv
333 do k = 1, 2 * this%msh%gdim
334 if (this%msh%facet_type(k,j) .eq. -i)
then
335 this%msh%facet_type(k,j) = msh_bc_type
342 do l = 1,
size(split_key)
343 if (trim(split_key(l)) .eq. trim(bc_key))
then
346 do j = 1,this%msh%nelv
347 do k = 1, 2 * this%msh%gdim
348 if (this%msh%facet_type(k,j) .eq. -i)
then
349 this%msh%facet_type(k,j) = msh_bc_type
364 class(
bc_t),
target,
intent(inout) :: this
367 integer :: facet_size, facet, el
368 integer :: i, j, k, l, msk_c
369 integer :: lx, ly, lz, n
379 allocate(this%msk(0:facet_size * this%marked_facet%size()))
380 allocate(this%facet(0:facet_size * this%marked_facet%size()))
383 bfp => this%marked_facet%array()
389 do i = 1, this%marked_facet%size()
391 facet = bc_facet%x(1)
399 this%facet(msk_c) = 1
407 this%facet(msk_c) = 2
415 this%facet(msk_c) = 3
423 this%facet(msk_c) = 4
431 this%facet(msk_c) = 5
439 this%facet(msk_c) = 6
446 this%facet(0) = msk_c
449 n = facet_size * this%marked_facet%size() + 1
464 type(
bc_list_t),
intent(inout),
target :: bclst
465 integer,
optional :: size
470 if (
present(size))
then
476 allocate(bclst%bc(n))
479 bclst%bc(i)%bcp => null()
493 if (
allocated(bclst%bc))
then
506 class(
bc_t),
intent(inout),
target ::
bc
507 type(
bcp_t),
allocatable :: tmp(:)
510 if(
bc%marked_facet%size() .eq. 0)
return
512 if (bclst%n .ge. bclst%size)
then
513 bclst%size = bclst%size * 2
514 allocate(tmp(bclst%size))
515 tmp(1:bclst%n) = bclst%bc
516 call move_alloc(tmp, bclst%bc)
519 bclst%n = bclst%n + 1
520 bclst%bc(bclst%n)%bcp =>
bc
531 integer,
intent(in) :: n
532 real(kind=
rp),
intent(inout),
dimension(n) :: x
533 real(kind=
rp),
intent(in),
optional :: t
534 integer,
intent(in),
optional :: tstep
540 if (
present(t) .and.
present(tstep))
then
542 call bclst%bc(i)%bcp%apply_scalar_dev(x_d, t=t, tstep=tstep)
544 else if (
present(t))
then
546 call bclst%bc(i)%bcp%apply_scalar_dev(x_d, t=t)
548 else if (
present(tstep))
then
550 call bclst%bc(i)%bcp%apply_scalar_dev(x_d, tstep=tstep)
554 call bclst%bc(i)%bcp%apply_scalar_dev(x_d)
558 if (
present(t) .and.
present(tstep))
then
560 call bclst%bc(i)%bcp%apply_scalar(x, n, t, tstep)
562 else if (
present(t))
then
564 call bclst%bc(i)%bcp%apply_scalar(x, n, t=t)
566 else if (
present(tstep))
then
568 call bclst%bc(i)%bcp%apply_scalar(x, n, tstep=tstep)
572 call bclst%bc(i)%bcp%apply_scalar(x, n)
588 integer,
intent(in) :: n
589 real(kind=
rp),
intent(inout),
dimension(n) :: x
590 real(kind=
rp),
intent(inout),
dimension(n) :: y
591 real(kind=
rp),
intent(inout),
dimension(n) :: z
592 real(kind=
rp),
intent(in),
optional :: t
593 integer,
intent(in),
optional :: tstep
603 if (
present(t) .and.
present(tstep))
then
605 call bclst%bc(i)%bcp%apply_vector_dev(x_d, y_d, z_d, t, tstep)
607 else if (
present(t))
then
609 call bclst%bc(i)%bcp%apply_vector_dev(x_d, y_d, z_d, t=t)
611 else if (
present(tstep))
then
613 call bclst%bc(i)%bcp%apply_vector_dev(x_d, y_d, z_d, tstep=tstep)
617 call bclst%bc(i)%bcp%apply_vector_dev(x_d, y_d, z_d)
621 if (
present(t) .and.
present(tstep))
then
623 call bclst%bc(i)%bcp%apply_vector(x, y, z, n, t, tstep)
625 else if (
present(t))
then
627 call bclst%bc(i)%bcp%apply_vector(x, y, z, n, t=t)
629 else if (
present(tstep))
then
631 call bclst%bc(i)%bcp%apply_vector(x, y, z, n, tstep=tstep)
635 call bclst%bc(i)%bcp%apply_vector(x, y, z, n)
Apply the boundary condition to a scalar field on the device.
Apply the boundary condition to a scalar field.
Apply the boundary condition to a vector field on the device.
Apply the boundary condition to a vector field.
Return the device pointer for an associated Fortran array.
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Defines a boundary condition.
subroutine bc_mark_zone(this, bc_zone)
Mark all facets from a zone.
subroutine, public bc_list_add(bclst, bc)
Add a condition to a list of boundary conditions.
subroutine, public bc_list_apply_vector(bclst, x, y, z, n, t, tstep)
Apply a list of boundary conditions to a vector field.
subroutine bc_finalize(this)
Finalize the construction of the bc by populting the msk and facet arrays.
subroutine bc_free_base(this)
Destructor for the base type, bc_t.
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 bc_init_base(this, coef)
Constructor.
subroutine bc_mark_zones_from_list(this, bc_zones, bc_key, bc_labels)
Mark all facets from a list of zones, also marks type of bc in the mesh. The facet_type in mesh is be...
subroutine bc_mark_facet(this, facet, el)
Mark facet on element el as part of the boundary condition.
subroutine bc_mark_facets(this, facet_list)
Mark all facets from a (facet, el) tuple list.
subroutine, public bc_list_apply_scalar(bclst, x, n, t, tstep)
Apply a list of boundary conditions to a scalar field.
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
subroutine, public device_free(x_d)
Deallocate memory on the device.
Defines a mapping of the degrees of freedom.
Defines a zone as a subset of facets in a mesh.
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
integer, parameter, public rp
Global precision used in computations.
Defines a function space.
Implements a dynamic stack ADT.
character(len=100) function, dimension(:), allocatable, public split_string(string, delimiter)
Split a string based on delimiter (tokenizer) OBS: very hacky, this should really be improved,...
pure integer function, public linear_index(i, j, k, l, lx, ly, lz)
Compute the address of a (i,j,k,l) array with sizes (1:lx, 1:ly, 1:lz, :)
A list of boundary conditions.
Base type for a boundary condition.
Pointer to boundary condtiion.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
The function space for the SEM solution fields.
Integer 2-tuple based stack.