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

Go to the source code of this file.

Data Structures

struct  Color
 Given a colormap and a minimum and maximum value, this function returns the red/green/blue triplet corresponding to val. More...
 

Macros

#define NCMAP   127
 

Typedefs

typedef void(* Colormap) (double cmap[127][3])
 

Functions

trace void output_field (scalar *list=all, FILE *fp=stdout, int n=N, bool linear=false, coord box[2]={{X0, Y0}, {X0+L0, Y0+L0 *Dimensions.y/Dimensions.x}})
 
trace void output_matrix (scalar f, FILE *fp=stdout, int n=N, bool linear=false, const char *file=NULL, coord box[2]={{X0, Y0}, {X0+L0, Y0+L0 *Dimensions.y/Dimensions.x}})
 
void jet (double cmap[127][3])
 
void cool_warm (double cmap[127][3])
 
void gray (double cmap[127][3])
 
void randomap (double cmap[127][3])
 
void blue_white_red (double cmap[127][3])
 
Color colormap_color (double cmap[127][3], double val, double min, double max)
 
static const charextension (const char *file, const char *ext)
 
static const charis_animation (const char *file)
 
static void open_image_cleanup ()
 
static FILEopen_image_lookup (const char *file)
 
static bool which (const char *command)
 
static FILEppm_fallback (const char *file, const char *mode)
 
FILEopen_image (const char *file, const char *options)
 
void close_image (const char *file, FILE *fp)
 
trace void output_ppm (scalar f, FILE *fp=stdout, int n=N, char *file=NULL, double min=0, double max=0, double spread=5, double z=0, bool linear=false, coord box[2]={{X0, Y0}, {X0+L0, Y0+L0 *Dimensions.y/Dimensions.x}}, scalar mask={-1}, Colormap map=jet, char *opt=NULL, int fps=0, FILE *checksum=NULL)
 
trace void output_grd (scalar f, FILE *fp=stdout, double Delta=L0/N, bool linear=false, coord box[2]={{X0, Y0}, {X0+L0, Y0+L0 *Dimensions.y/Dimensions.x}}, scalar mask={-1})
 

Variables

struct { 
 
   FILE **   fp 
 
   char **   names 
 
   int   n 
 
open_image_data = {NULL, NULL, 0} 
 

Macro Definition Documentation

◆ NCMAP

#define NCMAP   127

Colormaps

Colormaps are arrays of (127) red, green, blue triplets.

Definition at line 194 of file output.h.

Typedef Documentation

◆ Colormap

typedef void(* Colormap) (double cmap[127][3])

Definition at line 196 of file output.h.

Function Documentation

◆ blue_white_red()

void blue_white_red ( double  cmap[127][3])

Definition at line 286 of file output.h.

References i, NCMAP, and x.

◆ close_image()

void close_image ( const char file,
FILE fp 
)

Definition at line 508 of file output.h.

References assert, file, fp, is_animation(), open_image_lookup(), pclose, which(), and x.

Referenced by save().

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

◆ colormap_color()

Color colormap_color ( double  cmap[127][3],
double  val,
double  min,
double  max 
)

Definition at line 308 of file output.h.

References c, coef, i, j, max, min, NCMAP, nodata, val(), and x.

Referenced by colorized().

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

◆ cool_warm()

void cool_warm ( double  cmap[127][3])

Definition at line 219 of file output.h.

References i, j, k, NCMAP, and x.

Referenced by args().

Here is the caller graph for this function:

◆ extension()

static const char * extension ( const char file,
const char ext 
)
static

Image/animation conversion

The open_image()/close_image() functions use pipes to convert PPM images to other formats, including .mp4, .ogv and .gif animations.

The functions check whether the 'ffmpeg' or 'convert' executables are accessible, if they are not the conversion is disabled and the raw PPM images are saved. An extra ".ppm" extension is added to the file name to indicate that this happened.

Definition at line 348 of file output.h.

References file, and x.

Referenced by is_animation().

Here is the caller graph for this function:

◆ gray()

void gray ( double  cmap[127][3])

Definition at line 271 of file output.h.

References i, k, NCMAP, and x.

Referenced by args().

Here is the caller graph for this function:

◆ is_animation()

static const char * is_animation ( const char file)
static

Definition at line 353 of file output.h.

References extension(), file, and x.

Referenced by close_image(), open_image(), and save().

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

◆ jet()

void jet ( double  cmap[127][3])

Definition at line 198 of file output.h.

References i, NCMAP, and x.

Referenced by args(), if(), if(), if(), and if().

Here is the caller graph for this function:

◆ open_image()

FILE * open_image ( const char file,
const char options 
)

Definition at line 428 of file output.h.

References assert, file, fp, free_solver_func_add(), is_animation(), LINENO, open_image_cleanup(), open_image_data, open_image_lookup(), popen, ppm_fallback(), strdup(), which(), and x.

Referenced by save().

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

◆ open_image_cleanup()

static void open_image_cleanup ( )
static

Definition at line 368 of file output.h.

References free(), i, open_image_data, pclose, and x.

Referenced by open_image().

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

◆ open_image_lookup()

static FILE * open_image_lookup ( const char file)
static

Definition at line 381 of file output.h.

References file, i, open_image_data, and x.

Referenced by close_image(), and open_image().

Here is the caller graph for this function:

◆ output_field()

trace void output_field ( scalar list = all,
FILE fp = stdout,
int  n = N,
bool  linear = false,
coord  box[2] = {{X0Y0}, {X0 + L0Y0 + L0*Dimensions.y/Dimensions.x}} 
)

Output functions

<em>output_field()</em>: Multiple fields interpolated on a regular grid (text format)

This function interpolates a list of fields on a n+1 x n+1 regular grid. The resulting data are written in text format in the file pointed to by fp. The correspondance between column numbers and variables is summarised in the first line of the file. The data are written row-by-row and each row is separated from the next by a blank line. This format is compatible with the splot command of gnuplot i.e. one could use something like

gnuplot> set pm3d map
gnuplot> splot 'fields' u 1:2:4

The arguments and their default values are:

list* : list of fields to output. Default is all.

fp* : file pointer. Default is stdout.

n* : number of points along each dimension. Default is N.

linear* : use first-order (default) or bilinear interpolation.

box* : the lower-left and upper-right coordinates of the domain to consider. Default is the entire domain.

Definition at line 40 of file output.h.

References Dimensions, L0, ivec::x, X0, ivec::y, and Y0.

◆ output_grd()

trace void output_grd ( scalar  f,
FILE fp = stdout,
double  Delta = L0/N,
bool  linear = false,
coord  box[2] = {{X0Y0}, {X0 + L0Y0 + L0*Dimensions.y/Dimensions.x}},
scalar  mask = {-1} 
)

<em>output_grd()</em>: ESRI ASCII Grid format

The ESRI GRD format is a standard format for importing raster data into GIS systems.

The arguments and their default values are:

f* : a scalar field (compulsory).

fp* : a file pointer. Default is stdout.

\(\Delta\) : size of a grid element. Default is L0/N.

linear* : whether to use bilinear or first-order interpolation. Default is first-order.

box* : the lower-left and upper-right coordinates of the domain to consider. Default is the entire domain.

mask* : if set, this field will be used to mask out, the regions of the domain for which mask is negative.

Definition at line 724 of file output.h.

References Dimensions, L0, ivec::x, X0, ivec::y, and Y0.

◆ output_matrix()

trace void output_matrix ( scalar  f,
FILE fp = stdout,
int  n = N,
bool  linear = false,
const char file = NULL,
coord  box[2] = {{X0Y0}, {X0 + L0Y0 + L0*Dimensions.y/Dimensions.x}} 
)

<em>output_matrix()</em>: Single field interpolated on a regular grid (binary format)

This function writes a binary representation of a single field interpolated on a regular n x n grid. The format is compatible with the binary matrix format of gnuplot i.e. one could use

gnuplot> set pm3d map
gnuplot> splot 'matrix' binary u 2:1:3

The arguments and their default values are:

f* : a scalar field (compulsory).

fp* : file pointer. Default is stdout.

n* : number of points along each dimension. Default is N.

linear* : use first-order (default) or bilinear interpolation.

box* : the lower-left and upper-right coordinates of the domain to consider. Default is the entire domain.

Definition at line 128 of file output.h.

References Dimensions, L0, ivec::x, X0, ivec::y, and Y0.

◆ output_ppm()

trace void output_ppm ( scalar  f,
FILE fp = stdout,
int  n = N,
char file = NULL,
double  min = 0,
double  max = 0,
double  spread = 5,
double  z = 0,
bool  linear = false,
coord  box[2] = {{X0Y0}, {X0 + L0Y0 + L0*Dimensions.y/Dimensions.x}},
scalar  mask = {-1},
Colormap  map = jet,
char opt = NULL,
int  fps = 0,
FILE checksum = NULL 
)

<em>output_ppm()</em>: Portable PixMap (PPM) image output

Given a field, this function outputs a colormaped representation as a Portable PixMap image.

If ImageMagick is installed on the system, this image can optionally be converted to any image format supported by ImageMagick.

The arguments and their default values are:

f* : a scalar field (compulsory).

fp* : a file pointer. Default is stdout.

n* : number of pixels. Default is N.

file* : sets the name of the file used as output for ImageMagick. This allows outputs in all formats supported by ImageMagick. For example, one could use

output_ppm (f, file = "f.png");
scalar f[]
The primary fields are:
Definition two-phase.h:56
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define file
Definition config.h:120
#define output_ppm(...)
Definition output.h:270

to get a PNG image.

min, max* : minimum and maximum values used to define the colorscale. By default these are set automatically using the spread parameter.

spread* : if not specified explicitly, min and max are set to the average of the field minus (resp. plus) spread times the standard deviation. By default spread is five. If negative, the minimum and maximum values of the field are used.

z* : the z-coordinate (in 3D) of the plane being represented.

linear* : whether to use bilinear or first-order interpolation. Default is first-order.

box* : the lower-left and upper-right coordinates of the domain to consider. Default is the entire domain.

mask* : if set, this field will be used to mask out (in black), the regions of the domain for which mask is negative.

map* : the colormap: jet, cool_warm or gray. Default is jet.

opt* : options to pass to 'convert' or to the 'ppm2???' scripts (used with file).

fps* : used only for online output on GPUs.

checksum* : write a checksum of the generated image in the file pointed.

Definition at line 597 of file output.h.

References Dimensions, L0, ivec::x, X0, ivec::y, and Y0.

◆ ppm_fallback()

static FILE * ppm_fallback ( const char file,
const char mode 
)
static

Definition at line 412 of file output.h.

References file, fp, and x.

Referenced by open_image().

Here is the caller graph for this function:

◆ randomap()

void randomap ( double  cmap[127][3])

Definition at line 278 of file output.h.

References i, k, NCMAP, noise(), and x.

Referenced by args().

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

◆ which()

static bool which ( const char command)
static

Definition at line 389 of file output.h.

References f, fp, s, and x.

Referenced by close_image(), open_image(), and save().

Here is the caller graph for this function:

Variable Documentation

◆ fp

FILE** fp

Definition at line 363 of file output.h.

◆ n

int n

Definition at line 365 of file output.h.

◆ names

char** names

Definition at line 364 of file output.h.

◆ [struct]

struct { ... } open_image_data