84 type(json_file),
intent(inout) :: json
85 integer,
allocatable :: indices(:)
86 integer :: index, n_samples, var_type
87 logical :: found, output_h
88 character(len=:),
allocatable :: value
92 call json%info(
'value', found = found, var_type = var_type)
94 call neko_error(
'Wall GLL sampler requires a value')
97 select case (var_type)
99 call json_get(json,
'value', indices)
100 call this%init_from_indices(indices, output_h)
103 call this%init_from_indices([index], output_h)
106 if (trim(
value) /=
'user')
then
107 call neko_error(
'Wall GLL sampler value must be an integer, ' // &
110 call json_get(json,
'n_samples', n_samples)
111 call this%init_from_user(n_samples, output_h)
113 call neko_error(
'Wall GLL sampler value must be an integer, ' // &
200 type(
coef_t),
intent(in) :: coef
201 integer,
intent(in) :: msk(0:)
202 integer,
intent(in) :: facet(0:)
203 type(
vector_t),
intent(in) :: n_x, n_y, n_z
204 character(len=*),
optional,
intent(in) :: bc_name
205 type(
user_t),
target,
optional,
intent(in) :: user
206 integer :: i, j, p, fid, idx(4), sample(4), lx, ly, lz, offwall
207 real(kind=
rp) :: xw, yw, zw, dx, dy, dz
208 integer,
allocatable :: user_indices(:,:), sample_idx(:)
210 if (.not. this%user_values .and. .not.
allocated(this%indices))
then
211 call neko_error(
'Wall GLL sampler has not been initialized')
215 this%n_nodes = msk(0)
216 if (.not. this%user_values) this%n_samples =
size(this%indices)
218 if (this%user_values)
then
219 if (.not.
present(bc_name) .or. .not.
present(
user))
then
220 call neko_error(
'Wall GLL user sampler has no configured callback')
223 allocate(user_indices(this%n_samples, this%n_nodes))
225 call user%wall_sampling_gll(bc_name, msk(1:this%n_nodes), user_indices)
227 if (any(user_indices < 1))
then
228 call neko_error(
'Wall GLL sampler indices must be positive')
232 allocate(sample_idx(this%n_nodes * this%n_samples))
233 call this%h%init(
size(sample_idx))
238 do i = 1, this%n_nodes
240 xw = coef%dof%x(idx(1), idx(2), idx(3), idx(4))
241 yw = coef%dof%y(idx(1), idx(2), idx(3), idx(4))
242 zw = coef%dof%z(idx(1), idx(2), idx(3), idx(4))
244 do j = 1, this%n_samples
245 p = (i - 1) * this%n_samples + j
246 if (this%user_values)
then
247 offwall = user_indices(j,i)
249 offwall = this%indices(j)
254 sample(1) = sample(1) + offwall
256 sample(1) = sample(1) - offwall
258 sample(2) = sample(2) + offwall
260 sample(2) = sample(2) - offwall
262 sample(3) = sample(3) + offwall
264 sample(3) = sample(3) - offwall
266 call neko_error(
'Invalid facet in wall GLL sampler')
269 if (sample(1) < 1 .or. sample(1) > lx .or. &
270 sample(2) < 1 .or. sample(2) > ly .or. &
271 sample(3) < 1 .or. sample(3) > lz)
then
272 call neko_error(
'Wall GLL sampling index lies outside element')
275 sample_idx(p) =
linear_index(sample(1), sample(2), sample(3), &
276 sample(4), lx, ly, lz)
278 dx = coef%dof%x(sample(1), sample(2), sample(3), sample(4)) - xw
279 dy = coef%dof%y(sample(1), sample(2), sample(3), sample(4)) - yw
280 dz = coef%dof%z(sample(1), sample(2), sample(3), sample(4)) - zw
281 this%h%x(p) = -(dx*n_x%x(i) + dy*n_y%x(i) + dz*n_z%x(i))
285 call this%sample_idx%init(sample_idx,
size(sample_idx))
289 if (this%output_h_enabled .and.
present(bc_name))
then
290 call this%output_h(coef, msk, bc_name)
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, :)
subroutine wall_gll_sampler_finalize(this, coef, msk, facet, n_x, n_y, n_z, bc_name, user)
Construct field indices and wall-normal distances for sampling. Completes initialization.