107 s_target_list, s_index_list, interpolate, tolerance, padding, &
108 global_interp_subdict)
110 type(
field_t),
pointer,
intent(inout),
optional :: u,v,w,p,t
111 type(
field_list_t),
intent(inout),
optional :: s_target_list
112 integer,
intent(in),
optional :: s_index_list(:)
113 logical,
intent(in),
optional :: interpolate
114 real(kind=
dp),
intent(in),
optional :: tolerance
115 real(kind=
dp),
intent(in),
optional :: padding
116 type(json_file),
intent(inout),
optional :: global_interp_subdict
121 logical :: mesh_mismatch
122 logical :: interpolate_
125 type(
mesh_t) ,
pointer :: msh
134 character(len=LOG_SIZE) :: log_buf
137 interpolate_ = .false.
138 if (
present(interpolate)) interpolate_ = interpolate
149 dof => u%dof; msh => u%msh; xh => u%Xh
150 else if (
present(v))
then
151 dof => v%dof; msh => v%msh; xh => v%Xh
152 else if (
present(w))
then
153 dof => w%dof; msh => w%msh; xh => w%Xh
154 else if (
present(p))
then
155 dof => p%dof; msh => p%msh; xh => p%Xh
156 else if (
present(t))
then
157 dof => t%dof; msh => t%msh; xh => t%Xh
158 else if (
present(s_target_list))
then
159 if (s_target_list%size() .eq. 0)
then
160 call neko_error(
"Scalar target list is empty")
162 dof => s_target_list%items(1)%ptr%dof
163 msh => s_target_list%items(1)%ptr%msh
164 xh => s_target_list%items(1)%ptr%Xh
167 call neko_error(
"At least one field must be passed")
176 mesh_mismatch = (this%glb_nelv .ne. msh%glb_nelv .or. &
177 this%gdim .ne. msh%gdim)
179 if (mesh_mismatch .and. .not. interpolate_)
then
180 call neko_error(
"The fld file must match the current mesh! " // &
181 "Use 'interpolate': 'true' to enable interpolation.")
182 else if (.not. mesh_mismatch .and. interpolate_)
then
183 call neko_log%warning(
"You have activated interpolation but you " // &
184 "might still be using the same mesh.")
190 if (interpolate_)
then
194 if (.not.
associated(dof) .or. .not.
associated(msh))
then
195 call neko_error(
"both dof and msh must be associated")
201 call this%generate_interpolator(global_interp, dof, msh, &
202 tolerance = tolerance, padding = padding, &
203 global_interp_subdict = global_interp_subdict)
206 if (
present(u))
call global_interp%evaluate(u%x(:,1,1,1), this%u%x, &
208 if (
present(v))
call global_interp%evaluate(v%x(:,1,1,1), this%v%x, &
210 if (
present(w))
call global_interp%evaluate(w%x(:,1,1,1), this%w%x, &
212 if (
present(p))
call global_interp%evaluate(p%x(:,1,1,1), this%p%x, &
214 if (
present(t))
call global_interp%evaluate(t%x(:,1,1,1), this%t%x, &
216 if (
present(s_target_list))
then
219 if (
present(s_index_list))
then
220 do i = 1,
size(s_index_list)
222 if (s_index_list(i) .eq. 0)
then
223 call global_interp%evaluate(s_target_list%x(i), &
224 this%t%x, on_host = .false.)
225 else if (s_index_list(i) .ge. 1 .and. &
226 s_index_list(i) .le. this%n_scalars)
then
227 call global_interp%evaluate(s_target_list%x(i), &
228 this%s(s_index_list(i))%x, on_host = .false.)
230 call neko_error(
"s_index_list entry out of bounds")
236 do i = 1, s_target_list%size()
237 call global_interp%evaluate(s_target_list%x(i), this%s(i)%x, &
243 call global_interp%free()
248 if (.not.
associated(xh))
call neko_error(
"Xh is not associated")
251 call prev_xh%init(
gll, this%lx, this%ly, this%lz)
252 call space_interp%init(xh, prev_xh)
255 if (
present(u))
call space_interp%map(u%x, this%u%x, this%nelv, xh)
256 if (
present(v))
call space_interp%map(v%x, this%v%x, this%nelv, xh)
257 if (
present(w))
call space_interp%map(w%x, this%w%x, this%nelv, xh)
258 if (
present(p))
call space_interp%map(p%x, this%p%x, this%nelv, xh)
259 if (
present(t))
call space_interp%map(t%x, this%t%x, this%nelv, xh)
260 if (
present(s_target_list))
then
263 if (
present(s_index_list))
then
264 do i = 1,
size(s_index_list)
267 if (s_index_list(i) .eq. 0)
then
268 call space_interp%map(s_target_list%x(i), &
269 this%t%x, this%nelv, xh)
270 else if (s_index_list(i) .ge. 1 .and. &
271 s_index_list(i) .le. this%n_scalars)
then
272 call space_interp%map(s_target_list%x(i), &
273 this%s(s_index_list(i))%x, this%nelv, xh)
275 call neko_error(
"s_index_list entry out of bounds")
281 do i = 1, s_target_list%size()
282 call space_interp%map(s_target_list%x(i), this%s(i)%x, &
288 call space_interp%free
503 to_msh, tolerance, padding, global_interp_subdict)
506 type(
dofmap_t),
intent(in),
target :: to_dof
507 type(
mesh_t),
intent(in),
target :: to_msh
508 real(kind=
dp),
intent(in),
optional :: tolerance
509 real(kind=
dp),
intent(in),
optional :: padding
510 type(json_file),
intent(inout),
optional :: global_interp_subdict
514 real(kind=
rp),
allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), &
516 real(kind=
rp) :: center_x, center_y, center_z
521 type(
space_t),
pointer :: to_xh
525 if (.not.
allocated(this%x%x) .or. &
526 .not.
allocated(this%y%x) .or. &
527 .not.
allocated(this%z%x))
call neko_error(
"Unable to retrieve &
528 &mesh information from fld data.")
531 call fld_xh%init(
gll, this%lx, this%ly, this%lz)
535 allocate(x_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
536 allocate(y_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
537 allocate(z_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
541 if (
present(global_interp_subdict))
then
544 else if (
present(tolerance))
then
547 call neko_error(
"No tolerance provided for interpolation! " // &
548 "Please provide a tolerance or a subdict with a tolerance entry.")
555 do e = 1, to_msh%nelv
560 center_x = center_x + to_dof%x(i, 1, 1, e)
561 center_y = center_y + to_dof%y(i, 1, 1, e)
562 center_z = center_z + to_dof%z(i, 1, 1, e)
564 center_x = center_x / to_xh%lxyz
565 center_y = center_y / to_xh%lxyz
566 center_z = center_z / to_xh%lxyz
568 x_coords(i, 1, 1, e) = to_dof%x(i, 1, 1, e) - &
569 tol_ * (to_dof%x(i, 1, 1, e) - center_x)
570 y_coords(i, 1, 1, e) = to_dof%y(i, 1, 1, e) - &
571 tol_ * (to_dof%y(i, 1, 1, e) - center_y)
572 z_coords(i, 1, 1, e) = to_dof%z(i, 1, 1, e) - &
573 tol_ * (to_dof%z(i, 1, 1, e) - center_z)
579 if (
present(global_interp_subdict))
then
580 call global_interp%init(this%x%x, this%y%x, this%z%x, &
581 this%gdim, this%nelv, fld_xh, &
582 global_interp_subdict)
584 call global_interp%init(this%x%x, this%y%x, this%z%x, &
585 this%gdim, this%nelv, fld_xh, &
586 tol = tolerance, pad = padding)
589 call global_interp%find_points(x_coords, y_coords, z_coords, &
subroutine fld_file_data_import_fields(this, u, v, w, p, t, s_target_list, s_index_list, interpolate, tolerance, padding, global_interp_subdict)
Imports fields from an fld_file_data object, potentially with interpolation.