Mathematical helpers
NEML contains many helper functions to do tensor operations on Mandel-notation representations of tensors stored as pointers as well as common linear algebra operations like solving systems of equations and inverting matrices. These helpers are fairly self documenting. The interfaces are shown below.
Additionally, the Crystal plasticity module uses a new system for tensor operations using objects, rather than raw pointers. The new system considerably simplifies many common mathematical operations. The long-term plan for NEML is to switch the macroscale plasticity modules over to this new approach.
Tensor and rotation objects
Generic matrix system
Pointer array math functions
-
namespace neml
Functions
-
void SymSymR4SkewmSkewSymR4SymR4(const double *const M, const double *const W, double *const SS)
Specialty crystal plasticity operator: M_kmab*W_ml - W_km*M_mlab.
-
void SymSkewR4SymmSkewSymR4SymR4(const double *const D, const double *const M, double *const SS)
Specialty crystal plasticity operator: D_km * M_mlab - M_kmab D_ml.
-
void SpecialSymSymR4Sym(const double *const D, const double *const M, double *const SW)
Specialty operator for the skew part of the tangent: C_ijkb * e_ka - C_ijal * e_bl.
-
void transform_fourth(const double *const D, const double *const W, double *const M)
Convert the symmetric and skew parts voido a complete fourth order.
-
void truesdell_tangent_outer(const double *const S, double *const M)
The outer product used in constructing the truesdell tangent.
-
void full2skew(const double *const A, double *const M)
Convert a 9x9 to a skew derivative matrix.
-
void skew2full(const double *const M, double *const A)
Convert a skew derivative matrix to a 9x9.
-
void full2wws(const double *const A, double *const M)
Convert a 9x9 voido a ws matrix.
-
void wws2full(const double *const M, double *const A)
Convert a 3x6 ws matrix voido a 9x9.
-
void full2mandel(const double *const A, double *const M)
Convert a 9x9 to a mandel matrix.
-
void mandel2full(const double *const M, double *const A)
Convert a mandel matrix to a full 9x9.
-
void truesdell_update_sym(const double *const D, const double *const W, const double *const Sn, const double *const So, double *const Snp1)
Convect a symmetric tensor with a Truesdell rate.
-
void truesdell_mat(const double *const D, const double *const W, double *const M)
Form the 9x9 matrix used in the update.
-
void truesdell_rhs(const double *const D, const double *const W, const double *const Sn, const double *const So, double *const St)
Form the RHS of the update, as a symmetric vector.
-
void sym(const double *const A, double *const v)
Convert a full symmetric rank 2 to a Mandel vector.
-
void usym(const double *const v, double *const A)
Convert a symmetric vector to a full matrix.
-
void skew(const double *const A, double *const v)
Convert a full skew rank 2 to a skew vector.
-
void uskew(const double *const v, double *const A)
Convert a skew vector to a full matrix.
-
void minus_vec(double *const a, int n)
Negate a vector in place.
-
void add_vec(const double *const a, const double *const b, int n, double *const c)
Add vectors.
-
void sub_vec(const double *const a, const double *const b, int n, double *const c)
Subtract vectors.
-
double dot_vec(const double *const a, const double *const b, int n)
Compute a dot product.
-
double norm2_vec(const double *const a, int n)
Compute a two norm.
-
void normalize_vec(double *const a, int n)
Normalize a vector in place (2-norm)
-
void dev_vec(double *const a)
Return the deviatoric vector.
-
void outer_vec(const double *const a, int na, const double *const b, int nb, double *const C)
Outer product of two vectors.
-
void outer_update(const double *const a, int na, const double *const b, int nb, double *const C)
Rank 2 update.
-
void outer_update_minus(const double *const a, int na, const double *const b, int nb, double *const C)
Rank 2 update.
-
void mat_vec(const double *const A, int m, const double *const b, int n, double *const c)
Matrix-vector c = A . b.
-
void mat_vec_trans(const double *const A, int m, const double *const b, int n, double *const c)
Matrix-vector c = A.T . b.
-
void invert_mat(double *const A, int n)
Invert a matrix in place.
-
void mat_mat(int m, int n, int k, const double *const A, const double *const B, double *const C)
-
void mat_mat_ABT(int m, int n, int k, const double *const A, const double *const B, double *const C)
-
void solve_mat(const double *const A, int n, double *const x)
Solve unsymmetric system.
-
double condition(const double *const A, int n)
Get the condition number of a matrix.
-
double polyval(const std::vector<double> &poly, double x)
Evaluate a polynomial with Horner’s method, highest order term first.
-
std::vector<double> poly_from_roots(const std::vector<double> &roots)
Construct a polynomial with the given roots.
-
std::vector<double> differentiate_poly(const std::vector<double> &poly, int n = 1)
Get the derivative of a polynomial.
-
int gcd(int a, int b)
The greatest common divisor between two numbers.
-
int common_gcd(std::vector<int> in)
The greatest common divisor between a lot of numbers.
-
std::vector<int> reduce_gcd(std::vector<int> in)
Divide a vector by the collective GCD.
-
double convert_angle(double a, std::string)
Convert to radians.
-
double cast_angle(double a, std::string angles)
Convert from radians.
-
void qmult_vec(const double *const As, const double *const B, size_t n, double *const C)
Vectorized quaternion multiplication.
-
bool isclose(double a, double b)
This is only to be used for testing.
-
void rotate_matrix(int m, int n, const double *const A, const double *const B, double *C)
Perform A * B * A.T.
-
int fact(int n)
Factorial.
-
double factorial(int n)
Factorial as a double + cacheing.
-
void eigenvalues_sym(const double *const s, double *values)
Get the eigenvalues of a symmetric 3x3 matrix in Mandel notation.
-
void eigenvectors_sym(const double *const s, double *vectors)
Get the eigenvectors of a symmetric 3x3 matrix (row major)
-
double I1(const double *const s)
First principal invariant.
-
double I2(const double *const s)
Second principal invariant.
-
void SymSymR4SkewmSkewSymR4SymR4(const double *const M, const double *const W, double *const SS)