IFEM  90A354
Classes | Functions | Variables
utl Namespace Reference

General utility classes and functions. More...

Classes

class  Function
 Base class for unary functions of arbitrary result and argument type. More...
 
class  vector
 A vector class with some added algebraic operations. More...
 
class  matrixBase
 Common base class for multi-dimensional (2D and 3D) matrices. More...
 
class  matrix
 Two-dimensional rectangular matrix with some algebraic operations. More...
 
class  matrix3d
 Three-dimensional rectangular matrix with some algebraic operations. More...
 
class  matrix4d
 Four-dimensional rectangular matrix with some algebraic operations. More...
 
class  Function2
 Base class for binary function of arbitrary result and argument type. More...
 
class  SpatialFunction
 Base class for unary spatial function of arbitrary result type. More...
 
class  LogStream
 Logging stream class. More...
 
class  Point
 Class for representing points in 3D space. More...
 
class  prof
 Convenience class to profile the local scope. More...
 
class  cmpInt
 A helper class used to search for values in an integer map. More...
 

Functions

template<class T >
trunc (T v)
 Truncate a value to zero when it is less than a given threshold. More...
 
template<class T >
std::istream & operator>> (std::istream &s, vector< T > &X)
 Read the vector X from the stream s.
 
template<class T >
std::ostream & operator<< (std::ostream &s, const vector< T > &X)
 Print the vector X to the stream s.
 
template<class T >
std::istream & operator>> (std::istream &s, matrix< T > &A)
 Read the matrix A from the stream s.
 
template<class T >
std::ostream & operator<< (std::ostream &s, const matrix< T > &A)
 Print the matrix A to the stream s. More...
 
template<class T >
void writeMatlab (const char *label, const vector< T > &X, std::ostream &s=std::cout)
 Print the vector X to the stream s in matlab format.
 
template<class T >
void writeMatlab (const char *label, const matrix< T > &A, std::ostream &s=std::cout)
 Print the matrix A to the stream s in matlab format.
 
template<class T >
std::ostream & operator<< (std::ostream &s, const matrix3d< T > &A)
 Print the 3D matrix A to the stream s. More...
 
template<class T >
std::ostream & operator<< (std::ostream &s, const matrix4d< T > &A)
 Print the 4D matrix A to the stream s. More...
 
Vector operator* (const Vector &X, Real c)
 Multiplication of a vector and a scalar. More...
 
Vector operator* (Real c, const Vector &X)
 Multiplication of a scalar and a vector. More...
 
Vector operator/ (const Vector &X, Real d)
 Division of a vector by a scalar. More...
 
Vector operator+ (const Vector &X, const Vector &Y)
 Addition of two vectors. More...
 
Vector operator- (const Vector &X, const Vector &Y)
 Subtraction of two vectors. More...
 
Matrix operator* (const Matrix &A, Real c)
 Multiplication of a matrix and a scalar. More...
 
Matrix operator* (Real c, const Matrix &A)
 Multiplication of a scalar and a matrix. More...
 
Real operator* (const Vector &X, const Vector &Y)
 Dot product of two vectors. More...
 
RealArray operator* (const Matrix &A, const Vector &X)
 Multiplication of a matrix and a vector. More...
 
RealArray operator* (const Vector &X, const Matrix &A)
 Multiplication of a vector and a matrix. More...
 
Matrix operator* (const Matrix &A, const Matrix &B)
 Multiplication of two matrices. More...
 
bool transform (Matrix &A, const Matrix &Tn)
 Congruence transformation of a symmetric matrix. More...
 
bool transform (Vector &V, const Matrix &Tn, bool transpose=false)
 Congruence transformation of a vector. More...
 
bool invert (Matrix &A)
 Inverts the square matrix A.
 
bool solve (Matrix &A, RealArray &b, std::vector< int > *iPivot=nullptr)
 Solves the linear system of equations \( {\bf A x} = {\bf b} \). More...
 
void debugPrint (const char *label, const Vector &V, int level=2)
 Debug print of given vector V, if SP_DEBUGlevel.
 
Real Jacobian (matrix< Real > &J, matrix< Real > &dNdX, const matrix< Real > &X, const matrix< Real > &dNdu, bool computeGradient=true)
 Set up the Jacobian matrix of the coordinate mapping. More...
 
Real Jacobian (matrix< Real > &J, Vec3 &t, matrix< Real > &dNdX, const matrix< Real > &X, const matrix< Real > &dNdu, size_t tangent)
 Set up the Jacobian matrix of the coordinate mapping along an edge. More...
 
Real Jacobian (matrix< Real > &J, Vec3 &n, matrix< Real > &dNdX, const matrix< Real > &X, const matrix< Real > &dNdu, size_t t1, size_t t2)
 Set up the Jacobian matrix of the coordinate mapping on a boundary. More...
 
bool Hessian (matrix3d< Real > &H, matrix3d< Real > &d2NdX2, const matrix< Real > &Ji, const matrix< Real > &X, const matrix3d< Real > &d2Ndu2, const matrix< Real > &dNdX, bool geoMapping=true)
 Set up the Hessian matrix of the coordinate mapping. More...
 
void Hessian (const matrix3d< Real > &Hess, matrix< Real > &H)
 Convert a Hessian from a matrix3d to a matrix assuming symmetry.
 
void getGmat (const matrix< Real > &Ji, const Real *du, matrix< Real > &G)
 Compute the stabilization matrix G from the Jacobian inverse. More...
 
bool Hessian2 (matrix4d< Real > &d3NdX3, const matrix< Real > &Ji, const matrix4d< Real > &d3Ndu3)
 Set up third-order derivatives of the coordinate mapping. More...
 
void JacobianGradient (const matrix< Real > &dudX, const matrix3d< Real > &d2Xdu2, std::vector< matrix< Real >> &dJdX)
 Calculates the derivatives of the Jacobian of the coordinate mapping. More...
 
void detJacGradient (const matrix< Real > &J, const matrix< Real > &Ji, const matrix3d< Real > &H, std::vector< Real > &ddet)
 Calculates the derivatives of determinant of the Jacobian. More...
 
const RealFuncparseRealFunc (char *cline, Real A=Real(1), bool print=true)
 Creates a scalar-valued function by parsing a character string. More...
 
ScalarFuncparseTimeFunc (const char *func, const std::string &type="expression", Real eps=Real(1.0e-8))
 Creates a time function by parsing a character string. More...
 
VecTimeFuncparseVecTimeFunc (const char *func, const std::string &type)
 Creates a vector-valued time function by parsing a char string. More...
 
RealFuncparseRealFunc (const std::string &func, const std::string &type="expression", bool print=true)
 Creates a scalar-valued function by parsing a character string. More...
 
RealFuncparseExprRealFunc (const std::string &function, bool autodiff)
 Creates a scalar-valued function by parsing a character string. More...
 
VecFuncparseExprVecFunc (const std::string &function, bool autodiff)
 Creates a Vector-valued function by parsing a character string. More...
 
IntFuncparseIntFunc (const std::string &func, const std::string &type="expression")
 Creates a scalar-valued int function by parsing a character string. More...
 
VecFuncparseVecFunc (const std::string &func, const std::string &type="expression", const std::string &variables="")
 Creates a vector-valued function by parsing a character string. More...
 
TensorFuncparseTensorFunc (const std::string &func, const std::string &type)
 Creates a tensor-valued function by parsing a character string. More...
 
TractionFuncparseTracFunc (const std::string &func, const std::string &type="expression", int dir=0)
 Creates a vector-valued function defining a surface traction. More...
 
TractionFuncparseTracFunc (const tinyxml2::XMLElement *elem)
 Creates a vector-valued function defining a surface traction. More...
 
size_t Pascal (int p, unsigned short int nsd)
 Returns the number of monomials in Pascal's triangle. More...
 
void Pascal (int p, Real x, Real y, std::vector< Real > &phi)
 Evaluates the monomials of Pascal's triangle in 2D for order p.
 
void Pascal (int p, Real x, Real y, Real z, std::vector< Real > &phi)
 Evaluates the monomials of Pascal's triangle in 3D for order p.
 
Real Pos (Real x)
 Evaluates the positive ramp function \((x+|x|)/2\).
 
Real Neg (Real x)
 Evaluates the negative ramp function \((x-|x|)/2\).
 
Real Rad (Real x)
 Converts from degrees to radians.
 
bool parseIntegers (std::vector< int > &values, const char *argv)
 Parses a character string into an integer or an integer range. More...
 
bool parseVec (Vec3 &value, const char *argv)
 Parses a character string into a point vector. More...
 
bool parseKnots (std::vector< Real > &xi)
 Parses a (possibly graded) sequence of knot values. More...
 
char * readLine (std::istream &is)
 Reads one line, ignoring comment lines and leading blanks. More...
 
bool ignoreComments (std::istream &is)
 Ignores comment lines and blank lines from an input stream. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, bool &val)
 Extracts a boolean attribute value from the specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, int &val)
 Extracts an integer attribute value from the specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, char &val, bool useIntValue=true)
 Extracts a char attribute value from the specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, size_t &val)
 Extracts a size_t attribute value from the specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, Real &val)
 Extracts a real attribute value from the specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, Vec3 &val, int ncomp=0)
 Extracts a vector attribute value from the specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, std::vector< int > &val)
 Extracts an integer vector attribute from specified XML-element. More...
 
int getAttribute (const tinyxml2::XMLElement *xml, const char *att, std::string &val, bool toLower=false)
 Extracts a string attribute value from the specified XML-element. More...
 
const char * getValue (const tinyxml2::XMLNode *xml, const char *tag)
 Returns the value (if any) of the specified XML-node. More...
 
bool parseKnots (const tinyxml2::XMLNode *xml, std::vector< Real > &xi)
 Parses a sequence of knot values from the specified XML-node. More...
 
bool renumber (int &num, int &runner, IntMap &old2new)
 Transforms the integer value num into a unique range. More...
 
bool renumber (int &num, const IntMap &old2new, bool msg=false)
 Transforms the integer value num according to a given mapping. More...
 
int gather (const std::vector< int > &index, size_t nr, const std::vector< Real > &in, std::vector< Real > &out, size_t offset_in=0, size_t nskip=0)
 Compresses the rows of a 2D array based on given scatter indices. More...
 
int gather (const std::vector< int > &index, size_t nr, const std::vector< Real > &in, utl::matrix< Real > &out, size_t offset_in=0, size_t nskip=0)
 Compresses the rows of a 2D array based on given scatter indices. More...
 
int gather (const std::vector< int > &index, size_t ir, size_t nr, const std::vector< Real > &in, std::vector< Real > &out, size_t offset_in=0, int shift_idx=0, size_t nskip=0)
 Compresses a row of a 2D array based on given scatter indices. More...
 
void interleave (const std::vector< Real > &v1, const std::vector< Real > &v2, std::vector< Real > &out, size_t n1=1, size_t n2=1)
 Merges two arrays of nodal values into one array by interleaving. More...
 
size_t find_closest (const std::vector< Real > &a, Real v)
 Searches for a real value in an ordered array of reals. More...
 
std::string adjustRight (size_t width, const std::string &s, const std::string &suffix=" : ")
 Right-justifies the input string to the given total width.
 
std::set< int > getDigits (int value)
 Splits an integer into its (unique) digits in ascending order.
 
int getDirs (int ncmp)
 Makes a direction integer for given number of components.
 
IntMap::const_iterator findValue (const IntMap &iMap, int iVal)
 Returns a const iterator to the entry with value iVal.
 
int findKey (const IntMap &iMap, int iVal)
 Returns the key corresponding to the value iVal. More...
 
int findIndex (const std::vector< int > &iVec, int iVal)
 Returns the vector index corresponding to the value iVal. More...
 
void merge (std::vector< int > &a1, const std::vector< int > &a2)
 Merges integer array a2 into array a1. More...
 
void merge (std::vector< Real > &a1, const std::vector< Real > &a2, const std::vector< int > &k1, const std::vector< int > &k2)
 Merges real array a2 into array a1 based on array indices. More...
 
Real round (Real value, int pr)
 Rounds off value down to pr significant digits.
 

Variables

const char RETAIN = 2
 Flag for vector::resize() method telling it to retain its content.
 
double zero_print_tol = 1.0e-6
 Zero tolerance for printing numbers.
 
int nval_per_line = 6
 Number of values to print per line.
 
Profilerprofiler = nullptr
 Pointer to the one and only profiler object.
 

Detailed Description

General utility classes and functions.

Function Documentation

◆ detJacGradient()

void utl::detJacGradient ( const matrix< Real > &  J,
const matrix< Real > &  Ji,
const matrix3d< Real > &  H,
std::vector< Real > &  ddet 
)

Calculates the derivatives of determinant of the Jacobian.

Parameters
[in]JJacobian of the geometry mapping
[in]JiInverse jacobian of the geometry mapping
[in]HHessian of the geometry mapping wrt parameters
[out]ddetDerivatives of the determinant

References utl::matrix< T >::multiply(), Real, and utl::matrix< T >::rows().

Referenced by MxFiniteElement::piolaGradient().

◆ find_closest()

size_t utl::find_closest ( const std::vector< Real > &  a,
Real  v 
)

Searches for a real value in an ordered array of reals.

Parameters
[in]aThe array of real values
[in]vThe value to search for
Returns
0-based index of the closest array value.
Note
It is assumed that the array a is sorted in encreasing order on input. If this is not the case the method will deliver incorrect result.

Referenced by ASMs1DLag::evalPoint(), ASMs2DLag::evalPoint(), and ASMs3DLag::evalPoint().

◆ findIndex()

int utl::findIndex ( const std::vector< int > &  iVec,
int  iVal 
)

◆ findKey()

int utl::findKey ( const IntMap iMap,
int  iVal 
)

Returns the key corresponding to the value iVal.

If not in the map, the value iVal is returned.

References findValue().

Referenced by ASMbase::updateDirichlet().

◆ gather() [1/3]

int utl::gather ( const std::vector< int > &  index,
size_t  ir,
size_t  nr,
const std::vector< Real > &  in,
std::vector< Real > &  out,
size_t  offset_in = 0,
int  shift_idx = 0,
size_t  nskip = 0 
)

Compresses a row of a 2D array based on given scatter indices.

Parameters
[in]indexScatter indices of the columns that should be retained
[in]irIndex of the row to compress
[in]nrNumber of rows in the 2D array
[in]inThe input array stored column-wise in a 1D array
[out]outThe output array stored column-wise in a 1D array
[in]offset_inOptional start offset for the in vector
[in]shift_idxOptional constant shift in the scatter indices
[in]nskipIf nonzero, skip the last nskip entries in index

◆ gather() [2/3]

int utl::gather ( const std::vector< int > &  index,
size_t  nr,
const std::vector< Real > &  in,
std::vector< Real > &  out,
size_t  offset_in = 0,
size_t  nskip = 0 
)

◆ gather() [3/3]

int utl::gather ( const std::vector< int > &  index,
size_t  nr,
const std::vector< Real > &  in,
utl::matrix< Real > &  out,
size_t  offset_in = 0,
size_t  nskip = 0 
)

Compresses the rows of a 2D array based on given scatter indices.

Parameters
[in]indexScatter indices of the columns that should be retained
[in]nrNumber of rows in the 2D array
[in]inThe input array stored column-wise in a 1D array
[out]outThe output array stored as a 2D matrix
[in]offset_inOptional start offset for the in vector
[in]nskipIf nonzero, skip the last nskip entries in index

References utl::matrix< T >::fillColumn(), Real, and utl::matrix< T >::resize().

◆ getAttribute() [1/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
bool &  val 
)

Extracts a boolean attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
Returns
true if the attribute att is found in xml, otherwise false

Referenced by AnaSol::AnaSol(), MultiPatchModelGenerator1D::createG2(), MultiPatchModelGenerator2D::createG2(), DefaultGeometry1D::createG2(), DefaultGeometry2D::createG2(), MultiPatchModelGenerator3D::createG2(), DefaultGeometry3D::createG2(), MultiPatchModelGenerator1D::createGeometry(), MultiPatchModelGenerator2D::createGeometry(), MultiPatchModelGenerator3D::createGeometry(), ModelGenerator::createGeometry(), MultiPatchModelGenerator1D::MultiPatchModelGenerator1D(), MultiPatchModelGenerator2D::MultiPatchModelGenerator2D(), MultiPatchModelGenerator3D::MultiPatchModelGenerator3D(), DataExporter::OnControl(), SIMNodalConstraint< Dim >::parse(), SIMSolverTS< T1 >::parse(), HasGravityBase::parse(), AdaptiveSetup::parse(), EigenModeSIM::parse(), NewmarkSIM::parse(), NonLinSIM::parse(), SIM1D::parse(), SIM2D::parse(), SIMinput::parse(), SIMsupel::parse(), TimeStep::parse(), TextureProperties::parse(), SIMSemi3D< PlaneSolver >::parse(), SIMargsBase::parse(), SIM1D::parseBCTag(), SIM2D::parseBCTag(), SIM3D::parseBCTag(), SIMinput::parseBCTag(), SIMmultiCpl::parseConnection(), SIMoptions::parseConsoleTag(), SIMoptions::parseDiscretizationTag(), SIMinput::parseDualTag(), AnaSol::parseExpressionFunctions(), AnaSol::parseFieldFunctions(), SIM1D::parseGeometryTag(), SIM2D::parseGeometryTag(), SIM3D::parseGeometryTag(), SIMinput::parseICTag(), SIMCoupledSI< T1, T2 >::parseIterations(), parseKnots(), SIMinput::parseLinSolTag(), SIMinput::parseMaterialSet(), SIMinput::parseOutputTag(), SIMoptions::parseOutputTag(), SIMoutput::parseOutputTag(), SIMmodal::parseParams(), SIMinput::parsePatchList(), SIMinput::parsePeriodic(), SIMoptions::parseRestartTag(), SIMinput::parseTopologySet(), parseTracFunc(), LinSolParams::BlockParams::read(), ASM::readXML(), and ModelGenerator::topologySets().

◆ getAttribute() [2/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
char &  val,
bool  useIntValue = true 
)

Extracts a char attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
[in]useIntValueIf true, convert the value to an integer
Returns
true if the attribute att is found in xml, otherwise false

◆ getAttribute() [3/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
int &  val 
)

Extracts an integer attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
Returns
true if the attribute att is found in xml, otherwise false

◆ getAttribute() [4/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
Real val 
)

Extracts a real attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
Returns
true if the attribute att is found in xml, otherwise false

◆ getAttribute() [5/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
size_t &  val 
)

Extracts a size_t attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
Returns
true if the attribute att is found in xml, otherwise false

◆ getAttribute() [6/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
std::string &  val,
bool  toLower = false 
)

Extracts a string attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
[in]toLowerIf true, convert return string to lower case
Returns
true if the attribute att is found in xml, otherwise false

◆ getAttribute() [7/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
std::vector< int > &  val 
)

Extracts an integer vector attribute from specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
Returns
true if the attribute att is found in xml, otherwise false

References parseIntegers().

◆ getAttribute() [8/8]

int utl::getAttribute ( const tinyxml2::XMLElement *  xml,
const char *  att,
Vec3 val,
int  ncomp = 0 
)

Extracts a vector attribute value from the specified XML-element.

Parameters
[in]xmlPointer to XML-element to extract from
[in]attThe attribute tag
[out]valThe attribute value
[in]ncompMaximum number of components to read
Returns
true if the attribute att is found in xml, otherwise false

If fewer than ncomp components specified, use the last value for the rest. If ncomp is zero, use the value zero for the missing components, if any.

References Real, and Vec3::x.

◆ getGmat()

void utl::getGmat ( const matrix< Real > &  Ji,
const Real du,
matrix< Real > &  G 
)

Compute the stabilization matrix G from the Jacobian inverse.

Parameters
[in]JiThe inverse of the Jacobian matrix
[in]duElement lengths in each parametric direction
[out]GThe stabilization matrix (used in CFD simulators)

References utl::matrix< T >::cols(), Real, and utl::matrix< T >::resize().

Referenced by ASMs2D::integrate(), ASMs2Dmx::integrate(), ASMs3D::integrate(), ASMs3Dmx::integrate(), ASMu2D::integrate(), ASMu2Dmx::integrate(), ASMu3D::integrate(), and ASMu3Dmx::integrate().

◆ getValue()

const char * utl::getValue ( const tinyxml2::XMLNode *  xml,
const char *  tag 
)

Returns the value (if any) of the specified XML-node.

Parameters
[in]xmlPointer to XML-node to extract the value from
[in]tagThe name of the XML-element to extract the value from

This method accepts two alternative ways of specifying the value myValue :

<name>myValue</name> 

and

<name value="myValue"/> 

Referenced by SIMSolverTS< T1 >::parse(), AdaptiveSetup::parse(), EigenModeSIM::parse(), NewmarkSIM::parse(), NonLinSIM::parse(), SIMadmin::parse(), SIMoptions::parseEigSolTag(), SIMoptions::parseOutputTag(), SIMoutput::parseOutputTag(), LinSolParams::BlockParams::read(), and LinSolParams::read().

◆ Hessian()

bool utl::Hessian ( matrix3d< Real > &  H,
matrix3d< Real > &  d2NdX2,
const matrix< Real > &  Ji,
const matrix< Real > &  X,
const matrix3d< Real > &  d2Ndu2,
const matrix< Real > &  dNdX,
bool  geoMapping = true 
)

Set up the Hessian matrix of the coordinate mapping.

Parameters
[out]HThe Hessian matrix
[out]d2NdX2Second order derivatives of basis functions, w.r.t. X
[in]JiThe inverse of the Jacobian matrix
[in]XMatrix of element nodal coordinates
[in]d2Ndu2Second order derivatives of basis functions
[in]dNdXFirst order derivatives of basis functions
[in]geoMappingIf true, calculate geometry mapping
Returns
false if matrix dimensions are incompatible, otherwise true

If geoMapping is true, H is output, else H is input and assumed to be already calculated in a previous call.

References utl::matrixBase< T >::clear(), utl::matrix< T >::cols(), utl::matrixBase< T >::empty(), utl::matrix3d< T >::multiply(), PROFILE4, Real, utl::matrix3d< T >::resize(), and utl::matrix< T >::rows().

Referenced by SplineField::evalBasis(), LRSplineField::evalBasis(), SplineField::evalMapping(), LRSplineField::evalMapping(), ASMs2D::evalSolution(), ASMs3D::evalSolution(), ASMu2D::evalSolution(), ASMu3D::evalSolution(), ASMs1D::evalSolution(), MxFiniteElement::Hessian(), SplineFields1D::hessianFE(), ASMs1D::integrate(), ASMs2D::integrate(), ASMs3D::integrate(), ASMu2D::integrate(), and ASMu3D::integrate().

◆ Hessian2()

bool utl::Hessian2 ( matrix4d< Real > &  d3NdX3,
const matrix< Real > &  Ji,
const matrix4d< Real > &  d3Ndu3 
)

Set up third-order derivatives of the coordinate mapping.

Parameters
[out]d3NdX3Third order derivatives of basis functions, w.r.t. X
[in]JiThe inverse of the Jacobian matrix
[in]d3Ndu3Third order derivatives of basis functions
Returns
false if matrix dimensions are incompatible, otherwise true

References utl::matrix< T >::cols(), utl::matrixBase< T >::dim(), PROFILE4, utl::matrix4d< T >::resize(), and utl::matrix< T >::rows().

Referenced by ASMs2D::evalSolution(), ASMu2D::evalSolution(), ASMs1D::evalSolution(), ASMs1D::integrate(), ASMs2D::integrate(), and ASMu2D::integrate().

◆ ignoreComments()

bool utl::ignoreComments ( std::istream &  is)

Ignores comment lines and blank lines from an input stream.

Parameters
isFile stream to read from

◆ interleave()

void utl::interleave ( const std::vector< Real > &  v1,
const std::vector< Real > &  v2,
std::vector< Real > &  out,
size_t  n1 = 1,
size_t  n2 = 1 
)

Merges two arrays of nodal values into one array by interleaving.

Parameters
[in]v1The first array
[in]v2The second array
[out]outThe output array
[in]n1Number of entries per node in first array
[in]n2Number of entries per node in second array

Referenced by ASMu2D::regularInterpolation(), and ASMu3D::regularInterpolation().

◆ Jacobian() [1/3]

Real utl::Jacobian ( matrix< Real > &  J,
matrix< Real > &  dNdX,
const matrix< Real > &  X,
const matrix< Real > &  dNdu,
bool  computeGradient = true 
)

Set up the Jacobian matrix of the coordinate mapping.

Parameters
[out]JThe inverse of the Jacobian matrix
[out]dNdXFirst order derivatives of basis functions, w.r.t. X
[in]XMatrix of element nodal coordinates
[in]dNduFirst order derivatives of basis functions
[in]computeGradientIf false, skip calculation of dNdX
Returns
The Jacobian determinant

References utl::matrixBase< T >::clear(), utl::matrix< T >::cols(), epsZ, utl::matrix< T >::getColumn(), utl::matrix< T >::inverse(), Vec3::length(), utl::matrix< T >::multiply(), Real, and utl::matrix< T >::rows().

Referenced by ASMs1D::assembleL2matrices(), ASMs2DLag::assembleL2matrices(), ASMs3DLag::assembleL2matrices(), ASMu2D::assembleL2matrices(), ASMu3D::assembleL2matrices(), SplineField::evalMapping(), LRSplineField::evalMapping(), ASMs2DmxLag::evalSolution(), ASMs3DmxLag::evalSolution(), ASMs2DLag::evalSolution(), ASMs3DLag::evalSolution(), ASMs2DTri::evalSolution(), ASMs1DLag::evalSolution(), ASMs1DSpec::evalSolution(), ASMs2DSpec::evalSolution(), ASMs3DSpec::evalSolution(), ASMs2D::evalSolution(), ASMs3D::evalSolution(), ASMu2D::evalSolution(), ASMu3D::evalSolution(), ASMs1D::evalSolution(), ASMu2D::evaluateBasisNurbs(), LagrangeFields2D::gradFE(), LagrangeFields3D::gradFE(), SplineFields1D::gradFE(), LagrangeField3D::gradFE(), LagrangeField2D::gradFE(), SplineFields1D::hessianFE(), ASMs1D::integrate(), ASMs1DLag::integrate(), ASMs1DSpec::integrate(), ASMs2D::integrate(), ASMs2DSpec::integrate(), ASMs2DTri::integrate(), ASMs3D::integrate(), ASMs3DLag::integrate(), ASMs3DSpec::integrate(), ASMu2D::integrate(), ASMu3D::integrate(), ASMu3Dmx::integrate(), ASMs2DLag::integrate(), ASMs3D::integrateEdge(), ASMs3DLag::integrateEdge(), ASMs3DSpec::integrateEdge(), ASMs2DLag::integrateElm(), and MxFiniteElement::Jacobian().

◆ Jacobian() [2/3]

Real utl::Jacobian ( matrix< Real > &  J,
Vec3 n,
matrix< Real > &  dNdX,
const matrix< Real > &  X,
const matrix< Real > &  dNdu,
size_t  t1,
size_t  t2 
)

Set up the Jacobian matrix of the coordinate mapping on a boundary.

Parameters
[out]JThe inverse of the Jacobian matrix
[out]nOutward-directed unit normal vector on the boundary
[out]dNdX1st order derivatives of basis functions, w.r.t. X
[in]XMatrix of element nodal coordinates
[in]dNduFirst order derivatives of basis functions
[in]t1First parametric tangent direction of the boundary
[in]t2Second parametric tangent direction of the boundary
Returns
The surface/curve dilation of the boundary

References utl::matrixBase< T >::clear(), utl::matrix< T >::cols(), Vec3::cross(), epsZ, utl::matrix< T >::getColumn(), utl::matrix< T >::inverse(), utl::matrix< T >::multiply(), Vec3::normalize(), Real, and utl::matrix< T >::rows().

◆ Jacobian() [3/3]

Real utl::Jacobian ( matrix< Real > &  J,
Vec3 t,
matrix< Real > &  dNdX,
const matrix< Real > &  X,
const matrix< Real > &  dNdu,
size_t  tangent 
)

Set up the Jacobian matrix of the coordinate mapping along an edge.

Parameters
[out]JThe inverse of the Jacobian matrix
[out]tUnit tangent vector along the edge
[out]dNdX1st order derivatives of basis functions, w.r.t. X
[in]XMatrix of element nodal coordinates
[in]dNduFirst order derivatives of basis functions
[in]tangentParametric tangent direction along the edge
Returns
The curve dilation of the edge

References utl::matrixBase< T >::clear(), epsZ, utl::matrix< T >::getColumn(), utl::matrix< T >::inverse(), utl::matrix< T >::multiply(), Vec3::normalize(), and Real.

◆ JacobianGradient()

void utl::JacobianGradient ( const matrix< Real > &  dudX,
const matrix3d< Real > &  d2Xdu2,
std::vector< matrix< Real >> &  dJdX 
)

Calculates the derivatives of the Jacobian of the coordinate mapping.

Parameters
[in]dudXDerivatives of the geometry basis
[in]d2Xdu2Second order derivatives of the geometry basis
[out]dJdXDerivatives of the Jacobian wrt physical coordinates

References utl::matrix< T >::add(), utl::matrix< T >::resize(), and utl::matrix< T >::rows().

Referenced by MxFiniteElement::piolaGradient().

◆ merge() [1/2]

void utl::merge ( std::vector< int > &  a1,
const std::vector< int > &  a2 
)

Merges integer array a2 into array a1.

Does not require the arrays to be sorted. The values of a2 not already in a1 are appended to a1.

Referenced by ASMs2D::addInterfaceElms(), and ASMs2D::integrate().

◆ merge() [2/2]

void utl::merge ( std::vector< Real > &  a1,
const std::vector< Real > &  a2,
const std::vector< int > &  k1,
const std::vector< int > &  k2 
)

Merges real array a2 into array a1 based on array indices.

Does not require the arrays to be sorted. The values of a2 not already in a1 are appended to a1.

◆ operator*() [1/8]

Matrix utl::operator* ( const Matrix A,
const Matrix B 
)

Multiplication of two matrices.

Returns
\( {\bf C} = {\bf A} {\bf B} \)

References utl::matrix< T >::multiply().

◆ operator*() [2/8]

RealArray utl::operator* ( const Matrix A,
const Vector X 
)

Multiplication of a matrix and a vector.

Returns
\( {\bf Y} = {\bf A} {\bf X} \)

References utl::matrix< T >::multiply().

◆ operator*() [3/8]

Matrix utl::operator* ( const Matrix A,
Real  c 
)

Multiplication of a matrix and a scalar.

Returns
\( {\bf B} = c {\bf A} \)

References utl::matrix< T >::multiply().

◆ operator*() [4/8]

RealArray utl::operator* ( const Vector X,
const Matrix A 
)

Multiplication of a vector and a matrix.

Returns
\( {\bf Y} = {\bf A}^T {\bf X} \)

References utl::matrix< T >::multiply().

◆ operator*() [5/8]

Real utl::operator* ( const Vector X,
const Vector Y 
)
inline

Dot product of two vectors.

Returns
\( a = {\bf X}^T {\bf Y} \)

References utl::vector< T >::dot().

◆ operator*() [6/8]

Vector utl::operator* ( const Vector X,
Real  c 
)

Multiplication of a vector and a scalar.

Returns
\( {\bf Y} = c {\bf X} \)

◆ operator*() [7/8]

Matrix utl::operator* ( Real  c,
const Matrix A 
)
inline

Multiplication of a scalar and a matrix.

Returns
\( {\bf B} = c {\bf A} \)

◆ operator*() [8/8]

Vector utl::operator* ( Real  c,
const Vector X 
)
inline

Multiplication of a scalar and a vector.

Returns
\( {\bf Y} = c {\bf X} \)

◆ operator+()

Vector utl::operator+ ( const Vector X,
const Vector Y 
)

Addition of two vectors.

Returns
\( {\bf Z} = {\bf X} + {\bf Y} \)

References utl::vector< T >::add().

◆ operator-()

Vector utl::operator- ( const Vector X,
const Vector Y 
)

Subtraction of two vectors.

Returns
\( {\bf Z} = {\bf X} - {\bf Y} \)

References utl::vector< T >::add(), and Real.

◆ operator/()

Vector utl::operator/ ( const Vector X,
Real  d 
)
inline

Division of a vector by a scalar.

Returns
\( {\bf Y} = \frac{1}{d} {\bf X} \)

References Real.

◆ operator<<() [1/3]

template<class T >
std::ostream& utl::operator<< ( std::ostream &  s,
const matrix3d< T > &  A 
)

Print the 3D matrix A to the stream s.

The matrix is printed as a set of 2D sub-matrices based on the first two indices.

References utl::matrixBase< T >::dim(), utl::matrixBase< T >::empty(), utl::matrix< T >::fill(), utl::matrixBase< T >::ptr(), and utl::matrixBase< T >::size().

◆ operator<<() [2/3]

template<class T >
std::ostream& utl::operator<< ( std::ostream &  s,
const matrix4d< T > &  A 
)

Print the 4D matrix A to the stream s.

The matrix is printed as a set of 2D sub-matrices based on the first two indices.

References utl::matrixBase< T >::dim(), utl::matrixBase< T >::empty(), utl::matrix< T >::fill(), utl::matrixBase< T >::ptr(), and utl::matrixBase< T >::size().

◆ operator<<() [3/3]

template<class T >
std::ostream& utl::operator<< ( std::ostream &  s,
const matrix< T > &  A 
)

Print the matrix A to the stream s.

If the matrix is symmetric, only the upper triangular part of the matrix is printed, with the diagonal elements in the first column. The global variable zero_print_tol is used as a tolerance when checking whether the matrix is symmetric or not.

References utl::matrix< T >::cols(), utl::matrix< T >::isSymmetric(), utl::matrix< T >::rows(), trunc(), and zero_print_tol.

◆ parseExprRealFunc()

RealFunc * utl::parseExprRealFunc ( const std::string &  function,
bool  autodiff 
)

Creates a scalar-valued function by parsing a character string.

Parameters
[in]functionFunction expression
[in]autodiffIf true, auto-differentiation is enabled

The implementation of this method is in the file ExprFunctions.C for encapsulation of the autodiff package.

◆ parseExprVecFunc()

VecFunc * utl::parseExprVecFunc ( const std::string &  function,
bool  autodiff 
)

Creates a Vector-valued function by parsing a character string.

Parameters
[in]functionFunction expression
[in]autodiffIf true, auto-differentiation is enabled

The implementation of this method is in the file ExprFunctions.C for encapsulation of the autodiff package.

◆ parseIntegers()

bool utl::parseIntegers ( std::vector< int > &  values,
const char *  argv 
)

Parses a character string into an integer or an integer range.

Parameters
valuesThe integer value(s) is/are appended to this vector
[in]argvCharacter string with integer data

An integer range is recognised through the syntax i:j.

Referenced by getAttribute(), EigenModeSIM::parse(), ASMu1DLag::parseElemSet(), ASMu2DLag::parseElemSet(), ASMs1D::parseNodeSet(), ASMsupel::parseNodeSet(), and ASMu2DLag::parseNodeSet().

◆ parseIntFunc()

IntFunc * utl::parseIntFunc ( const std::string &  func,
const std::string &  type = "expression" 
)

Creates a scalar-valued int function by parsing a character string.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag

References IFEM::cout, utl::Function< Arg, Result >::evaluate(), and Real.

◆ parseKnots() [1/2]

bool utl::parseKnots ( const tinyxml2::XMLNode *  xml,
std::vector< Real > &  xi 
)

Parses a sequence of knot values from the specified XML-node.

Parameters
[in]xmlPointer to XML-node to extract from
xiThe knot value(s) is/are appended to this vector

References parseKnots().

◆ parseKnots() [2/2]

bool utl::parseKnots ( std::vector< Real > &  xi)

Parses a (possibly graded) sequence of knot values.

Parameters
xiThe knot value(s) is/are appended to this vector

The method uses the strtok function to parse a sequence of space-separated numbers and assumes that (at least one) call to strtok with the first argument different from nullptr has been made before invoking this method.

If the first character of the first token is a digit, it is assumed that the knot values are listed explicitly by the remaining tokens. Otherwise, various mesh grading schemes are assumed with the following syntax:

  • G n alpha xi1 xi2 - Geometric grading
  • B n alpha xi1 xi2 - Biased geometric grading
  • C n alpha xi1 xi2 - Centered geometric grading
  • C5 n X1 X2 xi1 xi2 - Centred grading based on a 5th order function

In each case the starting and ending knot values, xi1 and xi2, are optional. If not specified, 0.0 and 1.0 is assumed. The 4th scheme was proposed by Tymofiy Gerasimov 14.12.2016, and is described in the file mesh-grading-function.pdf located in the doc folder.

Referenced by SIM1D::parse(), SIM2D::parse(), SIM3D::parse(), SIM1D::parseGeometryTag(), SIM2D::parseGeometryTag(), SIM3D::parseGeometryTag(), and parseKnots().

◆ parseRealFunc() [1/2]

const RealFunc * utl::parseRealFunc ( char *  cline,
Real  A = Real(1),
bool  print = true 
)

Creates a scalar-valued function by parsing a character string.

The functions are assumed on the general form

\[ f({\bf X},t) = A * g({\bf X}) * h(t) \]

The character string cline is assumed to contain first the definition of the spatial function g( X ) and then the time function h(t). Either of the two components may be omitted, for creating a space-function constant in time, or a time function constant in space.

Note
This method invokes strtok() with nullptr as first argument, assuming the initial call with a non-null string has been performed outside.

References IFEM::cout, FieldFuncBase::FIXED_LEVEL, and Real.

Referenced by SIM1D::parse(), SIM2D::parse(), SIM3D::parse(), SIMinput::parse(), SIMinput::parseBCTag(), AnaSol::parseExpressionFunctions(), SIM2D::parseGeometryTag(), SIMoutput::parseOutputTag(), parseRealFunc(), parseTracFunc(), SIMinput::setInitialConditions(), and SIMinput::setNeumann().

◆ parseRealFunc() [2/2]

RealFunc * utl::parseRealFunc ( const std::string &  func,
const std::string &  type = "expression",
bool  print = true 
)

Creates a scalar-valued function by parsing a character string.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag
[in]printIf true, print function definition

References IFEM::cout, EvalFuncScalar< Scalar >::numError, parseRealFunc(), and Real.

◆ parseTensorFunc()

TensorFunc * utl::parseTensorFunc ( const std::string &  func,
const std::string &  type 
)

Creates a tensor-valued function by parsing a character string.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag

References FieldFuncBase::FIXED_LEVEL, and splitString().

Referenced by AnaSol::parseExpressionFunctions().

◆ parseTimeFunc()

ScalarFunc * utl::parseTimeFunc ( const char *  func,
const std::string &  type = "expression",
Real  eps = Real(1.0e-8) 
)

Creates a time function by parsing a character string.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag
[in]epsDomain increment for calculation of numerical derivative

References IFEM::cout.

Referenced by AdaptiveSetup::parse(), SIMCoupledSI< T1, T2 >::parseIterations(), and parseTracFunc().

◆ parseTracFunc() [1/2]

TractionFunc * utl::parseTracFunc ( const std::string &  func,
const std::string &  type = "expression",
int  dir = 0 
)

Creates a vector-valued function defining a surface traction.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag
[in]dirCoordinate direction of the traction (0=normal direction)

References IFEM::cout, parseRealFunc(), and Real.

Referenced by SIMinput::parseBCTag(), and SIMinput::setNeumann().

◆ parseTracFunc() [2/2]

TractionFunc * utl::parseTracFunc ( const tinyxml2::XMLElement *  elem)

Creates a vector-valued function defining a surface traction.

Parameters
[in]elemPointer to XML-element to parse function definition from

References IFEM::cout, getAttribute(), parseRealFunc(), parseTimeFunc(), and parseVecTimeFunc().

◆ parseVec()

bool utl::parseVec ( Vec3 value,
const char *  argv 
)

Parses a character string into a point vector.

Parameters
[out]valueThe parsed point vector
[in]argvCharacter string with data

References Real.

◆ parseVecFunc()

VecFunc * utl::parseVecFunc ( const std::string &  func,
const std::string &  type = "expression",
const std::string &  variables = "" 
)

Creates a vector-valued function by parsing a character string.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag
[in]variablesOptional variable definition for expression functions

References IFEM::cout, FieldFuncBase::FIXED_LEVEL, EvalFuncScalar< Scalar >::numError, and splitString().

Referenced by AnaSol::parseExpressionFunctions(), and SIMinput::setNeumann().

◆ parseVecTimeFunc()

VecTimeFunc * utl::parseVecTimeFunc ( const char *  func,
const std::string &  type 
)

Creates a vector-valued time function by parsing a char string.

Parameters
[in]funcCharacter string to parse function definition from
[in]typeFunction definition type flag

References IFEM::cout.

Referenced by parseTracFunc().

◆ Pascal()

size_t utl::Pascal ( int  p,
unsigned short int  nsd 
)

Returns the number of monomials in Pascal's triangle.

Parameters
[in]pPolynomial order (>= 0)
[in]nsdNumber of spatial dimensions (2 or 3)

Referenced by Pascal().

◆ readLine()

char * utl::readLine ( std::istream &  is)

Reads one line, ignoring comment lines and leading blanks.

The data read is kept in an internal static buffer.

Parameters
isFile stream to read from
Returns
Pointer to the static buffer containg the data read.

Referenced by AnaSol::AnaSol(), AdaptiveSetup::parse(), NonLinSIM::parse(), SIM1D::parse(), SIM2D::parse(), SIM3D::parse(), SIMinput::parse(), SIMoutput::parse(), TimeStep::parse(), SIMadmin::readFlat(), and ASM::readMatlab().

◆ renumber() [1/2]

bool utl::renumber ( int &  num,
const IntMap old2new,
bool  msg = false 
)

Transforms the integer value num according to a given mapping.

In this method the old2new mapping is not updated.

Parameters
numThe integer value to transform, updated value on output
[in]old2newMapping from old values to new values
[in]msgIf true, give error message if given value not found
Returns
true if num was found in the old2new mapping

◆ renumber() [2/2]

bool utl::renumber ( int &  num,
int &  runner,
IntMap old2new 
)

Transforms the integer value num into a unique range.

This method is invoked on a series of (non-unique) values. When a value that has not been encountered before is detected, it is transformed into runner+1 and runner is incremented.

Parameters
numThe integer value to transform, updated value on output
runnerThe last new value assigned
old2newMapping from old values to new values return true if the value of num changed

Referenced by DomainDecomposition::calcGlobalEqNumbers(), DomainDecomposition::calcGlobalNodeNumbers(), GlobalNodes::calcGlobalNodes(), ASMbase::renumberNodes(), and MPC::renumberNodes().

◆ solve()

bool utl::solve ( Matrix A,
RealArray b,
std::vector< int > *  iPivot = nullptr 
)

Solves the linear system of equations \( {\bf A x} = {\bf b} \).

If iPivot is null, the equation system is solved directly using DGESV from LAPACK. Otherwise, the matrix A is first LU-factorized using DGETRF (if iPivot[0] is zero), and then the equation system is solved using DGETRS. Therefore, it is possible to invoke this method several times to solve for more right-hand sides, if A and iPivot are retained between each call.

References utl::matrix< T >::cols(), dgesv_(), dgetrf_(), dgetrs_(), M, utl::matrixBase< T >::ptr(), Real, and utl::matrix< T >::rows().

◆ transform() [1/2]

bool utl::transform ( Matrix A,
const Matrix Tn 
)

Congruence transformation of a symmetric matrix.

Parameters
AThe matrix to be transformed
[in]TnNodal transformation matrix

The following matrix multiplication is performed by this function:

\[ {\bf A} = {\bf T}{\bf A}{\bf T}^T \]

where A is a full, symmetric matrix, and the transformation matrix T has the nodal sub-matrix Tn repeated on the diagonal and otherwise zero.

References utl::matrix< T >::cols(), utl::matrix< T >::fill(), K, M, Real, and utl::matrix< T >::rows().

Referenced by SIMsupel::recoverInternalDOFs(), and ASMsupel::transform().

◆ transform() [2/2]

bool utl::transform ( Vector V,
const Matrix Tn,
bool  transpose = false 
)

Congruence transformation of a vector.

Parameters
VThe vector to be transformed
[in]TnNodal transformation matrix
[in]transposeIf true, the transpose of Tn is used instead

The vector V is pre-multiplied with the transformation matrix T which has the nodal sub-matrix Tn (or its transpose) repeated on the diagonal and otherwise zero.

References utl::matrix< T >::cols(), utl::vector< T >::fill(), K, M, Real, utl::matrix< T >::rows(), and utl::vector< T >::size().

◆ trunc()

template<class T >
T utl::trunc ( v)
inline

Truncate a value to zero when it is less than a given threshold.

Used when printing matrices for easy comparison with other matrices when they contain terms that are numerically zero, except for some round-off noise. The value of the global variable zero_print_tol is used as a tolerance in this method.

References zero_print_tol.

Referenced by SIMoutput::dumpPrimSol(), SIMoutput::dumpResults(), SIMoutput::dumpSolution(), SIMoutput::dumpVector(), NewmarkSIM::initAcc(), operator<<(), SIMoutput::printNRforces(), SIMbase::printSolutionSummary(), SAM::printVector(), NewmarkSIM::solutionNorms(), SIMbase::systemModes(), writeMatlab(), and NonLinSIM::~NonLinSIM().