17 integer :: iigrid, igrid, ncycle, ncycle2, ifile, idim
18 double precision :: dtnew, qdtnew, dtmin_mype, factor,
dx^
d, dxmin^
d
19 double precision :: dtmax, dxmin, cmax_mype
20 double precision :: tco_mype, tco_global, tmax_mype, t_peak
21 double precision :: trac_alfa, trac_dmax, trac_tau, t_bott
22 integer,
parameter :: niter_print = 2000
25 dtmin_mype = bigdouble
30 do iigrid=1,igridstail_active; igrid=igrids_active(iigrid);
36 ps(igrid)%dt(
ixm^t)=bigdouble
40 dtnew=min(dtnew,qdtnew)
43 dtnew=min(dtnew,qdtnew)
47 dtnew = min(dtnew,qdtnew)
49 dtmin_mype = min(dtmin_mype,dtnew)
56 if (dtmin_mype<
dtmin)
then
57 write(
unitterm,*)
"Error: Time step too small!", dtmin_mype
65 dtmin_mype=dtmin_mype*factor
81 call mpi_allreduce(dtmin_mype,
dt,1,mpi_double_precision,mpi_min, &
92 if(dtmax > smalldouble)
then
112 if(
mype==0 .and. mod(
it-1, niter_print) .eq. 0)
then
113 write(*,*)
'Max number of STS cycles exceeded, reducing dt to',
dt
118 if(
mype==0 .and. mod(
it-1, niter_print) .eq. 0)
then
119 write(*,*)
'Max number of STS cycles exceeded, reducing dt to',
dt
134 call mpi_allreduce(tmax_mype,t_peak,1,mpi_double_precision,&
140 trac_alfa=trac_dmax**(
dt/trac_tau)
143 call mpi_allreduce(tco_mype,tco_global,1,mpi_double_precision,&
161 integer,
intent(in) :: ixI^L, ixO^L
162 double precision,
intent(in) :: x(ixI^S,1:ndim)
163 double precision,
intent(in) :: dx^D
164 double precision,
intent(inout) :: w(ixI^S,1:nw), dtnew, cmax_mype
166 double precision :: courantmax, dxinv(1:ndim), courantmaxtot, courantmaxtots
167 double precision :: cmax(ixI^S), cmaxtot(ixI^S), wprim(ixI^S,1:nw)
168 double precision :: tco_local, Tmax_local
191 {^ifoned tco_mype=max(tco_mype,tco_local) }
192 tmax_mype=max(tmax_mype,tmax_local)
201 ^d&dxinv(^d)=one/dx^d;
206 cmaxtot(hxo^s)=cmax(hxo^s)*dxinv(idims)
208 cmaxtot(hxo^s)=cmaxtot(hxo^s)+cmax(hxo^s)*dxinv(idims)
216 cmaxtot(hxo^s)=cmax(hxo^s)/
block%ds(hxo^s,idims)
218 cmaxtot(hxo^s)=cmaxtot(hxo^s)+cmax(hxo^s)/
block%ds(hxo^s,idims)
223 courantmaxtots=maxval(cmaxtot(ixo^s))
224 if(courantmaxtots>smalldouble) dtnew=min(dtnew,
courantpar/courantmaxtots)
233 ^d&dxinv(^d)=one/dx^d;
237 courantmax=max(courantmax,maxval(cmax(ixo^s)*dxinv(idims)))
238 courantmaxtot=courantmaxtot+courantmax
244 courantmax=max(courantmax,maxval(cmax(ixo^s)/
block%ds(ixo^s,idims)))
245 courantmaxtot=courantmaxtot+courantmax
249 if (courantmaxtot>smalldouble) dtnew=min(dtnew,
courantpar/courantmaxtot)
253 ^d&dxinv(^d)=one/dx^d;
257 courantmax=max(courantmax,maxval(cmax(ixo^s)*dxinv(idims)))
263 courantmax=max(courantmax,maxval(cmax(ixo^s)/
block%ds(ixo^s,idims)))
267 if (courantmax>smalldouble) dtnew=min(dtnew,
courantpar/courantmax)
subroutine getdt_courant(w, ixil, ixol, dtnew, dxd, x, cmax_mype)
compute CFL limited dt (for variable time stepping)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
subroutine, public setdt()
setdt - set dt for all levels between levmin and levmax. dtpar>0 --> use fixed dtpar for all level dt...
This module contains definitions of global parameters and variables and some generic functions/subrou...
type(state), pointer block
Block pointer for using one block and its previous state.
double precision unit_time
Physical scaling factor for time.
double precision global_time
The global simulation time.
double precision time_max
End time for the simulation.
integer it
Number of time steps taken.
integer it_init
initial iteration count
integer, parameter type_maxsum
integer switchers for type courant
double precision cmax_global
global fastest wave speed needed in fd scheme and glm method
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
double precision dtpar
If dtpar is positive, it sets the timestep dt, otherwise courantpar is used to limit the time step ba...
double precision, dimension(:), allocatable, parameter d
logical local_timestep
each cell has its own timestep or not
double precision dt
global time step
double precision courantpar
The Courant (CFL) number used for the simulation.
integer ixm
the mesh range of a physical block without ghost cells
integer ierrmpi
A global MPI error return code.
integer slowsteps
If > 1, then in the first slowsteps-1 time steps dt is reduced by a factor .
integer type_courant
How to compute the CFL-limited time step.
integer, parameter unitterm
Unit for standard output.
double precision, dimension(nfile) dtsave
Repeatedly save output of type N when dtsave(N) simulation time has passed.
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
double precision unit_temperature
Physical scaling factor for temperature.
logical final_dt_reduction
If true, allow final dt reduction for matching time_max on output.
integer, parameter type_summax
double precision, dimension(:,:), allocatable dx
spatial steps for all dimensions at all levels
logical phys_trac
Use TRAC for MHD or 1D HD.
double precision, dimension(nsavehi, nfile) tsave
Save output of type N on times tsave(:, N)
logical need_global_cmax
need global maximal wave speed
logical crash
Save a snapshot before crash a run met unphysical values.
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
double precision dtmin
Stop the simulation when the time step becomes smaller than this value.
integer, parameter nfile
Number of output methods.
logical final_dt_exit
Force timeloop exit when final dt < dtmin.
integer, parameter type_minimum
integer, dimension(nfile) isavet
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_convert), pointer phys_to_primitive
procedure(sub_get_dt), pointer phys_get_dt
procedure(sub_get_tcutoff), pointer phys_get_tcutoff
procedure(sub_get_auxiliary), pointer phys_get_auxiliary
procedure(sub_trac_after_setdt), pointer phys_trac_after_setdt
procedure(sub_get_cmax), pointer phys_get_cmax
Generic supertimestepping method which can be used for multiple source terms in the governing equatio...
integer, public sourcetype_sts
pure logical function, public is_sts_initialized()
logical function, public set_dt_sts_ncycles(my_dt)
This sets the explicit dt and calculates the number of cycles for each of the terms implemented with ...
integer, parameter, public sourcetype_sts_split
Module with all the methods that users can customize in AMRVAC.
procedure(get_dt), pointer usr_get_dt