35 use field,
only: field_t
36 use neko_config,
only: neko_bcknd_device
37 use num_types,
only: rp, xp
38 use utils,
only: neko_error
39 use point_zone,
only: point_zone_t
40 use scratch_registry,
only: neko_scratch_registry
41 use field_math,
only: field_cfill, field_copy
43 use device_math,
only: device_copy
46 use vector,
only: vector_t
64 type(vector_t),
intent(inout) :: vec
65 class(point_zone_t),
intent(inout) :: mask
66 real(kind=rp),
intent(in) :: const
67 type(field_t),
pointer :: work
68 integer :: temp_indices(1), i
83 call neko_scratch_registry%request_field(work, temp_indices(1))
85 if (vec%n .ne. work%size())
then
86 call neko_error(
'vector and field are of incompatible dimension')
90 call field_cfill(work, const)
93 if (neko_bcknd_device .eq. 1)
then
98 work%x(mask%mask(i), 1, 1, 1) = vec%x(mask%mask(i))
103 if (neko_bcknd_device .eq. 1)
then
104 call device_copy(vec%x_d, work%x_d, work%size())
106 call copy(vec%x, work%x, work%size())
109 call neko_scratch_registry%relinquish_field(temp_indices)
118 type(field_t),
intent(inout) :: fld
119 class(point_zone_t),
intent(inout) :: mask
120 real(kind=rp),
intent(in) :: const
121 type(field_t),
pointer :: work
122 integer :: temp_indices(1)
124 call neko_scratch_registry%request_field(work , temp_indices(1))
127 call field_cfill(work, const)
130 if (neko_bcknd_device .eq. 1)
then
134 call copy_mask(work%x, fld%x, fld%size(), mask%mask, mask%size)
138 call field_copy(fld, work)
140 call neko_scratch_registry%relinquish_field(temp_indices)
149 type(field_t),
intent(inout) :: fld
150 class(point_zone_t),
intent(inout) :: mask
151 type(field_t),
intent(inout) :: background
152 type(field_t),
pointer :: work
153 integer :: temp_indices(1)
155 call neko_scratch_registry%request_field(work , temp_indices(1))
158 call field_copy(work, background)
161 if (neko_bcknd_device .eq. 1)
then
165 call copy_mask(work%x, fld%x, fld%size(), mask%mask, mask%size)
169 call field_copy(fld, work)
171 call neko_scratch_registry%relinquish_field(temp_indices)
subroutine device_copy_mask(a_d, b_d, size, mask_d, mask_size)
Some common Masking operations we may need.
subroutine, public mask_exterior_fld(fld, mask, background)
Force everything outside the mask to be a background field.
subroutine mask_exterior_const_vec(vec, mask, const)
Force everything outside the mask to be a constant value.
subroutine mask_exterior_const_fld(fld, mask, const)
Force everything outside the mask to be a constant value.
subroutine copy_mask(a, b, size, mask, mask_size)
Copy within a mask. NOTE, this differs from masked_copy in the indexing. .