39 use json_module,
only : json_file
55 integer,
allocatable :: indices(:)
62 procedure, pass(this) :: init_from_indices => &
65 procedure,
private, pass(this) :: init_from_user => &
68 procedure, pass(this) :: init_from_components => &
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, ' // &
124 integer,
intent(in) :: indices(:)
125 logical,
intent(in) :: output_h
127 if (any(indices < 1))
then
128 call neko_error(
'Wall GLL sampler indices must be positive')
131 this%indices = indices
132 this%n_samples =
size(indices)
133 this%user_values = .false.
134 this%output_h_enabled = output_h
142 integer,
intent(in) :: n_samples
143 logical,
intent(in) :: output_h
145 if (n_samples < 1)
then
146 call neko_error(
'Wall GLL sampler n_samples must be positive')
149 this%n_samples = n_samples
150 this%user_values = .true.
151 this%output_h_enabled = output_h
164 integer,
intent(in) :: indices(:)
165 integer,
intent(in) :: sample_idx(:)
167 logical,
intent(in) :: output_h
170 if (
size(indices) < 1 .or. any(indices < 1))
then
171 call neko_error(
'Wall GLL sampler indices must be positive')
173 if (
size(sample_idx) < 1 .or. any(sample_idx < 1))
then
174 call neko_error(
'Wall GLL sampler sample indices must be positive')
176 if (mod(
size(sample_idx),
size(indices)) /= 0)
then
177 call neko_error(
'Wall GLL sampler sample indices have an invalid size')
180 n_nodes =
size(sample_idx) /
size(indices)
182 call this%init_base(n_nodes,
size(indices), h, output_h)
183 this%indices = indices
184 call this%sample_idx%init(sample_idx,
size(sample_idx))
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%x(idx(1), idx(2), idx(3), idx(4))
241 yw = coef%dof%y%x(idx(1), idx(2), idx(3), idx(4))
242 zw = coef%dof%z%x(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%x(sample(1), sample(2), sample(3), sample(4)) - xw
279 dy = coef%dof%y%x(sample(1), sample(2), sample(3), sample(4)) - yw
280 dz = coef%dof%z%x(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)
299 type(
field_t),
intent(inout) :: field
300 type(
vector_t),
intent(inout) :: values
303 n = this%n_nodes * this%n_samples
305 if (values%size() .ne. n)
then
306 call neko_error(
'Wall sampler destination has an invalid size')
311 this%sample_idx%get_d(),
field%size(), n)
322 call this%sample_idx%free()
324 if (
allocated(this%indices))
deallocate(this%indices)
330 this%user_values = .false.
331 this%output_h_enabled = .true.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
subroutine, public device_masked_gather_copy_aligned(a_d, b_d, mask_d, n, n_mask, strm)
Gather a masked vector .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Utilities for retrieving parameters from the case files.
Object for handling masks in Neko.
subroutine, public masked_gather_copy(a, b, mask, n, n_mask)
Gather a masked vector to reduced contigous vector .
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Interfaces for user interaction with NEKO.
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, :).
pure integer function, dimension(4), public nonlinear_index(linear_index, lx, ly, lz)
Compute (i,j,k,l) array given linear index with sizes (1:lx, 1:ly, 1:lz, :).
Implements sampling from GLL nodes at prescribed off-wall indices.
subroutine wall_gll_sampler_init(this, json)
Partial constructor from JSON.
subroutine wall_gll_sampler_init_from_components(this, indices, sample_idx, h, output_h)
Fully construct a GLL sampler from its resolved components.
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.
subroutine wall_gll_sampler_free(this)
Destructor.
subroutine wall_gll_sampler_init_from_user(this, n_samples, output_h)
Partial constructor for user-provided GLL sampling indices.
subroutine wall_gll_sampler_sample(this, field, values)
Sample the solution field at the sampling points.
subroutine wall_gll_sampler_init_from_indices(this, indices, output_h)
Partial constructor from off-wall GLL indices.
Defines the abstract interface for wall-model field samplers.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Type for consistently handling masks in Neko. This type encapsulates the mask array and its associate...
A type collecting all the overridable user routines and flag to suppress type injection from custom m...
Wall sampler implementation for GLL nodes at prescribed off-wall indices.
Base type for sampling solution fields at points associated with wall nodes. Samples belonging to one...