39 use json_module,
only : json_file
53 real(kind=
rp),
allocatable :: distances(:)
55 real(kind=
rp),
allocatable :: xyz(:,:)
62 procedure, pass(this) :: init_from_distances => &
65 procedure,
private, pass(this) :: init_from_user => &
68 procedure, pass(this) :: init_from_components => &
85 type(json_file),
intent(inout) :: json
86 real(kind=
rp),
allocatable :: distances(:)
87 real(kind=
rp) :: distance
88 integer :: n_samples, var_type
89 logical :: found, output_h
90 character(len=:),
allocatable :: value
94 call json%info(
'value', found = found, var_type = var_type)
96 call neko_error(
'Wall distance sampler requires a value')
99 select case (var_type)
101 call json_get(json,
'value', distances)
102 call this%init_from_distances(distances, output_h)
104 call json_get(json,
'value', distance)
105 call this%init_from_distances([distance], output_h)
108 if (trim(
value) /=
'user')
then
109 call neko_error(
'Wall distance sampler value must be a real,' // &
112 call json_get(json,
'n_samples', n_samples)
113 call this%init_from_user(n_samples, output_h)
115 call neko_error(
'Wall distance sampler value must be a real, array,' // &
127 real(kind=
rp),
intent(in) :: distances(:)
128 logical,
intent(in) :: output_h
130 if (
size(distances) < 1 .or. any(distances <= 0.0_rp))
then
131 call neko_error(
'Wall sampling distances must be positive')
133 this%distances = distances
134 this%n_samples =
size(distances)
135 this%user_values = .false.
136 this%output_h_enabled = output_h
144 integer,
intent(in) :: n_samples
145 logical,
intent(in) :: output_h
147 if (n_samples < 1)
then
148 call neko_error(
'Wall distance sampler n_samples must be positive')
151 this%n_samples = n_samples
152 this%user_values = .true.
153 this%output_h_enabled = output_h
167 type(
coef_t),
intent(in) :: coef
168 real(kind=
rp),
intent(in) :: distances(:)
169 real(kind=
rp),
intent(in) :: xyz(:,:)
171 logical,
intent(in) :: output_h
172 integer :: n_nodes, n_points
174 if (
size(distances) < 1 .or. any(distances <= 0.0_rp))
then
175 call neko_error(
'Wall sampling distances must be positive')
177 if (
size(xyz, 1) /= 3)
then
178 call neko_error(
'Wall sampler coordinates must have three components')
181 n_points =
size(xyz, 2)
182 if (n_points < 1 .or. mod(n_points,
size(distances)) /= 0)
then
183 call neko_error(
'Wall sampler coordinates have an invalid size')
186 n_nodes = n_points /
size(distances)
188 call this%init_base(n_nodes,
size(distances), h, output_h)
189 this%distances = distances
191 call this%interpolator%init(coef%dof)
192 call this%interpolator%find_points(this%xyz, n_points)
205 n_x, n_y, n_z, bc_name, user)
207 type(
coef_t),
intent(in) :: coef
208 integer,
intent(in) :: msk(0:)
209 integer,
intent(in) :: facet(0:)
210 type(
vector_t),
intent(in) :: n_x, n_y, n_z
211 character(len=*),
optional,
intent(in) :: bc_name
212 type(
user_t),
target,
optional,
intent(in) :: user
213 integer :: i, j, p, linear
214 real(kind=
rp) :: distance
215 real(kind=
rp),
allocatable :: user_distances(:,:)
217 if (.not. this%user_values .and. .not.
allocated(this%distances))
then
218 call neko_error(
'Wall distance sampler has not been initialized')
222 call this%interpolator%free()
224 if (
allocated(this%xyz))
deallocate(this%xyz)
226 this%n_nodes = msk(0)
227 if (.not. this%user_values) this%n_samples =
size(this%distances)
229 if (this%user_values)
then
230 if (.not.
present(bc_name) .or. .not.
present(
user))
then
231 call neko_error(
'Wall distance user sampler has no ' // &
232 'configured callback')
235 allocate(user_distances(this%n_samples, this%n_nodes))
236 call user%wall_sampling_distance(bc_name, msk(1:this%n_nodes), &
238 if (any(user_distances <= 0.0_rp))
then
239 call neko_error(
'Wall sampling distances must be positive')
242 allocate(this%xyz(3, this%n_nodes * this%n_samples))
243 call this%h%init(this%n_nodes * this%n_samples)
245 do i = 1, this%n_nodes
247 do j = 1, this%n_samples
248 p = (i - 1) * this%n_samples + j
249 if (this%user_values)
then
250 distance = user_distances(j,i)
252 distance = this%distances(j)
254 this%xyz(1,p) = coef%dof%x(linear,1,1,1) - &
256 this%xyz(2,p) = coef%dof%y(linear,1,1,1) - &
258 this%xyz(3,p) = coef%dof%z(linear,1,1,1) - &
260 this%h%x(p) = distance
264 call this%interpolator%init(coef%dof)
265 call this%interpolator%find_points(this%xyz, &
266 this%n_nodes * this%n_samples)
272 if (this%output_h_enabled .and.
present(bc_name))
then
273 call this%output_h(coef, msk, bc_name)
282 type(
field_t),
intent(inout) :: field
283 type(
vector_t),
intent(inout) :: values
286 n = this%n_nodes * this%n_samples
287 if (values%size() /= n)
then
288 call neko_error(
'Wall sampler destination has an invalid size')
291 call this%interpolator%evaluate(values%x,
field%x, &
299 call this%interpolator%free()
301 if (
allocated(this%distances))
deallocate(this%distances)
302 if (
allocated(this%xyz))
deallocate(this%xyz)
305 this%user_values = .false.
306 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.
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Implements global_interpolation given a dofmap.
Utilities for retrieving parameters from the case files.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Interfaces for user interaction with NEKO.
Implements wall_distance_sampler_t.
subroutine wall_distance_sampler_init_from_components(this, coef, distances, xyz, h, output_h)
Fully construct a distance sampler from its resolved components.
subroutine wall_distance_sampler_init_from_distances(this, distances, output_h)
Partial constructor from physical wall-normal distances.
subroutine wall_distance_sampler_finalize(this, coef, msk, facet, n_x, n_y, n_z, bc_name, user)
Construct sampling locations and initialise global interpolation.
subroutine wall_distance_sampler_sample(this, field, values)
Sample a field at the configured physical locations.
subroutine wall_distance_sampler_init_from_user(this, n_samples, output_h)
Partial constructor for user-provided sampling distances.
subroutine wall_distance_sampler_free(this)
Release sampler resources.
subroutine wall_distance_sampler_init(this, json)
Partial constructor from JSON.
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,...
Implements global interpolation for arbitrary points in the domain.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...
Implements wall-normal sampling at prescribed physical distances.
Base type for sampling solution fields at points associated with wall nodes. Samples belonging to one...