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 might &
184 &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.)
227 if (s_index_list(i) < 1 .or. &
228 s_index_list(i) > this%n_scalars)
then
229 call neko_error(
"s_index_list entry out of bounds")
231 call global_interp%evaluate(s_target_list%x(i), &
232 this%s(s_index_list(i))%x, on_host = .false.)
238 do i = 1, s_target_list%size()
239 call global_interp%evaluate(s_target_list%x(i), this%s(i)%x, &
245 call global_interp%free()
250 if (.not.
associated(xh))
call neko_error(
"Xh is not associated")
253 call prev_xh%init(
gll, this%lx, this%ly, this%lz)
254 call space_interp%init(xh, prev_xh)
257 if (
present(u))
call space_interp%map(u%x, this%u%x, this%nelv, xh)
258 if (
present(v))
call space_interp%map(v%x, this%v%x, this%nelv, xh)
259 if (
present(w))
call space_interp%map(w%x, this%w%x, this%nelv, xh)
260 if (
present(p))
call space_interp%map(p%x, this%p%x, this%nelv, xh)
261 if (
present(t))
call space_interp%map(t%x, this%t%x, this%nelv, xh)
262 if (
present(s_target_list))
then
265 if (
present(s_index_list))
then
266 do i = 1,
size(s_index_list)
269 if (s_index_list(i) .eq. 0)
then
270 call space_interp%map(s_target_list%x(i), &
271 this%t%x, this%nelv, xh)
273 call space_interp%map(s_target_list%x(i), &
274 this%s(s_index_list(i))%x, this%nelv, xh)
280 do i = 1, s_target_list%size()
281 call space_interp%map(s_target_list%x(i), this%s(i)%x, &
287 call space_interp%free
502 to_msh, tolerance, padding, global_interp_subdict)
505 type(
dofmap_t),
intent(in),
target :: to_dof
506 type(
mesh_t),
intent(in),
target :: to_msh
507 real(kind=
dp),
intent(in),
optional :: tolerance
508 real(kind=
dp),
intent(in),
optional :: padding
509 type(json_file),
intent(inout),
optional :: global_interp_subdict
513 real(kind=
rp),
allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), &
515 real(kind=
rp) :: center_x, center_y, center_z
520 type(
space_t),
pointer :: to_xh
524 if (.not.
allocated(this%x%x) .or. &
525 .not.
allocated(this%y%x) .or. &
526 .not.
allocated(this%z%x))
call neko_error(
"Unable to retrieve &
527 &mesh information from fld data.")
530 call fld_xh%init(
gll, this%lx, this%ly, this%lz)
534 allocate(x_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
535 allocate(y_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
536 allocate(z_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
540 if (
present(global_interp_subdict))
then
543 else if (
present(tolerance))
then
546 call neko_error(
"No tolerance provided for interpolation! " // &
547 "Please provide a tolerance or a subdict with a tolerance entry.")
554 do e = 1, to_msh%nelv
559 center_x = center_x + to_dof%x(i, 1, 1, e)
560 center_y = center_y + to_dof%y(i, 1, 1, e)
561 center_z = center_z + to_dof%z(i, 1, 1, e)
563 center_x = center_x / to_xh%lxyz
564 center_y = center_y / to_xh%lxyz
565 center_z = center_z / to_xh%lxyz
567 x_coords(i, 1, 1, e) = to_dof%x(i, 1, 1, e) - &
568 tol_ * (to_dof%x(i, 1, 1, e) - center_x)
569 y_coords(i, 1, 1, e) = to_dof%y(i, 1, 1, e) - &
570 tol_ * (to_dof%y(i, 1, 1, e) - center_y)
571 z_coords(i, 1, 1, e) = to_dof%z(i, 1, 1, e) - &
572 tol_ * (to_dof%z(i, 1, 1, e) - center_z)
578 if (
present(global_interp_subdict))
then
579 call global_interp%init(this%x%x, this%y%x, this%z%x, &
580 this%gdim, this%nelv, fld_xh, &
581 global_interp_subdict)
583 call global_interp%init(this%x%x, this%y%x, this%z%x, &
584 this%gdim, this%nelv, fld_xh, &
585 tol = tolerance, pad = padding)
588 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.