Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
gauges.h
Go to the documentation of this file.
1/** @file gauges.h
2 */
3/**
4# Tide gauges
5
6An array of *Gauge* structures passed to *output_gauges()* will create
7a file (called *name*) for each gauge. Each time *output_gauges()* is
8called a line will be appended to the file. The line contains the time
9and the value of each scalar in *list* in the cell containing
10*(x,y)*. The *desc* field can be filled with a longer description of
11the gauge. */
12
13typedef struct {
14 char * name;
15 double x, y;
16 char * desc;
18} Gauge;
19
22{
23 int n = 0;
24 for (Gauge * g = gauges; g->name; g++, n++);
25 coord a[n];
26 n = 0;
27 for (Gauge * g = gauges; g->name; g++, n++) {
28 double xp = g->x, yp = g->y;
29 unmap (&xp, &yp);
30 a[n].x = xp, a[n].y = yp;
31 }
32 int len = list_len(list);
33 double v[n*len];
34 interpolate_array (list, a, n, v, false);
35
36 if (pid() == 0) {
37 n = 0;
38 for (Gauge * g = gauges; g->name; g++) {
39 if (!g->fp) {
40 g->fp = fopen (g->name, "w");
41 if (g->desc)
42 fprintf (g->fp, "%s\n", g->desc);
43 }
44 if (v[n] != nodata) {
45 fprintf (g->fp, "%g", t);
46 for (int _s = 0; _s < 1; _s++) /* scalar in list */
47 fprintf (g->fp, " %g", v[n++]);
48 fputc ('\n', g->fp);
49 fflush (g->fp);
50 }
51 else
52 n += len;
53 }
54 }
55}
vector g[]
We store the combined pressure gradient and acceleration field in g*.
Definition all-mach.h:65
const vector a
Definition all-mach.h:59
trace void interpolate_array(scalar *list, coord *a, int n, double *v, bool linear=false)
define VT _attribute[s.i] v y scalar * list
Definition cartesian.h:276
int y
Definition common.h:76
int x
Definition common.h:76
#define nodata
Definition common.h:7
int list_len(scalar *list)
Definition common.h:180
define unmap(x, y) @define trash(x) auto macro2 BEGIN_FOREACH()
Definition config.h:20
else return n
Definition curvature.h:101
double v[2]
Definition embed.h:383
double t
Definition events.h:24
trace void output_gauges(Gauge *gauges, scalar *list)
Definition gauges.h:21
Definition gauges.h:13
double x
Definition gauges.h:15
char * desc
Definition gauges.h:16
char * name
Definition gauges.h:14
FILE * fp
Definition gauges.h:17
Definition common.h:78
scalar x
Definition common.h:47
scalar y
Definition common.h:49
src vof fflush(ferr)