Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
utils.h File Reference
#include "output.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  timing
 
struct  norm
 
struct  stats
 The statsf() function returns the minimum, maximum, volume sum, standard deviation and volume for field f. More...
 

Functions

void update_perf ()
 Performance statistics are gathered by this function, which is typically called by the run() loop.
 
timing timer_timing (timer t, int i, size_t tnc, double *mpi)
 Given a timer, iteration count i, total number of cells tnc and array of MPI timings mpi (with a size equal to the number of processes), this function returns the statistics above.
 
void timer_print (timer t, int i, size_t tnc)
 This function writes timing statistics on standard output.
 
norm normf (scalar f)
 
stats statsf (scalar f)
 
static double generic_limiter (double r, double beta)
 
double minmod (double s0, double s1, double s2)
 
double superbee (double s0, double s1, double s2)
 
double sweby (double s0, double s1, double s2)
 
double minmod2 (double s0, double s1, double s2)
 
void gradients (scalar *f, vector *g)
 Given a list of scalar fields f, this function fills the gradient fields g with the corresponding gradients.
 
void vorticity (const vector u, scalar omega)
 
double change (scalar s, scalar sn)
 Given two scalar fields s and sn this function returns the maximum of their absolute difference.
 
scalar lookup_field (const char *name)
 These functions return the scalar/vector fields called name, or -1 if they don't exist.
 
vector lookup_vector (const char *name)
 
macro foreach_segment (coord S[2], coord p[2], Reduce reductions=None)
 The macro below traverses the set of sub-segments intersecting the mesh and spanning the [A:B] segment.
 
void fields_stats (scalar *list=all)
 This function returns a summary of the currently-defined fields.
 

Variables

double DT = HUGE [0,1]
 
double CFL = 0.5 [0]
 
struct { 
 
   long   nc 
 
   long   tnc 
 
   double   t 
 
   double   tp 
 
   double   speed 
 
   double   ispeed 
 
   timer   gt 
 
perf = {0} 
 Performance statistics are stored in this structure.
 
double theta = 1.3 [0]
 This is the generalised minmod limiter.
 

Function Documentation

◆ change()

double change ( scalar  s,
scalar  sn 
)

Given two scalar fields s and sn this function returns the maximum of their absolute difference.

Definition at line 303 of file utils.h.

References dv, max, s, and x.

◆ fields_stats()

void fields_stats ( scalar list = all)

This function returns a summary of the currently-defined fields.

Definition at line 382 of file utils.h.

References s, statsf(), t, and x.

Referenced by main(), and process_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foreach_segment()

macro foreach_segment ( coord  S[2],
coord  p[2],
Reduce  reductions = None 
)

The macro below traverses the set of sub-segments intersecting the mesh and spanning the [A:B] segment.

The pair of coordinates defining the sub-segment contained in each cell are defined by p[0] and p[1].

Definition at line 349 of file utils.h.

References _i, a, alpha, clamp(), dimension, p, reductions, S, sq(), t, vector::x, x, coord::x, vector::y, and y.

Referenced by segment_flux().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generic_limiter()

static double generic_limiter ( double  r,
double  beta 
)
static

Slope limiters

Given three values, these slope limiters return the corresponding slope-limited gradient.

Definition at line 197 of file utils.h.

References beta, max, min, and x.

Referenced by minmod(), superbee(), and sweby().

Here is the caller graph for this function:

◆ gradients()

void gradients ( scalar f,
vector g 
)

Given a list of scalar fields f, this function fills the gradient fields g with the corresponding gradients.

If the gradient attribute of a field is set (typically to one of the limiting functions above), it is used to compute the gradient, otherwise simple centered differencing is used.

Definition at line 247 of file utils.h.

References _i, assert, dimension, f, fs, g, list_len(), s, v, vectors_len(), vector::x, and x.

Referenced by tracer_fluxes(), update_conservation(), and update_saint_venant().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_field()

scalar lookup_field ( const char name)

These functions return the scalar/vector fields called name, or -1 if they don't exist.

Definition at line 321 of file utils.h.

References s, and x.

Referenced by assemble_node(), and slave_interpolate().

Here is the caller graph for this function:

◆ lookup_vector()

vector lookup_vector ( const char name)

Definition at line 330 of file utils.h.

References s, and x.

◆ minmod()

double minmod ( double  s0,
double  s1,
double  s2 
)

Definition at line 204 of file utils.h.

References generic_limiter(), and x.

Here is the call graph for this function:

◆ minmod2()

double minmod2 ( double  s0,
double  s1,
double  s2 
)

Definition at line 225 of file utils.h.

References max, min, theta, and x.

Referenced by event_defaults().

Here is the caller graph for this function:

◆ normf()

norm normf ( scalar  f)

Definition at line 142 of file utils.h.

References norm::avg, dv, f, max, n, nodata, sq(), v, and x.

Here is the call graph for this function:

◆ statsf()

stats statsf ( scalar  f)

Definition at line 170 of file utils.h.

References dv, f, max, min, nodata, s, sq(), sum, and x.

Referenced by event_init(), fields_stats(), RPE(), and zarea().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ superbee()

double superbee ( double  s0,
double  s1,
double  s2 
)

Definition at line 208 of file utils.h.

References generic_limiter(), and x.

Here is the call graph for this function:

◆ sweby()

double sweby ( double  s0,
double  s1,
double  s2 
)

Definition at line 212 of file utils.h.

References generic_limiter(), and x.

Here is the call graph for this function:

◆ timer_print()

void timer_print ( timer  t,
int  i,
size_t  tnc 
)

This function writes timing statistics on standard output.

Definition at line 110 of file utils.h.

References datasize, fflush(), glFinish, GRIDNAME, i, npe, s, t, timer_timing(), tnc, and x.

Referenced by run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timer_timing()

timing timer_timing ( timer  t,
int  i,
size_t  tnc,
double mpi 
)

Given a timer, iteration count i, total number of cells tnc and array of MPI timings mpi (with a size equal to the number of processes), this function returns the statistics above.

Definition at line 64 of file utils.h.

References i, mpi, n, npe, s, t, timer_elapsed(), tnc, and x.

Referenced by timer_print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_perf()

void update_perf ( )

Performance statistics are gathered by this function, which is typically called by the run() loop.

Definition at line 34 of file utils.h.

References grid, Grid::n, perf, timer_elapsed(), and Grid::tn.

Referenced by run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vorticity()

void vorticity ( const vector  u,
scalar  omega 
)

Other functions

Given a velocity field \(\mathbf{u}\), this function fills a scalar field \(\omega\) with the vorticity field

\[ \omega = \partial_x u_y - \partial_y u_x \]

To properly take the metric into account, \(\omega\) is computed as an average over the (surface) element, which is easily obtained as the circulation of \(\mathbf{u}\) along the boundary of the element. Using the definitions of the metric factors fm and cm, this gives the expression below.

Definition at line 290 of file utils.h.

References _i, cm, fm, omega, SEPS, u, vector::x, x, and vector::y.

Variable Documentation

◆ CFL

◆ DT

double DT = HUGE [0,1]

Various utility functions

Default parameters and variables

The default maximum timestep and CFL number.

Definition at line 10 of file utils.h.

Referenced by event_init(), event_velocity(), run(), and timestep().

◆ gt

timer gt

Definition at line 27 of file utils.h.

◆ ispeed

double ispeed

Definition at line 25 of file utils.h.

◆ nc

long nc

Definition at line 17 of file utils.h.

Referenced by args(), embed_fraction_refine(), fine(), for(), and fraction_refine().

◆ [struct]

struct { ... } perf

Performance statistics are stored in this structure.

Referenced by event_perfs(), event_runtime(), run(), run(), and update_perf().

◆ speed

double speed

Definition at line 23 of file utils.h.

◆ t

double t

Definition at line 21 of file utils.h.

Referenced by fields_stats(), foreach_segment(), timer_print(), and timer_timing().

◆ theta

double theta = 1.3 [0]

This is the generalised minmod limiter.

The \(\theta\) global variable can be used to tune the limiting ( \(\theta=1\) gives minmod, the most dissipative limiter and \(\theta=2\) gives superbee, the least dissipative).

Definition at line 223 of file utils.h.

Referenced by eigenvalues(), event_defaults(), event_tracer_diffusion(), if(), minmod2(), and VARIABLES().

◆ tnc

long tnc

Definition at line 19 of file utils.h.

Referenced by timer_print(), and timer_timing().

◆ tp

double tp

Definition at line 21 of file utils.h.

Referenced by poisson_thermal(), relax_thermal(), and residual_thermal().