programmer's documentation
Functions | Variables
cs_cdo_toolbox.c File Reference
#include "cs_defs.h"
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <float.h>
#include <limits.h>
#include <bft_mem.h>
#include <bft_printf.h>
#include "cs_cdo.h"
#include "cs_cdo_toolbox.h"
Include dependency graph for cs_cdo_toolbox.c:

Functions

static cs_data_info_t _init_dinfo (cs_datatype_t datatype)
 Intialize by default a cs_data_info_t structure according to the datatype. More...
 
static void _compute_info_double (cs_lnum_t n_elts, const cs_real_t data[], cs_data_info_t *info)
 Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley) More...
 
static void _compute_info_int32 (cs_lnum_t n_elts, const cs_lnum_t data[], cs_data_info_t *info)
 Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley) More...
 
double _dp3 (const cs_real_3_t u, const cs_real_3_t v)
 Compute a dot product for vector of dimension 3. More...
 
double _n3 (const cs_real_3_t v)
 Compute the euclidean norm of a vector of dimension 3. More...
 
double _length3 (const cs_real_3_t xa, const cs_real_3_t xb)
 Compute the length (euclidien norm) between two points xu and xv in a cartesian coordinate system of dimension 3. More...
 
void _lenunit3 (const cs_real_3_t xa, const cs_real_3_t xb, cs_real_t *len, cs_real_3_t *unit)
 Compute the length (euclidien norm) between two points xu and xv in a cartesian coordinate system of dimension 3. More...
 
void _cp3 (const cs_real_3_t u, const cs_real_3_t v, cs_real_3_t *w)
 Compute the cross product of a vector of dimension 3. More...
 
void _mv3 (const cs_real_33_t m, const cs_real_3_t v, cs_real_3_t *mv)
 Compute the 3x3 matrice by vector product. More...
 
void _invmat33 (const cs_real_33_t in, cs_real_33_t *inv)
 Inverse a 3x3 matrix. More...
 
double cs_surftri (const cs_real_3_t xv, const cs_real_3_t xe, const cs_real_3_t xf)
 Compute the area of the convex_hull generated by 3 points. This corresponds to the computation of the surface of a triangle. More...
 
double cs_voltet (const cs_real_3_t xv, const cs_real_3_t xe, const cs_real_3_t xf, const cs_real_3_t xc)
 Compute the volume of the convex_hull generated by 4 points. This is equivalent to the computation of the volume of a tetrahedron. More...
 
void cs_daxpy (int size, double alpha, const cs_real_t x[], cs_real_t beta, const cs_real_t y[], cs_real_t *p_z[], _Bool reset)
 Compute alpha*x + beta*y = z. More...
 
double cs_dp (int size, const double v[], const double w[])
 Compute the dot product of two vectors of dimension "size" This algorithm tries to reduce round-off error thanks to intermediate sums. More...
 
double cs_euclidean_norm (int len, const double v[])
 Compute the euclidean norm 2 of a vector of size len This algorithm tries to reduce round-off error thanks to intermediate sums. More...
 
double cs_sum (cs_lnum_t size, const double v[], const double w[], cs_toolbox_type_sum_t op)
 Compute by default the sum of the elements of an array of double Additional operation are also possible: square, abs This algorithm tries to reduce round-off errors thanks to intermediate sums. More...
 
void cs_toolbox_init (cs_lnum_t ref_size)
 Allocate and initialize a private structure for this file used for reducing round-off errors during summation. More...
 
void cs_toolbox_finalize (void)
 Free a private structure for this file used for reducing round-off errors during summation. More...
 
void cs_tmpbuf_alloc (size_t bufsize, cs_tmpbuf_t **p_tb)
 Allocate or reallocate a temporary buffer structure. More...
 
cs_tmpbuf_tcs_tmpbuf_free (cs_tmpbuf_t *tb)
 Free a temporary buffer structure. More...
 
cs_toolbox_locmat_tcs_toolbox_locmat_create (int n_max_ent)
 Allocate and initialize a cs_toolbox_locmat_t structure. More...
 
void cs_toolbox_locmat_dump (int parent_id, const cs_toolbox_locmat_t *lm)
 Dump a local discrete Hodge operator. More...
 
cs_toolbox_locmat_tcs_toolbox_locmat_free (cs_toolbox_locmat_t *lm)
 Free a cs_toolbox_locmat_t structure. More...
 
cs_data_info_t cs_analysis_data (cs_lnum_t n_elts, int stride, cs_datatype_t datatype, const void *indata, _Bool do_abs)
 Compute some simple statistics from an array. More...
 
void cs_data_info_dump (const char *name, FILE *f, cs_lnum_t n_elts, cs_datatype_t datatype, const cs_data_info_t dinfo)
 Dump a cs_data_info_t structure. More...
 

Variables

static struct _subsum_t _op_subsum
 
static const double _tools_oversix = 1/6.0
 
static const double _overdim = 1/3.0
 

Function Documentation

static void _compute_info_double ( cs_lnum_t  n_elts,
const cs_real_t  data[],
cs_data_info_t info 
)
static

Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley)

Parameters
[in]n_eltsnumber of couples in data
[in]databuffer containing input data
[in,out]infopointer to a cs_data_info_t structure
static void _compute_info_int32 ( cs_lnum_t  n_elts,
const cs_lnum_t  data[],
cs_data_info_t info 
)
static

Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley)

Parameters
[in]n_eltsnumber of couples in data
[in]databuffer containing input data
[in,out]infopointer to a cs_data_info_t structure
void _cp3 ( const cs_real_3_t  u,
const cs_real_3_t  v,
cs_real_3_t w 
)
inline

Compute the cross product of a vector of dimension 3.

Parameters
[in]ufirst vector
[in]vsecond vector
[out]wresult of u x v
double _dp3 ( const cs_real_3_t  u,
const cs_real_3_t  v 
)
inline

Compute a dot product for vector of dimension 3.

Parameters
[in]ufirst vector
[in]vsecond vector
Returns
the value of the dot product
static cs_data_info_t _init_dinfo ( cs_datatype_t  datatype)
static

Intialize by default a cs_data_info_t structure according to the datatype.

Parameters
[in]datatype
Returns
a cs_data_info_t structure
void _invmat33 ( const cs_real_33_t  in,
cs_real_33_t inv 
)
inline

Inverse a 3x3 matrix.

Parameters
[in]inmatrix to inverse
[out]invinversed matrix
double _length3 ( const cs_real_3_t  xa,
const cs_real_3_t  xb 
)
inline

Compute the length (euclidien norm) between two points xu and xv in a cartesian coordinate system of dimension 3.

Parameters
[in]xafirst coordinate
[in]xbsecond coordinate
Returns
the length (in euclidean norm) between two points xa and xb
void _lenunit3 ( const cs_real_3_t  xa,
const cs_real_3_t  xb,
cs_real_t len,
cs_real_3_t unit 
)
inline

Compute the length (euclidien norm) between two points xu and xv in a cartesian coordinate system of dimension 3.

Parameters
[in]xacoordinate of the first extremity
[in]xbcoordinate of the second extremity
[out]lenpointer to the length of the vector va -> vb
[out]unitunitary vector anlong va -> vb
void _mv3 ( const cs_real_33_t  m,
const cs_real_3_t  v,
cs_real_3_t mv 
)
inline

Compute the 3x3 matrice by vector product.

Parameters
[in]ma 3x3 matrix
[in]va vector
[in,out]mvpointer to the vector resulting of the matrix-vector op.
double _n3 ( const cs_real_3_t  v)
inline

Compute the euclidean norm of a vector of dimension 3.

Parameters
[in]v
Returns
the norm value
cs_data_info_t cs_analysis_data ( cs_lnum_t  n_elts,
int  stride,
cs_datatype_t  datatype,
const void *  indata,
_Bool  do_abs 
)

Compute some simple statistics from an array.

Parameters
[in]n_eltsnumber of couples in data
[in]stridesize of a couple of data
[in]datatypedatatype
[in]indatabuffer containing input data
[in]do_absanalyse the absolute value of indata
Returns
a cs_data_info_t structure
void cs_data_info_dump ( const char *  name,
FILE *  f,
cs_lnum_t  n_elts,
cs_datatype_t  datatype,
const cs_data_info_t  dinfo 
)

Dump a cs_data_info_t structure.

Parameters
[in]namefilename if not NULL
[in]foutput file if not NULL
[in]n_eltsnumber of couples in data
[in]datatypedatatype
[in]dinfocs_data_info_t structure
void cs_daxpy ( int  size,
double  alpha,
const cs_real_t  x[],
cs_real_t  beta,
const cs_real_t  y[],
cs_real_t p_z[],
_Bool  reset 
)

Compute alpha*x + beta*y = z.

Parameters
[in]sizevector dimension
[in]alphacoefficient for x vector
[in]xfirst vector
[in]betacoefficient for y vector
[in]ysecond vector
[in,out]zresulting vector (allocated if NULL)
[in]resetreset z vector before computation
double cs_dp ( int  size,
const double  v[],
const double  w[] 
)

Compute the dot product of two vectors of dimension "size" This algorithm tries to reduce round-off error thanks to intermediate sums.

Parameters
[in]sizevector dimension
[in]vfirst vector
[in]wsecond vector
Returns
the dot product of two vectors
double cs_euclidean_norm ( int  len,
const double  v[] 
)

Compute the euclidean norm 2 of a vector of size len This algorithm tries to reduce round-off error thanks to intermediate sums.

Parameters
[in]lenvector dimension
[in]vvector
Returns
the euclidean norm of a vector
double cs_sum ( cs_lnum_t  size,
const double  v[],
const double  w[],
cs_toolbox_type_sum_t  op 
)

Compute by default the sum of the elements of an array of double Additional operation are also possible: square, abs This algorithm tries to reduce round-off errors thanks to intermediate sums.

Parameters
[in]sizearray dimension
[in]vvalues
[in]wweights (possibly NULL)
[in]opoperation to do when doing the sum
Returns
the sum (with possibly additional op) of a vector
double cs_surftri ( const cs_real_3_t  xv,
const cs_real_3_t  xe,
const cs_real_3_t  xf 
)

Compute the area of the convex_hull generated by 3 points. This corresponds to the computation of the surface of a triangle.

Parameters
[in]xv
[in]xe
[in]xf
Returns
the surface of a triangle
void cs_tmpbuf_alloc ( size_t  bufsize,
cs_tmpbuf_t **  p_tb 
)

Allocate or reallocate a temporary buffer structure.

Parameters
[in]bufsizereference size
[in,out]p_tbpointer to the temporary structure to allocate
cs_tmpbuf_t* cs_tmpbuf_free ( cs_tmpbuf_t tb)

Free a temporary buffer structure.

Parameters
[in]tbpointer to the temporary structure to free
Returns
NULL pointer
void cs_toolbox_finalize ( void  )

Free a private structure for this file used for reducing round-off errors during summation.

void cs_toolbox_init ( cs_lnum_t  ref_size)

Allocate and initialize a private structure for this file used for reducing round-off errors during summation.

Parameters
[in]ref_sizereference array dimension
cs_toolbox_locmat_t* cs_toolbox_locmat_create ( int  n_max_ent)

Allocate and initialize a cs_toolbox_locmat_t structure.

Parameters
[in]n_max_entmax number of entities
Returns
a new allocated cs_toolbox_locmat_t structure
void cs_toolbox_locmat_dump ( int  parent_id,
const cs_toolbox_locmat_t lm 
)

Dump a local discrete Hodge operator.

Parameters
[in]parent_idid of the related parent entity
[in]lmpointer to the cs_sla_locmat_t struct.
cs_toolbox_locmat_t* cs_toolbox_locmat_free ( cs_toolbox_locmat_t lm)

Free a cs_toolbox_locmat_t structure.

Parameters
[in]hbpointer to a cs_toolbox_locmat_t struct. to free
Returns
a NULL pointer
double cs_voltet ( const cs_real_3_t  xv,
const cs_real_3_t  xe,
const cs_real_3_t  xf,
const cs_real_3_t  xc 
)

Compute the volume of the convex_hull generated by 4 points. This is equivalent to the computation of the volume of a tetrahedron.

Parameters
[in]xv
[in]xe
[in]xf
[in]xc
Returns
the volume of the tetrahedron.

Variable Documentation

struct _subsum_t _op_subsum
static
const double _overdim = 1/3.0
static
const double _tools_oversix = 1/6.0
static