Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
predictor-corrector.h
Go to the documentation of this file.
1/** @file predictor-corrector.h
2 */
3// Generic predictor/corrector time-integration
4
5#include "utils.h"
6
7// Required from solver
8// fields updated by time-integration
9extern scalar * evolving;
10// how to compute updates
12
13// User-provided functions
14// gradient
16
17// the timestep
18double dt = 0.;
19
22 double dt)
23{
24 if (input != output)
25 trash (output);
26 for (int _i = 0; _i < _N; _i++) /* foreach */ {
27 scalar o, i, u;
28 for (o,i,u in output,input,updates)
29 o[] = i[] + dt*u[];
30 }
31}
32
34 double dt) = advance_generic;
35
36/** @brief Event: defaults (i = 0) */
37void event_defaults (void)
38{
39 // limiting
40 for (int _s = 0; _s < 1; _s++) /* scalar in all */
41 s.gradient = gradient;
42
43 display ("box();");
44}
45
47void run()
48{
49 t = 0., iter = 0; /* dim: dt == DT */;
50 init_grid (N);
51
52 // main loop
53 perf.nc = perf.tnc = 0;
54 perf.gt = timer_start();
55 while (events (true)) {
56 // list of updates
59 if (gradient != zero) {
60 /* 2nd-order time-integration */
62 /* predictor */
64 /* corrector */
66 delete (predictor);
68 }
70 delete (updates);
71 free (updates);
73 iter = inext, t = tnext;
74 }
75 timer_print (perf.gt, iter, perf.tnc);
76
77 free_grid();
78}
#define u
Definition advection.h:30
double dtmax
The timestep is computed using the CFL condition on the face velocity field.
Definition all-mach.h:105
scalar * list_clone(scalar *l)
if TRASH undef trash define trash(list) reset(list
free(list1)
int x
Definition common.h:76
double zero(double s0, double s1, double s2)
Definition common.h:116
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
coord o
Definition curvature.h:672
scalar s
Definition embed-tree.h:56
scalar int i
Definition embed.h:74
double dtnext(double dt)
Definition events.h:276
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
static int input(void)
Definition include.c:2085
double dt
These come from the multilayer solver.
static trace void advance_generic(scalar *output, scalar *input, scalar *updates, double dt)
scalar * evolving
The generic time-integration scheme in predictor-corrector.h needs to know which fields are updated i...
void event_defaults(void)
Event: defaults (i = 0)
double(* update)(scalar *evolving, scalar *updates, double dtmax)
trace void run()
double(* gradient)(double, double, double)
static void(* advance)(scalar *output, scalar *input, scalar *updates, double dt)
int events
Definition qcc.c:60
def _i
Definition stencils.h:405
void timer_print(timer t, int i, size_t tnc)
This function writes timing statistics on standard output.
Definition utils.h:110
double DT
Definition utils.h:10
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.
double minmod2(double s0, double s1, double s2)
Definition utils.h:225