39 use iso_c_binding,
only : c_associated
52 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
53 use json_module,
only : json_file
62 type,
public,
abstract ::
bc_t
64 integer,
allocatable :: msk(:)
66 integer,
allocatable :: facet(:)
70 type(
coef_t),
pointer :: coef => null()
72 type(
mesh_t),
pointer :: msh => null()
78 type(c_ptr) :: msk_d = c_null_ptr
80 type(c_ptr) :: facet_d = c_null_ptr
85 logical :: strong = .true.
88 logical :: updated = .false.
90 character(len=:),
allocatable :: name
92 integer,
allocatable :: zone_indices(:)
134 class(
bc_t),
pointer :: ptr => null()
139 class(
bc_t),
allocatable :: obj
147 class(
bc_t),
intent(inout),
target :: this
148 type(
coef_t),
target,
intent(in) :: coef
149 type(json_file),
intent(inout) :: json
157 class(
bc_t),
intent(inout),
target :: this
165 class(
bc_t),
intent(inout),
target :: this
166 logical,
optional,
intent(in) :: only_facets
179 class(
bc_t),
intent(inout) :: this
180 integer,
intent(in) :: n
181 real(kind=
rp),
intent(inout),
dimension(n) :: x
183 logical,
intent(in),
optional :: strong
199 class(
bc_t),
intent(inout) :: this
200 integer,
intent(in) :: n
201 real(kind=
rp),
intent(inout),
dimension(n) :: x
202 real(kind=
rp),
intent(inout),
dimension(n) :: y
203 real(kind=
rp),
intent(inout),
dimension(n) :: z
205 logical,
intent(in),
optional :: strong
219 class(
bc_t),
intent(inout),
target :: this
220 type(c_ptr),
intent(inout) :: x_d
222 logical,
intent(in),
optional :: strong
223 type(c_ptr),
intent(inout) :: strm
238 class(
bc_t),
intent(inout),
target :: this
239 type(c_ptr),
intent(inout) :: x_d
240 type(c_ptr),
intent(inout) :: y_d
241 type(c_ptr),
intent(inout) :: z_d
243 logical,
intent(in),
optional :: strong
244 type(c_ptr),
intent(inout) :: strm
253 class(
bc_t),
intent(inout) :: this
254 type(
coef_t),
target,
intent(in) :: coef
260 this%Xh => this%dof%Xh
261 this%msh => this%dof%msh
263 call this%marked_facet%init()
269 class(
bc_t),
intent(inout) :: this
271 call this%marked_facet%free()
278 if (
allocated(this%msk))
then
282 if (
allocated(this%facet))
then
283 deallocate(this%facet)
286 if (c_associated(this%msk_d))
then
288 this%msk_d = c_null_ptr
291 if (c_associated(this%facet_d))
then
293 this%facet_d = c_null_ptr
296 if (
allocated(this%name))
then
297 deallocate(this%name)
300 if (
allocated(this%zone_indices))
then
301 deallocate(this%zone_indices)
315 class(
bc_t),
intent(inout) :: this
316 type(
field_t),
intent(inout) :: x
317 type(
field_t),
intent(inout) :: y
318 type(
field_t),
intent(inout) :: z
320 logical,
intent(in),
optional :: strong
321 type(c_ptr),
intent(inout),
optional :: strm
324 character(len=256) :: msg
330 if (y%size() .ne. n .or. z%size() .ne. n)
then
331 msg =
"Fields x, y, z must have the same size in " // &
332 "bc_list_apply_vector_field"
338 if (
present(strm))
then
344 call this%apply_vector_dev(x%x_d, y%x_d, z%x_d, time = time, &
345 strong = strong, strm = strm_)
347 call this%apply_vector(x%x, y%x, z%x, n, time = time, strong = strong)
359 class(
bc_t),
intent(inout) :: this
360 type(
field_t),
intent(inout) :: x
362 logical,
intent(in),
optional :: strong
363 type(c_ptr),
intent(inout),
optional :: strm
372 if (
present(strm))
then
378 call this%apply_scalar_dev(x%x_d, time = time, strong = strong, &
381 call this%apply_scalar(x%x, n, time = time)
390 class(
bc_t),
intent(inout) :: this
391 integer,
intent(in) :: facet
392 integer,
intent(in) :: el
396 call this%marked_facet%push(t)
403 class(
bc_t),
intent(inout) :: this
408 fp => facet_list%array()
409 do i = 1, facet_list%size()
410 call this%marked_facet%push(fp(i))
418 class(
bc_t),
intent(inout) :: this
421 do i = 1, bc_zone%size
422 call this%marked_facet%push(bc_zone%facet_el(i))
434 class(
bc_t),
target,
intent(inout) :: this
435 logical,
optional,
intent(in) :: only_facets
439 integer :: facet_size, facet, el
440 logical :: only_facet = .false.
441 integer :: i, j, k, l, msk_c
442 integer :: lx, ly, lz, n
443 character(len=LOG_SIZE) :: log_buf
447 if (
present(only_facets))
then
448 only_facet = only_facets
456 allocate(this%msk(0:facet_size * this%marked_facet%size()))
457 allocate(this%facet(0:facet_size * this%marked_facet%size()))
460 bfp => this%marked_facet%array()
466 do i = 1, this%marked_facet%size()
468 facet = bc_facet%x(1)
476 this%facet(msk_c) = 1
483 this%msk(msk_c) =
linear_index(lx, k, l, el, lx, ly, lz)
484 this%facet(msk_c) = 2
492 this%facet(msk_c) = 3
499 this%msk(msk_c) =
linear_index(j, ly, l, el, lx, ly, lz)
500 this%facet(msk_c) = 4
508 this%facet(msk_c) = 5
515 this%msk(msk_c) =
linear_index(j, k, lz, el, lx, ly, lz)
516 this%facet(msk_c) = 6
521 this%facet(0) = msk_c
529 if ( .not. only_facet)
then
531 call test_field%init(this%dof)
533 n = test_field%size()
534 test_field%x = 0.0_rp
537 test_field%x(this%msk(i),1,1,1) = 1.0
544 call this%coef%gs_h%op(test_field,
gs_op_add)
550 do i = 1, this%dof%size()
551 if (test_field%x(i,1,1,1) .gt. 0.5)
then
557 allocate(this%msk(0:msk_c))
559 do i = 1, this%dof%size()
560 if (test_field%x(i,1,1,1) .gt. 0.5)
then
566 call test_field%free()
578 if (.not.
allocated(this%name))
then
581 write(log_buf,
'(A,A)')
'BC assigned name : ', trim(this%name)
585 if (.not.
allocated(this%zone_indices))
then
586 allocate(this%zone_indices(1))
587 this%zone_indices(1) = -1
596 class(
bc_t),
intent(inout) :: this
597 character(len=*),
intent(in) :: file_name
602 call bdry_field%init(this%coef%dof,
'bdry')
606 bdry_field%x(k,1,1,1) = 1.0_rp
608 call dump_file%init(file_name)
609 call dump_file%write(bdry_field)
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.
Finalize by building the mask and facet arrays.
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 bc_free_base(this)
Destructor for the base type, bc_t.
subroutine bc_init_base(this, coef)
Constructor.
subroutine bc_apply_scalar_generic(this, x, time, strong, strm)
Apply the boundary condition to a scalar field. Dispatches to the CPU or the device version.
subroutine bc_finalize_base(this, only_facets)
Finalize the construction of the bc by populting the msk and facet arrays.
subroutine bc_apply_vector_generic(this, x, y, z, time, strong, strm)
Apply the boundary condition to a vector field. Dispatches to the CPU or the device version.
subroutine bc_debug_mask(this, file_name)
Write a field showing the mask of the bc.
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.
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
subroutine, public device_free(x_d)
Deallocate memory on the device.
integer, parameter, public device_to_host
type(c_ptr), bind(C), public glb_cmd_queue
Global command queue.
Defines a mapping of the degrees of freedom.
Defines a zone as a subset of facets in a mesh.
Module for file I/O operations.
Defines Gather-scatter operations.
integer, parameter, public gs_op_add
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
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.
Module with things related to the simulation time.
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, :)
Base type for a boundary condition.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
The function space for the SEM solution fields.
Integer 2-tuple based stack.
A struct that contains all info about the time, expand as needed.