Skip to content

Commit

Permalink
(demo) Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
donnaaboise committed Jul 22, 2024
1 parent 0f1e2c1 commit 8680197
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 209 deletions.
5 changes: 3 additions & 2 deletions applications/clawpack/advection/2d/swirl/swirl_ray.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton
Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -218,7 +218,8 @@ int swirl_intersect_ray (fclaw_domain_t *domain,
}
/* Four cases */
int found_intersection = 0;
point_t pstart, pend;
point_t pstart = {0,0};
point_t pend = {0,0};
if (istart < 0 && iend < 0)
{
/* No intersection found */
Expand Down
4 changes: 2 additions & 2 deletions applications/demo/2d/filament_swirl/filament_swirl_split.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton
Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -161,7 +161,7 @@ main (int argc, char **argv)

/* MPI COMMs */
int size, rank;
sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank);
fclaw_app_get_mpi_size_rank (app, &size, &rank);

/* Globs */
fclaw_global_t *filament_glob = fclaw_global_new_comm (subcomm, size, rank);
Expand Down
206 changes: 1 addition & 205 deletions applications/demo/2d/filament_swirl/user_run.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton
Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -301,210 +301,6 @@ double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw_global_t *glo
return ctx->final_time;
}

static
void outstyle_3(fclaw_global_t *glob)
{
fclaw_domain_t** domain = &glob->domain;

int init_flag = 1;
fclaw_diagnostics_gather(glob,init_flag);
init_flag = 0;

int iframe = 0;
fclaw_output_frame(glob,iframe);


const fclaw_options_t *fclaw_opt = fclaw_get_options(glob);
double initial_dt = fclaw_opt->initial_dt;


//fclaw2d_time_sync_reset(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,1);

double t0 = 0;
double dt_minlevel = initial_dt;
glob->curr_time = t0;
int nstep_outer = fclaw_opt->nout;
int nstep_inner = fclaw_opt->nstep;
int nregrid_interval = fclaw_opt->regrid_interval;
int level_factor = pow_int(2,fclaw_opt->maxlevel-fclaw_opt->minlevel);
if (!fclaw_opt->subcycle)
{
if (fclaw_opt->advance_one_step)
{
if (!fclaw_opt->outstyle_uses_maxlevel)
{
/* Multiply nout/nstep by 2^(maxlevel-minlevel) so that
a given nout/nstep pair works for both subcycled
and non-subcycled cases.
Note : Regrid_interval remains unchanged.*/

nstep_outer *= level_factor;
nstep_inner *= level_factor; /* Only produce nout/nstep output files */
}
}
}

int n = 0;
double t_curr = t0;
while (n < nstep_outer)
{
double dt_step = dt_minlevel;
if (!fclaw_opt->subcycle && fclaw_opt->advance_one_step)
{
/* if domain->global_maxlevel < fclaw_opt->maxlevel, this choice
of time step will take more steps than necessary on
finest level. */
dt_step /= level_factor;
}

/* In case we have to reject this step */
if (!fclaw_opt->use_fixed_dt)
{
save_time_step(glob);
}

/* Get current domain data since it may change during regrid */
glob->curr_dt = dt_step;
double maxcfl_step = fclaw_advance_all_levels(glob, t_curr,dt_step);

/* This is a collective communication - everybody needs to wait here. */
if (fclaw_opt->reduce_cfl)
{
/* If we are taking a variable time step, we have to reduce the
maxcfl so that every processor takes the same size dt */
fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]);
maxcfl_step = fclaw_domain_global_maximum (*domain, maxcfl_step);
fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]);
}

double tc = t_curr + dt_step;
int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ?
fclaw_opt->maxlevel : fclaw_opt->minlevel;

fclaw_global_productionf("Level %d (%d-%d) step %5d : dt = %12.3e; maxcfl (step) = " \
"%12.6f; Final time = %12.4f\n",
level2print,
(*domain)->global_minlevel,
(*domain)->global_maxlevel,
n+1,dt_step,maxcfl_step, tc);

if (fclaw_opt->reduce_cfl & (maxcfl_step > fclaw_opt->max_cfl))
{
if (!fclaw_opt->use_fixed_dt)
{
fclaw_global_productionf(" WARNING : Maximum CFL exceeded; retaking time step\n");
restore_time_step(glob);

dt_minlevel = dt_minlevel*fclaw_opt->desired_cfl/maxcfl_step;

/* Go back to start of loop without incrementing step counter or
current time. */
continue;
}
else
{
fclaw_global_productionf(" WARNING : Maximum CFL exceeded\n");
}
}

/* We are happy with this time step */
t_curr = tc;
glob->curr_time = t_curr;

/* New time step, which should give a cfl close to the desired cfl. */
if (!fclaw_opt->use_fixed_dt)
{
dt_minlevel = dt_minlevel*fclaw_opt->desired_cfl/maxcfl_step;
}

n++; /* Increment outer counter */

if (fclaw_opt->regrid_interval > 0)
{
if (n % nregrid_interval == 0)
{
fclaw_global_infof("regridding at step %d\n",n);
fclaw_regrid(glob);
}
}

if (fclaw_opt->advance_one_step)
{
//fclaw2d_diagnostics_gather(glob,init_flag);
}

if (n % nstep_inner == 0)
{
iframe++;
fclaw_diagnostics_gather(glob,init_flag);
fclaw_output_frame(glob,iframe);
}
}
}


static
void outstyle_4(fclaw_global_t *glob)
{

/* Write out an initial time file */
int iframe = 0;
fclaw_output_frame(glob,iframe);

int init_flag = 1;
fclaw_diagnostics_gather(glob,init_flag);
init_flag = 0;

const fclaw_options_t *fclaw_opt = fclaw_get_options(glob);
double initial_dt = fclaw_opt->initial_dt;
int nstep_outer = fclaw_opt->nout;
int nstep_inner = fclaw_opt->nstep;
double dt_minlevel = initial_dt;

double t0 = 0;
double t_curr = t0;
glob->curr_time = t_curr;
int n = 0;
while (n < nstep_outer)
{
/* Get current domain data since it may change during regrid */
fclaw_advance_all_levels(glob, t_curr, dt_minlevel);

int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ?
fclaw_opt->maxlevel : fclaw_opt->minlevel;

fclaw_global_productionf("Level %d step %5d : dt = %12.3e; Final time = %16.6e\n",
level2print,
n+1,dt_minlevel, t_curr+dt_minlevel);

t_curr += dt_minlevel;
n++;

glob->curr_time = t_curr;

if (fclaw_opt->regrid_interval > 0)
{
if (n % fclaw_opt->regrid_interval == 0)
{
fclaw_global_infof("regridding at step %d\n",n);

fclaw_regrid(glob);
}
}
else
{
/* Only use the initial grid */
}

if (n % nstep_inner == 0)
{
fclaw_diagnostics_gather(glob,init_flag);
iframe++;
fclaw_output_frame(glob,iframe);
}
}
}


/* ------------------------------------------------------------------
Public interface
Expand Down

0 comments on commit 8680197

Please sign in to comment.