Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
run.h
Go to the documentation of this file.
1/** @file run.h
2 */
3/**
4# Generic time loop
5
6The `run()` function below implements a generic time loop which
7executes events until termination.
8
9The timestep `dt` can be accessed as a global variable. */
10
11double dt = 1.;
12
13#include "utils.h"
14
16void run (void)
17{
18 iter = 0, t = 0., dt = 1.;
19 init_grid (N);
20
21 perf.nc = perf.tnc = 0;
22 perf.gt = timer_start();
23 while (events (true)) {
24
25 /**
26 We store the total number of cells advanced in time for computing
27 speed statistics. */
28
30 iter = inext, t = tnext;
31 }
32
33 /**
34 Time/speed statistics are written out on standard output. */
35
36 timer_print (perf.gt, iter, perf.tnc);
37
38 free_grid();
39}
40
41/**
42By default we display the boundaries of the domain. */
43
44/** @brief Event: defaults (i = 0) */
45void event_defaults (void) {
46 display ("box();");
47}
48
49/**
50At the end of the run we need to empty the default display, otherwise
51we would append multiple copies when re-running. */
52
53/** @brief Event: cleanup (t = end, last) */
54void event_cleanup (void) {
55 display ("", true);
56}
int x
Definition common.h:76
void display(const char *commands, bool overwrite=false)
Definition common.h:527
int N
Definition common.h:39
timer timer_start(void)
Definition common.h:368
double t
Definition events.h:24
int inext
Definition events.h:23
int iter
Definition events.h:23
double tnext
Definition events.h:24
#define free_grid()
Definition grid.h:1404
#define init_grid(n)
Definition grid.h:1402
int events
Definition qcc.c:60
double dt
These come from the multilayer solver.
Definition run.h:11
void event_cleanup(void)
At the end of the run we need to empty the default display, otherwise we would append multiple copies...
Definition run.h:54
void event_defaults(void)
By default we display the boundaries of the domain.
Definition run.h:45
trace void run(void)
Definition run.h:16
void timer_print(timer t, int i, size_t tnc)
This function writes timing statistics on standard output.
Definition utils.h:110
void update_perf()
Performance statistics are gathered by this function, which is typically called by the run() loop.
Definition utils.h:34
struct @16 perf
Performance statistics are stored in this structure.