/*@@ @file Courant.c @date September 4 1999 @author Gabrielle Allen @desc Specification of timestep using Courant condition @enddesc @@*/ #include #include #include "cctk.h" #include "cctk_Arguments.h" #include "cctk_Parameters.h" static char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusBase_Time_Courant_c) void Time_Courant(CCTK_ARGUMENTS); void Time_Courant(CCTK_ARGUMENTS) { DECLARE_CCTK_PARAMETERS DECLARE_CCTK_ARGUMENTS CCTK_REAL min_spacing=0; char *message; /* Calculate the minimum grid spacing */ if (cctk_dim>=1) { min_spacing = cctk_delta_space[0]; } if (cctk_dim>=2) { min_spacing = (min_spacing=3) { min_spacing = (min_spacing=4) { CCTK_WARN(0,"Time Step not defined for greater than 4 dimensions"); } /* Calculate the courant timestep */ if (CCTK_Equals(timestep_method,"courant_time")) { *courant_dt = courant_fac*(*courant_min_time)/sqrt((CCTK_REAL )cctk_dim); } else if (CCTK_Equals(timestep_method,"courant_speed")) { *courant_dt = courant_fac/(*courant_wave_speed)/sqrt((CCTK_REAL )cctk_dim); } /* Set the Cactus timestep */ if (! timestep_outonly) { cctkGH->cctk_delta_time = *courant_dt; message = (char *)malloc(1024*sizeof(char)); sprintf(message,"Time step set to %f",cctkGH->cctk_delta_time); CCTK_INFO(message); free(message); } else { cctkGH->cctk_delta_time = dtfac*min_spacing; } }