100 s_target_list, s_index_list, interpolate, tolerance)
102 type(
field_t),
pointer,
intent(inout),
optional :: u,v,w,p,t
103 type(
field_list_t),
intent(inout),
optional :: s_target_list
104 integer,
intent(in),
optional :: s_index_list(:)
105 logical,
intent(in),
optional :: interpolate
106 real(kind=
rp),
intent(in),
optional :: tolerance
111 logical :: mesh_mismatch
112 logical :: interpolate_
115 type(
mesh_t) ,
pointer :: msh
124 character(len=LOG_SIZE) :: log_buf
127 interpolate_ = .false.
128 if (
present(interpolate)) interpolate_ = interpolate
139 dof => u%dof; msh => u%msh; xh => u%Xh
140 else if (
present(v))
then
141 dof => v%dof; msh => v%msh; xh => v%Xh
142 else if (
present(w))
then
143 dof => w%dof; msh => w%msh; xh => w%Xh
144 else if (
present(p))
then
145 dof => p%dof; msh => p%msh; xh => p%Xh
146 else if (
present(t))
then
147 dof => t%dof; msh => t%msh; xh => t%Xh
148 else if (
present(s_target_list))
then
149 if (s_target_list%size() .eq. 0)
then
150 call neko_error(
"Scalar target list is empty")
152 dof => s_target_list%items(1)%ptr%dof
153 msh => s_target_list%items(1)%ptr%msh
154 xh => s_target_list%items(1)%ptr%Xh
157 call neko_error(
"At least one field must be passed")
166 mesh_mismatch = (this%glb_nelv .ne. msh%glb_nelv .or. &
167 this%gdim .ne. msh%gdim)
169 if (mesh_mismatch .and. .not. interpolate_)
then
170 call neko_error(
"The fld file must match the current mesh! &
171 &Use 'interpolate': 'true' to enable interpolation.")
172 else if (.not. mesh_mismatch .and. interpolate_)
then
173 call neko_log%warning(
"You have activated interpolation but you might &
174 &still be using the same mesh.")
180 if (interpolate_)
then
184 if (.not.
associated(dof) .or. .not.
associated(msh))
then
185 call neko_error(
"both dof and msh must be associated")
189 call this%generate_interpolator(global_interp, dof, msh, &
190 tolerance = tolerance)
193 if (
present(u))
call global_interp%evaluate(u%x(:,1,1,1), this%u%x, &
195 if (
present(v))
call global_interp%evaluate(v%x(:,1,1,1), this%v%x, &
197 if (
present(w))
call global_interp%evaluate(w%x(:,1,1,1), this%w%x, &
199 if (
present(p))
call global_interp%evaluate(p%x(:,1,1,1), this%p%x, &
201 if (
present(t))
call global_interp%evaluate(t%x(:,1,1,1), this%t%x, &
203 if (
present(s_target_list))
then
206 if (
present(s_index_list))
then
207 do i = 1,
size(s_index_list)
209 if (s_index_list(i) .eq. 0)
then
210 call global_interp%evaluate(s_target_list%x(i), &
211 this%t%x, on_host = .false.)
214 if (s_index_list(i) < 1 .or. &
215 s_index_list(i) > this%n_scalars)
then
216 call neko_error(
"s_index_list entry out of bounds")
218 call global_interp%evaluate(s_target_list%x(i), &
219 this%s(s_index_list(i))%x, on_host = .false.)
225 do i = 1, s_target_list%size()
226 call global_interp%evaluate(s_target_list%x(i), this%s(i)%x, &
232 call global_interp%free()
237 if (.not.
associated(xh))
call neko_error(
"Xh is not associated")
240 call prev_xh%init(
gll, this%lx, this%ly, this%lz)
241 call space_interp%init(xh, prev_xh)
244 if (
present(u))
call space_interp%map(u%x, this%u%x, this%nelv, xh)
245 if (
present(v))
call space_interp%map(v%x, this%v%x, this%nelv, xh)
246 if (
present(w))
call space_interp%map(w%x, this%w%x, this%nelv, xh)
247 if (
present(p))
call space_interp%map(p%x, this%p%x, this%nelv, xh)
248 if (
present(t))
call space_interp%map(t%x, this%t%x, this%nelv, xh)
249 if (
present(s_target_list))
then
252 if (
present(s_index_list))
then
253 do i = 1,
size(s_index_list)
256 if (s_index_list(i) .eq. 0)
then
257 call space_interp%map(s_target_list%x(i), &
258 this%t%x, this%nelv, xh)
260 call space_interp%map(s_target_list%x(i), &
261 this%s(s_index_list(i))%x, this%nelv, xh)
267 do i = 1, s_target_list%size()
268 call space_interp%map(s_target_list%x(i), this%s(i)%x, &
274 call space_interp%free
413 real(kind=
rp),
intent(in) :: c
416 if (this%u%size() .gt. 0)
call cmult(this%u%x, c, this%u%size())
417 if (this%v%size() .gt. 0)
call cmult(this%v%x, c, this%v%size())
418 if (this%w%size() .gt. 0)
call cmult(this%w%x, c, this%w%size())
419 if (this%p%size() .gt. 0)
call cmult(this%p%x, c, this%p%size())
420 if (this%t%size() .gt. 0)
call cmult(this%t%x, c, this%t%size())
422 do i = 1, this%n_scalars
423 if (this%s(i)%size() .gt. 0)
call cmult(this%s(i)%x, c, this%s(i)%size())
434 if (this%u%size() .gt. 0)
call add2(this%u%x, other%u%x, this%u%size())
435 if (this%v%size() .gt. 0)
call add2(this%v%x, other%v%x, this%v%size())
436 if (this%w%size() .gt. 0)
call add2(this%w%x, other%w%x, this%w%size())
437 if (this%p%size() .gt. 0)
call add2(this%p%x, other%p%x, this%p%size())
438 if (this%t%size() .gt. 0)
call add2(this%t%x, other%t%x, this%t%size())
440 do i = 1, this%n_scalars
441 if (this%s(i)%size() .gt. 0)
call add2(this%s(i)%x, other%s(i)%x, &
488 type(
dofmap_t),
intent(in),
target :: to_dof
489 type(
mesh_t),
intent(in),
target :: to_msh
490 real(kind=
rp),
intent(in) :: tolerance
494 real(kind=
rp),
allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), &
496 real(kind=
rp) :: center_x, center_y, center_z
500 type(
space_t),
pointer :: to_Xh
504 if (.not.
allocated(this%x%x) .or. &
505 .not.
allocated(this%y%x) .or. &
506 .not.
allocated(this%z%x))
call neko_error(
"Unable to retrieve &
507 &mesh information from fld data.")
510 call fld_xh%init(
gll, this%lx, this%ly, this%lz)
514 allocate(x_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
515 allocate(y_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
516 allocate(z_coords(to_xh%lx, to_xh%ly, to_xh%lz, to_msh%nelv))
522 do e = 1, to_msh%nelv
527 center_x = center_x + to_dof%x(i, 1, 1, e)
528 center_y = center_y + to_dof%y(i, 1, 1, e)
529 center_z = center_z + to_dof%z(i, 1, 1, e)
531 center_x = center_x / to_xh%lxyz
532 center_y = center_y / to_xh%lxyz
533 center_z = center_z / to_xh%lxyz
535 x_coords(i, 1, 1, e) = to_dof%x(i, 1, 1, e) - &
536 tolerance * (to_dof%x(i, 1, 1, e) - center_x)
537 y_coords(i, 1, 1, e) = to_dof%y(i, 1, 1, e) - &
538 tolerance * (to_dof%y(i, 1, 1, e) - center_y)
539 z_coords(i, 1, 1, e) = to_dof%z(i, 1, 1, e) - &
540 tolerance * (to_dof%z(i, 1, 1, e) - center_z)
546 call global_interp%init(this%x%x, this%y%x, this%z%x, this%gdim, &
547 this%nelv, fld_xh, tol = tolerance)
548 call global_interp%find_points(x_coords, y_coords, z_coords, &