src/fclaw2d_advance.c
/* -------------------------------------------------------------
   Main routine : Called from fclaw2d_run.
   ------------------------------------------------------------- */
Main routine : Called from fclaw2d_run.
Main routine : Called from fclaw2d_run .
double fclaw2d_advance_all_levels(fclaw2d_global_t *glob,
								  double t_curr, double dt)
{
	fclaw2d_domain_t* domain = glob->domain;
	int level;
	fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADVANCE]);
	const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob);
	fclaw2d_timestep_counters *ts_counter;
	initialize_timestep_counters(glob,&ts_counter,t_curr,dt);
	int minlevel = domain->global_minlevel;
	int maxlevel = domain->global_maxlevel;
	double maxcfl = 0;
	FCLAW_ASSERT(ts_counter[maxlevel].step_inc == 1);
	int n_fine_steps = ts_counter[maxlevel].total_steps;
	int nf;
	for(nf = 0; nf < n_fine_steps; nf++)
	{
		double cfl_step = advance_level(glob,maxlevel,nf,maxcfl,ts_counter);
		maxcfl = fmax(cfl_step,maxcfl);
		int last_step = ts_counter[maxlevel].last_step;
		if (last_step < ts_counter[maxlevel].total_steps)
		{
			double sync_time = ts_counter[maxlevel].current_time;
			if (fclaw_opt->subcycle)
			{
				int time_interp_level = timeinterp_level(ts_counter,maxlevel);
				int time_interp = 1;
				fclaw2d_ghost_update(glob,
									 time_interp_level+1,
									 maxlevel,
									 sync_time,
									 time_interp,
									 FCLAW2D_TIMER_ADVANCE);
				if (fclaw_opt->time_sync)
			    {
			    	fclaw2d_time_sync(glob,time_interp_level+1,maxlevel);
			    }
			}
			else
			{
				int time_interp = 0;
				fclaw2d_ghost_update(glob,
									 minlevel,
									 maxlevel,
									 sync_time,
									 time_interp,
									 FCLAW2D_TIMER_ADVANCE);
				if (fclaw_opt->time_sync)
			    {
				    fclaw2d_time_sync(glob,minlevel,maxlevel);
			    }
			}
		}
	}
	fclaw_global_infof("Advance is done with coarse grid step at " \
					  " time %12.6e\n",t_curr);
	for(level = domain->local_minlevel; level <= domain->global_maxlevel; level++)
	{
		FCLAW_ASSERT(ts_counter[level].last_step ==
					 ts_counter[level].step_inc*ts_counter[level].total_steps);
	}
	double sync_time =  ts_counter[maxlevel].current_time;
	int time_interp = 0;
	fclaw2d_ghost_update(glob,minlevel,maxlevel,sync_time,
						 time_interp,FCLAW2D_TIMER_ADVANCE);
	if (fclaw_opt->time_sync)
	{
		fclaw2d_time_sync(glob,minlevel,maxlevel);
	}
	delete_timestep_counters(&ts_counter);
	fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADVANCE]);
	glob->count_grids_per_proc +=  domain->local_num_patches;
	glob->count_grids_local_boundary +=  domain->num_exchange_patches;
	glob->count_grids_remote_boundary +=  domain->num_ghost_patches;
	++glob->count_amr_advance;
	return maxcfl;
}
double fclaw2d_advance_all_levels ( fclaw2d_global_t * glob , double t_curr , double dt ) { fclaw2d_domain_t * domain = glob -> domain ; int level ; fclaw2d_timer_start ( & glob -> timers [ FCLAW2D_TIMER_ADVANCE ] ) ; const fclaw_options_t * fclaw_opt = fclaw2d_get_options ( glob ) ; fclaw2d_timestep_counters * ts_counter ; initialize_timestep_counters ( glob , & ts_counter , t_curr , dt ) ; int minlevel = domain -> global_minlevel ; int maxlevel = domain -> global_maxlevel ; double maxcfl = 0 ; FCLAW_ASSERT ( ts_counter [ maxlevel ] . step_inc == 1 ) ; int n_fine_steps = ts_counter [ maxlevel ] . total_steps ; int nf ; for ( nf = 0 ; nf < n_fine_steps ; nf ++ ) { double cfl_step = advance_level ( glob , maxlevel , nf , maxcfl , ts_counter ) ; maxcfl = fmax ( cfl_step , maxcfl ) ; int last_step = ts_counter [ maxlevel ] . last_step ; if ( last_step < ts_counter [ maxlevel ] . total_steps ) { double sync_time = ts_counter [ maxlevel ] . current_time ; if ( fclaw_opt -> subcycle ) { int time_interp_level = timeinterp_level ( ts_counter , maxlevel ) ; int time_interp = 1 ; fclaw2d_ghost_update ( glob , time_interp_level + 1 , maxlevel , sync_time , time_interp , FCLAW2D_TIMER_ADVANCE ) ; if ( fclaw_opt -> time_sync ) { fclaw2d_time_sync ( glob , time_interp_level + 1 , maxlevel ) ; } } else { int time_interp = 0 ; fclaw2d_ghost_update ( glob , minlevel , maxlevel , sync_time , time_interp , FCLAW2D_TIMER_ADVANCE ) ; if ( fclaw_opt -> time_sync ) { fclaw2d_time_sync ( glob , minlevel , maxlevel ) ; } } } } fclaw_global_infof ( " " " \n " , t_curr ) ; for ( level = domain -> local_minlevel ; level <= domain -> global_maxlevel ; level ++ ) { FCLAW_ASSERT ( ts_counter [ level ] . last_step == ts_counter [ level ] . step_inc * ts_counter [ level ] . total_steps ) ; } double sync_time = ts_counter [ maxlevel ] . current_time ; int time_interp = 0 ; fclaw2d_ghost_update ( glob , minlevel , maxlevel , sync_time , time_interp , FCLAW2D_TIMER_ADVANCE ) ; if ( fclaw_opt -> time_sync ) { fclaw2d_time_sync ( glob , minlevel , maxlevel ) ; } delete_timestep_counters ( & ts_counter ) ; fclaw2d_timer_stop ( & glob -> timers [ FCLAW2D_TIMER_ADVANCE ] ) ; glob -> count_grids_per_proc += domain -> local_num_patches ; glob -> count_grids_local_boundary += domain -> num_exchange_patches ; glob -> count_grids_remote_boundary += domain -> num_ghost_patches ; ++ glob -> count_amr_advance ; return maxcfl ; }
Main routine : Called from fclaw2d_run.
Main routine : Called from fclaw2d_run .
/* Advance all grids that are present somewhere (on any proc) */ /* Keep track of largest cfl over all grid updates */ /* Step inc at maxlevel should be 1 by definition */ /* Coarser levels get updated recursively */ /* Advance stores anything needed for later synchronization */ /* This loop is entered if we are doing local time stepping */ /* Do intermediate ghost cell exchanges */ /* Find time interpolated level and do ghost patch exchange
				   and ghost cell exchange for next update. */ /* Do conservative fix up here */ /* End up here is we are doing global time stepping but return from 
				   advance after 2^(maxlevel-minlevel) time steps. */ /* This is the final synchronization not covered in fine_steps loop */ /* Stop the timer */ /* Count total grids on this processor */ /* Count the number of times that advance is called */