IFEM  90A354
Namespaces | Typedefs | Functions
Utilities.h File Reference

Various utility methods. More...

#include "matrix.h"
#include <map>
#include <set>
#include <string>
Include dependency graph for Utilities.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 utl
 General utility classes and functions.
 

Typedefs

using IntMap = std::map< int, int >
 Convenience type alias.
 

Functions

bool utl::parseIntegers (std::vector< int > &values, const char *argv)
 Parses a character string into an integer or an integer range. More...
 
bool utl::parseVec (Vec3 &value, const char *argv)
 Parses a character string into a point vector. More...
 
bool utl::parseKnots (std::vector< Real > &xi)
 Parses a (possibly graded) sequence of knot values. More...
 
char * utl::readLine (std::istream &is)
 Reads one line, ignoring comment lines and leading blanks. More...
 
bool utl::ignoreComments (std::istream &is)
 Ignores comment lines and blank lines from an input stream. More...
 
int utl::getAttribute (const tinyxml2::XMLElement *xml, const char *att, bool &val)
 Extracts a boolean attribute value from the specified XML-element. More...
 
int utl::getAttribute (const tinyxml2::XMLElement *xml, const char *att, int &val)
 Extracts an integer attribute value from the specified XML-element. More...
 
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. More...
 
int utl::getAttribute (const tinyxml2::XMLElement *xml, const char *att, size_t &val)
 Extracts a size_t attribute value from the specified XML-element. More...
 
int utl::getAttribute (const tinyxml2::XMLElement *xml, const char *att, Real &val)
 Extracts a real attribute value from the specified XML-element. More...
 
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. More...
 
int utl::getAttribute (const tinyxml2::XMLElement *xml, const char *att, std::vector< int > &val)
 Extracts an integer vector attribute from specified XML-element. More...
 
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. More...
 
const char * utl::getValue (const tinyxml2::XMLNode *xml, const char *tag)
 Returns the value (if any) of the specified XML-node. More...
 
bool utl::parseKnots (const tinyxml2::XMLNode *xml, std::vector< Real > &xi)
 Parses a sequence of knot values from the specified XML-node. More...
 
bool utl::renumber (int &num, int &runner, IntMap &old2new)
 Transforms the integer value num into a unique range. More...
 
bool utl::renumber (int &num, const IntMap &old2new, bool msg=false)
 Transforms the integer value num according to a given mapping. More...
 
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)
 Compresses the rows of a 2D array based on given scatter indices. More...
 
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. More...
 
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. More...
 
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. More...
 
size_t utl::find_closest (const std::vector< Real > &a, Real v)
 Searches for a real value in an ordered array of reals. More...
 
std::string utl::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 > utl::getDigits (int value)
 Splits an integer into its (unique) digits in ascending order.
 
int utl::getDirs (int ncmp)
 Makes a direction integer for given number of components.
 
IntMap::const_iterator utl::findValue (const IntMap &iMap, int iVal)
 Returns a const iterator to the entry with value iVal.
 
int utl::findKey (const IntMap &iMap, int iVal)
 Returns the key corresponding to the value iVal. More...
 
int utl::findIndex (const std::vector< int > &iVec, int iVal)
 Returns the vector index corresponding to the value iVal. More...
 
void utl::merge (std::vector< int > &a1, const std::vector< int > &a2)
 Merges integer array a2 into array a1. More...
 
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. More...
 
Real utl::round (Real value, int pr)
 Rounds off value down to pr significant digits.
 

Detailed Description

Various utility methods.

Date
May 29 2009
Author
Knut Morten Okstad / SINTEF