advance_ab2 Subroutine

private subroutine advance_ab2(mesh, flow, params, fields, rhs, local_ustar)

Advances velocity using the 2nd-order Adams-Bashforth scheme.

Falls back to 1st-order Forward Euler on the very first timestep when previous RHS data is unavailable.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
real(kind=rk), intent(in) :: rhs(:,:)
real(kind=rk), intent(out) :: local_ustar(:,:)

Source Code

   subroutine advance_ab2(mesh, flow, params, fields, rhs, local_ustar)
      type(mesh_t), intent(in) :: mesh
      type(flow_mpi_t), intent(in) :: flow
      type(case_params_t), intent(in) :: params
      type(flow_fields_t), intent(in) :: fields
      real(rk), intent(in) :: rhs(:,:)
      real(rk), intent(out) :: local_ustar(:,:)

      integer :: c
      real(rk) :: c_curr, c_old

      local_ustar = zero

      if (fields%rhs_old_valid .and. params%dt_old > tiny_safe) then
         c_curr = 1.0_rk + 0.5_rk * (params%dt / params%dt_old)
         c_old = -0.5_rk * (params%dt / params%dt_old)
         do c = flow%first_cell, flow%last_cell
            local_ustar(:, c) = fields%u(:, c) + params%dt * &
               (c_curr * rhs(:, c) + c_old * fields%rhs_old(:, c))
         end do
      else
         do c = flow%first_cell, flow%last_cell
            local_ustar(:, c) = fields%u(:, c) + params%dt * rhs(:, c)
         end do
      end if

      associate(dummy => mesh%ncells)
      end associate
   end subroutine advance_ab2