148 ext_bdf, gs_Xh, c_Xh, rho, mu, bd, dt, &
149 bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, &
150 Ax_vel, Ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, vel_max_iter)
152 type(
field_t),
intent(inout) :: u_res, v_res, w_res, p_res
153 type(
coef_t),
intent(inout) :: c_Xh
154 type(
gs_t),
intent(inout) :: gs_Xh
156 type(
bc_list_t),
intent(inout) :: bclst_dp, bclst_du, bclst_dv, bclst_dw
157 type(
bc_list_t),
intent(inout) :: bclst_vel_res
158 class(
ax_t),
intent(in) :: Ax_vel
159 class(
ax_t),
intent(in) :: Ax_prs
160 class(
ksp_t),
intent(inout) :: ksp_prs, ksp_vel
161 class(
pc_t),
intent(inout) :: pc_prs, pc_vel
162 real(kind=
rp),
intent(in) :: bd
163 real(kind=
rp),
intent(in) :: rho, dt
165 integer,
intent(in) :: vel_max_iter, prs_max_iter
167 real(kind=
rp) :: xlmin, xlmax
168 real(kind=
rp) :: ylmin, ylmax
169 real(kind=
rp) :: zlmin, zlmax
171 type(
field_t),
pointer :: ta1, ta2, ta3
172 integer :: temp_indices(3)
179 associate(msh => c_xh%msh, p_vol => this%p_vol, &
180 u_vol => this%u_vol, v_vol => this%v_vol, w_vol => this%w_vol)
183 xlmin =
glmin(c_xh%dof%x, n)
184 xlmax =
glmax(c_xh%dof%x, n)
185 ylmin =
glmin(c_xh%dof%y, n)
186 ylmax =
glmax(c_xh%dof%y, n)
187 zlmin =
glmin(c_xh%dof%z, n)
188 zlmax =
glmax(c_xh%dof%z, n)
189 if (this%flow_dir .eq. 1)
then
190 this%domain_length = xlmax - xlmin
192 if (this%flow_dir .eq. 2)
then
193 this%domain_length = ylmax - ylmin
195 if (this%flow_dir .eq. 3)
then
196 this%domain_length = zlmax - zlmin
204 c_xh%h1(i,1,1,1) = 1.0_rp / rho
205 c_xh%h2(i,1,1,1) = 0.0_rp
212 if (this%flow_dir .eq. 1)
then
213 call cdtp(p_res%x, c_xh%h1, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
216 if (this%flow_dir .eq. 2)
then
217 call cdtp(p_res%x, c_xh%h1, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
220 if (this%flow_dir .eq. 3)
then
221 call cdtp(p_res%x, c_xh%h1, c_xh%drdz, c_xh%dsdz, c_xh%dtdz, c_xh)
224 call gs_xh%op(p_res, gs_op_add)
225 call bclst_dp%apply_scalar(p_res%x, n)
227 ksp_results(1) = ksp_prs%solve(ax_prs, p_vol, p_res%x, n, &
228 c_xh, bclst_dp, gs_xh, prs_max_iter)
232 call opgrad(u_res%x, v_res%x, w_res%x, p_vol%x, c_xh)
240 call opchsign(u_res%x, v_res%x, w_res%x, msh%gdim, n)
241 call copy(ta1%x, c_xh%B, n)
242 call copy(ta2%x, c_xh%B, n)
243 call copy(ta3%x, c_xh%B, n)
245 call bclst_vel_res%apply_vector(ta1%x, ta2%x, ta3%x, n)
250 if (this%flow_dir .eq. 1)
then
252 else if (this%flow_dir .eq. 2)
then
254 else if (this%flow_dir .eq. 3)
then
258 if (this%flow_dir .eq. 1)
then
259 call add2(u_res%x, ta1%x, n)
260 else if (this%flow_dir .eq. 2)
then
261 call add2(v_res%x, ta2%x, n)
262 else if (this%flow_dir .eq. 3)
then
263 call add2(w_res%x, ta3%x, n)
271 call copy(c_xh%h1, mu%x, n)
272 c_xh%h2 = rho * (bd / dt)
276 call rotate_cyc(u_res%x, v_res%x, w_res%x, 1, c_xh)
277 call gs_xh%op(u_res, gs_op_add)
278 call gs_xh%op(v_res, gs_op_add)
279 call gs_xh%op(w_res, gs_op_add)
280 call rotate_cyc(u_res%x, v_res%x, w_res%x, 0, c_xh)
282 call bclst_vel_res%apply_vector(u_res%x, v_res%x, w_res%x, n)
285 ksp_results(2:4) = ksp_vel%solve_coupled(ax_vel, &
286 u_vol, v_vol, w_vol, &
287 u_res%x, v_res%x, w_res%x, &
289 bclst_du, bclst_dv, bclst_dw, &
293 if (this%flow_dir .eq. 1)
then
295 device_glsc2(u_vol%x_d, c_xh%B_d, n) / this%domain_length
298 if (this%flow_dir .eq. 2)
then
300 device_glsc2(v_vol%x_d, c_xh%B_d, n) / this%domain_length
303 if (this%flow_dir .eq. 3)
then
305 device_glsc2(w_vol%x_d, c_xh%B_d, n) / this%domain_length
308 if (this%flow_dir .eq. 1)
then
309 this%base_flow =
glsc2(u_vol%x, c_xh%B, n) / this%domain_length
312 if (this%flow_dir .eq. 2)
then
313 this%base_flow =
glsc2(v_vol%x, c_xh%B, n) / this%domain_length
316 if (this%flow_dir .eq. 3)
then
317 this%base_flow =
glsc2(w_vol%x, c_xh%B, n) / this%domain_length
335 c_Xh, gs_Xh, ext_bdf, rho, mu, dt, &
336 bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, &
337 Ax_vel, Ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, vel_max_iter)
340 type(field_t),
intent(inout) :: u, v, w, p
341 type(field_t),
intent(inout) :: u_res, v_res, w_res, p_res
342 type(coef_t),
intent(inout) :: c_Xh
343 type(gs_t),
intent(inout) :: gs_Xh
344 type(time_scheme_controller_t),
intent(in) :: ext_bdf
345 real(kind=rp),
intent(in) :: rho, dt
347 type(bc_list_t),
intent(inout) :: bclst_dp, bclst_du, bclst_dv, bclst_dw
348 type(bc_list_t),
intent(inout) :: bclst_vel_res
349 class(ax_t),
intent(in) :: Ax_vel
350 class(ax_t),
intent(in) :: Ax_prs
351 class(ksp_t),
intent(inout) :: ksp_prs, ksp_vel
352 class(pc_t),
intent(inout) :: pc_prs, pc_vel
353 integer,
intent(in) :: prs_max_iter, vel_max_iter
354 real(kind=rp) :: ifcomp, flow_rate, xsec
355 real(kind=rp) :: current_flow, delta_flow, scale
356 integer :: n, ierr, i
358 associate(u_vol => this%u_vol, v_vol => this%v_vol, &
359 w_vol => this%w_vol, p_vol => this%p_vol)
368 if ((.not. abscmp(dt, this%dtlag)) .or. &
369 (.not. abscmp(ext_bdf%diffusion_coeffs(1), this%bdlag)))
then
374 this%bdlag = ext_bdf%diffusion_coeffs(1)
376 call mpi_allreduce(mpi_in_place, ifcomp, 1, &
377 mpi_real_precision, mpi_sum, neko_comm, ierr)
379 if (ifcomp .gt. 0d0)
then
380 call this%compute(u_res, v_res, w_res, p_res, &
381 ext_bdf, gs_xh, c_xh, rho, mu, ext_bdf%diffusion_coeffs(1), dt, &
382 bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, &
383 ax_vel, ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
387 if (neko_bcknd_device .eq. 1)
then
388 if (this%flow_dir .eq. 1)
then
390 device_glsc2(u%x_d, c_xh%B_d, n) / this%domain_length
391 else if (this%flow_dir .eq. 2)
then
393 device_glsc2(v%x_d, c_xh%B_d, n) / this%domain_length
394 else if (this%flow_dir .eq. 3)
then
396 device_glsc2(w%x_d, c_xh%B_d, n) / this%domain_length
399 if (this%flow_dir .eq. 1)
then
400 current_flow = glsc2(u%x, c_xh%B, n) / this%domain_length
401 else if (this%flow_dir .eq. 2)
then
402 current_flow = glsc2(v%x, c_xh%B, n) / this%domain_length
403 else if (this%flow_dir .eq. 3)
then
404 current_flow = glsc2(w%x, c_xh%B, n) / this%domain_length
408 if (this%avflow)
then
409 xsec = c_xh%volume / this%domain_length
410 flow_rate = this%flow_rate*xsec
412 flow_rate = this%flow_rate
415 delta_flow = flow_rate - current_flow
416 scale = delta_flow / this%base_flow
418 if (neko_bcknd_device .eq. 1)
then
419 call device_add2s2(u%x_d, u_vol%x_d, scale, n)
420 call device_add2s2(v%x_d, v_vol%x_d, scale, n)
421 call device_add2s2(w%x_d, w_vol%x_d, scale, n)
422 call device_add2s2(p%x_d, p_vol%x_d, scale, n)
424 do concurrent(i = 1: n)
425 u%x(i,1,1,1) = u%x(i,1,1,1) + scale * u_vol%x(i,1,1,1)
426 v%x(i,1,1,1) = v%x(i,1,1,1) + scale * v_vol%x(i,1,1,1)
427 w%x(i,1,1,1) = w%x(i,1,1,1) + scale * w_vol%x(i,1,1,1)
428 p%x(i,1,1,1) = p%x(i,1,1,1) + scale * p_vol%x(i,1,1,1)
subroutine fluid_vol_flow(this, u, v, w, p, u_res, v_res, w_res, p_res, c_xh, gs_xh, ext_bdf, rho, mu, dt, bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, ax_vel, ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, vel_max_iter)
Adjust flow volume.
subroutine fluid_vol_flow_compute(this, u_res, v_res, w_res, p_res, ext_bdf, gs_xh, c_xh, rho, mu, bd, dt, bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, ax_vel, ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, vel_max_iter)
Compute flow adjustment.