grid.h File Reference

#include "utils.h"
#include "except.hh"

Go to the source code of this file.

Classes

struct  s_axis
 Axis: Basic Metadata element for regular grids. More...
struct  grid
 Regular grid struct. More...

Defines

#define TOL   100.0*REAL_EPS
#define EXTINT   100

Typedefs

typedef s_axis axis
 Axis: Basic Metadata element for regular grids.

Functions

void init_default_axis (axis *a)
 default constructor.
void init_axis (axis *a, size_t n, ireal d, ireal o)
 main constructor - not terribly useful.
void copy_axis (axis *tgt, const axis *src)
 deep copy function
void print_axis (axis a)
 print axis to stdout
void fprint_axis (FILE *fp, axis a)
 print axis to stream
void fprint_num_axis (FILE *fp, int i, axis a)
int compare_axis (axis a1, axis a2)
 compare two axes for equality
void init_default_grid (grid *g)
 default constructor.
int init_grid (grid *g, int dim, int gdim)
 main constructor.
void copy_grid (grid *tgt, const grid *src)
 deep copy
void print_grid (grid a)
 print grid to stdout
void fprint_grid (FILE *fp, grid a)
 print grid to stream
int compare_grid (const grid g1, const grid g2)
 compare two grids by comparing their axes
int compatible_grid (const grid g1, const grid g2)
 decide if two grids are compatible, that is, define sublattices of a common parent lattice
int get_dimension_grid (grid g)
 return effective (physical plus internal extended) grid dimension
int get_datasize_grid (grid g)
 get number of physical gridpoints (product of n's)
int get_extended_datasize_grid (grid g)
 get number of physical and internal extended gridpoints (product of n's)
size_t get_global_datasize_grid (grid g)
 get total number of gridpoints (product of n's)
ireal get_cellvol_grid (grid g)
 returns (physical, non-extended) cell vol
ireal get_extended_cellvol_grid (grid g)
 returns physical + internal extended cell vol
ireal get_global_cellvol_grid (grid g)
 returns global (all axes) cell vol
int get_panelnum_grid (grid g)
 get total number of records = physical (+ internal ext'd) grids within global grid (product of n's)
void get_n (IPNT n, grid g)
 get axis length array
void get_d (_RPNT d, grid g)
 get step array
void get_o (_RPNT o, grid g)
 get grid origin coordinate array
void get_gs (IPNT gs, grid g)
 get array of indices of grid origin in global grid
void get_ge (IPNT ge, grid g)
 get array of indices of grid origin in global grid
void get_id (IPNT id, grid g)
 get array of axis ids as function of axis index - next function inverts this relation
void get_ord (IPNT a, grid g)
 returns axis order array, i.e.
bool grid_union (grid *g, axis const *ax)
 convex hull operation.
bool init_step (grid g, IPNT step, bool fwd)
 initializes steps through the non-spatial axes of a grid.
bool next_step (grid g, IPNT step)
 increments index array for next step in simulation - time axis first, then other non-spatial axes in order.


Define Documentation

#define TOL   100.0*REAL_EPS

Definition at line 8 of file grid.h.

#define EXTINT   100

Definition at line 11 of file grid.h.


Typedef Documentation

typedef struct s_axis axis

Axis: Basic Metadata element for regular grids.

Defines a uniformly sampled axis, after the fashion of SEPlib77 or RSF. Struct part of RVLGrid Axis class.

Innovative feature: each axis carries an integer token (axis.id) meant to signify its position in a global ordering of axes (hence its physical meaning)..


Function Documentation

void init_default_axis ( axis a  ) 

default constructor.

Default values: n=1, d=1.0, o=0.0, id=1

Parameters:
[out] a (axis *) - axis to be initialized

void init_axis ( axis a,
size_t  n,
ireal  d,
ireal  o 
)

main constructor - not terribly useful.

id defaults to 1.

Parameters:
[out] a (axis *) - axis to be initialized
[in] n (int) - number of gridpoints on axis
[in] d (ireal) - step
[in] o (ireal) - coord of first data point

void copy_axis ( axis tgt,
const axis src 
)

deep copy function

Parameters:
[out] tgt - target axis
[in] src - source axis

void print_axis ( axis  a  ) 

print axis to stdout

Parameters:
[in] a (axis) - axis to be printed

void fprint_axis ( FILE *  fp,
axis  a 
)

print axis to stream

Parameters:
[in] fp (FILE *) - output stream f
[in] a (axis) - axis to be printed

void fprint_num_axis ( FILE *  fp,
int  i,
axis  a 
)

int compare_axis ( axis  a1,
axis  a2 
)

compare two axes for equality

Parameters:
[in] a1 (axis) - first axis
[in] a2 (axis) - second axis
Returns:
0 if axes are same, else 1

void init_default_grid ( grid g  ) 

default constructor.

Parameters:
[out] g (grid *) - grid to be initialized

int init_grid ( grid g,
int  dim,
int  gdim 
)

main constructor.

initializes metadata (dim) but not data (axes). Since no dynamic allocation takes place, only real role is to sanity-check dim.

Parameters:
[out] g (grid *) - grid to be initialized
[in] dim (int) - dimension of grid, at most RARR_MAX_NDIM
Returns:
0 for normal return, E_BADINPUT if input inconsistent

void copy_grid ( grid tgt,
const grid src 
)

deep copy

Parameters:
[out] tgt - target grid
[in] src - source grid

void print_grid ( grid  a  ) 

print grid to stdout

Parameters:
[in] a (grid) - grid to be printed

void fprint_grid ( FILE *  fp,
grid  a 
)

print grid to stream

Parameters:
[in] a (grid) - grid to be printed
[in] fp (FILE *) - stream to which to print

int compare_grid ( const grid  g1,
const grid  g2 
)

compare two grids by comparing their axes

Returns:
0 if grids same, else 1

int compatible_grid ( const grid  g1,
const grid  g2 
)

decide if two grids are compatible, that is, define sublattices of a common parent lattice

Returns:
0 if compatible, else 1

int get_dimension_grid ( grid  g  ) 

return effective (physical plus internal extended) grid dimension

int get_datasize_grid ( grid  g  ) 

get number of physical gridpoints (product of n's)

Returns:
product of physical axis lengths

int get_extended_datasize_grid ( grid  g  ) 

get number of physical and internal extended gridpoints (product of n's)

Returns:
product of physical, internal extended axis lengths

size_t get_global_datasize_grid ( grid  g  ) 

get total number of gridpoints (product of n's)

Returns:
product of axis lengths

ireal get_cellvol_grid ( grid  g  ) 

returns (physical, non-extended) cell vol

ireal get_extended_cellvol_grid ( grid  g  ) 

returns physical + internal extended cell vol

ireal get_global_cellvol_grid ( grid  g  ) 

returns global (all axes) cell vol

int get_panelnum_grid ( grid  g  ) 

get total number of records = physical (+ internal ext'd) grids within global grid (product of n's)

Returns:
product of external ext'd axis lengths

void get_n ( IPNT  n,
grid  g 
)

get axis length array

Parameters:
[out] n (IPNT) - axis lengths

void get_d ( _RPNT  d,
grid  g 
)

get step array

Parameters:
[out] d (RPNT) - steps

void get_o ( _RPNT  o,
grid  g 
)

get grid origin coordinate array

Parameters:
[out] o (RPNT) - grid origin

void get_gs ( IPNT  gs,
grid  g 
)

get array of indices of grid origin in global grid

Parameters:
[out] gs (IPNT) - global indices of grid origin

void get_ge ( IPNT  ge,
grid  g 
)

get array of indices of grid origin in global grid

Parameters:
[out] gs (IPNT) - global indices of grid origin

void get_id ( IPNT  id,
grid  g 
)

get array of axis ids as function of axis index - next function inverts this relation

void get_ord ( IPNT  a,
grid  g 
)

returns axis order array, i.e.

axis index as a function of id, rather than id as a function of axis index (which is stored).

Parameters:
[out] a (IPNT) - axis order array

bool grid_union ( grid g,
axis const *  ax 
)

convex hull operation.

Loops through axis vector input. If axis has new id, then added to grid. If axis id same as existing, then axis enlarged convex hull of existing and new axis. Axes must be commensurable.

bool init_step ( grid  g,
IPNT  step,
bool  fwd 
)

initializes steps through the non-spatial axes of a grid.

Assumption is that time is the first axis, so should be reversed for adjoint stepping.

bool next_step ( grid  g,
IPNT  step 
)

increments index array for next step in simulation - time axis first, then other non-spatial axes in order.

Time axis decremented for adjoint case. Returns true until no more steps are possible (including along non-time axes), then false.


Generated on 5 Jan 2017 for IWAVEGRID by  doxygen 1.4.7