2010-10-13 03:32:10 -03:00
|
|
|
!!******************************************************************************
|
2008-12-07 18:57:08 -06:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! This file is part of the AMUN source code, a program to perform
|
|
|
|
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
|
|
|
!! adaptive mesh.
|
2008-12-07 18:57:08 -06:00
|
|
|
!!
|
2014-01-02 11:52:59 -02:00
|
|
|
!! Copyright (C) 2008-2014 Grzegorz Kowal <grzegorz@amuncode.org>
|
2008-12-07 18:57:08 -06:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! This program is free software: you can redistribute it and/or modify
|
|
|
|
!! it under the terms of the GNU General Public License as published by
|
|
|
|
!! the Free Software Foundation, either version 3 of the License, or
|
|
|
|
!! (at your option) any later version.
|
2008-12-07 18:57:08 -06:00
|
|
|
!!
|
2011-04-29 11:21:30 -03:00
|
|
|
!! This program is distributed in the hope that it will be useful,
|
2008-12-07 18:57:08 -06:00
|
|
|
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
!! GNU General Public License for more details.
|
|
|
|
!!
|
|
|
|
!! You should have received a copy of the GNU General Public License
|
2012-07-22 12:30:20 -03:00
|
|
|
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-07 18:57:08 -06:00
|
|
|
!!
|
2010-10-13 03:32:10 -03:00
|
|
|
!!******************************************************************************
|
2008-12-07 18:57:08 -06:00
|
|
|
!!
|
2012-07-28 11:47:14 -03:00
|
|
|
!! module: EVOLUTION
|
|
|
|
!!
|
2013-12-11 10:59:25 -02:00
|
|
|
!! This module provides an interface for temporal integration with
|
|
|
|
!! the stability handling. New integration methods can be added by
|
|
|
|
!! implementing more evolve_* subroutines.
|
2012-07-22 12:30:20 -03:00
|
|
|
!!
|
|
|
|
!!******************************************************************************
|
2008-12-07 18:57:08 -06:00
|
|
|
!
|
|
|
|
module evolution
|
|
|
|
|
2012-07-28 11:47:14 -03:00
|
|
|
! module variables are not implicit by default
|
|
|
|
!
|
2008-12-07 18:57:08 -06:00
|
|
|
implicit none
|
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
! pointer to the temporal integration subroutine
|
|
|
|
!
|
|
|
|
procedure(evolve_euler), pointer, save :: evolve => null()
|
|
|
|
|
2012-07-28 11:47:14 -03:00
|
|
|
! evolution parameters
|
|
|
|
!
|
2014-08-26 13:25:31 -03:00
|
|
|
real(kind=8), save :: cfl = 5.0d-01
|
|
|
|
integer , save :: stages = 2
|
2012-07-28 11:47:14 -03:00
|
|
|
|
2013-12-12 15:36:55 -02:00
|
|
|
! coefficient controlling the decay of scalar potential ѱ
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), save :: alpha = 2.0d+00
|
|
|
|
real(kind=8), save :: decay = 1.0d+00
|
2013-12-12 15:36:55 -02:00
|
|
|
|
2012-08-01 12:56:52 -03:00
|
|
|
! time variables
|
2012-07-28 11:47:14 -03:00
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
integer , save :: step = 0
|
|
|
|
real(kind=8), save :: time = 0.0d+00
|
|
|
|
real(kind=8), save :: dt = 1.0d+00
|
|
|
|
real(kind=8), save :: dtn = 1.0d+00
|
2008-12-07 18:57:08 -06:00
|
|
|
|
2012-07-28 11:47:14 -03:00
|
|
|
! by default everything is private
|
|
|
|
!
|
|
|
|
private
|
|
|
|
|
|
|
|
! declare public subroutines
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
public :: initialize_evolution, finalize_evolution
|
2013-12-11 22:48:48 -02:00
|
|
|
public :: advance, new_time_step
|
2012-07-28 11:47:14 -03:00
|
|
|
|
|
|
|
! declare public variables
|
|
|
|
!
|
2014-01-08 17:34:15 -02:00
|
|
|
public :: cfl, step, time, dt, dtn
|
2012-07-28 11:47:14 -03:00
|
|
|
|
|
|
|
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
!
|
2008-12-07 18:57:08 -06:00
|
|
|
contains
|
|
|
|
!
|
2008-12-08 21:07:10 -06:00
|
|
|
!===============================================================================
|
2012-07-28 11:47:14 -03:00
|
|
|
!!
|
|
|
|
!!*** PUBLIC SUBROUTINES *****************************************************
|
|
|
|
!!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-28 11:47:14 -03:00
|
|
|
! subroutine INITIALIZE_EVOLUTION:
|
|
|
|
! -------------------------------
|
|
|
|
!
|
2012-08-01 12:56:52 -03:00
|
|
|
! Subroutine initializes module EVOLUTION by setting its parameters.
|
2012-07-28 11:47:14 -03:00
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
! Arguments:
|
|
|
|
!
|
|
|
|
! verbose - a logical flag turning the information printing;
|
|
|
|
! iret - an integer flag for error return value;
|
2012-07-28 11:47:14 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
subroutine initialize_evolution(verbose, iret)
|
2012-07-28 11:47:14 -03:00
|
|
|
|
2012-08-01 12:56:52 -03:00
|
|
|
! include external procedures
|
2012-07-28 11:47:14 -03:00
|
|
|
!
|
2014-08-26 13:25:31 -03:00
|
|
|
use parameters, only : get_parameter_string, get_parameter_real &
|
|
|
|
, get_parameter_integer
|
2012-07-28 11:47:14 -03:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! subroutine arguments
|
|
|
|
!
|
|
|
|
logical, intent(in) :: verbose
|
|
|
|
integer, intent(inout) :: iret
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
character(len=255) :: integration = "rk2"
|
|
|
|
character(len=255) :: name_int = ""
|
2012-07-28 11:47:14 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
! get the integration method and the value of the CFL coefficient
|
2012-07-28 11:47:14 -03:00
|
|
|
!
|
2014-08-26 13:25:31 -03:00
|
|
|
call get_parameter_string ("time_advance", integration)
|
|
|
|
call get_parameter_integer("stages" , stages )
|
|
|
|
call get_parameter_real ("cfl" , cfl )
|
|
|
|
call get_parameter_real ("alpha" , alpha )
|
2012-07-28 11:47:14 -03:00
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
! select the integration method, check the correctness of the integration
|
|
|
|
! parameters and adjust the CFL coefficient if necessary
|
2012-07-31 15:13:51 -03:00
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
select case(trim(integration))
|
|
|
|
|
|
|
|
case ("euler", "EULER")
|
|
|
|
|
2014-08-21 12:39:35 -03:00
|
|
|
name_int = "1st order Euler"
|
2013-12-11 10:59:25 -02:00
|
|
|
evolve => evolve_euler
|
|
|
|
|
|
|
|
case ("rk2", "RK2")
|
|
|
|
|
2014-08-21 12:39:35 -03:00
|
|
|
name_int = "2nd order Runge-Kutta"
|
2013-12-11 10:59:25 -02:00
|
|
|
evolve => evolve_rk2
|
|
|
|
|
2014-08-26 13:25:31 -03:00
|
|
|
case ("ssprk(m,2)", "SSPRK(m,2)")
|
|
|
|
|
|
|
|
stages = max(2, min(9, stages))
|
|
|
|
write(name_int, "('2nd order SSPRK(',i1,',2)')") stages
|
|
|
|
evolve => evolve_ssprk2
|
|
|
|
cfl = (stages - 1) * cfl
|
|
|
|
|
2014-08-19 20:50:49 -03:00
|
|
|
case ("rk3", "RK3")
|
|
|
|
|
2014-08-21 12:39:35 -03:00
|
|
|
name_int = "3rd order Runge-Kutta"
|
2014-08-19 20:50:49 -03:00
|
|
|
evolve => evolve_rk3
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
case ("rk3.4", "RK3.4", "ssprk(4,3)", "SSPRK(4,3)")
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
name_int = "3rd order SSPRK(4,3)"
|
|
|
|
evolve => evolve_ssprk34
|
2014-08-19 21:12:20 -03:00
|
|
|
cfl = 2.0d+00 * cfl
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
case ("rk3.5", "RK3.5", "ssprk(5,3)", "SSPRK(5,3)")
|
2014-08-26 13:51:11 -03:00
|
|
|
|
|
|
|
name_int = "3rd order SSPRK(5,3)"
|
|
|
|
evolve => evolve_ssprk35
|
|
|
|
cfl = 2.65062919143939d+00 * cfl
|
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
case default
|
|
|
|
|
|
|
|
if (verbose) then
|
|
|
|
write (*,"(1x,a)") "The selected time advance method is not " // &
|
|
|
|
"implemented: " // trim(integration)
|
|
|
|
name_int = "2nd order Runge-Kutta method"
|
|
|
|
evolve => evolve_rk2
|
|
|
|
end if
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
2013-12-12 15:36:55 -02:00
|
|
|
! calculate the decay factor for magnetic field divergence scalar source term
|
|
|
|
!
|
|
|
|
decay = exp(- alpha * cfl)
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! print information about the Riemann solver
|
|
|
|
!
|
|
|
|
if (verbose) then
|
|
|
|
|
|
|
|
write (*,"(4x,a,1x,a)" ) "time advance =", trim(name_int)
|
|
|
|
|
|
|
|
end if
|
2012-07-31 15:13:51 -03:00
|
|
|
|
2012-07-28 11:47:14 -03:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine initialize_evolution
|
|
|
|
!
|
|
|
|
!===============================================================================
|
2008-12-07 18:57:08 -06:00
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
! subroutine FINALIZE_EVOLUTION:
|
|
|
|
! -----------------------------
|
|
|
|
!
|
|
|
|
! Subroutine releases memory used by the module.
|
|
|
|
!
|
|
|
|
! Arguments:
|
|
|
|
!
|
|
|
|
! iret - an integer flag for error return value;
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine finalize_evolution(iret)
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! subroutine arguments
|
|
|
|
!
|
|
|
|
integer, intent(inout) :: iret
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2014-01-02 12:18:04 -02:00
|
|
|
nullify(evolve)
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine finalize_evolution
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-31 15:04:40 -03:00
|
|
|
! subroutine ADVANCE:
|
|
|
|
! ------------------
|
|
|
|
!
|
2012-08-01 12:56:52 -03:00
|
|
|
! Subroutine advances the solution by one time step using the selected time
|
|
|
|
! integration method.
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2014-01-08 18:07:54 -02:00
|
|
|
! Arguments:
|
|
|
|
!
|
|
|
|
! dtnext - next time step;
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-01-08 18:07:54 -02:00
|
|
|
subroutine advance(dtnext)
|
2012-07-31 15:04:40 -03:00
|
|
|
|
2012-08-01 12:56:52 -03:00
|
|
|
! include external procedures
|
|
|
|
!
|
2014-01-23 10:58:15 -02:00
|
|
|
use blocks , only : set_blocks_update
|
2012-08-01 12:56:52 -03:00
|
|
|
use boundaries , only : boundary_variables
|
|
|
|
use mesh , only : update_mesh
|
|
|
|
|
|
|
|
! include external variables
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2012-08-01 12:56:52 -03:00
|
|
|
use coordinates , only : toplev
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
2014-01-08 18:07:54 -02:00
|
|
|
|
|
|
|
! input variables
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), intent(in) :: dtnext
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
! find new time step
|
|
|
|
!
|
2014-01-08 18:07:54 -02:00
|
|
|
call new_time_step(dtnext)
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! advance the solution using the selected method
|
|
|
|
!
|
|
|
|
call evolve()
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! chec if we need to perform the refinement step
|
|
|
|
!
|
|
|
|
if (toplev > 1) then
|
|
|
|
|
2014-01-23 10:58:15 -02:00
|
|
|
! set all meta blocks to not be updated
|
|
|
|
!
|
|
|
|
call set_blocks_update(.false.)
|
|
|
|
|
2012-07-31 15:04:40 -03:00
|
|
|
! check refinement and refine
|
|
|
|
!
|
|
|
|
call update_mesh()
|
|
|
|
|
2012-07-31 16:38:16 -03:00
|
|
|
! update primitive variables
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2014-01-23 10:58:15 -02:00
|
|
|
call update_variables()
|
|
|
|
|
2014-04-09 08:51:04 -03:00
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2014-07-14 13:25:30 -03:00
|
|
|
#ifdef DEBUG
|
|
|
|
! check variables for NaNs
|
|
|
|
!
|
|
|
|
call check_variables()
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2014-01-23 10:58:15 -02:00
|
|
|
! set all meta blocks to be updated
|
|
|
|
!
|
|
|
|
call set_blocks_update(.true.)
|
|
|
|
|
|
|
|
end if ! toplev > 1
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine advance
|
|
|
|
!
|
|
|
|
!===============================================================================
|
2014-01-08 18:07:54 -02:00
|
|
|
!
|
|
|
|
! subroutine NEW_TIME_STEP:
|
|
|
|
! ------------------------
|
|
|
|
!
|
|
|
|
! Subroutine estimates the new time step from the maximum speed in the system
|
|
|
|
! and source term constraints.
|
|
|
|
!
|
|
|
|
! Arguments:
|
|
|
|
!
|
|
|
|
! dtnext - next time step;
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine new_time_step(dtnext)
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use equations , only : maxspeed, cmax, cmax2
|
|
|
|
#ifdef MPI
|
|
|
|
use mpitools , only : reduce_maximum_real, reduce_maximum_integer
|
|
|
|
#endif /* MPI */
|
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : adx, ady, adz
|
|
|
|
use coordinates , only : toplev
|
2014-05-29 12:04:55 -03:00
|
|
|
use sources , only : viscosity, resistivity
|
2014-01-08 18:07:54 -02:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input variables
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), intent(in) :: dtnext
|
2014-01-08 18:07:54 -02:00
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_data), pointer :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: iret
|
|
|
|
integer(kind=4) :: lev
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8) :: cm, dx_min
|
2014-01-08 18:07:54 -02:00
|
|
|
|
|
|
|
! local parameters
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), parameter :: eps = tiny(cmax)
|
2014-01-08 18:07:54 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! reset the maximum speed, and the highest level
|
|
|
|
!
|
|
|
|
cmax = eps
|
|
|
|
lev = 1
|
|
|
|
|
|
|
|
! iterate over all data blocks in order to find the maximum speed among them
|
|
|
|
! and the highest level which is required to obtain the spatial step
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
|
|
|
! find the maximum level occupied by blocks (can be smaller than toplev)
|
|
|
|
!
|
|
|
|
lev = max(lev, pblock%meta%level)
|
|
|
|
|
|
|
|
! obtain the maximum speed for the current block
|
|
|
|
!
|
|
|
|
cm = maxspeed(pblock%q(:,:,:,:))
|
|
|
|
|
|
|
|
! compare global and local maximum speeds
|
|
|
|
!
|
|
|
|
cmax = max(cmax, cm)
|
|
|
|
|
|
|
|
! assiociate the pointer with the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
#ifdef MPI
|
|
|
|
! find maximum speed in the system from all processors
|
|
|
|
!
|
|
|
|
call reduce_maximum_real (cmax, iret)
|
|
|
|
call reduce_maximum_integer(lev , iret)
|
|
|
|
#endif /* MPI */
|
|
|
|
|
|
|
|
! calculate squared cmax
|
|
|
|
!
|
|
|
|
cmax2 = cmax * cmax
|
|
|
|
|
|
|
|
! find the smallest spatial step
|
|
|
|
!
|
|
|
|
#if NDIMS == 2
|
|
|
|
dx_min = min(adx(lev), ady(lev))
|
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
|
|
|
dx_min = min(adx(lev), ady(lev), adz(lev))
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
2014-08-20 18:10:30 -03:00
|
|
|
! calculate the new time step
|
2014-01-08 18:07:54 -02:00
|
|
|
!
|
2014-08-20 18:10:30 -03:00
|
|
|
dtn = cfl * dx_min / max(cmax &
|
2014-06-02 11:47:37 -03:00
|
|
|
+ 2.0d+00 * max(viscosity, resistivity) / dx_min, eps)
|
2014-01-08 18:07:54 -02:00
|
|
|
|
2014-08-20 18:10:30 -03:00
|
|
|
! substitute the new time step
|
2014-01-08 18:07:54 -02:00
|
|
|
!
|
2014-08-20 18:10:30 -03:00
|
|
|
dt = dtn
|
2014-01-08 18:07:54 -02:00
|
|
|
|
|
|
|
! round the time
|
|
|
|
!
|
|
|
|
if (dtnext > 0.0d+00) dt = min(dt, dtnext)
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine new_time_step
|
|
|
|
!
|
|
|
|
!===============================================================================
|
2012-07-28 11:47:14 -03:00
|
|
|
!!
|
|
|
|
!!*** PRIVATE SUBROUTINES ****************************************************
|
|
|
|
!!
|
|
|
|
!===============================================================================
|
2010-12-01 10:39:18 -02:00
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! subroutine EVOLVE_EULER:
|
|
|
|
! -----------------------
|
|
|
|
!
|
|
|
|
! Subroutine advances the solution by one time step using the 1st order
|
|
|
|
! Euler integration method.
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine evolve_euler()
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use boundaries , only : boundary_variables
|
2014-04-29 18:35:58 -03:00
|
|
|
use sources , only : update_sources
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : im, jm, km
|
2013-12-12 16:09:47 -02:00
|
|
|
use equations , only : nv, ibp
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_data), pointer :: pblock
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), dimension(nv,im,jm,km) :: du
|
2013-12-11 10:59:25 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! update the solution using numerical fluxes stored in the data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
call update_increment(pblock, du(:,:,:,:))
|
2013-12-11 10:59:25 -02:00
|
|
|
|
2014-04-29 18:35:58 -03:00
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pblock, du(:,:,:,:))
|
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
pblock%u0(1:nv,:,:,:) = pblock%u0(1:nv,:,:,:) + dt * du(1:nv,:,:,:)
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
2013-12-12 15:36:55 -02:00
|
|
|
pblock%u => pblock%u0
|
|
|
|
|
|
|
|
! update ψ by its source term
|
|
|
|
!
|
|
|
|
if (ibp > 0) pblock%u(ibp,:,:,:) = decay * pblock%u(ibp,:,:,:)
|
2013-12-11 10:59:25 -02:00
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
2014-04-09 08:51:04 -03:00
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine evolve_euler
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! subroutine EVOLVE_RK2:
|
|
|
|
! ---------------------
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
|
|
|
! Subroutine advances the solution by one time step using the 2nd order
|
|
|
|
! Runge-Kutta time integration method.
|
|
|
|
!
|
2014-08-19 20:50:49 -03:00
|
|
|
! References:
|
|
|
|
!
|
|
|
|
! [1] Press, W. H, Teukolsky, S. A., Vetterling, W. T., Flannery, B. P.,
|
|
|
|
! "Numerical Recipes in Fortran",
|
|
|
|
! Cambridge University Press, Cambridge, 1992
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
subroutine evolve_rk2()
|
2012-07-31 15:04:40 -03:00
|
|
|
|
2012-08-01 12:56:52 -03:00
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use boundaries , only : boundary_variables
|
2014-04-29 18:35:58 -03:00
|
|
|
use sources , only : update_sources
|
2012-08-01 12:56:52 -03:00
|
|
|
|
|
|
|
! include external variables
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2012-08-01 12:56:52 -03:00
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : im, jm, km
|
2013-12-12 15:36:55 -02:00
|
|
|
use equations , only : nv, ibp
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_data), pointer :: pblock
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), dimension(nv,im,jm,km) :: du
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-31 16:02:59 -03:00
|
|
|
! update fluxes for the first step of the RK2 integration
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2012-07-31 16:02:59 -03:00
|
|
|
call update_fluxes()
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! update the solution using numerical fluxes stored in the data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
2012-07-31 16:23:20 -03:00
|
|
|
! calculate variable increment for the current block
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
call update_increment(pblock, du(:,:,:,:))
|
2012-07-31 15:04:40 -03:00
|
|
|
|
2014-04-29 18:35:58 -03:00
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pblock, du(:,:,:,:))
|
|
|
|
|
2012-07-31 15:04:40 -03:00
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
pblock%u1(1:nv,:,:,:) = pblock%u0(1:nv,:,:,:) + dt * du(1:nv,:,:,:)
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pblock%u => pblock%u1
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
2012-07-31 16:38:16 -03:00
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
2014-04-09 08:51:04 -03:00
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2012-07-31 16:02:59 -03:00
|
|
|
! update fluxes for the second step of the RK2 integration
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2012-07-31 16:02:59 -03:00
|
|
|
call update_fluxes()
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! update the solution using numerical fluxes stored in the data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
2012-07-31 16:23:20 -03:00
|
|
|
! calculate variable increment for the current block
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
call update_increment(pblock, du(:,:,:,:))
|
2012-07-31 15:04:40 -03:00
|
|
|
|
2014-04-29 18:35:58 -03:00
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pblock, du(:,:,:,:))
|
|
|
|
|
2012-07-31 15:04:40 -03:00
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
pblock%u0(1:nv,:,:,:) = 0.5d+00 * (pblock%u0(1:nv,:,:,:) &
|
|
|
|
+ pblock%u1(1:nv,:,:,:) + dt * du(1:nv,:,:,:))
|
2012-07-31 15:04:40 -03:00
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pblock%u => pblock%u0
|
|
|
|
|
2013-12-12 15:36:55 -02:00
|
|
|
! update ψ by its source term
|
|
|
|
!
|
|
|
|
if (ibp > 0) pblock%u(ibp,:,:,:) = decay * pblock%u(ibp,:,:,:)
|
|
|
|
|
2012-07-31 15:04:40 -03:00
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
2014-04-09 08:51:04 -03:00
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2012-07-31 15:04:40 -03:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
end subroutine evolve_rk2
|
2012-07-31 15:04:40 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-08-26 13:25:31 -03:00
|
|
|
! subroutine EVOLVE_SSPRK2:
|
|
|
|
! ------------------------
|
|
|
|
!
|
|
|
|
! Subroutine advances the solution by one time step using the 2nd order
|
|
|
|
! m-stage Strong Stability Preserving Runge-Kutta time integration method.
|
|
|
|
! Up to 9 stages are allowed, due to stability problems with more stages.
|
|
|
|
!
|
|
|
|
! References:
|
|
|
|
!
|
|
|
|
! [1] Gottlieb, S. and Gottlieb, L.-A., J.
|
|
|
|
! "Strong Stability Preserving Properties of Runge-Kutta Time
|
|
|
|
! Discretization Methods for Linear Constant Coefficient Operators",
|
|
|
|
! Journal of Scientific Computing,
|
|
|
|
! 2003, vol. 18, no. 1, pp. 83-109
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine evolve_ssprk2()
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use boundaries , only : boundary_variables
|
|
|
|
use sources , only : update_sources
|
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : im, jm, km
|
|
|
|
use equations , only : nv, ibp
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_data), pointer :: pdata
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: n
|
|
|
|
real(kind=8) :: ds
|
|
|
|
|
|
|
|
! local saved variables
|
|
|
|
!
|
|
|
|
logical , save :: first = .true.
|
|
|
|
real(kind=8), save :: ft, fl, fr
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real(kind=8), dimension(nv,im,jm,km) :: du
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! prepare things which don't change later
|
|
|
|
!
|
|
|
|
if (first) then
|
|
|
|
|
|
|
|
! calculate integration coefficients
|
|
|
|
!
|
|
|
|
ft = 1.0d+00 / (stages - 1)
|
|
|
|
fl = 1.0d+00 / stages
|
|
|
|
fr = 1.0d+00 - fl
|
|
|
|
|
|
|
|
! update first flag
|
|
|
|
!
|
|
|
|
first = .false.
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
! calculate the fractional time step
|
|
|
|
!
|
|
|
|
ds = ft * dt
|
|
|
|
|
|
|
|
!= 1st step: U(0) = U(n)
|
|
|
|
!
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! copy conservative array u0 to u1
|
|
|
|
!
|
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = pdata%u0(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pdata%u => pdata%u1
|
|
|
|
|
|
|
|
! assign pdata to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
!= 2nd step: U(i) = [1 + dt/(m-1) L] U(i-1), for i = 1, ..., m-1
|
|
|
|
!
|
|
|
|
! integrate intermediate steps
|
|
|
|
!
|
|
|
|
do n = 1, stages - 1
|
|
|
|
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! assign pdata to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
end do ! n = 1, stages - 1
|
|
|
|
|
|
|
|
!= 3rd step: U(n+1) = 1/m U(0) + (m-1)/m [1 + dt/(m-1) L] U(m-1)
|
|
|
|
!
|
|
|
|
! update fluxes for the last step
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u0(1:nv,1:im,1:jm,1:km) = fl * pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ fr * (pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pdata%u => pdata%u0
|
|
|
|
|
|
|
|
! update ψ by its source term
|
|
|
|
!
|
|
|
|
if (ibp > 0) pdata%u(ibp,1:im,1:jm,1:km) = &
|
|
|
|
decay * pdata%u(ibp,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine evolve_ssprk2
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-08-19 20:50:49 -03:00
|
|
|
! subroutine EVOLVE_RK3:
|
|
|
|
! ---------------------
|
|
|
|
!
|
|
|
|
! Subroutine advances the solution by one time step using the 3rd order
|
|
|
|
! Runge-Kutta time integration method.
|
|
|
|
!
|
|
|
|
! References:
|
|
|
|
!
|
|
|
|
! [1] Press, W. H, Teukolsky, S. A., Vetterling, W. T., Flannery, B. P.,
|
|
|
|
! "Numerical Recipes in Fortran",
|
|
|
|
! Cambridge University Press, Cambridge, 1992
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine evolve_rk3()
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use boundaries , only : boundary_variables
|
|
|
|
use sources , only : update_sources
|
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : im, jm, km
|
|
|
|
use equations , only : nv, ibp
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_data), pointer :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
real(kind=8) :: ds
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real(kind=8), dimension(nv,im,jm,km) :: du
|
|
|
|
|
|
|
|
! local integration parameters
|
|
|
|
!
|
|
|
|
real(kind=8), parameter :: f21 = 3.0d+00 / 4.0d+00, f22 = 1.0d+00 / 4.0d+00
|
|
|
|
real(kind=8), parameter :: f31 = 1.0d+00 / 3.0d+00, f32 = 2.0d+00 / 3.0d+00
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
!! 1st substep of integration
|
|
|
|
!!
|
|
|
|
! prepare fractional time step
|
|
|
|
!
|
|
|
|
ds = dt
|
|
|
|
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! update the solution using numerical fluxes stored in the data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pblock, du(:,:,:,:))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pblock, du(:,:,:,:))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pblock%u1(1:nv,:,:,:) = pblock%u0(1:nv,:,:,:) + ds * du(1:nv,:,:,:)
|
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pblock%u => pblock%u1
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!! 2nd substep of integration
|
|
|
|
!!
|
|
|
|
! prepare fractional time step
|
|
|
|
!
|
|
|
|
ds = f22 * dt
|
|
|
|
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! update the solution using numerical fluxes stored in the data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pblock, du(:,:,:,:))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pblock, du(:,:,:,:))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pblock%u1(1:nv,:,:,:) = f21 * pblock%u0(1:nv,:,:,:) &
|
|
|
|
+ f22 * pblock%u1(1:nv,:,:,:) + ds * du(1:nv,:,:,:)
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!! 3rd substep of integration
|
|
|
|
!!
|
|
|
|
! prepare fractional time step
|
|
|
|
!
|
|
|
|
ds = f32 * dt
|
|
|
|
|
|
|
|
! update fluxes for the second step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! update the solution using numerical fluxes stored in the data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pblock, du(:,:,:,:))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pblock, du(:,:,:,:))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pblock%u0(1:nv,:,:,:) = f31 * pblock%u0(1:nv,:,:,:) &
|
|
|
|
+ f32 * pblock%u1(1:nv,:,:,:) + ds * du(1:nv,:,:,:)
|
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pblock%u => pblock%u0
|
|
|
|
|
|
|
|
! update ψ by its source term
|
|
|
|
!
|
|
|
|
if (ibp > 0) pblock%u(ibp,:,:,:) = decay * pblock%u(ibp,:,:,:)
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine evolve_rk3
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
! subroutine EVOLVE_SSPRK34:
|
|
|
|
! -------------------------
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
! Subroutine advances the solution by one time step using the 3rd order
|
2014-08-26 14:47:16 -03:00
|
|
|
! 4-stage Strong Stability Preserving Runge-Kutta time integration method.
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
! References:
|
|
|
|
!
|
|
|
|
! [1] Ruuth, S. J.,
|
|
|
|
! "Global Optimization of Explicit Strong-Stability-Preserving
|
|
|
|
! Runge-Kutta methods",
|
|
|
|
! Mathematics of Computation,
|
2014-08-26 14:47:16 -03:00
|
|
|
! 2006, vol. 75, no. 253, pp. 183-207
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
subroutine evolve_ssprk34()
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use boundaries , only : boundary_variables
|
|
|
|
use sources , only : update_sources
|
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : im, jm, km
|
|
|
|
use equations , only : nv, ibp
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
type(block_data), pointer :: pdata
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
real(kind=8) :: ds
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real(kind=8), dimension(nv,im,jm,km) :: du
|
|
|
|
|
|
|
|
! local integration parameters
|
|
|
|
!
|
2014-08-21 14:01:27 -03:00
|
|
|
real(kind=8), parameter :: b1 = 1.0d+00 / 2.0d+00, b3 = 1.0d+00 / 6.0d+00
|
|
|
|
real(kind=8), parameter :: a31 = 2.0d+00 / 3.0d+00, a33 = 1.0d+00 / 3.0d+00
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
!= 1st step: U(1) = U(n) + 1/2 dt F[U(n)]
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
! calculate the fractional time step
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-21 14:01:27 -03:00
|
|
|
ds = b1 * dt
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! update fluxes
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata with the first block on the data block list
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata => list_data
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! iterate over all data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
do while (associated(pdata))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! calculate the variable increment
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! add the source terms
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the intermediate solution
|
|
|
|
!
|
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata%u => pdata%u1
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata to the next block
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata => pdata%next
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
end do ! over data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
!= 2nd step: U(2) = U(1) + 1/2 dt F[U(1)]
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
! update fluxes
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata with the first block on the data block list
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata => list_data
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! iterate over all data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
do while (associated(pdata))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! calculate the variable increment
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! add the source terms
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! update the intermediate solution
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
!= 3rd step: U(3) = 2/3 U(n) + 1/3 U(2) + 1/6 dt F[U(2)]
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
! calculate the fractional time step
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-21 14:01:27 -03:00
|
|
|
ds = b3 * dt
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! update fluxes
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata with the first block on the data block list
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata => list_data
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! iterate over all data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
do while (associated(pdata))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! calculate the variable increment
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! add the source terms
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! update the intermediate solution
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = a31 * pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ a33 * pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
!= the final step: U(n+1) = U(3) + 1/2 dt F[U(3)]
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
! calculate fractional time step
|
|
|
|
!
|
2014-08-21 14:01:27 -03:00
|
|
|
ds = b1 * dt
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! update fluxes
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata with the first block on the data block list
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata => list_data
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! iterate over all data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
do while (associated(pdata))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! calculate the variable increment
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! add the source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the final solution
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata%u0(1:nv,1:im,1:jm,1:km) = pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata%u => pdata%u0
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update ψ by its source term
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
if (ibp > 0) pdata%u(ibp,1:im,1:jm,1:km) = &
|
|
|
|
decay * pdata%u(ibp,1:im,1:jm,1:km)
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
! assign pdata to the next block
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
pdata => pdata%next
|
2014-08-19 21:12:20 -03:00
|
|
|
|
2014-08-26 14:47:16 -03:00
|
|
|
end do ! over data blocks
|
2014-08-19 21:12:20 -03:00
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2014-08-26 14:47:16 -03:00
|
|
|
end subroutine evolve_ssprk34
|
2014-08-19 21:12:20 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-08-26 13:51:11 -03:00
|
|
|
! subroutine EVOLVE_SSPRK35:
|
|
|
|
! -------------------------
|
|
|
|
!
|
|
|
|
! Subroutine advances the solution by one time step using the 3rd order
|
|
|
|
! 5-stage Strong Stability Preserving Runge-Kutta time integration method.
|
|
|
|
!
|
|
|
|
! References:
|
|
|
|
!
|
|
|
|
! [1] Ruuth, S. J.,
|
|
|
|
! "Global Optimization of Explicit Strong-Stability-Preserving
|
|
|
|
! Runge-Kutta methods",
|
|
|
|
! Mathematics of Computation,
|
|
|
|
! 2006, vol. 75, no. 253, pp. 183-207
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine evolve_ssprk35()
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use boundaries , only : boundary_variables
|
|
|
|
use sources , only : update_sources
|
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : im, jm, km
|
|
|
|
use equations , only : nv, ibp
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_data), pointer :: pdata
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
real(kind=8) :: ds
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real(kind=8), dimension(nv,im,jm,km) :: du
|
|
|
|
|
|
|
|
! local integration parameters
|
|
|
|
!
|
|
|
|
real(kind=8), parameter :: b1 = 3.77268915331368d-01
|
|
|
|
real(kind=8), parameter :: b3 = 2.42995220537396d-01
|
|
|
|
real(kind=8), parameter :: b4 = 2.38458932846290d-01
|
|
|
|
real(kind=8), parameter :: b5 = 2.87632146308408d-01
|
|
|
|
real(kind=8), parameter :: a31 = 3.55909775063327d-01
|
|
|
|
real(kind=8), parameter :: a33 = 6.44090224936674d-01
|
|
|
|
real(kind=8), parameter :: a41 = 3.67933791638137d-01
|
|
|
|
real(kind=8), parameter :: a44 = 6.32066208361863d-01
|
|
|
|
real(kind=8), parameter :: a53 = 2.37593836598569d-01
|
|
|
|
real(kind=8), parameter :: a55 = 7.62406163401431d-01
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
!= 1st step of the integration: U(1) = U(n) + b1 dt F[U(n)]
|
|
|
|
!
|
|
|
|
! calculate fractional time step
|
|
|
|
!
|
|
|
|
ds = b1 * dt
|
|
|
|
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pdata%u => pdata%u1
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!= 2nd step of the integration: U(2) = U(1) + b1 dt F[U(1)]
|
|
|
|
!
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!= 3rd step of the integration: U(3) = a31 U(n) + a33 U(2) + b3 dt F[U(2)]
|
|
|
|
!
|
|
|
|
! calculate fractional time step
|
|
|
|
!
|
|
|
|
ds = b3 * dt
|
|
|
|
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u1(1:nv,1:im,1:jm,1:km) = a31 * pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ a33 * pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!= 4th step of the integration: U(4) = a41 U(n) + a44 U(3) + b4 dt F[U(3)]
|
|
|
|
!
|
|
|
|
! calculate fractional time step
|
|
|
|
!
|
|
|
|
ds = b4 * dt
|
|
|
|
|
|
|
|
! update fluxes for the first step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u0(1:nv,1:im,1:jm,1:km) = a41 * pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ a44 * pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! update the conservative variable pointer
|
|
|
|
!
|
|
|
|
pdata%u => pdata%u0
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!= update the final solution: U(n+1) = a53 U(2) + a55 U(4) + b5 dt F[U(4)]
|
|
|
|
!
|
|
|
|
! calculate fractional time step
|
|
|
|
!
|
|
|
|
ds = b5 * dt
|
|
|
|
|
|
|
|
! update fluxes for the second step of the RK2 integration
|
|
|
|
!
|
|
|
|
call update_fluxes()
|
|
|
|
|
|
|
|
! assign pdata with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! calculate variable increment for the current block
|
|
|
|
!
|
|
|
|
call update_increment(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! add source terms
|
|
|
|
!
|
|
|
|
call update_sources(pdata, du(1:nv,1:im,1:jm,1:km))
|
|
|
|
|
|
|
|
! update the solution for the fluid variables
|
|
|
|
!
|
|
|
|
pdata%u0(1:nv,1:im,1:jm,1:km) = a53 * pdata%u1(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ a55 * pdata%u0(1:nv,1:im,1:jm,1:km) &
|
|
|
|
+ ds * du(1:nv,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! update ψ by its source term
|
|
|
|
!
|
|
|
|
if (ibp > 0) pdata%u(ibp,1:im,1:jm,1:km) = &
|
|
|
|
decay * pdata%u(ibp,1:im,1:jm,1:km)
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do ! over data blocks
|
|
|
|
|
|
|
|
! update primitive variables
|
|
|
|
!
|
|
|
|
call update_variables()
|
|
|
|
|
|
|
|
! update boundaries
|
|
|
|
!
|
|
|
|
call boundary_variables()
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine evolve_ssprk35
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-31 16:02:59 -03:00
|
|
|
! subroutine UPDATE_FLUXES:
|
|
|
|
! ------------------------
|
|
|
|
!
|
|
|
|
! Subroutine iterates over all data blocks and calculates the numerical
|
|
|
|
! fluxes for each block. After the fluxes are updated, they are corrected
|
|
|
|
! for blocks which have neighbours at higher refinement level.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine update_fluxes()
|
|
|
|
|
2012-08-01 12:56:52 -03:00
|
|
|
! include external procedures
|
2012-07-31 16:02:59 -03:00
|
|
|
!
|
2012-08-01 17:41:56 -03:00
|
|
|
use boundaries , only : boundary_fluxes
|
2012-08-01 16:38:10 -03:00
|
|
|
use schemes , only : update_flux
|
2012-08-01 12:56:52 -03:00
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
use coordinates , only : adx, ady, adz
|
2012-07-31 16:02:59 -03:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
type(block_data), pointer :: pblock
|
2012-07-31 16:02:59 -03:00
|
|
|
|
|
|
|
! local vectors
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
real(kind=8), dimension(3) :: dx
|
2012-07-31 16:23:20 -03:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2014-08-04 09:12:05 -03:00
|
|
|
integer :: n
|
2012-07-31 16:02:59 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
pblock => list_data
|
|
|
|
do while (associated(pblock))
|
|
|
|
|
|
|
|
! obtain dx, dy, and dz for the current block
|
|
|
|
!
|
|
|
|
dx(1) = adx(pblock%meta%level)
|
|
|
|
dx(2) = ady(pblock%meta%level)
|
|
|
|
dx(3) = adz(pblock%meta%level)
|
|
|
|
|
|
|
|
! update the flux for the current block
|
|
|
|
!
|
|
|
|
do n = 1, NDIMS
|
2012-07-31 16:49:14 -03:00
|
|
|
call update_flux(n, dx(n), pblock%q(:,:,:,:), pblock%f(n,:,:,:,:))
|
2012-07-31 16:02:59 -03:00
|
|
|
end do
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pblock => pblock%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
! correct the numerical fluxes of the blocks which have neighbours at higher
|
|
|
|
! level
|
|
|
|
!
|
2012-08-01 17:41:56 -03:00
|
|
|
call boundary_fluxes()
|
2012-07-31 16:02:59 -03:00
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine update_fluxes
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2014-05-27 16:29:53 -03:00
|
|
|
! subroutine UPDATE_INCREMENT:
|
|
|
|
! ---------------------------
|
|
|
|
!
|
|
|
|
! Subroutine calculate the conservative variable increment from the fluxes.
|
|
|
|
!
|
|
|
|
! Arguments:
|
|
|
|
!
|
|
|
|
! dh - the ratio of the time step to the spatial step;
|
|
|
|
! f - the array of numerical fluxes;
|
|
|
|
! du - the array of variable increment;
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine update_increment(pdata, du)
|
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_data
|
|
|
|
use coordinates , only : im, jm, km, ibl, jbl, kbl, ieu, jeu, keu
|
|
|
|
use coordinates , only : adxi, adyi, adzi
|
|
|
|
use equations , only : nv
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! subroutine arguments
|
|
|
|
!
|
|
|
|
type(block_data), pointer , intent(inout) :: pdata
|
|
|
|
real(kind=8), dimension(nv,im,jm,km), intent(inout) :: du
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i , j , k
|
|
|
|
real(kind=8) :: dxi, dyi, dzi
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! reset the increment array du
|
|
|
|
!
|
|
|
|
du(:,:,:,:) = 0.0d+00
|
|
|
|
|
|
|
|
! prepare coordinate intervals
|
|
|
|
!
|
|
|
|
dxi = adxi(pdata%meta%level)
|
|
|
|
dyi = adyi(pdata%meta%level)
|
|
|
|
#if NDIMS == 3
|
|
|
|
dzi = adzi(pdata%meta%level)
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! perform update along the X direction
|
|
|
|
!
|
|
|
|
do i = ibl, ieu
|
|
|
|
du(:,i,:,:) = du(:,i,:,:) &
|
|
|
|
- dxi * (pdata%f(1,:,i,:,:) - pdata%f(1,:,i-1,:,:))
|
|
|
|
end do
|
|
|
|
|
|
|
|
! perform update along the Y direction
|
|
|
|
!
|
|
|
|
do j = jbl, jeu
|
|
|
|
du(:,:,j,:) = du(:,:,j,:) &
|
|
|
|
- dyi * (pdata%f(2,:,:,j,:) - pdata%f(2,:,:,j-1,:))
|
|
|
|
end do
|
|
|
|
|
|
|
|
#if NDIMS == 3
|
|
|
|
! perform update along the Z direction
|
|
|
|
!
|
|
|
|
do k = kbl, keu
|
|
|
|
du(:,:,:,k) = du(:,:,:,k) &
|
|
|
|
- dzi * (pdata%f(3,:,:,:,k) - pdata%f(3,:,:,:,k-1))
|
|
|
|
end do
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine update_increment
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-31 16:38:16 -03:00
|
|
|
! subroutine UPDATE_VARIABLES:
|
|
|
|
! ---------------------------
|
|
|
|
!
|
|
|
|
! Subroutine iterates over all data blocks and converts the conservative
|
|
|
|
! variables to their primitive representation.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine update_variables()
|
|
|
|
|
2012-08-01 12:56:52 -03:00
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use equations , only : update_primitive_variables
|
2014-02-07 12:12:27 -02:00
|
|
|
use shapes , only : update_shapes
|
2012-08-01 12:56:52 -03:00
|
|
|
|
|
|
|
! include external variables
|
2012-07-31 16:38:16 -03:00
|
|
|
!
|
2014-01-23 10:56:29 -02:00
|
|
|
use blocks , only : block_meta, list_meta
|
2012-08-01 12:56:52 -03:00
|
|
|
use blocks , only : block_data, list_data
|
2012-07-31 16:38:16 -03:00
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
2014-01-23 10:56:29 -02:00
|
|
|
type(block_meta), pointer :: pmeta
|
|
|
|
type(block_data), pointer :: pdata
|
2012-07-31 16:38:16 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2014-01-23 10:56:29 -02:00
|
|
|
! associate the pointer with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
2012-07-31 16:38:16 -03:00
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
2014-01-23 10:56:29 -02:00
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! associate pmeta with the corresponding meta block
|
|
|
|
!
|
|
|
|
pmeta => pdata%meta
|
2012-07-31 16:38:16 -03:00
|
|
|
|
2014-02-07 12:12:27 -02:00
|
|
|
! convert conserved variables to primitive ones for the current block and
|
|
|
|
! update shapes if necessary
|
2012-07-31 16:38:16 -03:00
|
|
|
!
|
2014-02-07 12:12:27 -02:00
|
|
|
if (pmeta%update) then
|
|
|
|
call update_primitive_variables(pdata%u, pdata%q)
|
|
|
|
call update_shapes(pdata)
|
|
|
|
end if
|
2012-07-31 16:38:16 -03:00
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
2014-01-23 10:56:29 -02:00
|
|
|
pdata => pdata%next
|
2012-07-31 16:38:16 -03:00
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine update_variables
|
2014-07-14 13:25:30 -03:00
|
|
|
#ifdef DEBUG
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! subroutine CHECK_VARIABLES:
|
|
|
|
! --------------------------
|
|
|
|
!
|
|
|
|
! Subroutine iterates over all data blocks and converts the conservative
|
|
|
|
! variables to their primitive representation.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine check_variables()
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
!
|
|
|
|
use coordinates , only : im, jm, km
|
|
|
|
use equations , only : nv, pvars, cvars
|
2014-08-13 07:31:05 -03:00
|
|
|
#ifdef IBM
|
|
|
|
use, intrinsic :: ieee_arithmetic
|
|
|
|
#endif /* IBM */
|
2014-07-14 13:25:30 -03:00
|
|
|
|
|
|
|
! include external variables
|
|
|
|
!
|
|
|
|
use blocks , only : block_meta, list_meta
|
|
|
|
use blocks , only : block_data, list_data
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i, j, k, p
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
|
|
|
type(block_meta), pointer :: pmeta
|
|
|
|
type(block_data), pointer :: pdata
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! associate the pointer with the first block on the data block list
|
|
|
|
!
|
|
|
|
pdata => list_data
|
|
|
|
|
|
|
|
! iterate over all data blocks
|
|
|
|
!
|
|
|
|
do while (associated(pdata))
|
|
|
|
|
|
|
|
! associate pmeta with the corresponding meta block
|
|
|
|
!
|
|
|
|
pmeta => pdata%meta
|
|
|
|
|
|
|
|
! check if there are NaNs in primitive variables
|
|
|
|
!
|
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
|
|
|
do i = 1, im
|
|
|
|
do p = 1, nv
|
2014-08-13 07:31:05 -03:00
|
|
|
#ifdef IBM
|
|
|
|
if (ieee_is_nan(pdata%u(p,i,j,k))) then
|
|
|
|
print *, 'U NaN:', cvars(p), pdata%meta%id, i, j, k
|
|
|
|
end if
|
2014-08-13 07:43:14 -03:00
|
|
|
if (ieee_is_nan(pdata%q(p,i,j,k))) then
|
2014-08-13 07:31:05 -03:00
|
|
|
print *, 'Q NaN:', pvars(p), pdata%meta%id, i, j, k
|
|
|
|
end if
|
|
|
|
#else /* IBM */
|
2014-07-14 13:25:30 -03:00
|
|
|
if (isnan(pdata%u(p,i,j,k))) then
|
|
|
|
print *, 'U NaN:', cvars(p), pdata%meta%id, i, j, k
|
|
|
|
end if
|
|
|
|
if (isnan(pdata%q(p,i,j,k))) then
|
|
|
|
print *, 'Q NaN:', pvars(p), pdata%meta%id, i, j, k
|
|
|
|
end if
|
2014-08-13 07:31:05 -03:00
|
|
|
#endif /* IBM */
|
2014-07-14 13:25:30 -03:00
|
|
|
end do ! p = 1, nv
|
|
|
|
end do ! i = 1, im
|
|
|
|
end do ! j = 1, jm
|
|
|
|
end do ! k = 1, km
|
|
|
|
|
|
|
|
! assign pointer to the next block
|
|
|
|
!
|
|
|
|
pdata => pdata%next
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine check_variables
|
|
|
|
#endif /* DEBUG */
|
2011-05-19 18:35:36 -03:00
|
|
|
|
2008-12-08 21:07:10 -06:00
|
|
|
!===============================================================================
|
2008-12-07 18:57:08 -06:00
|
|
|
!
|
2012-08-01 16:38:10 -03:00
|
|
|
end module evolution
|