156 ext_bdf, gs_Xh, c_Xh, rho, mu, bd, dt, &
157 dp_projector, vel_projector, &
158 Ax_vel, Ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
161 type(
field_t),
intent(inout) :: u_res, v_res, w_res, p_res
162 type(
coef_t),
intent(inout) :: c_Xh
163 type(
gs_t),
intent(inout) :: gs_Xh
167 class(
ax_t),
intent(in) :: Ax_vel
168 class(
ax_t),
intent(in) :: Ax_prs
169 class(
ksp_t),
intent(inout) :: ksp_prs, ksp_vel
170 class(
pc_t),
intent(inout) :: pc_prs, pc_vel
171 real(kind=
rp),
intent(in) :: bd
172 real(kind=
rp),
intent(in) :: rho, dt
174 integer,
intent(in) :: vel_max_iter, prs_max_iter
176 real(kind=
rp) :: xlmin, xlmax
177 real(kind=
rp) :: ylmin, ylmax
178 real(kind=
rp) :: zlmin, zlmax
180 type(
field_t),
pointer :: ta1, ta2, ta3
181 integer :: temp_indices(3)
188 associate(msh => c_xh%msh, p_vol => this%p_vol, &
189 u_vol => this%u_vol, v_vol => this%v_vol, w_vol => this%w_vol)
192 xlmin =
glmin(c_xh%dof%x, n)
193 xlmax =
glmax(c_xh%dof%x, n)
194 ylmin =
glmin(c_xh%dof%y, n)
195 ylmax =
glmax(c_xh%dof%y, n)
196 zlmin =
glmin(c_xh%dof%z, n)
197 zlmax =
glmax(c_xh%dof%z, n)
198 if (this%flow_dir .eq. 1)
then
199 this%domain_length = xlmax - xlmin
201 if (this%flow_dir .eq. 2)
then
202 this%domain_length = ylmax - ylmin
204 if (this%flow_dir .eq. 3)
then
205 this%domain_length = zlmax - zlmin
218 c_xh%h1(i,1,1,1) = 1.0_rp / rho
219 c_xh%h2(i,1,1,1) = 0.0_rp
227 if (this%flow_dir .eq. 1)
then
228 call cdtp(p_res%x, c_xh%h1, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
231 if (this%flow_dir .eq. 2)
then
232 call cdtp(p_res%x, c_xh%h1, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
235 if (this%flow_dir .eq. 3)
then
236 call cdtp(p_res%x, c_xh%h1, c_xh%drdz, c_xh%dsdz, c_xh%dtdz, c_xh)
239 call gs_xh%op(p_res, gs_op_add)
240 call dp_projector%apply(p_res%x, n)
242 ksp_results(1) = ksp_prs%solve(ax_prs, p_vol, p_res%x, n, &
243 c_xh, dp_projector, gs_xh, prs_max_iter)
247 call opgrad(u_res%x, v_res%x, w_res%x, p_vol%x, c_xh)
255 call opchsign(u_res%x, v_res%x, w_res%x, msh%gdim, n)
256 call copy(ta1%x, c_xh%B, n)
257 call copy(ta2%x, c_xh%B, n)
258 call copy(ta3%x, c_xh%B, n)
260 call vel_projector%apply(ta1%x, ta2%x, ta3%x, n)
265 if (this%flow_dir .eq. 1)
then
267 else if (this%flow_dir .eq. 2)
then
269 else if (this%flow_dir .eq. 3)
then
273 if (this%flow_dir .eq. 1)
then
274 call add2(u_res%x, ta1%x, n)
275 else if (this%flow_dir .eq. 2)
then
276 call add2(v_res%x, ta2%x, n)
277 else if (this%flow_dir .eq. 3)
then
278 call add2(w_res%x, ta3%x, n)
286 call copy(c_xh%h1, mu%x, n)
287 c_xh%h2 = rho * (bd / dt)
292 call gs_xh%op(u_res%x, v_res%x, w_res%x, n, gs_op_add)
295 call vel_projector%apply(u_res%x, v_res%x, w_res%x, n)
298 ksp_results(2:4) = ksp_vel%solve_coupled(ax_vel, &
299 u_vol, v_vol, w_vol, &
300 u_res%x, v_res%x, w_res%x, &
306 if (this%flow_dir .eq. 1)
then
308 device_glsc2(u_vol%x_d, c_xh%B_d, n) / this%domain_length
311 if (this%flow_dir .eq. 2)
then
313 device_glsc2(v_vol%x_d, c_xh%B_d, n) / this%domain_length
316 if (this%flow_dir .eq. 3)
then
318 device_glsc2(w_vol%x_d, c_xh%B_d, n) / this%domain_length
321 if (this%flow_dir .eq. 1)
then
322 this%base_flow =
glsc2(u_vol%x, c_xh%B, n) / this%domain_length
325 if (this%flow_dir .eq. 2)
then
326 this%base_flow =
glsc2(v_vol%x, c_xh%B, n) / this%domain_length
329 if (this%flow_dir .eq. 3)
then
330 this%base_flow =
glsc2(w_vol%x, c_xh%B, n) / this%domain_length
348 c_Xh, gs_Xh, ext_bdf, rho, mu, dt, time, &
349 dp_projector, vel_projector, &
350 Ax_vel, Ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
354 type(field_t),
intent(inout) :: u, v, w, p
355 type(field_t),
intent(inout) :: u_res, v_res, w_res, p_res
356 type(coef_t),
intent(inout) :: c_Xh
357 type(gs_t),
intent(inout) :: gs_Xh
358 type(time_scheme_controller_t),
intent(in) :: ext_bdf
359 type(time_state_t),
intent(in) :: time
360 real(kind=rp),
intent(in) :: rho, dt
362 type(scalar_bc_projector_t),
intent(inout) :: dp_projector
363 class(vector_bc_projector_t),
intent(inout) :: vel_projector
364 class(ax_t),
intent(in) :: Ax_vel
365 class(ax_t),
intent(in) :: Ax_prs
366 class(ksp_t),
intent(inout) :: ksp_prs, ksp_vel
367 class(pc_t),
intent(inout) :: pc_prs, pc_vel
368 integer,
intent(in) :: prs_max_iter, vel_max_iter
369 real(kind=rp) :: ifcomp, flow_rate, xsec
370 real(kind=rp) :: current_flow, delta_flow, scale
371 integer :: n, ierr, i
372 character(len=5) :: flow_dir_label
373 character(len=12) :: step_str
375 character(len=200) :: log_buf
377 associate(u_vol => this%u_vol, v_vol => this%v_vol, &
378 w_vol => this%w_vol, p_vol => this%p_vol)
387 if ((.not. abscmp(dt, this%dtlag)) .or. &
388 (.not. abscmp(ext_bdf%diffusion_coeffs%x(1), this%bdlag)))
then
393 this%bdlag = ext_bdf%diffusion_coeffs%x(1)
395 call mpi_allreduce(mpi_in_place, ifcomp, 1, &
396 mpi_real_precision, mpi_sum, neko_comm, ierr)
398 if (ifcomp .gt. 0d0)
then
399 call this%compute(u_res, v_res, w_res, p_res, &
400 ext_bdf, gs_xh, c_xh, rho, mu, ext_bdf%diffusion_coeffs%x(1), dt, &
401 dp_projector, vel_projector, &
402 ax_vel, ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, &
406 if (neko_bcknd_device .eq. 1)
then
407 if (this%flow_dir .eq. 1)
then
409 device_glsc2(u%x_d, c_xh%B_d, n) / this%domain_length
410 else if (this%flow_dir .eq. 2)
then
412 device_glsc2(v%x_d, c_xh%B_d, n) / this%domain_length
413 else if (this%flow_dir .eq. 3)
then
415 device_glsc2(w%x_d, c_xh%B_d, n) / this%domain_length
418 if (this%flow_dir .eq. 1)
then
419 current_flow = glsc2(u%x, c_xh%B, n) / this%domain_length
420 else if (this%flow_dir .eq. 2)
then
421 current_flow = glsc2(v%x, c_xh%B, n) / this%domain_length
422 else if (this%flow_dir .eq. 3)
then
423 current_flow = glsc2(w%x, c_xh%B, n) / this%domain_length
427 if (this%avflow)
then
428 xsec = c_xh%volume / this%domain_length
429 flow_rate = this%flow_rate*xsec
431 flow_rate = this%flow_rate
434 delta_flow = flow_rate - current_flow
435 scale = delta_flow / this%base_flow
437 if (this%log .and. pe_rank .eq. 0)
then
438 if (this%flow_dir .eq. 1)
then
439 flow_dir_label =
' x'
440 else if (this%flow_dir .eq. 2)
then
441 flow_dir_label =
' y'
442 else if (this%flow_dir .eq. 3)
then
443 flow_dir_label =
' z'
445 write(step_str,
'(I12)') time%tstep
446 step_str = adjustl(step_str)
447 write(log_buf,
'(A,A3,A5,1X,5A18)') &
448 'Flow rate ',
' | ',
'Dir.:',
'Time:',
'Scale:',
'Rate:', &
450 call neko_log%message(log_buf)
451 write(log_buf,
'(A12,A3,A5,1X,5E18.9)') step_str,
' | ', &
452 flow_dir_label, time%t, scale, flow_rate, current_flow, &
454 call neko_log%message(log_buf)
457 if (neko_bcknd_device .eq. 1)
then
458 call device_add2s2(u%x_d, u_vol%x_d, scale, n)
459 call device_add2s2(v%x_d, v_vol%x_d, scale, n)
460 call device_add2s2(w%x_d, w_vol%x_d, scale, n)
461 call device_add2s2(p%x_d, p_vol%x_d, scale, n)
469 u%x(i,1,1,1) = u%x(i,1,1,1) + scale * u_vol%x(i,1,1,1)
470 v%x(i,1,1,1) = v%x(i,1,1,1) + scale * v_vol%x(i,1,1,1)
471 w%x(i,1,1,1) = w%x(i,1,1,1) + scale * w_vol%x(i,1,1,1)
472 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, dp_projector, vel_projector, ax_vel, ax_prs, ksp_prs, ksp_vel, pc_prs, pc_vel, prs_max_iter, vel_max_iter)
Adjust flow volume.