47 use,
intrinsic :: iso_c_binding, only : c_ptr
68 generic :: mark => mark_bc, mark_bc_list
81 call this%dof_mask%free()
91 class(
bc_t),
intent(in) :: bc
93 integer,
pointer :: current_mask(:)
94 integer,
allocatable :: merged_mask(:)
95 integer,
allocatable :: perm(:)
96 integer :: current_size
97 integer :: incoming_size
98 integer :: merged_size
101 if (.not.
allocated(
bc%msk))
then
102 call neko_error(
"Attempting to mark projector from an unfinalized BC.")
105 incoming_size =
bc%msk(0)
106 if (incoming_size .eq. 0)
return
109 if (.not. this%dof_mask%is_set())
then
110 allocate(merged_mask(incoming_size), perm(incoming_size))
111 merged_mask =
bc%msk(1:incoming_size)
112 call sort(merged_mask, perm, incoming_size)
115 do i = 2, incoming_size
116 if (merged_mask(i) .ne. merged_mask(merged_size))
then
117 merged_size = merged_size + 1
118 merged_mask(merged_size) = merged_mask(i)
122 call this%dof_mask%init(merged_mask(1:merged_size), merged_size)
127 current_size = this%dof_mask%size()
128 current_mask => this%dof_mask%get()
129 allocate(merged_mask(current_size + incoming_size))
130 allocate(perm(current_size + incoming_size))
132 merged_mask(1:current_size) = current_mask(1:current_size)
133 merged_mask(current_size + 1:current_size + incoming_size) = &
134 bc%msk(1:incoming_size)
137 call sort(merged_mask, perm, current_size + incoming_size)
141 do i = 2, current_size + incoming_size
142 if (merged_mask(i) .ne. merged_mask(merged_size))
then
143 merged_size = merged_size + 1
144 merged_mask(merged_size) = merged_mask(i)
148 call this%dof_mask%set(merged_mask(1:merged_size), merged_size)
159 do i = 1, bclst%size()
160 call this%mark_bc(bclst%get(i))
170 integer,
intent(in) :: n
171 real(kind=
rp),
intent(inout) :: x(n)
172 type(c_ptr),
intent(inout),
optional :: strm
175 if (.not. this%dof_mask%is_set())
return
180 this%dof_mask%size(), strm = strm)
182 call cfill_mask(x, 0.0_rp, n, this%dof_mask%get(), this%dof_mask%size())
191 character(len=*),
intent(in),
optional :: field_name
192 type(
field_t),
pointer :: mask_field
194 integer :: scratch_idx
195 character(len=:),
allocatable :: field_name_
197 if (
present(field_name))
then
198 field_name_ = trim(field_name)
200 field_name_ =
'scalar_bc_projector_mask'
205 if (this%dof_mask%is_set())
then
208 this%dof_mask%get_d(), this%dof_mask%size())
211 call cfill_mask(mask_field%x, 1.0_rp, mask_field%size(), &
212 this%dof_mask%get(), this%dof_mask%size())
216 call mask_file%init(field_name_ //
'.fld')
217 call mask_file%write(mask_field)
Return the device pointer for an associated Fortran array.
Defines a boundary condition.
subroutine, public device_cfill_mask(a_d, c, n, mask_d, n_mask, strm)
Fill a constant to a masked vector. .
Device abstraction, common interface for various accelerators.
integer, parameter, public device_to_host
Object for handling masks in Neko.
subroutine, public cfill_mask(a, c, n, mask, n_mask)
Fill a constant to a masked vector. .
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Implements scalar_projector_t.
subroutine scalar_bc_projector_mark_bc(this, bc)
Add the constrained dofs from a scalar boundary condition.
subroutine scalar_bc_projector_debug_output(this, field_name)
Write a field showing the resolved scalar BC mask.
subroutine scalar_bc_projector_free(this)
Destructor.
subroutine scalar_bc_projector_apply(this, x, n, strm)
Apply the scalar boundary constraints by zeroing constrained dofs.
subroutine scalar_bc_projector_mark_bc_list(this, bclst)
Add the constrained dofs from all boundary conditions in a list.
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
Interface for NEKTON fld files.
Type for consistently handling masks in Neko. This type encapsulates the mask array and its associate...
Projector for scalar boundary conditions.