SIFEL/GEFEL/mathem.h File Reference

#include "vector.h"
#include "matrix.h"
#include "basefun.h"

Go to the source code of this file.

Functions

int check_math_err ()
int check_math_errel (long eid)
double genheaviside (double x, double eps)
double heaviside (double x)
void interpolelem (gtopology *gt, long &nli, long **&lin, long &ntr, long **&trn, long &nqu, long **&qun, long &nte, long **&ten, long &ncu, long **&cun, long &nmp, double **&mpn, char flag)
double length (vector &coorda, vector &coordb)
double lsm_quad (matrix &a, vector &r, vector &l, double x, double y, double x_old, double y_old, double zero, long solc)
void maxmin_3 (double *x, double &max, double &min)
void maxmin_4 (double *x, double &max, double &min)
void nc_lin_3_2d (double xx, double yy, double *x, double *y, double &xi, double &eta)
void nc_lin_4_2d (double acc, double xx, double yy, double *x, double *y, double &xi, double &eta)
void nc_quad_3_2d (double acc, double xx, double yy, double *x, double *y, double &xi, double &eta)
void nc_quad_4_2d (double acc, double xx, double yy, double *x, double *y, double &xi, double &eta)
void nodal_values (double **val, vector &nx, vector &ny, vector &nz, double *lhs, long dim, long fi, long ncomp)
double polynom_4 (double x, double *a)
void print_dx (gtopology *gt, const char *file, double **valnod, double **valel, char tve, long *dimindex, char **caption, long nindex)
void print_ex (gtopology *gt, const char *file, double *valnod, double *valel)
double radius (vector &x, vector &natcoord)
double sgn (double i)
long solv_1le (double a, double b, double &x)
long solv_2le (double *a, double *b, double *c, double &x, double &y)
long solv_2nle (double *a, double *b, double *c, double *d, double *x, double *y)
long solv_polynom_2 (double a, double b, double c, double &r1, double &r2)
long solv_polynom_3 (double a, double b, double c, double d, double &r1, double &r2, double &r3)
long solv_polynom_4 (double *coeff, double a, double b, double acc, double *roots)
void sort_2 (long *x)
void sort_3 (double *x)
void sort_3 (long *x)
void sort_4 (long *x)
double sqr (double x)
long test_math_err ()

Function Documentation

int check_math_err (  ) 

Definition at line 1518 of file mathem.cpp.

References print_err().

Referenced by slesolv::solve_system().

int check_math_errel ( long  eid  ) 
double genheaviside ( double  x,
double  eps 
)

generalized Heaviside function

for x<0, H(x)=0 for x>=0, H(x)=1;

Parameters:
x - variable
eps - radius of transition zone for the Heaviside function

3. 10. 2013, JK

Definition at line 168 of file mathem.cpp.

References h().

Referenced by saltmat4::c11(), saltmat4::c21(), saltmat4::c22(), saltmat4::c31(), saltmat4::c32(), saltmat4::k11(), and saltmat4::k14().

double heaviside ( double  x  ) 

Heaviside function

for x<0, H(x)=0 for x>=0, H(x)=1;

Parameters:
x - variable

3. 10. 2013, JK

Definition at line 148 of file mathem.cpp.

void interpolelem ( gtopology gt,
long &  nli,
long **&  lin,
long &  ntr,
long **&  trn,
long &  nqu,
long **&  qun,
long &  nte,
long **&  ten,
long &  ncu,
long **&  cun,
long &  nmp,
double **&  mpn,
char  flag 
)

Function (i) divides all "elements" into linear "subelements", because postprocesors are able to image only linear - line, triangle, tetrahedra, rectangle and cube. (ii) fills array 'lin' by lines (between two nodes), of which is composed mesh. (iii) computes coordinates of centre point for quadratic rectangle elements. -> linear triangle is divided into one lineat triangle -> linear rectangle is divided into one lineat rectangle -> quadratic triangle is divided into four lineat triangles and composed of 6 lines -> quadratic rectangle is divided into four lineat rectangles and composed of 8 lines -> linear tetrahedra is divided into one linear tetrahedra -> linear hexahedra(cube) is divided into one linear cube

Parameters:
nli - number of lines
lin - array of line nodes
ntr - number of triangles
trn - array of triangle nodes
nqu - number of quadrilaterals (rectangles)
qun - array of quadrilateral nodes
nte - number of tetrahedras
ten - array of tetrahedra nodes
ncu - number of cubes
cun - array of cube nodes
nmp - number of midpoints
mpn - array of midpoint coordinates and numbers of corresponding elements
flag - switch: 'e' = data for postprocesor Elixir, 'e' = data for postprocesor OpenDx

created 20.11.2002, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 989 of file mathem.cpp.

References gelement::auxinf, gtopology::gelements, gtopology::gnodes, gtopology::ne, gtopology::nn, gelement::nodes, nodes, gnode::x, and gnode::y.

Referenced by print_dx(), and print_ex().

double length ( vector coorda,
vector coordb 
)

function computes distance between points A and B

Parameters:
coorda - coordinates of point A
coordb - coordinates of point B

30.12.2001

Definition at line 57 of file mathem.cpp.

References vector::n.

Referenced by fixnodesel::check_triangle(), dist(), SparseConectivityMtxII::GetCmpRows(), give_max_adjacip(), in_dist(), parseldofinit(), seldofinit(), and Parser::TreeToText().

double lsm_quad ( matrix a,
vector r,
vector l,
double  x,
double  y,
double  x_old,
double  y_old,
double  zero,
long  solc 
)

Function assembles matrix for point approximation with quadratic function y = a*x^2 + b*x + c. The least square method is used. One new point is added and coefficients of the matrix a and vector of right hand side r are updated and solved. One old point is subtracted from the matrix (it is used for moving least square method). The solution is saved in the vector l and the function returns values of derivatives in the point x. The function is used in iterative solvers (e.g. Newton-Raphson) for divergency check.

Parameters:
a - matrix of normal equations
r - right hand side vector
l - vector of solution(coefficients of quadratic function) l[0] = c, l[1] = b, l[2] = a.
x - x coordinate of added point
y - y coordinate of added point
x_old - x coordinate of old point which will be subtracted
y_old - y coordinate of old point which will be subtracted
zero - limit value for zero determinant detection
solc - flag for computation of coefficients of quadratic approximation solc=0 accumulation of values only, no computation of coefficients, solc=1 accumulation of values and computation of coeffcients and derivatives solc=2 accumulation/removal of values and computation of coeffcients and derivatives
Return values:
The function returns value of the derivative in the given point [x,y] (2*a*x+b)

TKo 8.2008

Definition at line 1444 of file mathem.cpp.

References matrix::m, vector::n, matrix::n, and print_err().

Referenced by check_divergence(), check_divergency(), newton_raphson_gparcoupl_lin(), newton_raphson_gparcoupl_nonlin(), newton_raphson_parcoupl_lin(), newton_raphson_parcoupl_nonlin(), newton_raphsonrv1(), par_newton_raphson_gparcoupl_lin(), par_newton_raphson_gparcoupl_nonlin(), par_newton_raphson_parcoupl_lin(), par_newton_raphson_parcoupl_nonlin(), par_solve_prob_constr_phases(), par_solve_timemech_prob(), solve_prob_constr_phases(), and visco_solver().

void maxmin_3 ( double *  x,
double &  max,
double &  min 
)

Function finds maximal and minimal number in first three members of array x.

Parameters:
x - 1D array of given numbers
max,min - answers

created 19.8.2002, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 1374 of file mathem.cpp.

Referenced by least_square::nsp_spcoord_maxcoord_assembling(), and patch_averaging::nsp_spcoord_maxcoord_assembling().

void maxmin_4 ( double *  x,
double &  max,
double &  min 
)

Function finds maximal and minimal number in first four members of array x.

Parameters:
x - 1D array of given numbers
max,min - answers

created 19.8.2002, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 1392 of file mathem.cpp.

Referenced by least_square::nsp_spcoord_maxcoord_assembling(), and patch_averaging::nsp_spcoord_maxcoord_assembling().

void nc_lin_3_2d ( double  xx,
double  yy,
double *  x,
double *  y,
double &  xi,
double &  eta 
)

function computes natural coordinates of "point" in linear triangle

Parameters:
xx,yy - cartesian coordinates of "point"
x,y - arrays of cartesian coordinates of element nodes, dimension is 3
xi,eta - answer - natural coordinates of "point"

created 11.1.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 747 of file mathem.cpp.

Referenced by give_valuesinpoints(), and nc_quad_3_2d().

void nc_lin_4_2d ( double  acc,
double  xx,
double  yy,
double *  x,
double *  y,
double &  xi,
double &  eta 
)

function computes natural coordinates of "point" in linear rectangle

Parameters:
acc - relative accuracy of natural coordinates => (exact_xi - xi)/exact_xi is in (-acc;acc) ;; acc > 1e-14
xx,yy - cartesian coordinates of "point"
x,y - arrays of cartesian coordinates of element nodes, dimension is 4
xi,eta - answer - natural coordinates of "point"

created 11.1.2002, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 882 of file mathem.cpp.

References solv_polynom_2().

Referenced by planeelemqt::give_sig_roof(), give_valuesinpoints(), and nc_quad_4_2d().

void nc_quad_3_2d ( double  acc,
double  xx,
double  yy,
double *  x,
double *  y,
double &  xi,
double &  eta 
)

function computes natural coordinates of "point" in quadratic triangle

Parameters:
acc - relative accuracy of natural coordinates => (exact_xi - xi)/exact_xi is in (-acc;acc) ;; acc > 1e-14
xx,yy - cartesian coordinates of "point"
x,y - arrays of cartesian coordinates of element nodes, dimension is 6
xi,eta - answer - natural coordinates of "point"

created 13.1.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 767 of file mathem.cpp.

References nc_lin_3_2d(), p, solv_polynom_2(), and solv_polynom_4().

Referenced by give_valuesinpoints().

void nc_quad_4_2d ( double  acc,
double  xx,
double  yy,
double *  x,
double *  y,
double &  xi,
double &  eta 
)

function computes natural coordinates of "point" in quadratic rectangle

Parameters:
acc - relative accuracy of natural coordinates => (exact_xi - xi)/exact_xi is in (-acc;acc) ;; acc > 1e-14
xx,yy - cartesian coordinates of "point"
x,y - arrays of cartesian coordinates of element nodes, dimension is 8
xi,eta - answer - natural coordinates of "point"

created xx.x.xxxx, xxxxxxxx xxxxxxx, xxxxxx@cml.fsv.cvut.cz

Definition at line 949 of file mathem.cpp.

References nc_lin_4_2d().

Referenced by give_valuesinpoints().

void nodal_values ( double **  val,
vector nx,
vector ny,
vector nz,
double *  lhs,
long  dim,
long  fi,
long  ncomp 
)

function computes nodal values with help of least square problem solution

Parameters:
val - array containing nodal values on element
nx,ny,nz - arrays containing natural coordinates of nodes
lhs - array of coefficients of linear functions (solution of least square problem)
dim - problem dimension
fi - first index
ncomp - number of stored components

15.7.2002

Definition at line 92 of file mathem.cpp.

References vector::n.

Referenced by soilplateq::elem_strains(), planeelemsubqt::elem_strains(), planeelemrotlt::elem_strains(), planeelemqt::elem_strains(), linhex::elem_strains(), axisymqq::elem_strains(), axisymlq::elem_strains(), planeelemsubqt::elem_stresses(), planeelemrotlt::elem_stresses(), planeelemqt::elem_stresses(), linhex::elem_stresses(), axisymqq::elem_stresses(), and axisymlq::elem_stresses().

double polynom_4 ( double  x,
double *  a 
)

function establishs to polynom of 4th order

Definition at line 190 of file mathem.cpp.

Referenced by solv_polynom_4().

void print_dx ( gtopology gt,
const char *  file,
double **  valnod,
double **  valel,
char  tve,
long *  dimindex,
char **  caption,
long  nindex 
)

function prints data-file for OpenDX

Parameters:
gt - gtopology
file - name of printed file
valnod - array of depicted values in nodes
valel - array of depicted values in centre of element - only for quadratic rectangel, for other elements **valel==anything
dimindex -
caption -
nindex - dimension of dimindex

created 20.11.2002, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 1165 of file mathem.cpp.

References gelement::auxinf, gtopology::gelements, gtopology::gnodes, interpolelem(), gtopology::ne, gtopology::nn, gnode::x, gnode::y, and gnode::z.

Referenced by print_default_dx(), and print_valel().

void print_ex ( gtopology gt,
const char *  file,
double *  valnod,
double *  valel 
)

function prints data-file for Elixir it is possible only one

Parameters:
gt - gtopology
file - name of printed file
valnod - array of depicted values in nodes
valel - array of depicted values in centre of element - only for quadratic rectangel, for other elements **valel==anything

created 20.11.2002, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 1096 of file mathem.cpp.

References gtopology::gnodes, interpolelem(), gtopology::ne, gtopology::nn, gnode::x, gnode::y, and gnode::z.

Referenced by print_valel().

double radius ( vector x,
vector natcoord 
)
double sgn ( double  i  ) 

function returns the signum of given value (if value is < 0 returns -1, otherwise returns 1)

Definition at line 132 of file mathem.cpp.

Referenced by adapt_psi_coeff(), quadeqcoeff(), and solv_polynom_3().

long solv_1le ( double  a,
double  b,
double &  x 
)

function solves linear equation: a*x + b = 0 answer: -1 = infinite number of results 0,1 = number of results

Parameters:
a,b - coeficients of equation
x - result

created 4.4.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 582 of file mathem.cpp.

References MATH_ZERO.

Referenced by solv_2nle().

long solv_2le ( double *  a,
double *  b,
double *  c,
double &  x,
double &  y 
)

function solves system of two linear equations: a[0]*x + b[0]*y + c[0] = 0 a[1]*x + b[1]*y + c[1] = 0 answer: -1 = infinite number of results 0,1 = number of results

Parameters:
a,b,c - arrays of coeficients of equations, dimension is 2
x,y - results

created 4.4.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 611 of file mathem.cpp.

References MATH_ZERO.

Referenced by solv_2nle().

long solv_2nle ( double *  a,
double *  b,
double *  c,
double *  d,
double *  x,
double *  y 
)

function solves system of two non-linear equations: a[0]*x*y + b[0]*x + c[0]*y + d[0] = 0 a[1]*x*y + b[1]*x + c[1]*y + d[1] = 0 answer: -1 = infinite number of results 0,1,2 = number of results

Parameters:
a,b,c,d - arrays of coeficients of equations, dimension is 2
x,y - arrays results, dimension is 2

created 4.4.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 668 of file mathem.cpp.

References MATH_ZERO, solv_1le(), solv_2le(), and solv_polynom_2().

long solv_polynom_2 ( double  a,
double  b,
double  c,
double &  r1,
double &  r2 
)

function searchs roots of polynom of 2nd order = quadratic equation a*x^2 + b*x + c = 0 answer: -1 = infinite number of results 0,1,2 = no,one,two results

Parameters:
a,b,c - coeficients of quadratic equation
r1,r2 - roots of quadratic equation

created 11.1.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 388 of file mathem.cpp.

References MATH_ZERO.

Referenced by arclength(), arclengthadapt(), arclengthrv(), arclengthrv1(), determine_dlambda(), nc_lin_4_2d(), nc_quad_3_2d(), quadeqcoeff(), solv_2nle(), and solv_polynom_3().

long solv_polynom_3 ( double  a,
double  b,
double  c,
double  d,
double &  r1,
double &  r2,
double &  r3 
)

function searchs roots of polynom of 3rd order = cubic equation ax^3 + bx^2 + cx + d = 0 answer: -1 = infinite number of results 0,1,2,3 = no,one,two,three results

Parameters:
a,b,c,d - coeficients of cubic equation
r1,r2,r3 - roots of cubic equation

created xx.x.xxxx, Borek Pacak, bp@cml.fsv.cvut.cz

Definition at line 432 of file mathem.cpp.

References MATH_ZERO, p, sgn(), and solv_polynom_2().

Referenced by solv_polynom_4().

long solv_polynom_4 ( double *  coeff,
double  a,
double  b,
double  acc,
double *  roots 
)

function searchs roots of polynom of 4th order in interval <a,b> coeff[0]*x^4 + coeff[1]*x^3 + coeff[2]*x^2 + coeff[3]*x + coeff[4] = 0 answer: -1 = infinite number of results 0,1,2,3,4 = no,one,two,three,four results

Parameters:
coeff - array of coefficients of polynom
a,b - interval of searching
acc - relative accuracy of roots => (exact_root - root)/exact_root is in (-acc;acc) ;; acc > 1e-14
roots - roots of polynom

created 1.10.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 509 of file mathem.cpp.

References MATH_ZERO, polynom_4(), solv_polynom_3(), and sort_3().

Referenced by nc_quad_3_2d().

void sort_2 ( long *  x  ) 

Function sorts first two members of array with ascending order.

Parameters:
x - sorted array

created 27.3.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 205 of file mathem.cpp.

void sort_3 ( double *  x  ) 

Function sorts first three members of array with ascending order.

Parameters:
x - sorted array

created 12.1.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 337 of file mathem.cpp.

void sort_3 ( long *  x  ) 

Function sorts first three members of array with ascending order.

Parameters:
x - sorted array

created 27.3.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 221 of file mathem.cpp.

Referenced by solv_polynom_4(), and sort_4().

void sort_4 ( long *  x  ) 

Function sorts first four members of array with ascending order

Parameters:
x - sorted array

created 27.3.2003, Ladislav Svoboda, termit@cml.fsv.cvut.cz

Definition at line 268 of file mathem.cpp.

References sort_3().

double sqr ( double  x  ) 

Definition at line 74 of file mathem.cpp.

long test_math_err (  ) 

Definition at line 1554 of file mathem.cpp.

Referenced by dampermeability::matcond().


Generated by  doxygen 1.6.2