155 ext_bdf, gs_Xh, c_Xh, rho, mu, bd, dt, &
156 bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, &
157 Ax_vel, Ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
160 type(
field_t),
intent(inout) :: u_res, v_res, w_res, p_res
161 type(
coef_t),
intent(inout) :: c_Xh
162 type(
gs_t),
intent(inout) :: gs_Xh
164 type(
bc_list_t),
intent(inout) :: bclst_dp, bclst_du, bclst_dv, bclst_dw
165 type(
bc_list_t),
intent(inout) :: bclst_vel_res
166 class(
ax_t),
intent(in) :: Ax_vel
167 class(
ax_t),
intent(in) :: Ax_prs
168 class(
ksp_t),
intent(inout) :: ksp_prs, ksp_vel
169 class(
pc_t),
intent(inout) :: pc_prs, pc_vel
170 real(kind=
rp),
intent(in) :: bd
171 real(kind=
rp),
intent(in) :: rho, dt
173 integer,
intent(in) :: vel_max_iter, prs_max_iter
175 real(kind=
rp) :: xlmin, xlmax
176 real(kind=
rp) :: ylmin, ylmax
177 real(kind=
rp) :: zlmin, zlmax
179 type(
field_t),
pointer :: ta1, ta2, ta3
180 integer :: temp_indices(3)
187 associate(msh => c_xh%msh, p_vol => this%p_vol, &
188 u_vol => this%u_vol, v_vol => this%v_vol, w_vol => this%w_vol)
191 xlmin =
glmin(c_xh%dof%x, n)
192 xlmax =
glmax(c_xh%dof%x, n)
193 ylmin =
glmin(c_xh%dof%y, n)
194 ylmax =
glmax(c_xh%dof%y, n)
195 zlmin =
glmin(c_xh%dof%z, n)
196 zlmax =
glmax(c_xh%dof%z, n)
197 if (this%flow_dir .eq. 1)
then
198 this%domain_length = xlmax - xlmin
200 if (this%flow_dir .eq. 2)
then
201 this%domain_length = ylmax - ylmin
203 if (this%flow_dir .eq. 3)
then
204 this%domain_length = zlmax - zlmin
212 c_xh%h1(i,1,1,1) = 1.0_rp / rho
213 c_xh%h2(i,1,1,1) = 0.0_rp
220 if (this%flow_dir .eq. 1)
then
221 call cdtp(p_res%x, c_xh%h1, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
224 if (this%flow_dir .eq. 2)
then
225 call cdtp(p_res%x, c_xh%h1, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
228 if (this%flow_dir .eq. 3)
then
229 call cdtp(p_res%x, c_xh%h1, c_xh%drdz, c_xh%dsdz, c_xh%dtdz, c_xh)
232 call gs_xh%op(p_res, gs_op_add)
233 call bclst_dp%apply_scalar(p_res%x, n)
235 ksp_results(1) = ksp_prs%solve(ax_prs, p_vol, p_res%x, n, &
236 c_xh, bclst_dp, gs_xh, prs_max_iter)
240 call opgrad(u_res%x, v_res%x, w_res%x, p_vol%x, c_xh)
248 call opchsign(u_res%x, v_res%x, w_res%x, msh%gdim, n)
249 call copy(ta1%x, c_xh%B, n)
250 call copy(ta2%x, c_xh%B, n)
251 call copy(ta3%x, c_xh%B, n)
253 call bclst_vel_res%apply_vector(ta1%x, ta2%x, ta3%x, n)
258 if (this%flow_dir .eq. 1)
then
260 else if (this%flow_dir .eq. 2)
then
262 else if (this%flow_dir .eq. 3)
then
266 if (this%flow_dir .eq. 1)
then
267 call add2(u_res%x, ta1%x, n)
268 else if (this%flow_dir .eq. 2)
then
269 call add2(v_res%x, ta2%x, n)
270 else if (this%flow_dir .eq. 3)
then
271 call add2(w_res%x, ta3%x, n)
279 call copy(c_xh%h1, mu%x, n)
280 c_xh%h2 = rho * (bd / dt)
285 call gs_xh%op(u_res%x, v_res%x, w_res%x, n, gs_op_add)
288 call bclst_vel_res%apply_vector(u_res%x, v_res%x, w_res%x, n)
291 ksp_results(2:4) = ksp_vel%solve_coupled(ax_vel, &
292 u_vol, v_vol, w_vol, &
293 u_res%x, v_res%x, w_res%x, &
295 bclst_du, bclst_dv, bclst_dw, &
299 if (this%flow_dir .eq. 1)
then
301 device_glsc2(u_vol%x_d, c_xh%B_d, n) / this%domain_length
304 if (this%flow_dir .eq. 2)
then
306 device_glsc2(v_vol%x_d, c_xh%B_d, n) / this%domain_length
309 if (this%flow_dir .eq. 3)
then
311 device_glsc2(w_vol%x_d, c_xh%B_d, n) / this%domain_length
314 if (this%flow_dir .eq. 1)
then
315 this%base_flow =
glsc2(u_vol%x, c_xh%B, n) / this%domain_length
318 if (this%flow_dir .eq. 2)
then
319 this%base_flow =
glsc2(v_vol%x, c_xh%B, n) / this%domain_length
322 if (this%flow_dir .eq. 3)
then
323 this%base_flow =
glsc2(w_vol%x, c_xh%B, n) / this%domain_length
341 c_Xh, gs_Xh, ext_bdf, rho, mu, dt, time, &
342 bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, &
343 Ax_vel, Ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
347 type(field_t),
intent(inout) :: u, v, w, p
348 type(field_t),
intent(inout) :: u_res, v_res, w_res, p_res
349 type(coef_t),
intent(inout) :: c_Xh
350 type(gs_t),
intent(inout) :: gs_Xh
351 type(time_scheme_controller_t),
intent(in) :: ext_bdf
352 type(time_state_t),
intent(in) :: time
353 real(kind=rp),
intent(in) :: rho, dt
355 type(bc_list_t),
intent(inout) :: bclst_dp, bclst_du, bclst_dv, bclst_dw
356 type(bc_list_t),
intent(inout) :: bclst_vel_res
357 class(ax_t),
intent(in) :: Ax_vel
358 class(ax_t),
intent(in) :: Ax_prs
359 class(ksp_t),
intent(inout) :: ksp_prs, ksp_vel
360 class(pc_t),
intent(inout) :: pc_prs, pc_vel
361 integer,
intent(in) :: prs_max_iter, vel_max_iter
362 real(kind=rp) :: ifcomp, flow_rate, xsec
363 real(kind=rp) :: current_flow, delta_flow, scale
364 integer :: n, ierr, i
365 character(len=5) :: flow_dir_label
366 character(len=12) :: step_str
368 character(len=200) :: log_buf
370 associate(u_vol => this%u_vol, v_vol => this%v_vol, &
371 w_vol => this%w_vol, p_vol => this%p_vol)
380 if ((.not. abscmp(dt, this%dtlag)) .or. &
381 (.not. abscmp(ext_bdf%diffusion_coeffs%x(1), this%bdlag)))
then
386 this%bdlag = ext_bdf%diffusion_coeffs%x(1)
388 call mpi_allreduce(mpi_in_place, ifcomp, 1, &
389 mpi_real_precision, mpi_sum, neko_comm, ierr)
391 if (ifcomp .gt. 0d0)
then
392 call this%compute(u_res, v_res, w_res, p_res, &
393 ext_bdf, gs_xh, c_xh, rho, mu, ext_bdf%diffusion_coeffs%x(1), dt, &
394 bclst_dp, bclst_du, bclst_dv, bclst_dw, bclst_vel_res, &
395 ax_vel, ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
399 if (neko_bcknd_device .eq. 1)
then
400 if (this%flow_dir .eq. 1)
then
402 device_glsc2(u%x_d, c_xh%B_d, n) / this%domain_length
403 else if (this%flow_dir .eq. 2)
then
405 device_glsc2(v%x_d, c_xh%B_d, n) / this%domain_length
406 else if (this%flow_dir .eq. 3)
then
408 device_glsc2(w%x_d, c_xh%B_d, n) / this%domain_length
411 if (this%flow_dir .eq. 1)
then
412 current_flow = glsc2(u%x, c_xh%B, n) / this%domain_length
413 else if (this%flow_dir .eq. 2)
then
414 current_flow = glsc2(v%x, c_xh%B, n) / this%domain_length
415 else if (this%flow_dir .eq. 3)
then
416 current_flow = glsc2(w%x, c_xh%B, n) / this%domain_length
420 if (this%avflow)
then
421 xsec = c_xh%volume / this%domain_length
422 flow_rate = this%flow_rate*xsec
424 flow_rate = this%flow_rate
427 delta_flow = flow_rate - current_flow
428 scale = delta_flow / this%base_flow
430 if (this%log .and. pe_rank .eq. 0)
then
431 if (this%flow_dir .eq. 1)
then
432 flow_dir_label =
' x'
433 else if (this%flow_dir .eq. 2)
then
434 flow_dir_label =
' y'
435 else if (this%flow_dir .eq. 3)
then
436 flow_dir_label =
' z'
438 write(step_str,
'(I12)') time%tstep
439 step_str = adjustl(step_str)
440 write(log_buf,
'(A,A3,A5,1X,5A18)') &
441 'Flow rate ',
' | ',
'Dir.:',
'Time:',
'Scale:',
'Rate:', &
443 call neko_log%message(log_buf)
444 write(log_buf,
'(A12,A3,A5,1X,5E18.9)') step_str,
' | ', &
445 flow_dir_label, time%t, scale, flow_rate, current_flow, &
447 call neko_log%message(log_buf)
450 if (neko_bcknd_device .eq. 1)
then
451 call device_add2s2(u%x_d, u_vol%x_d, scale, n)
452 call device_add2s2(v%x_d, v_vol%x_d, scale, n)
453 call device_add2s2(w%x_d, w_vol%x_d, scale, n)
454 call device_add2s2(p%x_d, p_vol%x_d, scale, n)
456 do concurrent(i = 1: n)
457 u%x(i,1,1,1) = u%x(i,1,1,1) + scale * u_vol%x(i,1,1,1)
458 v%x(i,1,1,1) = v%x(i,1,1,1) + scale * v_vol%x(i,1,1,1)
459 w%x(i,1,1,1) = w%x(i,1,1,1) + scale * w_vol%x(i,1,1,1)
460 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, time, 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.