src/run.h
Generic time loop
The run()
function below implements a generic time loop
which executes events until termination.
The timestep dt
can be accessed as a global
variable.
double dt = 1.;
#include "utils.h"
trace
void run (void)
{
= 0, t = 0., dt = 1.;
iter (N);
init_grid
.nc = perf.tnc = 0;
perf.gt = timer_start();
perfwhile (events (true)) {
We store the total number of cells advanced in time for computing speed statistics.
update_perf();
= inext, t = tnext;
iter }
Time/speed statistics are written out on standard output.
timer_print (perf.gt, iter, perf.tnc);
();
free_grid}
By default we display the boundaries of the domain.
event defaults (i = 0) {
("box();");
display }
At the end of the run we need to empty the default display, otherwise we would append multiple copies when re-running.
event cleanup (t = end, last) {
("", true);
display }
Usage
- Incompressible Navier–Stokes solver (centered formulation)
- Incompressible Navier–Stokes solver (MAC formulation)
Examples
- Coupled reaction–diffusion equations
- The complex Ginzburg–Landau equation
- [Conway’s game of life](http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)