tk namespace

Toolkit declarations and definitions for general purpose utilities.

Namespaces

namespace ctr
Toolkit control, general purpose user input to internal data transfer.
namespace grm
Toolkit general purpose grammar definition.
namespace mkl
Toolkit, grammar definition for Intel's Math Kernel Library.
namespace random123
Toolkit, grammar definition for the Random123 library.
namespace rngsse
Toolkit, grammar definition for the RNGSSE library.
namespace zoltan
Interoperation with the Zoltan library, used for static mesh partitioning.

Classes

class Around
Helper class simplifying client code for iterating on entries surrounding entries via linked lists derived from unstructured mesh connectivity.
class ASCMeshReader
ASCMeshReader : tk::Reader.
class BiPDF
Joint bivariate PDF estimator.
class ChareStateCollector
template<typename... T>
class cmd_keywords
template<uint8_t Layout>
class Data
Zero-runtime-cost data-layout wrappers with type-based compile-time dispatch.
class DiagWriter
DiagWriter : tk::Writer.
class Exception
Basic exception class for producing file:func:line info + call trace.
class ExodusIIMeshReader
class ExodusIIMeshWriter
class FileParser
FileParser.
class GmshMeshReader
class GmshMeshWriter
class H5PartWriter
template<typename, typename = std::void_t<>>
struct HasFunction_expect_choices
Detect if a type defines function 'expect::choices()'.
template<typename, typename = std::void_t<>>
struct HasFunction_expect_description
Detect if a type defines function 'expect::description()'.
template<typename, typename = std::void_t<>>
struct HasTypedef_alias
Detect if a type defines type 'alias'.
template<typename, typename = std::void_t<>>
struct HasTypedef_code
Detect if a type defines type 'code'.
template<typename, typename = std::void_t<>>
struct HasVar_expect_lower
Detect if a type defines variable 'expect::lower'.
template<typename, typename = std::void_t<>>
struct HasVar_expect_upper
Detect if a type defines variable 'expect::upper'.
class HyperMeshReader
HyperMeshReader : tk::Reader.
template<bool Condition, typename Then, typename Else = void>
struct if_
Type selection: if_< Condition, Then, Else >::type.
class LBSwitch
class LinearMap
class MeshReader
class MeshWriter
Charm++ group used to output particle data to file in parallel.
class MKLRNG
MKL-based random number generator used polymorphically with tk::RNG.
class NetgenMeshReader
NetgenMeshReader : tk::Reader.
class NetgenMeshWriter
class Omega_h_MeshReader
template<class HostProxy>
class ParticleWriter
Charm++ group used to output particle data to file in parallel using H5Part and MPI-IO.
class PDFWriter
PDFWriter : Writer.
class Print
template<std::size_t N>
class Progress
class QuietCerr
template<class CBRNG>
class Random123
Random123-based random number generator used polymorphically with tk::RNG.
class Reader
class RNG
Random number generator.
class RNGPrint
RNGPrint : Print.
template<class State, typename SeqNumType, unsigned int(*)(State*) Generate>
class RNGSSE
RNGSSE-based random number generator used polymorphically with tk::RNG.
class RNGStack
Random number generator stack.
class SiloWriter
SiloWriter.
class Statistics
Statistics estimator.
class STLMesh
STLMesh.
class STLTxtMeshReader
STLTxtMeshReader : tk::Reader.
class StringParser
StringParser.
template<class List>
class TaggedTuple
Tagged tuple, allowing tag-based access.
class Timer
template<typename Enum>
class Toggle
Toggle is the base for an Option, doing generic searches.
class Tracker
Tracker advances Lagrangian particles in state space.
class TriPDF
Joint trivariate PDF estimator.
class TxtStatWriter
TxtStatWriter : tk::Writer.
class UniPDF
Univariate PDF estimator.
class UnsMesh
3D unstructured mesh class
class UnsMeshMap
Charm++ array map for initial placement of array elements using an unstructured grid.
class Writer

Enums

enum ErrCode { SUCCESS = EXIT_SUCCESS, FAILURE = EXIT_FAILURE }
Error codes for the OS (or whatever calls us)
enum Style { QUIET =0, VERBOSE =1 }
Output verbosity. C-style enum as this is used for template argument.
enum class ExoElemType: int { TET = 0, TRI = 1 }
enum class ExoWriter { CREATE, OPEN }
ExodusII writer constructor modes.
enum GmshElemType { LIN = 1, TRI = 2, TRI = 1, TET = 4, TET = 0, PNT = 15 }
Identifiers of supported Gmsh elements.
enum class GmshFileType { UNDEFINED = -1, ASCII = 0, BINARY = 1 }
Supported Gmsh mesh file types.
enum class MeshReaderType: uint8_t { GMSH =0, NETGEN, EXODUSII, HYPER, ASC, OMEGA_H }
Supported mesh readers.
enum class MeshWriterType: uint8_t { GMSH =0, NETGEN, EXODUSII }
Supported mesh writers.
enum class HeaderType: uint8_t { INCITER =0, RNGTEST, UNITTEST, MESHCONV, FILECONV, WALKER }
Executable types for which an ascii logo is available in tk::Print.
enum class Centering: uint8_t { NODE, ELEM }

Typedefs

template<class li, class lo>
using cartesian_product = brigand::reverse_fold<brigand::list<li, lo>, brigand::list<brigand::list<>>, brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::_2, brigand::defer<brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::parent<brigand::_1>, brigand::defer<brigand::bind<brigand::list, brigand::bind<brigand::push_front, brigand::_1, brigand::parent<brigand::_1>>>>>>>>>>
using ChareState = TaggedTuple<brigand::list<tag::ch, std::string, tag::id, int, tag::pe, int, tag::it, uint64_t, tag::fn, std::string, tag::time, tk::real>>
Chare state.
using Table = std::vector<std::pair<tk::real, tk::real>>
Type alias for declaring, defining, and storing a discrete y = f(x) function.
using real = double
Real number type used throughout the whole code.
using SiloErrorHandler = void(*)(char*)
Silo error handler function type.
using SolutionFn = std::function<std::vector<real>(ncomp_t, ncomp_t, real, real, real, real)>
using RiemannFluxFn = std::function<std::vector<real>(const std::array<real, 3>&, const std::array<std::vector<real>, 2>&, const std::vector<std::array<real, 3>>&)>
using FluxFn = std::function<std::vector<std::array<real, 3>>(ncomp_t, ncomp_t, const std::vector<real>&, const std::vector<std::array<real, 3>>&)>
using VelFn = std::function<std::vector<std::array<tk::real, 3>>(ncomp_t, ncomp_t, real, real, real)>
using StateFn = std::function<std::array<std::vector<real>, 2>(ncomp_t, ncomp_t, const std::vector<real>&, real, real, real, real, const std::array<tk::real, 3>&)>
using SrcFn = std::function<std::vector<tk::real>(ncomp_t, ncomp_t, real, real, real, real)>
using RNGFactory = std::map<ctr::RNGType, std::function<RNG()>>
Random number generator factory: keys associated to their constructors.

Functions

template<class Container>
void unique(Container& c)
template<class Container>
auto uniquecopy(const Container& src) -> Container
template<typename T>
auto extents(const std::vector<T>& vec) -> std::array<T, 2>
Return minimum and maximum values of a vector.
template<class T, class Allocator>
auto operator+=(std::vector<T, Allocator>& dst, const std::vector<T, Allocator>& src) -> std::vector<T, Allocator>&
Add all elements of a vector to another one.
template<class C1, class C2>
auto keyEqual(const C1& a, const C2& b) -> bool
template<class Container>
auto sumsize(const Container& c) -> std::size_t
template<class Container>
auto numunique(const Container& c) -> std::size_t
template<class Map>
auto sumvalsize(const Map& c) -> std::size_t
template<class Container>
void destroy(Container& c)
template<typename Container, typename Predicate>
void erase_if(Container& items, const Predicate& predicate)
template<uint8_t Layout>
auto operator*(tk::real lhs, const Data<Layout>& rhs) -> Data<Layout>
template<uint8_t Layout>
auto min(const Data<Layout>& a, const Data<Layout>& b) -> Data<Layout>
template<uint8_t Layout>
auto max(const Data<Layout>& a, const Data<Layout>& b) -> Data<Layout>
template<uint8_t Layout>
auto operator==(const Data<Layout>& lhs, const Data<Layout>& rhs) -> bool
template<uint8_t Layout>
auto operator!=(const Data<Layout>& lhs, const Data<Layout>& rhs) -> bool
template<uint8_t Layout>
auto maxdiff(const Data<Layout>& lhs, const Data<Layout>& rhs) -> std::pair<std::size_t, tk::real>
template<class C, class Key, class Factory, typename... ConstructorArgs>
void record(Factory& f, const Key& key, ConstructorArgs&&... args)
template<class Factory, class Key, class Obj = typename std::remove_pointer< typename Factory::mapped_type::result_type>::type>
auto instantiate(const Factory& f, const Key& key) -> std::unique_ptr<Obj>
template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void recordModel(Factory& f, const Key& key, ModelConstrArgs&&... args)
template<class Host, class ModelConstructor, class Factory, class Key, typename ModelConstrArg>
void recordModelLate(Factory& f, const Key& key, ModelConstrArg)
template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void recordCharmModel(Factory& f, const Key& key, ModelConstrArgs&&... args)
template<typename A, typename B>
auto flip_pair(const std::pair<A, B>& p) -> std::pair<B, A>
template<typename A, typename B>
auto flip_map(const std::map<A, B>& src) -> std::multimap<B, A>
template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
auto serialize(const std::unordered_map<Key, T, Hash, Eq>& m) -> std::pair<int, std::unique_ptr<char[]>>
template<class T>
void concat(const std::vector<T>& src, std::vector<T>& dst)
template<class T>
void concat(const std::vector<std::pair<bool, T>>& src, std::vector<std::pair<bool, T>>& dst)
template<class Key, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
void concat(const std::unordered_set<Key, Hash, Eq>& src, std::unordered_set<Key, Hash, Eq>& dst)
template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
auto mergeHashMap(int nmsg, CkReductionMsg** msgs) -> CkReductionMsg*
Charm++ custom reducer for merging std::unordered_maps during reduction across PEs.
auto linearLoadDistributor(real virtualization, uint64_t load, int npe, uint64_t& chunksize, uint64_t& remainder) -> uint64_t
Compute linear load distribution for given total work and virtualization.
void rm(const std::string& file)
Remove file from file system.
void signalHandler(int signum)
Signal handler for multiple signals, SIGABRT, SIGSEGV, etc.
auto setSignalHandlers() -> int
Set signal handlers for multiple signals, SIGABRT, SIGSEGV, etc.
void processExceptionCharm()
Process an exception from the Charm++ runtime system.
template<typename T>
auto swap_endian(T u) -> T
template<>
auto swap_endian(double u) -> double
template<typename T, typename Ch, typename Tr>
auto operator<<(std::basic_ostream<Ch, Tr>& os, const T& e) -> std::basic_ostream<Ch, Tr>&
template<typename T, typename Ch, typename Tr>
auto operator<<(std::basic_string<Ch, Tr>& lhs, const T& e) -> std::basic_string<Ch, Tr>
template<typename T, typename Ch, typename Tr>
auto operator<<(std::basic_string<Ch, Tr>&& lhs, const T& e) -> std::basic_string<Ch, Tr>
auto splitLines(std::string str, std::string indent, const std::string& name = "", std::size_t width = 80) -> std::string
Clean up whitespaces and format a long string into multiple lines.
auto sample(tk::real x, const tk::Table& table) -> tk::real
Sample a discrete y = f(x) function at x.
auto hms(tk::real stamp) -> Timer::Watch
Convert existing time stamp as a real to Watch (global scope)
auto cross(const std::array<real, 3>& v1, const std::array<real, 3>& v2) -> std::array<real, 3>
Compute the cross-product of two vectors.
auto crossdiv(const std::array<real, 3>& v1, const std::array<real, 3>& v2, real j) -> std::array<real, 3>
Compute the cross-product of two vectors divided by a scalar.
auto dot(const std::array<real, 3>& v1, const std::array<real, 3>& v2) -> real
Compute the dot-product of two vectors.
auto triple(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3) -> real
Compute the triple-product of three vectors.
auto rotateX(const std::array<real, 3>& v, real angle) -> std::array<real, 3>
Rotate vector about X axis.
auto rotateY(const std::array<real, 3>& v, real angle) -> std::array<real, 3>
Rotate vector about Y axis.
auto rotateZ(const std::array<real, 3>& v, real angle) -> std::array<real, 3>
Rotate vector about Z axis.
auto Jacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4) -> real
Compute the determinant of the Jacobian of a coordinate transformation over a tetrahedron.
auto inverseJacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4) -> std::array<std::array<real, 3>, 3>
Compute the inverse of the Jacobian of a coordinate transformation over a tetrahedron.
auto determinant(const std::array<std::array<tk::real, 3>, 3>& a) -> tk::real
Compute the determinant of 3x3 matrix.
auto cramer(const std::array<std::array<tk::real, 3>, 3>& a, const std::array<tk::real, 3>& b) -> std::array<tk::real, 3>
Solve a 3x3 system of equations using Cramer's rule.
auto detectInput(const std::string& filename) -> MeshReaderType
Detect input mesh file type.
auto pickOutput(const std::string& filename) -> MeshWriterType
Determine output mesh file type.
auto readUnsMesh(const tk::Print& print, const std::string& filename, std::pair<std::string, tk::real>& timestamp) -> UnsMesh
Read unstructured mesh from file.
auto writeUnsMesh(const tk::Print& print, const std::string& filename, UnsMesh& mesh, bool reorder) -> std::vector<std::pair<std::string, tk::real>>
Write unstructured mesh to file.
void SiloError(char* msg)
Silo error handler.
static auto workdir() -> std::string
auto curtime() -> std::string
Wrapper for the standard C library's gettimeofday() from.
void echoHeader(const Print& print, HeaderType header)
Echo program header.
void echoBuildEnv(const Print& print, const std::string& executable)
Echo build environment.
void echoRunEnv(const Print& print, int argc, char** argv, bool verbose, bool quiescence, bool charestate, bool trace)
Echo runtime environment.
template<class Driver, class Printer, class CmdLine>
auto Main(int argc, char* argv[], const CmdLine& cmdline, HeaderType header, const std::string& executable, const Printer& print) -> Driver
Generic Main() used for all executables for code-reuse and a uniform output.
template<class MainProxy, class CmdLine>
void MainCtor(MainProxy& mp, const MainProxy& thisProxy, std::vector<tk::Timer>& timer, const CmdLine& cmdline, const CkCallback& quiescenceTarget)
template<class CmdLine>
void dumpstate(const CmdLine& cmdline, const tk::Print& print, CkReductionMsg* msg)
template<class CmdLine>
void finalize(const CmdLine& cmdline, const std::vector<tk::Timer>& timer, const tk::Print& print, tk::CProxy_ChareStateCollector& state, std::vector<std::pair<std::string, tk::Timer::Watch>>& timestamp, const CkCallback& dumpstateTarget, bool clean = true)
auto npoin_in_graph(const std::vector<std::size_t>& inpoel) -> std::size_t
Compute number of points (nodes) in mesh from connectivity.
auto genEsup(const std::vector<std::size_t>& inpoel, std::size_t nnpe) -> std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
Generate derived data structure, elements surrounding points.
auto genPsup(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
Generate derived data structure, points surrounding points.
auto genEdsup(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
Generate derived data structure, edges surrounding points.
auto genInpoed(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::vector<std::size_t>
Generate derived data structure, edge connectivity.
auto genEsupel(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
Generate derived data structure, elements surrounding points of elements.
auto genEsuel(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
Generate derived data structure, elements surrounding elements.
auto genInedel(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::vector<std::size_t>& inpoed) -> std::vector<std::size_t>
Generate derived data structure, edges of elements.
auto genEsued(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
Generate derived data structure, elements surrounding edges.
auto genNbfacTet(std::size_t tnbfac, const std::vector<std::size_t>& inpoel, const std::vector<std::size_t>& triinpoel_complete, const std::map<int, std::vector<std::size_t>>& bface_complete, const std::unordered_map<std::size_t, std::size_t>& lid, std::vector<std::size_t>& triinpoel, std::map<int, std::vector<std::size_t>>& bface) -> std::size_t
Generate total number of boundary faces in this chunk.
auto genEsuelTet(const std::vector<std::size_t>& inpoel, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::vector<int>
Generate derived data structure, elements surrounding elements as a fixed length data structure as a full vector, including boundary elements as -1.
auto genNipfac(std::size_t nfpe, std::size_t nbfac, const std::vector<int>& esuelTet) -> std::size_t
Generate number of internal and physical-boundary faces.
auto genEsuf(std::size_t nfpe, std::size_t nipfac, std::size_t nbfac, const std::vector<std::size_t>& belem, const std::vector<int>& esuelTet) -> std::vector<int>
Generate derived data structure, elements surrounding faces.
auto genInpofaTet(std::size_t nipfac, std::size_t nbfac, const std::vector<std::size_t>& inpoel, const std::vector<std::size_t>& triinpoel, const std::vector<int>& esuelTet) -> std::vector<std::size_t>
Generate derived data structure, node-face connectivity.
auto genBelemTet(std::size_t nbfac, const std::vector<std::size_t>& inpofa, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup) -> std::vector<std::size_t>
Generate derived data structure, host/boundary element.
auto genGeoFaceTri(std::size_t nipfac, const std::vector<std::size_t>& inpofa, const tk::UnsMesh::Coords& coord) -> tk::Fields
Generate derived data structure, face geometry.
auto normal(const std::array<tk::real, 3>& x, const std::array<tk::real, 3>& y, const std::array<tk::real, 3>& z) -> std::array<tk::real, 3>
Compute the unit normal vector of a triangle.
auto geoFaceTri(const std::array<tk::real, 3>& x, const std::array<tk::real, 3>& y, const std::array<tk::real, 3>& z) -> tk::Fields
Compute geometry of the face given by three vertices.
auto genGeoElemTet(const std::vector<std::size_t>& inpoel, const tk::UnsMesh::Coords& coord) -> tk::Fields
Generate derived data structure, element geometry.
auto leakyPartition(const std::vector<int>& esueltet, const std::vector<std::size_t>& inpoel, const tk::UnsMesh::Coords& coord) -> bool
Perform leak-test on mesh (partition)
auto conforming(const std::vector<std::size_t>& inpoel, const tk::UnsMesh::Coords& coord, bool cerr) -> bool
Check if mesh (partition) is conforming.
auto nodegrad(std::size_t node, const std::array<std::vector<tk::real>, 3>& coord, const std::vector<std::size_t>& inpoel, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup, const tk::Fields& U, ncomp_t c) -> std::array<tk::real, 3>
Compute gradient at a mesh node.
auto edgegrad(std::size_t edge, const std::array<std::vector<tk::real>, 3>& coord, const std::vector<std::size_t>& inpoel, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esued, const tk::Fields& U, ncomp_t c) -> std::array<tk::real, 3>
Compute gradient at a mesh edge.
auto shiftToZero(std::vector<std::size_t>& inpoel) -> std::size_t
Shift node IDs to start with zero in element connectivity.
void remap(std::vector<std::size_t>& ids, const std::vector<std::size_t>& map)
Apply new mapping to vector of indices.
void remap(std::vector<tk::real>& r, const std::vector<std::size_t>& map)
Apply new mapping to vector of real numbers.
auto remap(const std::vector<std::size_t>& ids, const std::vector<std::size_t>& map) -> std::vector<std::size_t>
Create remapped vector of indices using a vector.
void remap(std::vector<std::size_t>& ids, const std::unordered_map<std::size_t, std::size_t>& map)
In-place remap vector of indices using a map.
auto remap(const std::vector<std::size_t>& ids, const std::unordered_map<std::size_t, std::size_t>& map) -> std::vector<std::size_t>
Create remapped vector of indices using a map.
auto remap(const std::map<int, std::vector<std::size_t>>& ids, const std::unordered_map<std::size_t, std::size_t>& map) -> std::map<int, std::vector<std::size_t>>
Create remapped map of vector of indices using a map.
auto renumber(const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& psup) -> std::vector<std::size_t>
Reorder mesh points with the advancing front technique.
auto assignLid(const std::vector<std::size_t>& gid) -> std::unordered_map<std::size_t, std::size_t>
Assign local ids to global ids.
auto global2local(const std::vector<std::size_t>& ginpoel) -> std::tuple<std::vector<std::size_t>, std::vector<std::size_t>, std::unordered_map<std::size_t, std::size_t>>
Generate element connectivity of local node IDs from connectivity of global node IDs also returning the mapping between local to global IDs.
auto positiveJacobians(const std::vector<std::size_t>& inpoel, const std::array<std::vector<real>, 3>& coord) -> bool
Test positivity of the Jacobian for all cells in a mesh.
auto eval_gp(const std::size_t igp, const std::array<std::array<tk::real, 3>, 3>& coordfa, const std::array<std::vector<tk::real>, 2>& coordgp) -> std::array<tk::real, 3>
Compute the coordinates of quadrature points for face integral.
auto eval_gp(const std::size_t igp, const std::array<std::array<tk::real, 3>, 4>& coord, const std::array<std::vector<tk::real>, 3>& coordgp) -> std::array<tk::real, 3>
Compute the coordinates of quadrature points for volume integral.
auto eval_dBdx_p1(const std::size_t ndof, const std::array<std::array<tk::real, 3>, 3>& jacInv) -> std::array<std::vector<tk::real>, 3>
Compute the derivatives of basis function for DG(P1)
void eval_dBdx_p2(const std::size_t igp, const std::array<std::vector<tk::real>, 3>& coordgp, const std::array<std::array<tk::real, 3>, 3>& jacInv, std::array<std::vector<tk::real>, 3>& dBdx)
Compute the derivatives of basis function for DG(P2)
auto eval_basis(const std::size_t ndof, const tk::real xi, const tk::real eta, const tk::real zeta) -> std::vector<tk::real>
Compute the Dubiner basis functions.
auto eval_state(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const std::size_t e, const Fields& U, const std::vector<tk::real>& B) -> std::vector<tk::real>
Compute the state variables for the tetrahedron element.
void bndSurfInt(ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<bcconf_t>& bcconfig, const inciter::FaceData& fd, const Fields& geoFace, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, real t, const RiemannFluxFn& flux, const VelFn& vel, const StateFn& state, const Fields& U, const Fields& P, const std::vector<std::size_t>& ndofel, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)
Compute boundary surface flux integrals for a given boundary type for DG.
void update_rhs_bc(ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_l, const tk::real wt, const std::array<tk::real, 3>& fn, const std::size_t el, const std::vector<tk::real>& fl, const std::vector<tk::real>& B_l, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)
Update the rhs by adding the boundary surface integration term.
void initialize(ncomp_t system, ncomp_t ncomp, ncomp_t offset, const Fields& L, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const SolutionFn& solution, Fields& unk, real t, const std::size_t nielem)
void update_rhs(ncomp_t ncomp, const std::size_t ndof, const tk::real wt, const std::vector<tk::real>& B, const std::vector<tk::real>& s, std::vector<tk::real>& R)
Update the rhs by adding the initial analytical solution term.
void eval_init(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::size_t e, const std::vector<tk::real>& R, const Fields& L, Fields& unk)
Compute the initial conditions.
void mass(ncomp_t ncomp, ncomp_t offset, const Fields& geoElem, Fields& l)
Compute the block-diagnoal mass matrix for DG.
void nonConservativeInt(] ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const Fields& U, const std::vector<std::vector<tk::real>>& riemannDeriv, const std::vector<std::size_t>& ndofel, Fields& R)
void update_rhs_ncn(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, ] const std::size_t ndof_el, const tk::real wt, const std::size_t e, ] const std::array<std::vector<tk::real>, 3>& dBdx, const std::vector<tk::real>& ncf, Fields& R)
void nonConservativeInt(ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const Fields& U, const std::vector<std::vector<tk::real>>& riemannDeriv, const std::vector<std::size_t>& ndofel, Fields& R)
Compute volume integrals of non-conservative terms for multi-material DG.
void update_rhs_ncn(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const tk::real wt, const std::size_t e, const std::array<std::vector<tk::real>, 3>& dBdx, const std::vector<tk::real>& ncf, Fields& R)
Update the rhs by adding the non-conservative term integrals.
auto NGvol(const std::size_t ndof) -> std::size_t constexpr
auto NGfa(const std::size_t ndof) -> std::size_t constexpr
auto NGdiag(const std::size_t ndof) -> std::size_t constexpr
Initialization of number of Gauss points for volume integration in error estimation.
auto NGinit(const std::size_t ndof) -> std::size_t constexpr
Initialization of number of Gauss points for volume integration in DG initialization.
void GaussQuadratureTet(std::size_t NG, std::array<std::vector<real>, 3>& coordgp, std::vector<real>& wgp)
Initialize Gaussian quadrature points locations and weights for a tetrahedron.
void GaussQuadratureTri(std::size_t NG, std::array<std::vector<real>, 2>& coordgp, std::vector<real>& wgp)
Initialize Gaussian quadrature points locations and weights for a triangle.
void srcInt(ncomp_t system, ncomp_t ncomp, ncomp_t offset, real t, const std::size_t ndof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const SrcFn& src, const std::vector<std::size_t>& ndofel, Fields& R)
Compute source term integrals for DG.
void update_rhs(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const tk::real wt, const std::size_t e, const std::vector<tk::real>& B, const std::vector<tk::real>& s, Fields& R)
Update the rhs by adding the source term integrals.
void surfInt(ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const inciter::FaceData& fd, const Fields& geoFace, const RiemannFluxFn& flux, const VelFn& vel, const Fields& U, const Fields& P, const std::vector<std::size_t>& ndofel, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)
Compute internal surface flux integrals for DG.
void update_rhs_fa(ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_l, const std::size_t ndof_r, const tk::real wt, const std::array<tk::real, 3>& fn, const std::size_t el, const std::size_t er, const std::vector<tk::real>& fl, const std::vector<tk::real>& B_l, const std::vector<tk::real>& B_r, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)
void volInt(ncomp_t system, ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const FluxFn& flux, const VelFn& vel, const Fields& U, const std::vector<std::size_t>& ndofel, Fields& R)
Compute volume integrals for DG.
void update_rhs(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const tk::real wt, const std::size_t e, const std::array<std::vector<tk::real>, 3>& dBdx, const std::vector<std::array<tk::real, 3>>& fl, Fields& R)
Update the rhs by adding the source term integrals.
void intLeastSq_P0P1(ncomp_t ncomp, ncomp_t offset, const std::size_t rdof, const inciter::FaceData& fd, const Fields& geoElem, const Fields& U, std::vector<std::array<std::array<real, 3>, 3>>& lhs_ls, std::vector<std::vector<std::array<real, 3>>>& rhs_ls)
Compute internal surface contributions to the least-squares reconstruction.
void bndLeastSq_P0P1(ncomp_t system, ncomp_t ncomp, ncomp_t offset, std::size_t rdof, const std::vector<bcconf_t>& bcconfig, const inciter::FaceData& fd, const Fields& geoFace, const Fields& geoElem, real t, const StateFn& state, const Fields& U, std::vector<std::array<std::array<real, 3>, 3>>& lhs_ls, std::vector<std::vector<std::array<real, 3>>>& rhs_ls, std::size_t nprim = 0)
Compute boundary face contributions to the least-squares reconstruction.
void solveLeastSq_P0P1(ncomp_t ncomp, ncomp_t offset, const std::size_t rdof, const std::vector<std::array<std::array<real, 3>, 3>>& lhs, const std::vector<std::vector<std::array<real, 3>>>& rhs, Fields& U)
Solve 3x3 system for least-squares reconstruction.
void transform_P0P1(ncomp_t ncomp, ncomp_t offset, std::size_t rdof, std::size_t nelem, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, Fields& U)
Transform the reconstructed P1-derivatives to the Dubiner dofs.
void getMultiMatPrimitives_P0P1(ncomp_t offset, std::size_t nmat, std::size_t rdof, std::size_t nelem, const Fields& U, Fields& P)
Reconstruct the vector of high-order primitives.
auto serialize(const std::vector<tk::UniPDF>& u) -> std::pair<int, std::unique_ptr<char[]>>
Serialize univariate PDF to raw memory stream.
auto mergeUniPDFs(int nmsg, CkReductionMsg** msgs) -> CkReductionMsg*
Charm++ custom reducer for merging a univariate PDF during reduction across PEs.
auto serialize(const std::vector<tk::UniPDF>& u, const std::vector<tk::BiPDF>& b, const std::vector<tk::TriPDF>& t) -> std::pair<int, std::unique_ptr<char[]>>
Serialize vectors of PDFs to raw memory stream.
auto mergePDF(int nmsg, CkReductionMsg** msgs) -> CkReductionMsg*
Charm++ custom reducer for merging PDFs during reduction across PEs.
static auto operator<<(std::ostream& os, const tk::UniPDF& p) -> std::ostream&

Variables

const uint8_t UnkEqComp
Tags for selecting data layout policies.
const std::array<std::size_t, 2> ExoNnpe
const std::array<std::array<std::size_t, 3>, 4> expofa
const std::array<UnsMesh::Face, 4> lpofa
static highwayhash::HH_U64 hh_key constexpr
static std::stringstream cerr_quiet
std::tringstream used to quiet std::cerr's stream by redirecting to it
static std::streambuf* cerr_old
std::streambuf used to store state of std::cerr before redirecting it

Enum documentation

enum tk::ErrCode

Error codes for the OS (or whatever calls us)

Enumerators
SUCCESS

Everything went fine.

FAILURE

Exceptions occurred.

enum class tk::ExoElemType: int

Supported ExodusII mesh cell types

Enumerators
TET
TRI

enum class tk::Centering: uint8_t

Mesh/scheme centering types

Enumerators
NODE
ELEM

Typedef documentation

template<class li, class lo>
using tk::cartesian_product = brigand::reverse_fold<brigand::list<li, lo>, brigand::list<brigand::list<>>, brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::_2, brigand::defer<brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::parent<brigand::_1>, brigand::defer<brigand::bind<brigand::list, brigand::bind<brigand::push_front, brigand::_1, brigand::parent<brigand::_1>>>>>>>>>>

Cartesian product of two brigand lists

using tk::SolutionFn = std::function<std::vector<real>(ncomp_t, ncomp_t, real, real, real, real)>

Function prototype for Problem::solution() functions

Functions of this type are used to evaluate known (e.g., analytical) solutions or setting initial conditions

using tk::RiemannFluxFn = std::function<std::vector<real>(const std::array<real, 3>&, const std::array<std::vector<real>, 2>&, const std::vector<std::array<real, 3>>&)>

Function prototype for Riemann flux functions

Functions of this type are used to compute numerical fluxes across a surface using a Riemann solver

using tk::FluxFn = std::function<std::vector<std::array<real, 3>>(ncomp_t, ncomp_t, const std::vector<real>&, const std::vector<std::array<real, 3>>&)>

Function prototype for flux vector functions

Functions of this type are used to compute physical flux functions in the PDEs being solved. These are different than the RiemannFluxFn because they compute the actual flux functions, not the solution to a Riemann problem.

using tk::VelFn = std::function<std::vector<std::array<tk::real, 3>>(ncomp_t, ncomp_t, real, real, real)>

Function prototype for evaluating a prescribed velocity field

Functions of this type are used to prescribe known velocity fields

using tk::StateFn = std::function<std::array<std::vector<real>, 2>(ncomp_t, ncomp_t, const std::vector<real>&, real, real, real, real, const std::array<tk::real, 3>&)>

Function prototype for physical boundary states

Functions of this type are used to provide the left and right states of boundary faces along physical boundaries

using tk::SrcFn = std::function<std::vector<tk::real>(ncomp_t, ncomp_t, real, real, real, real)>

Function prototype for evaluating a source term for a system of PDEs

Functions of this type are used to evaluate an arbitrary source term specialized to a particular problem, e.g., derived using the method of manufactured solutions, and specialized to a particular system of PDEs

Function documentation

template<class Container>
void tk::unique(Container& c)

Parameters
in/out Container

Make elements of container unique (in-place, overwriting source container)

template<class Container>
Container tk::uniquecopy(const Container& src)

Parameters
src in Container
Returns Container containing only unique elements compared to src

Make elements of container unique (on a copy, leaving the source as is)

template<typename T>
std::array<T, 2> tk::extents(const std::vector<T>& vec)

Return minimum and maximum values of a vector.

Parameters
vec in Vector whose extents to compute
Returns Array of two values with the minimum and maximum values

template<class T, class Allocator>
std::vector<T, Allocator>& tk::operator+=(std::vector<T, Allocator>& dst, const std::vector<T, Allocator>& src)

Add all elements of a vector to another one.

Parameters
dst in/out Destination vector, i.e., left-hand side of v1 += v2
src in Source vector, i.e., righ-hand side of v1 += v2
Returns Destination containing v1[0] += v2[0], v1[1] += v2[1], ...

If src.size() > dst.size() will grow dst to that of src.size() padding with zeros.

template<class C1, class C2>
bool tk::keyEqual(const C1& a, const C2& b)

Parameters
in 1st container to compare
in 2nd container to compare
Returns True if the containers have the same size and all keys (and only the keys) of the two containers are equal

Test if all keys of two associative containers are equal

template<class Container>
std::size_t tk::sumsize(const Container& c)

Parameters
in Container of containers
Returns Sum of the sizes of the containers of the container

Compute the sum of the sizes of a container of containers

template<class Container>
std::size_t tk::numunique(const Container& c)

Parameters
in Container of containers
Returns Number of unique values in a container of containers

Compute the number of unique values in a container of containers

template<class Map>
std::size_t tk::sumvalsize(const Map& c)

Template parameters
Map Container of containers type
Parameters
in Container of containers
Returns Sum of the sizes of the values of the associative container

Compute the sum of the sizes of the values of an associative container

template<class Container>
void tk::destroy(Container& c)

Parameters
in Container defining a swap() member function

Free memory of a container See http://stackoverflow.com/a/10465032 as to why this is done with the swap() member function of the container.

template<typename Container, typename Predicate>
void tk::erase_if(Container& items, const Predicate& predicate)

Template parameters
Container Type of container to remove from
Predicate Type for functor defining the predicate
Parameters
items Container object to remove from
predicate Predicate object instance to use

Remove items from container based on predicate

template<uint8_t Layout>
Data<Layout> tk::operator*(tk::real lhs, const Data<Layout>& rhs)

Parameters
lhs in Scalar to multiply with
rhs in Date object to multiply
Returns New Data object with all items multipled with lhs

Operator * multiplying all items by a scalar from the left

template<uint8_t Layout>
Data<Layout> tk::min(const Data<Layout>& a, const Data<Layout>& b)

Parameters
in 1st Data object
in 2nd Data object
Returns New Data object containing the minimum of all values for each value in a and b

Operator min between two Data objects

template<uint8_t Layout>
Data<Layout> tk::max(const Data<Layout>& a, const Data<Layout>& b)

Parameters
in 1st Data object
in 2nd Data object
Returns New Data object containing the maximum of all values for each value in a and b

Operator max between two Data objects

template<uint8_t Layout>
bool tk::operator==(const Data<Layout>& lhs, const Data<Layout>& rhs)

Parameters
lhs in Data object to compare
rhs in Data object to compare
Returns True if all entries are equal up to epsilon

Operator == between two Data objects

template<uint8_t Layout>
bool tk::operator!=(const Data<Layout>& lhs, const Data<Layout>& rhs)

Parameters
lhs in Data object to compare
rhs in Data object to compare
Returns True if all entries are unequal up to epsilon

Operator != between two Data objects

template<uint8_t Layout>
std::pair<std::size_t, tk::real> tk::maxdiff(const Data<Layout>& lhs, const Data<Layout>& rhs)

Parameters
lhs in 1st Data object
rhs in 2nd Data object
Returns The index, i.e., the raw position, of and the largest absolute value of the difference between all corresponding elements of lhs and rhs.

Compute the maximum difference between the elements of two Data objects The position returned is the position in the underlying raw data structure, independent of components, offsets, etc. If lhs == rhs with precision std::numeric_limits< tk::real >::epsilon(), a pair of (0,0.0) is returned.

template<class C, class Key, class Factory, typename... ConstructorArgs>
void tk::record(Factory& f, const Key& key, ConstructorArgs&&... args)

Parameters
in Factory to register to (std::map with value using reference semantics)
key in Key used to identify the entry in the factory
args in Variable number of arguments to pass to the constructor being registered. Note that the constructor arguments are only bound to the constructor and stored in the factory (an std::map with value using reference semantics). The object is not instantiated here, i.e., the constructor is not called here. The object can be instantiated by function instantiate.

Register class into factory with given key. This is used to register a derived-class object's constructor (deriving from some base class) to a factory. The factory itself is a std::map< key, std::function< Child*() > >, i.e., an associative container, associating some key to a std::function object holding a pointer of Child's base class constructor. The constructor and its bound arguments are stored via boost::factory, which, in this use-case, yields the correct function object of type Base constructor pointer and thus facilitates runtime polymorphism. This function works in conjunction with boost::factory, i.e., uses reference semantics (works with storing pointers of objects). For a simple example on how to use this function, see tests/unit/Base/Factory.h.

template<class Factory, class Key, class Obj = typename std::remove_pointer< typename Factory::mapped_type::result_type>::type>
std::unique_ptr<Obj> tk::instantiate(const Factory& f, const Key& key)

Parameters
in Factory to instantiate object from (std::map with value using reference semantics)
key in Key used to identify the object to instantiate from factory
Returns std::unique_ptr pointing to the object instantiated from factory

Instantiate object from factory. Factory must have a mapped_value which must have a result_type ptr, e.g., std::map< Key, std::function< Obj*() > >. This wrapper function can be used to instantiate an derived-class object from a factory, repeatedly filled with wrapper function 'record' above. The factory, as described in the documentation of 'record', stores base class pointers in an associative container, thereby facilitating runtime polymorphism and a simple lookup-and-instantiate-style object creation. The object instantiated is of type Child class. This function works in conjunction with boost::factory, i.e., uses reference semantics (works with storing pointers of objects). For a simple example on how to use this function, see tests/unit//Base/Factory.h.

template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void tk::recordModel(Factory& f, const Key& key, ModelConstrArgs&&... args)

Parameters
in Factory to register to (std::map with value using value semantics)
key in Key used to identify the entry in the factory
args in Variable number of arguments to pass to the constructor being registered. Note that the constructor arguments are only bound to the constructor and stored in the factory (an std::map with value using value semantics). The object is not instantiated here, i.e., the constructor is not called here. The object can be instantiated by simply calling the function call operator () on the mapped value. For an example, RNGStack::selected() in RNG/RNGStack.C.

Register "model" class of "host" into factory with given key. This wrapper can be used to in a similar manner to 'record', but uses boost::value_factory to bind the model object constructor to its arguments and place it in the associative container storing host class objects. The container is thus of type std::map< key, std::function< T() > >, i.e., associating a key to a function holding a constructor (and not its pointer). Runtime polymorphism here is realized entirely within the "base" class. See walker::DiffEq in DiffEq/DiffEq.h for an example and more information on runtime polymorphism without client-side inheritance. As a result, this wrapper works with factories that use value semantics, as opposed to 'record' and instantiate which work with reference semantics factories. In order to differentiate between runtime polymorphic classes using reference semantics, consistent with classes realizing runtime polymorphism without client-side inheritance, we call Host as the "Base" class and Model as the "derived" (or child) class. This wrapper function works in conjunction with boost::value_factory, i.e., uses value semantics (works with storing objects instead of object pointers). For a simple example on how to use this function, see tests/unit//Base/Factory.h.

template<class Host, class ModelConstructor, class Factory, class Key, typename ModelConstrArg>
void tk::recordModelLate(Factory& f, const Key& key, ModelConstrArg)

Parameters
in Factory to register to (std::map with value using value semantics)
key in Key used to identify the entry in the factory

Register model class of host into factory with given key using late binding. This variant of 'record' is very similar to 'recordModel', but registers a model class constructor to a factory with late binding of the constructor argument. Late binding allows specifying the constructor argument at the time when the object is instantiated instead of at the time when it is registered. This has all the benefits of using a factory and allows passing information into the model object only when it is available. The late bind is facilitated via std::bind instead of std::bind using a placeholder, _1, which stands for the first argument (bound later, i.e., not here). The value of the model constructor argument is then not used here, only its type, used to perform the late binding. The binding happens to both the model constructor via std::function (passed to the host constructor) as well as explicitly to the host constructor. Prescribing late binding to the model constructor ensures that the compiler requires the argument to the model constructor, i.e., ensures that the host constructor is required to pass the argument to the model constructor. Prescribing late binding to the host constructor puts in the actual request that an argument (with the correct type) must be passed to the host constructor at instantiate time, which then will forward it to the model constructor. See also, for example, walker::DiffEq's corresponding constructor. An example of client-side code is in walker::DiffEqStack::registerDiffEq for registration into factory, and DiffEqStack::createDiffEq for instantiation late-passing the argument.

template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void tk::recordCharmModel(Factory& f, const Key& key, ModelConstrArgs&&... args)

Parameters
in Factory to register to (std::map with value using value semantics)
key in Key used to identify the entry in the factory
args in Variable number of arguments to pass to the constructor being registered.

Register Charm++ model class of host into factory with given key. We bind a host constructor to its arguments of which the first one is a std::function holding a model constructor type (modeling, i.e., used polymorhically with host), followed by an optional number of others (possibly zero) with arbitrary types. Note that the model constructor is a nullptr (default- constructed) and only used to forward its type to the call site inside std::function. The host constructor function is then placed into the factory. This is because Charm++ chares do not explicitly invoke constructors, only call ckNew() on their proxy, which requires all constructor arguments to be present and forwarded to the actual constructor that is only called at a later point in time. This can then be used by those constructors of hosts that invoke the model constructors' proxies' ckNew() and ignore the std::function. See, e.g., rngtest::Battery() and the associated unit tests in tests/unit//Base/Factory.h.

template<typename A, typename B>
std::pair<B, A> tk::flip_pair(const std::pair<A, B>& p)

Parameters
in std::pair of arbitrary types, A and B
Returns std::pair of arbitrary types, B and A

Flip a std::pair of arbitrary types

template<typename A, typename B>
std::multimap<B, A> tk::flip_map(const std::map<A, B>& src)

Parameters
src in std::map of arbitrary key and value pairs of types A and B
Returns std::multimap of arbitrary key and value pairs of types B and A

Flip a std::map of arbitrary types, yielding a std::multimap sorted by std::map::value_type.

template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
std::pair<int, std::unique_ptr<char[]>> tk::serialize(const std::unordered_map<Key, T, Hash, Eq>& m)

Template parameters
Key Map key
T Map value
Hash Map hasher
Eq Map equality operator
Parameters
in Hash map to serialize
Returns Pair of the length and the raw stream containing the serialized map

Serialize std::unordered_map to raw memory stream

template<class T>
void tk::concat(const std::vector<T>& src, std::vector<T>& dst)

Template parameters
T Vector value type
Parameters
src in Source vector
dst in/out Destination vector

Concatenate vectors of T

template<class T>
void tk::concat(const std::vector<std::pair<bool, T>>& src, std::vector<std::pair<bool, T>>& dst)

Template parameters
T Vector value type
Parameters
src in Source vector
dst in/out Destination vector

Overwrite vectors of pair< bool, tk::real >

template<class Key, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
void tk::concat(const std::unordered_set<Key, Hash, Eq>& src, std::unordered_set<Key, Hash, Eq>& dst)

Template parameters
Key Set key
Hash Set hasher
Eq Set equality operator
Parameters
src in Source set
dst in/out Destination set

Concatenate unordered sets

template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
CkReductionMsg* tk::mergeHashMap(int nmsg, CkReductionMsg** msgs)

Charm++ custom reducer for merging std::unordered_maps during reduction across PEs.

Template parameters
Key Map key
T Map value
Hash Map hasher
Eq Map equality operator
Parameters
nmsg in Number of messages in msgs
msgs in Charm++ reduction message containing the serialized maps
Returns Aggregated std::unordered_maps built for further aggregation if needed

During aggregation the map keys are inserted, i.e., the keys remain unique and the mapped values, assuming containers defining begin() and end() iterators() are concatenated.

uint64_t tk::linearLoadDistributor(real virtualization, uint64_t load, int npe, uint64_t& chunksize, uint64_t& remainder)

Compute linear load distribution for given total work and virtualization.

Parameters
virtualization in Degree of virtualization [0.0...1.0]
load in Total load, e.g., number of particles, number of mesh cells
npe in Number of processing elements to distribute the load to
chunksize in/out Chunk size, see detailed description
remainder in/out Remainder, see detailed description
Returns Number of work units

Compute load distibution (number of chares and chunksize) based on total work (e.g., total number of particles) and virtualization

The virtualization parameter, specified by the user, is a real number between 0.0 and 1.0, inclusive, which controls the degree of virtualization or over-decomposition. Independent of the value of virtualization the work is approximately evenly distributed among the available processing elements, given by npe. For zero virtualization (no over-decomposition), the work is simply decomposed into total_work/numPEs, which yields the smallest number of Charm++ chares and the largest chunks of work units. The other extreme is unity virtualization, which decomposes the total work into the smallest size work units possible, yielding the largest number of Charm++ chares. Obviously, the optimum will be between 0.0 and 1.0, depending on the problem.

The formula implemented uses a linear relationship between the virtualization parameter and the number of work units with the extremes described above. The formula is given by

chunksize = (1 - n) * v + n;

where

  • v = degree of virtualization
  • n = load/npes
  • load = total work, e.g., number of particles, number of mesh cells
  • npes = number of hardware processing elements

void tk::rm(const std::string& file)

Remove file from file system.

Parameters
file in File name to delete (shell wildcards NOT expanded)

Since we use pstream's basic_ipstream constructor with signature ( const std::string & file, const argv_type & argv, pmode mode = pstdout ) and the file argument doesn't contain a slash, the actions of the shell are duplicated in searching for an executable in PATH. The shell will not interpret the other arguments, so wildcard expansion will not take place.

void tk::signalHandler(int signum)

Signal handler for multiple signals, SIGABRT, SIGSEGV, etc.

Parameters
signum in Signal number

Signals caught: SIGABRT is generated when the program calls the abort() function, such as when an assert() triggers SIGSEGV is generated when the program makes an illegal memory access, such as reading unaligned memory, dereferencing a null pointer, reading memory out of bounds etc. SIGILL is generated when the program tries to execute a malformed instruction. This happens when the execution pointer starts reading non-program data, or when a pointer to a function is corrupted. SIGFPE is generated when executing an illegal floating point instruction, most commonly division by zero or floating point overflow.

int tk::setSignalHandlers()

Set signal handlers for multiple signals, SIGABRT, SIGSEGV, etc.

Returns Ignore, used for calling in a constructor's initializer list

void tk::processExceptionCharm()

Process an exception from the Charm++ runtime system.

See Josuttis, The C++ Standard Library - A Tutorial and Reference, 2nd Edition, 2012.

template<typename T>
T tk::swap_endian(T u)

Parameters
in Integral type to convert
Returns Converted integer

Swap endianness of an integral type

template<>
double tk::swap_endian(double u)

Parameters
in Double to convert
Returns Converted double

Swap endianness of a double

template<typename T, typename Ch, typename Tr>
std::basic_ostream<Ch, Tr>& tk::operator<<(std::basic_ostream<Ch, Tr>& os, const T& e)

Parameters
os in Output stream into which t is written
in Value of arbitrary non-enum-class type to write to stream
Returns Updated output stream for chain-use of the operator

Delegate operator << to default for writing non-enums to output streams.

template<typename T, typename Ch, typename Tr>
std::basic_string<Ch, Tr> tk::operator<<(std::basic_string<Ch, Tr>& lhs, const T& e)

Parameters
lhs in Output std::basic_string into which e is written
in Value of arbitrary type to write to string
Returns Updated string

Operator << for adding (concatenating) T to a std::basic_string for lvalues.

template<typename T, typename Ch, typename Tr>
std::basic_string<Ch, Tr> tk::operator<<(std::basic_string<Ch, Tr>&& lhs, const T& e)

Parameters
lhs in Output std::basic_string into which e is written
in Value of arbitrary type to write to string
Returns Updated string

Operator << for adding (concatenating) T to a std::basic_string for rvalues.

std::string tk::splitLines(std::string str, std::string indent, const std::string& name = "", std::size_t width = 80)

Clean up whitespaces and format a long string into multiple lines.

Parameters
str in String to format
indent in String to use as identation
name in String to insert before string to output
width in Width in characters to insert newlines for output

tk::real tk::sample(tk::real x, const tk::Table& table)

Sample a discrete y = f(x) function at x.

Parameters
in Value of abscissa at which to sample y = f(x)
table in tk::Table to sample
Returns Sampled value from discrete table

If x is lower than the first x value in the function table, the first function value is returned. If x is larger than the last x value in the function table, the last function value is returned. In other words, no extrapolation is performed. If x falls between the first/lowest and the last/largest value in the table, linear interpolation is used to compute a sample between the two closest x values of the table around the abscissa given.

Timer::Watch tk::hms(tk::real stamp)

Convert existing time stamp as a real to Watch (global scope)

Parameters
stamp in Time stamp as a real number
Returns Time as hours, minutes, and seconds, as a Watch struct.

Convert existing time stamp as a real to Watch (global-scope)

std::array<real, 3> tk::cross(const std::array<real, 3>& v1, const std::array<real, 3>& v2)

Compute the cross-product of two vectors.

Parameters
v1 in 1st vector
v2 in 2nd vector
Returns Cross-product

std::array<real, 3> tk::crossdiv(const std::array<real, 3>& v1, const std::array<real, 3>& v2, real j)

Compute the cross-product of two vectors divided by a scalar.

Parameters
v1 in 1st vector
v2 in 2nd vector
in Scalar to divide each component by
Returns Cross-product divided by scalar

real tk::dot(const std::array<real, 3>& v1, const std::array<real, 3>& v2)

Compute the dot-product of two vectors.

Parameters
v1 in 1st vector
v2 in 2nd vector
Returns Dot-product

real tk::triple(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3)

Compute the triple-product of three vectors.

Parameters
v1 in 1st vector
v2 in 2nd vector
v3 in 3rd vector
Returns Triple-product

std::array<real, 3> tk::rotateX(const std::array<real, 3>& v, real angle)

Rotate vector about X axis.

Parameters
in Vector to rotate
angle in Angle to use to rotate with
Returns Rotated vector

Rotate vector about X axis by -45 degress

std::array<real, 3> tk::rotateY(const std::array<real, 3>& v, real angle)

Rotate vector about Y axis.

Parameters
in Vector to rotate
angle in Angle to use to rotate with
Returns Rotated vector

Rotate vector about Y axis by -45 degress

std::array<real, 3> tk::rotateZ(const std::array<real, 3>& v, real angle)

Rotate vector about Z axis.

Parameters
in Vector to rotate
angle in Angle to use to rotate with
Returns Rotated vector

Rotate vector about Z axis by -45 degress

real tk::Jacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4)

Compute the determinant of the Jacobian of a coordinate transformation over a tetrahedron.

Parameters
v1 in (x,y,z) coordinates of 1st vertex of the tetrahedron
v2 in (x,y,z) coordinates of 2nd vertex of the tetrahedron
v3 in (x,y,z) coordinates of 3rd vertex of the tetrahedron
v4 in (x,y,z) coordinates of 4th vertex of the tetrahedron
Returns Determinant of the Jacobian of transformation of physical tetrahedron to reference (xi, eta, zeta) space

std::array<std::array<real, 3>, 3> tk::inverseJacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4)

Compute the inverse of the Jacobian of a coordinate transformation over a tetrahedron.

Parameters
v1 in (x,y,z) coordinates of 1st vertex of the tetrahedron
v2 in (x,y,z) coordinates of 2nd vertex of the tetrahedron
v3 in (x,y,z) coordinates of 3rd vertex of the tetrahedron
v4 in (x,y,z) coordinates of 4th vertex of the tetrahedron
Returns Inverse of the Jacobian of transformation of physical tetrahedron to reference (xi, eta, zeta) space

tk::real tk::determinant(const std::array<std::array<tk::real, 3>, 3>& a)

Compute the determinant of 3x3 matrix.

Parameters
in 3x3 matrix
Returns Determinant of the 3x3 matrix

std::array<tk::real, 3> tk::cramer(const std::array<std::array<tk::real, 3>, 3>& a, const std::array<tk::real, 3>& b)

Solve a 3x3 system of equations using Cramer's rule.

Parameters
in 3x3 lhs matrix
in 3x1 rhs matrix
Returns Array of solutions of the 3x3 system

MeshReaderType tk::detectInput(const std::string& filename)

Detect input mesh file type.

Parameters
filename in File to open and detect its type
Returns enum specifying the mesh reader type

MeshWriterType tk::pickOutput(const std::string& filename)

Determine output mesh file type.

Parameters
filename in Filename to pick its type based on extension given
Returns enum specifying the mesh writer type

UnsMesh tk::readUnsMesh(const tk::Print& print, const std::string& filename, std::pair<std::string, tk::real>& timestamp)

Read unstructured mesh from file.

Parameters
print in Pretty printer
filename in Filename to read mesh from
timestamp out A time stamp consisting of a timer label (a string), and a time state (a tk::real in seconds) measuring the mesh read time
Returns Unstructured mesh object

Create unstructured mesh to store mesh

std::vector<std::pair<std::string, tk::real>> tk::writeUnsMesh(const tk::Print& print, const std::string& filename, UnsMesh& mesh, bool reorder)

Write unstructured mesh to file.

Parameters
print in Pretty printer
filename in Filename to write mesh to
mesh in Unstructured mesh object to write from
reorder in Whether to also reorder mesh nodes
Returns Vector of time stamps consisting of a timer label (a string), and a time state (a tk::real in seconds) measuring the renumber and the mesh write time

void tk::SiloError(char* msg)

Silo error handler.

Parameters
msg in Error message

static std::string tk::workdir()

Returns A stirng containing the current working directory

std::string tk::curtime()

Wrapper for the standard C library's gettimeofday() from.

Returns A stirng containing the current date and time

void tk::echoHeader(const Print& print, HeaderType header)

Echo program header.

Parameters
print in Pretty printer
header in Header type enum indicating which header to print

void tk::echoBuildEnv(const Print& print, const std::string& executable)

Echo build environment.

Parameters
print in Pretty printer
executable in Name of the executable

Echo information read from build_dir/Base/Config.h filled by CMake based on src/Main/Config.h.in.

void tk::echoRunEnv(const Print& print, int argc, char** argv, bool verbose, bool quiescence, bool charestate, bool trace)

Echo runtime environment.

Parameters
print in Pretty printer
argc in Number of command-line arguments to executable
argv in C-style string array to command-line arguments to executable
verbose in True for verbose screen-output
quiescence in True if quiescence detection is enabled
charestate in True if chare state collection is enabled
trace in True if call and stack trace output is enabled

template<class Driver, class Printer, class CmdLine>
Driver tk::Main(int argc, char* argv[], const CmdLine& cmdline, HeaderType header, const std::string& executable, const Printer& print)

Generic Main() used for all executables for code-reuse and a uniform output.

Parameters
argc in Number of command-line arguments to executable
argv in C-style string array to command-line arguments to executable
cmdline in Command line object storing data parsed from the command line arguments
header in Header type enum indicating which executable header to print
executable in Name of the executable
print in Pretty printer to use
Returns Instantiated driver object which can then be used to execute() whatever it is intended to drive

The template arguments configure this Main class that is practically used instead of the usual main(). This allows code-reuse and a unfirom screen-output. The template arguments are:

  • Driver, specializaing the driver type to be created, see tk::Driver
  • Printer, specializaing the pretty printer type to use, see tk::Print
  • CmdLine, specializing the command line object storing data parsed from the command line

template<class MainProxy, class CmdLine>
void tk::MainCtor(MainProxy& mp, const MainProxy& thisProxy, std::vector<tk::Timer>& timer, const CmdLine& cmdline, const CkCallback& quiescenceTarget)

Template parameters
MainProxy Main Charm++ chare proxy for the executable
CmdLine Executable-specific tagged tuple storing the rusult of the command line parser
Parameters
mp in/out MainProxy to set for the main chare
thisProxy in 'thisProxy' to set as MainProxy
timer in/out Vector of timers, held by the main chare, in which to start the first timer, measuring the migration of global-scope data
cmdline in Command line grammar stack for the executable (assumed already parsed)
quiescenceTarget in Pre-created Charm++ callback to use as the target function to call if quiescence is detected

Generic Main Charm++ module constructor for all executables

template<class CmdLine>
void tk::dumpstate(const CmdLine& cmdline, const tk::Print& print, CkReductionMsg* msg)

Template parameters
CmdLine Executable-specific tagged tuple storing the rusult of the command line parser
Parameters
cmdline in Command line grammar stack for the executable
print in Pretty printer
msg in Charm++ reduction message containing the chare state aggregated from all PEs

Generic function to dump the Charm++ chare state (if collected)

template<class CmdLine>
void tk::finalize(const CmdLine& cmdline, const std::vector<tk::Timer>& timer, const tk::Print& print, tk::CProxy_ChareStateCollector& state, std::vector<std::pair<std::string, tk::Timer::Watch>>& timestamp, const CkCallback& dumpstateTarget, bool clean = true)

Parameters
cmdline in Command line grammar stack for the executable
timer in Vector of timers, held by the main chare
print in Pretty printer
state in/out Chare state collector proxy
timestamp in/out Vector of time stamps in h:m:s with labels
dumpstateTarget in Pre-created Charm++ callback to use as the target function for dumping chare state
clean in True if we should exit with a zero exit code, false to exit with a nonzero exit code

Generic finalize function for different executables

std::size_t tk::npoin_in_graph(const std::vector<std::size_t>& inpoel)

Compute number of points (nodes) in mesh from connectivity.

Parameters
inpoel in Inteconnectivity of points and elements. These are the
Returns Number of mesh points (nodes)

std::pair<std::vector<std::size_t>, std::vector<std::size_t>> tk::genEsup(const std::vector<std::size_t>& inpoel, std::size_t nnpe)

Generate derived data structure, elements surrounding points.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element
Returns Linked lists storing elements surrounding points

The data generated here is stored in a linked list, more precisely, two linked arrays (vectors), esup1 and esup2, where esup2 holds the indices at which esup1 holds the element ids surrounding points. Looping over all elements surrounding all points can then be accomplished by the following loop:

for (std::size_t p=0; p<npoin; ++p)
  for (auto i=esup.second[p]+1; i<=esup.second[p+1]; ++i)
     use element id esup.first[i]

To find out the number of points, npoin, the mesh connectivity, inpoel, can be queried:

auto minmax = std::minmax_element( begin(inpoel), end(inpoel) );
Assert( *minmax.first == 0, "node ids should start from zero" );
auto npoin = *minmax.second + 1;

std::pair<std::vector<std::size_t>, std::vector<std::size_t>> tk::genPsup(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, points surrounding points.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Linked lists storing points surrounding points

The data generated here is stored in a linked list, more precisely, two linked arrays (vectors), psup1 and psup2, where psup2 holds the indices at which psup1 holds the point ids surrounding points. Looping over all points surrounding all points can then be accomplished by the following loop:

for (std::size_t p=0; p<npoin; ++p)
  for (auto i=psup.second[p]+1; i<=psup.second[p+1]; ++i)
     use point id psup.first[i]

To find out the number of points, npoin, the mesh connectivity, inpoel, can be queried:

auto minmax = std::minmax_element( begin(inpoel), end(inpoel) );
Assert( *minmax.first == 0, "node ids should start from zero" );
auto npoin = *minmax.second + 1;

or the length-1 of the generated index list: auto npoin = psup.second.size()-1;

std::pair<std::vector<std::size_t>, std::vector<std::size_t>> tk::genEdsup(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, edges surrounding points.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element (3 or 4)
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Linked lists storing edges (point ids p < q) emanating from points

The data generated here is stored in a linked list, more precisely, two linked arrays (vectors), edsup1 and edsup2, where edsup2 holds the indices at which edsup1 holds the edge-end point ids emanating from points for all points. The generated data structure, linked lists edsup1 and edsup2, are very similar to psup1 and psup2, generated by genPsup(), except here only unique edges are stored, i.e., for edges with point ids p < q, only ids q are stored that are still associated to point p. Looping over all unique edges can then be accomplished by the following loop:

for (std::size_t p=0; p<npoin; ++p)
  for (auto i=edsup.second[p]+1; i<=edsup.second[p+1]; ++i)
    use edge with point ids p < edsup.first[i]

To find out the number of points, npoin, the mesh connectivity, inpoel, can be queried:

auto minmax = std::minmax_element( begin(inpoel), end(inpoel) );
Assert( *minmax.first == 0, "node ids should start from zero" );
auto npoin = *minmax.second + 1;

std::vector<std::size_t> tk::genInpoed(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, edge connectivity.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element (3 or 4)
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Linear vector storing edge connectivity (point ids p < q)

The data generated here is stored in a linear vector and is very similar to the linked lists, edsup1 and _edsup2, generated by genEdsup(). The difference is that in the linear vector, inpoed, generated here, both edge point ids are stored as a pair, p < q, as opposed to the linked lists edsup1 and edsup2, in which edsup1 only stores the edge-end point ids (still associated to edge-start point ids when used together with edsup2). The rationale is that while inpoed is larger in memory, it allows direct access to edges (pair of point ids making up an edge), edsup1 and edsup2 are smaller in memory, still allow accessing the same data (edge point id pairs) but only in a linear fashion, not by direct access to particular edges. Accessing all unique edges using the edge connectivity data structure, inpoed, generated here can be accomplished by

for (std::size_t e=0; e<inpoed.size()/2; ++e) {
  use point id p of edge e = inpoed[e*2];
  use point id q of edge e = inpoed[e*2+1];
}

std::pair<std::vector<std::size_t>, std::vector<std::size_t>> tk::genEsupel(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, elements surrounding points of elements.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Linked lists storing elements surrounding points of elements

The data generated here is stored in a linked list, more precisely, two linked arrays (vectors), esupel1 and esupel2, where esupel2 holds the indices at which esupel1 holds the element ids surrounding points of elements. Looping over all elements surrounding the points of all elements can then be accomplished by the following loop:

for (std::size_t e=0; e<nelem; ++e)
  for (auto i=esupel.second[e]+1; i<=esupel.second[e+1]; ++i)
     use element id esupel.first[i]

To find out the number of elements, nelem, the size of the mesh connectivity vector, inpoel, can be devided by the number of nodes per elements, nnpe: auto nelem = inpoel.size()/nnpe;

std::pair<std::vector<std::size_t>, std::vector<std::size_t>> tk::genEsuel(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, elements surrounding elements.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Linked lists storing elements surrounding elements

The data generated here is stored in a linked list, more precisely, two linked arrays (vectors), esuel1 and esuel2, where esuel2 holds the indices at which esuel1 holds the element ids surrounding elements. Looping over elements surrounding elements can then be accomplished by the following loop:

for (std::size_t e=0; e<nelem; ++e)
  for (auto i=esuel.second[e]+1; i<=esuel.second[e+1]; ++i)
     use element id esuel.first[i]

To find out the number of elements, nelem, the size of the mesh connectivity vector, inpoel, can be devided by the number of nodes per elements, nnpe: auto nelem = inpoel.size()/nnpe;

std::vector<std::size_t> tk::genInedel(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::vector<std::size_t>& inpoed)

Generate derived data structure, edges of elements.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element
inpoed in Edge connectivity as linear vector, see tk::genInpoed
Returns Linear vector storing all edge ids * 2 of all elements

The data generated here is stored in a linear vector with all edge ids (as defined by inpoed) of all elements. The edge ids stored in inedel can be directly used to index the vector inpoed. Because the derived data structure generated here, inedel, is intended to be used in conjunction with the linear vector inpoed and not with the linked lists edsup1 and edsup2, this function takes inpoed as an argument. Accessing the edges of element e using the edge of elements data structure, inedel, generated here can be accomplished by

for (std::size_t e=0; e<nelem; ++e) {
  for (std::size_t i=0; i<nepe; ++i) {
    use edge id inedel[e*nepe+i] of element e, or
    use point ids p < q of edge id inedel[e*nepe+i] of element e as
      p = inpoed[ inedel[e*nepe+i]*2 ]
      q = inpoed[ inedel[e*nepe+i]*2+1 ]
  }
}

where nepe denotes the number of edges per elements: 3 for triangles, 6 for tetrahedra. To find out the number of elements, nelem, the size of the mesh connectivity vector, inpoel, can be devided by the number of nodes per elements, nnpe: auto nelem = inpoel.size()/nnpe;

std::pair<std::vector<std::size_t>, std::vector<std::size_t>> tk::genEsued(const std::vector<std::size_t>& inpoel, std::size_t nnpe, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, elements surrounding edges.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

nnpe in Number of nodes per element (3 or 4)
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Linked lists storing elements surrounding edges

The data generated here is stored in a linked list, more precisely, two linked arrays (vectors), esued1 and esued2, where esued2 holds the indices at which esued1 holds the element ids surrounding edges. Looping over all elements surrounding edges can then be accomplished by the following loop:

for (std::size_t e=0; e<nedge; ++e)
  for (auto i=esued.second[e]+1; i<=esued.second[e+1]; ++i)
    use element id esued.first[i]

To find out the number of edges, nedge, the edge connectivity, inpoed, can be queried:

auto esup = tk::genEsup(inpoel,nnpe);
auto nedge = tk::genInpoed(inpoel,nnpe,esup).size()/2;

where nnpe is the number of nodes per element (4 for tetrahedra, 3 for triangles).

std::size_t tk::genNbfacTet(std::size_t tnbfac, const std::vector<std::size_t>& inpoel, const std::vector<std::size_t>& triinpoel_complete, const std::map<int, std::vector<std::size_t>>& bface_complete, const std::unordered_map<std::size_t, std::size_t>& lid, std::vector<std::size_t>& triinpoel, std::map<int, std::vector<std::size_t>>& bface)

Generate total number of boundary faces in this chunk.

Parameters
tnbfac in Total number of boundary faces in the entire mesh.
inpoel in Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh.
triinpoel_complete in Interconnectivity of points and boundary-face in the entire mesh.
bface_complete in Map of boundary-face lists mapped to corresponding side set ids for the entire mesh.
lid in Mapping between the node indices used in the smaller inpoel connectivity (a subset of the entire triinpoel_complete connectivity), e.g., after mesh partitioning.
triinpoel in/out Interconnectivity of points and boundary-face in this mesh-partition.
bface in/out Map of boundary-face lists mapped to corresponding side set ids for this mesh-partition
Returns Number of boundary-faces on this chare/mesh-partition.

This function takes a mesh by its domain-element (tetrahedron-connectivity) in inpoel and a boundary-face (triangle) connectivity in triinpoel_complete. Based on these two arrays, it searches for those faces of triinpoel_complete that are also in inpoel and as a result it generates (1) the number of boundary faces shared with the mesh in inpoel and (2) the intersection of the triangle element connectivity whose faces are shared with inpoel. An example use case is where triinpoel_complete contains the connectivity for the boundary of the full problem/mesh and inpoel contains the connectivity for only a chunk of an already partitioned mesh. This function then intersects triinpoel_complete with inpoel and returns only those faces that share nodes with inpoel.

std::vector<int> tk::genEsuelTet(const std::vector<std::size_t>& inpoel, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, elements surrounding elements as a fixed length data structure as a full vector, including boundary elements as -1.

Parameters
inpoel in

Inteconnectivity of points and elements. These are the node ids of each element of an unstructured mesh. Example:

std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                    10, 14, 13, 12 };

specifies two tetrahedra whose vertices (node ids) are { 12, 14, 9, 11 }, and { 10, 14, 13, 12 }.

esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Vector storing elements surrounding elements

The data generated here is stored in a single vector, with length nfpe * nelem. Note however, that nelem is not explicitly provided, but calculated from inpoel. For boundary elements, at the boundary face, this esuelTet stores value -1 indicating that this is outside the domain. The convention for numbering the local face (triangle) connectivity is very important, e.g., in generating the inpofa array later. This node ordering convention is stored in tk::lpofa. Thus function is specific to tetrahedra, which is reflected in the fact that nnpe and nfpe are being set here in the function rather than being input arguments. To find out the number of elements, nelem, the size of the mesh connectivity vector, inpoel, can be devided by the number of nodes per elements, nnpe: auto nelem = inpoel.size()/nnpe;

std::size_t tk::genNipfac(std::size_t nfpe, std::size_t nbfac, const std::vector<int>& esuelTet)

Generate number of internal and physical-boundary faces.

Parameters
nfpe in Number of faces per element.
nbfac in Number of boundary faces.
esuelTet in Elements surrounding elements.
Returns Total number of faces in the mesh

The unsigned integer here gives the number of internal and

std::vector<int> tk::genEsuf(std::size_t nfpe, std::size_t nipfac, std::size_t nbfac, const std::vector<std::size_t>& belem, const std::vector<int>& esuelTet)

Generate derived data structure, elements surrounding faces.

Parameters
nfpe in Number of faces per element.
nipfac in Number of internal and physical-boundary faces.
nbfac in Number of boundary faces.
belem in Boundary element vector.
esuelTet in Elements surrounding elements.
Returns Elements surrounding faces.

The unsigned integer vector gives the IDs of the elements to the

std::vector<std::size_t> tk::genInpofaTet(std::size_t nipfac, std::size_t nbfac, const std::vector<std::size_t>& inpoel, const std::vector<std::size_t>& triinpoel, const std::vector<int>& esuelTet)

Generate derived data structure, node-face connectivity.

Parameters
nipfac in Number of internal and physical-boundary faces.
nbfac in Number of boundary faces.
inpoel in Element-node connectivity.
triinpoel in Face-node connectivity.
esuelTet in Elements surrounding elements.
Returns Points surrounding faces. The unsigned integer vector gives the elements to the left and to the right of each face in the mesh.

std::vector<std::size_t> tk::genBelemTet(std::size_t nbfac, const std::vector<std::size_t>& inpofa, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup)

Generate derived data structure, host/boundary element.

Parameters
nbfac in Number of boundary faces.
inpofa in Face-node connectivity.
esup in Elements surrounding points as linked lists, see tk::genEsup
Returns Host elements or boundary elements. The unsigned integer vector gives the elements to the left of each boundary face in the mesh.

tk::Fields tk::genGeoFaceTri(std::size_t nipfac, const std::vector<std::size_t>& inpofa, const tk::UnsMesh::Coords& coord)

Generate derived data structure, face geometry.

Parameters
nipfac in Number of internal and physical-boundary faces.
inpofa in Face-node connectivity.
coord in Co-ordinates of nodes in this mesh-chunk.
Returns Face geometry information. This includes face area, unit normal pointing outward of the element to the left of the face, and face centroid coordinates. Use the following examples to access this information for face-f. face area: geoFace(f,0,0), unit-normal x-component: geoFace(f,1,0), y-component: geoFace(f,2,0), z-component: geoFace(f,3,0), centroid x-coordinate: geoFace(f,4,0), y-coordinate: geoFace(f,5,0), z-coordinate: geoFace(f,6,0).

std::array<tk::real, 3> tk::normal(const std::array<tk::real, 3>& x, const std::array<tk::real, 3>& y, const std::array<tk::real, 3>& z)

Compute the unit normal vector of a triangle.

Parameters
in x-coordinates of the three vertices of the triangle
in y-coordinates of the three vertices of the triangle
in z-coordinates of the three vertices of the triangle
Returns Unit normal

Compute the unit normal vector of a triangle

tk::Fields tk::geoFaceTri(const std::array<tk::real, 3>& x, const std::array<tk::real, 3>& y, const std::array<tk::real, 3>& z)

Compute geometry of the face given by three vertices.

Parameters
in x-coordinates of the three vertices of the triangular face.
in y-coordinates of the three vertices of the triangular face.
in z-coordinates of the three vertices of the triangular face.
Returns Face geometry information. This includes face area, unit normal pointing outward of the element to the left of the face, and face centroid coordinates.

Compute geometry of the face given by three vertices

tk::Fields tk::genGeoElemTet(const std::vector<std::size_t>& inpoel, const tk::UnsMesh::Coords& coord)

Generate derived data structure, element geometry.

Parameters
inpoel in Element-node connectivity.
coord in Co-ordinates of nodes in this mesh-chunk.
Returns Element geometry information. This includes element volume and element centroid coordinates. Use the following examples to access this information for element-e. volume: geoElem(e,0,0), centroid x-coordinate: geoElem(f,1,0), y-coordinate: geoElem(f,2,0), z-coordinate: geoElem(f,3,0).

bool tk::leakyPartition(const std::vector<int>& esueltet, const std::vector<std::size_t>& inpoel, const tk::UnsMesh::Coords& coord)

Perform leak-test on mesh (partition)

Parameters
esueltet in Elements surrounding elements for tetrahedra, see tk::genEsueltet()
inpoel in Element connectivity
coord in Node coordinates
Returns True if partition leaks.

This function computes a surface integral over the boundary of the incoming mesh (partition). A non-zero vector result indicates a leak, e.g., a hole in the mesh (partition), which indicates an error either in the

bool tk::conforming(const std::vector<std::size_t>& inpoel, const tk::UnsMesh::Coords& coord, bool cerr)

Check if mesh (partition) is conforming.

Parameters
inpoel in Element connectivity
coord in Node coordinates
cerr in True if hanging-node edge data should be output to std::cerr (true by default)
Returns True if mesh (partition) has no hanging nodes and thus the mesh is conforming, false if non-conforming.

A conforming mesh by definition has no hanging nodes. A node is hanging if an edge of one element coincides with two (or more) edges (of two or more other elements). Thus, testing for conformity relies on checking the coordinates of all vertices: if any vertex coincides with that of a mid-point node of an edge, that is a hanging node. Note that this assumes that hanging nodes can only be at the mid-point of edges. This may happen after a mesh refinement step, due to a problem/bug, within the mesh refinement algorithm given by J. Waltz, Parallel adaptive refinement for unsteady flow calculations on 3D unstructured grids, International Journal for Numerical Methods in Fluids, 46: 37–57, 2004, which always adds/removes vertices at the mid-points of edges of a tetrahedron mesh within a single refinement step. Thus this algorithm is intended for this specific case, i.e., test for conformity after a single refinement step and not after multiple ones or for detecting hanging nodes in an arbitrary meshes.

std::array<tk::real, 3> tk::nodegrad(std::size_t node, const std::array<std::vector<tk::real>, 3>& coord, const std::vector<std::size_t>& inpoel, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esup, const tk::Fields& U, ncomp_t c)

Compute gradient at a mesh node.

Parameters
node in Node id at which to compute gradient
coord in Mesh node coordinates
inpoel in Mesh element connectivity
esup in Linked lists storing elements surrounding points, see tk::genEsup()
in Field vector whose component gradient to compute
in Scalar component to compute gradient of
Returns Gradient of U(c) at mesh node

std::array<tk::real, 3> tk::edgegrad(std::size_t edge, const std::array<std::vector<tk::real>, 3>& coord, const std::vector<std::size_t>& inpoel, const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& esued, const tk::Fields& U, ncomp_t c)

Compute gradient at a mesh edge.

Parameters
edge in Edge id at which to compute gradient
coord in Mesh node coordinates
inpoel in Mesh element connectivity
esued in Linked lists storing elements surrounding edges, see tk::genEsued()
in Field vector whose component gradient to compute
in Scalar component to compute gradient of
Returns Gradient of U(c) at mesh edge

std::size_t tk::shiftToZero(std::vector<std::size_t>& inpoel)

Shift node IDs to start with zero in element connectivity.

Parameters
inpoel in/out Inteconnectivity of points and elements
Returns Amount shifted

This function implements a simple reordering of the node ids of the element connectivity in inpoel by shifting the node ids so that the smallest is zero.

void tk::remap(std::vector<std::size_t>& ids, const std::vector<std::size_t>& map)

Apply new mapping to vector of indices.

Parameters
ids in/out Vector of integer IDs to remap
map in Array of indices creating a new order

This function applies a mapping (reordering) to the integer IDs passed in using the map passed in. The mapping is expressed between the array index and its value. The function overwrites every value, i, of vector ids with map[i].

void tk::remap(std::vector<tk::real>& r, const std::vector<std::size_t>& map)

Apply new mapping to vector of real numbers.

Parameters
in/out Vector of real numbers to remap
map in Array of indices creating a new order

This function applies a mapping (reordering) to the real values passed in using the map passed in. The mapping is expressed between the array index and its value. The function moves every value r[i] to r[ map[i] ].

std::vector<std::size_t> tk::remap(const std::vector<std::size_t>& ids, const std::vector<std::size_t>& map)

Create remapped vector of indices using a vector.

Parameters
ids in Vector of integer IDs to remap
map in Array of indices creating a new order
Returns Remapped vector of ids

This function applies a mapping (reordering) to the integer IDs passed in using the map passed in. The mapping is expressed between the array index and its value. The function creates and returns a new container with remapped ids of identical size of the origin ids container.

void tk::remap(std::vector<std::size_t>& ids, const std::unordered_map<std::size_t, std::size_t>& map)

In-place remap vector of indices using a map.

Parameters
ids in Vector of integer IDs to remap
map in Hash-map of key->value creating a new order

This function applies a mapping (reordering) to the integer IDs passed in using the map passed in. The mapping is expressed as a hash-map of key->value pairs, where the key is the original and the value is the new ids of the mapping. The function overwrites the ids container with the remapped ids of identical size.

std::vector<std::size_t> tk::remap(const std::vector<std::size_t>& ids, const std::unordered_map<std::size_t, std::size_t>& map)

Create remapped vector of indices using a map.

Parameters
ids in Vector of integer IDs to create new container of ids from
map in Hash-map of key->value creating a new order
Returns Remapped vector of ids

This function applies a mapping (reordering) to the integer IDs passed in using the map passed in. The mapping is expressed as a hash-map of key->value pairs, where the key is the original and the value is the new ids of the mapping. The function creates and returns a new container with the remapped ids of identical size of the original ids container.

std::map<int, std::vector<std::size_t>> tk::remap(const std::map<int, std::vector<std::size_t>>& ids, const std::unordered_map<std::size_t, std::size_t>& map)

Create remapped map of vector of indices using a map.

Parameters
ids in Map of vector of integer IDs to create new container of ids from
map in Hash-map of key->value creating a new order
Returns Remapped vector of ids

This function applies a mapping (reordering) to the map of integer IDs passed in using the map passed in by applying remap(vector,map) on each vector of ids. The keys in the returned map will be the same as in ids.

std::vector<std::size_t> tk::renumber(const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& psup)

Reorder mesh points with the advancing front technique.

Parameters
psup in Points surrounding points
Returns Mapping created by renumbering (reordering)

std::unordered_map<std::size_t, std::size_t> tk::assignLid(const std::vector<std::size_t>& gid)

Assign local ids to global ids.

Parameters
gid in Global ids
Returns Map associating global ids to local ids

std::tuple<std::vector<std::size_t>, std::vector<std::size_t>, std::unordered_map<std::size_t, std::size_t>> tk::global2local(const std::vector<std::size_t>& ginpoel)

Generate element connectivity of local node IDs from connectivity of global node IDs also returning the mapping between local to global IDs.

Parameters
ginpoel in Element connectivity with global node IDs
Returns Tuple of (1) element connectivity with local node IDs, (2) the vector of unique global node IDs (i.e., the mapping between local to global node IDs), and (3) mapping between global to local node IDs.

bool tk::positiveJacobians(const std::vector<std::size_t>& inpoel, const std::array<std::vector<real>, 3>& coord)

Test positivity of the Jacobian for all cells in a mesh.

Parameters
inpoel in Element connectivity (zero-based, i.e., local if parallel)
coord in Node coordinates
Returns True if Jacobians of all mesh cells are positive

std::array<tk::real, 3> tk::eval_gp(const std::size_t igp, const std::array<std::array<tk::real, 3>, 3>& coordfa, const std::array<std::vector<tk::real>, 2>& coordgp)

Compute the coordinates of quadrature points for face integral.

Parameters
igp in Index of quadrature points
coordfa in Array of nodal coordinates for face element
coordgp in Array of coordinates for quadrature points in reference space
Returns Array of coordinates for quadrature points in physical space

std::array<tk::real, 3> tk::eval_gp(const std::size_t igp, const std::array<std::array<tk::real, 3>, 4>& coord, const std::array<std::vector<tk::real>, 3>& coordgp)

Compute the coordinates of quadrature points for volume integral.

Parameters
igp in Index of quadrature points
coord in Array of nodal coordinates for tetrahedron element
coordgp in Array of coordinates for quadrature points in reference space
Returns Array of coordinates for quadrature points in physical space

std::array<std::vector<tk::real>, 3> tk::eval_dBdx_p1(const std::size_t ndof, const std::array<std::array<tk::real, 3>, 3>& jacInv)

Compute the derivatives of basis function for DG(P1)

Parameters
ndof in Number of degrees of freedom
jacInv in Array of the inverse of Jacobian
Returns Array of the derivatives of basis functions

void tk::eval_dBdx_p2(const std::size_t igp, const std::array<std::vector<tk::real>, 3>& coordgp, const std::array<std::array<tk::real, 3>, 3>& jacInv, std::array<std::vector<tk::real>, 3>& dBdx)

Compute the derivatives of basis function for DG(P2)

Parameters
igp in Index of quadrature points
coordgp in Gauss point coordinates for tetrahedron element
jacInv in Array of the inverse of Jacobian
dBdx in/out Array of the derivatives of basis function

std::vector<tk::real> tk::eval_basis(const std::size_t ndof, const tk::real xi, const tk::real eta, const tk::real zeta)

Compute the Dubiner basis functions.

Parameters
ndof in Number of degrees of freedom
xi in Coordinates for quadrature points in reference space
eta in Coordinates for quadrature points in reference space
zeta in Coordinates for quadrature points in reference space
Returns Vector of basis functions

std::vector<tk::real> tk::eval_state(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const std::size_t e, const Fields& U, const std::vector<tk::real>& B)

Compute the state variables for the tetrahedron element.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
ndof_el in Number of degrees of freedom for the local element
in Index for the tetrahedron element
in Solution vector at recent time step
in Vector of basis functions
Returns Vector of state variable for tetrahedron element

void tk::bndSurfInt(ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<bcconf_t>& bcconfig, const inciter::FaceData& fd, const Fields& geoFace, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, real t, const RiemannFluxFn& flux, const VelFn& vel, const StateFn& state, const Fields& U, const Fields& P, const std::vector<std::size_t>& ndofel, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)

Compute boundary surface flux integrals for a given boundary type for DG.

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
nmat in Number of materials in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
rdof in Maximum number of reconstructed degrees of freedom
bcconfig in BC configuration vector for multiple side sets
fd in Face connectivity and boundary conditions object
geoFace in Face geometry array
inpoel in Element-node connectivity
coord in Array of nodal coordinates
in Physical time
flux in Riemann flux function to use
vel in Function to use to query prescribed velocity (if any)
state in Function to evaluate the left and right solution state at boundaries
in Solution vector at recent time step
in Vector of primitives at recent time step
ndofel in Vector of local number of degrees of freedom
in/out Right-hand side vector computed
riemannDeriv in/out Derivatives of partial-pressures and velocities computed from the Riemann solver for use in the non-conservative terms. These derivatives are used only for multi-material hydro and unused for single-material compflow and linear transport.

Compute boundary surface flux integrals for a given boundary type for DG

This function computes contributions from surface integrals along all faces for a particular boundary condition type, configured by the state function

void tk::update_rhs_bc(ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_l, const tk::real wt, const std::array<tk::real, 3>& fn, const std::size_t el, const std::vector<tk::real>& fl, const std::vector<tk::real>& B_l, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)

Update the rhs by adding the boundary surface integration term.

Parameters
ncomp in Number of scalar components in this PDE system
nmat in Number of materials in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
ndof_l in Number of degrees of freedom for the left element
wt in Weight of gauss quadrature point
fn in Face/Surface normal
el in Left element index
fl in Surface flux
B_l in Basis function for the left element
in/out Right-hand side vector computed
riemannDeriv in/out Derivatives of partial-pressures and velocities computed from the Riemann solver for use in the non-conservative terms. These derivatives are used only for multi-material hydro and unused for single-material compflow and linear transport.

void tk::initialize(ncomp_t system, ncomp_t ncomp, ncomp_t offset, const Fields& L, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const SolutionFn& solution, Fields& unk, real t, const std::size_t nielem)

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
in Block diagonal mass matrix
inpoel in Element-node connectivity
coord in Array of node coordinates
solution in Function to call to evaluate known solution or initial conditions at x,y,z,t
unk in/out Array of unknowns
in Physical time
nielem in Number of internal elements

Initalize a PDE system for DG by projecting the exact solution in the DG solution space

Initalize a system of DGPDEs by projecting the exact solution in the DG solution space

This is the public interface exposed to client code.

void tk::update_rhs(ncomp_t ncomp, const std::size_t ndof, const tk::real wt, const std::vector<tk::real>& B, const std::vector<tk::real>& s, std::vector<tk::real>& R)

Update the rhs by adding the initial analytical solution term.

Parameters
ncomp in Number of scalar components in this PDE system
ndof in Number of degrees of freedom
wt in Weight of gauss quadrature point
in Vector of basis functions
in Vector of analytical solution at quadrature point
in/out Right-hand side vector

void tk::eval_init(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::size_t e, const std::vector<tk::real>& R, const Fields& L, Fields& unk)

Compute the initial conditions.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
ndof in Number of degrees of freedom
rdof in Total number of reconstructed degrees of freedom
in Element index
in Right-hand side vector
in Block diagonal mass matrix
unk in/out Array of unknowns

void tk::mass(ncomp_t ncomp, ncomp_t offset, const Fields& geoElem, Fields& l)

Compute the block-diagnoal mass matrix for DG.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
geoElem in Element geometry array
in/out Block diagonal mass matrix

void tk::nonConservativeInt(] ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const Fields& U, const std::vector<std::vector<tk::real>>& riemannDeriv, const std::vector<std::size_t>& ndofel, Fields& R)

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
nmat in Number of materials in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
rdof in Maximum number of reconstructed degrees of freedom
inpoel in Element-node connectivity
coord in Array of nodal coordinates
geoElem in Element geometry array
in Solution vector at recent time step
riemannDeriv in Derivatives of partial-pressures and velocities computed from the Riemann solver for use in the non-conservative terms
ndofel in Vector of local number of degrees of freedome
in/out Right-hand side vector added to

This is called for multi-material DG, computing volume integrals of terms in the volume fraction and energy equations, which do not exist in the single-material flow formulation (for CompFlow DG). For further details see Pelanti, M., & Shyue, K. M. (2019). A numerical model for multiphase liquid–vapor–gas flows with interfaces and cavitation. International Journal of Multiphase Flow, 113, 208-230.

void tk::update_rhs_ncn(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, ] const std::size_t ndof_el, const tk::real wt, const std::size_t e, ] const std::array<std::vector<tk::real>, 3>& dBdx, const std::vector<tk::real>& ncf, Fields& R)

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
ndof_el in Number of degrees of freedom for local element
wt in Weight of gauss quadrature point
in Element index
dBdx in Vector of basis function derivatives
ncf in Vector of non-conservative terms
in/out Right-hand side vector computed

std::size_t tk::NGvol(const std::size_t ndof) constexpr

Parameters
ndof in Number of degrees of freedom

Initialization of number of Gauss points for volume integration

std::size_t tk::NGfa(const std::size_t ndof) constexpr

Parameters
ndof in Number of degrees of freedom

Initialization of number of Gauss points for face integration

std::size_t tk::NGdiag(const std::size_t ndof) constexpr

Initialization of number of Gauss points for volume integration in error estimation.

Parameters
ndof in Number of degrees of freedom

std::size_t tk::NGinit(const std::size_t ndof) constexpr

Initialization of number of Gauss points for volume integration in DG initialization.

Parameters
ndof in Number of degrees of freedom

void tk::GaussQuadratureTet(std::size_t NG, std::array<std::vector<real>, 3>& coordgp, std::vector<real>& wgp)

Initialize Gaussian quadrature points locations and weights for a tetrahedron.

Parameters
NG in number of quadrature points
coordgp in/out 3 spatial coordinates of quadrature points
wgp in/out Weights of quadrature points

Initialize Gaussian quadrature points locations and weights for a tetrahedron

void tk::GaussQuadratureTri(std::size_t NG, std::array<std::vector<real>, 2>& coordgp, std::vector<real>& wgp)

Initialize Gaussian quadrature points locations and weights for a triangle.

Parameters
NG in number of quadrature points
coordgp in/out 2 spatial coordinates of quadrature points
wgp in/out Weights of quadrature points

Initialize Gaussian quadrature points locations and weights for a triangle

void tk::srcInt(ncomp_t system, ncomp_t ncomp, ncomp_t offset, real t, const std::size_t ndof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const SrcFn& src, const std::vector<std::size_t>& ndofel, Fields& R)

Compute source term integrals for DG.

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
in Physical time
ndof in Maximum number of degrees of freedom
inpoel in Element-node connectivity
coord in Array of nodal coordinates
geoElem in Element geometry array
src in Source function to use
ndofel in Vector of local number of degrees of freedome
in/out Right-hand side vector computed

void tk::update_rhs(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const tk::real wt, const std::size_t e, const std::vector<tk::real>& B, const std::vector<tk::real>& s, Fields& R)

Update the rhs by adding the source term integrals.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
ndof_el in Number of degrees of freedom for local element
wt in Weight of gauss quadrature point
in Element index
in Vector of basis functions
in Vector of source terms
in/out Right-hand side vector computed

void tk::surfInt(ncomp_t system, ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t rdof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const inciter::FaceData& fd, const Fields& geoFace, const RiemannFluxFn& flux, const VelFn& vel, const Fields& U, const Fields& P, const std::vector<std::size_t>& ndofel, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)

Compute internal surface flux integrals for DG.

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
nmat in Number of materials in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
rdof in Maximum number of reconstructed degrees of freedom
inpoel in Element-node connectivity
coord in Array of nodal coordinates
fd in Face connectivity and boundary conditions object
geoFace in Face geometry array
flux in Riemann flux function to use
vel in Function to use to query prescribed velocity (if any)
in Solution vector at recent time step
in Vector of primitives at recent time step
ndofel in Vector of local number of degrees of freedome
in/out Right-hand side vector computed
riemannDeriv in/out Derivatives of partial-pressures and velocities computed from the Riemann solver for use in the non-conservative terms. These derivatives are used only for multi-material hydro and unused for single-material compflow and linear transport.

void tk::update_rhs_fa(ncomp_t ncomp, std::size_t nmat, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_l, const std::size_t ndof_r, const tk::real wt, const std::array<tk::real, 3>& fn, const std::size_t el, const std::size_t er, const std::vector<tk::real>& fl, const std::vector<tk::real>& B_l, const std::vector<tk::real>& B_r, Fields& R, std::vector<std::vector<tk::real>>& riemannDeriv)

Parameters
ncomp in Number of scalar components in this PDE system
nmat in Number of materials in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
ndof_l in Number of degrees of freedom for left element
ndof_r in Number of degrees of freedom for right element
wt in Weight of gauss quadrature point
fn in Face/Surface normal
el in Left element index
er in Right element index
fl in Surface flux
B_l in Basis function for the left element
B_r in Basis function for the right element
in/out Right-hand side vector computed
riemannDeriv in/out Derivatives of partial-pressures and velocities computed from the Riemann solver for use in the non-conservative terms. These derivatives are used only for multi-material hydro and unused for single-material compflow and linear transport.

void tk::volInt(ncomp_t system, ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, const Fields& geoElem, const FluxFn& flux, const VelFn& vel, const Fields& U, const std::vector<std::size_t>& ndofel, Fields& R)

Compute volume integrals for DG.

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
inpoel in Element-node connectivity
coord in Array of nodal coordinates
geoElem in Element geometry array
flux in Flux function to use
vel in Function to use to query prescribed velocity (if any)
in Solution vector at recent time step
ndofel in Vector of local number of degrees of freedome
in/out Right-hand side vector added to

void tk::update_rhs(ncomp_t ncomp, ncomp_t offset, const std::size_t ndof, const std::size_t ndof_el, const tk::real wt, const std::size_t e, const std::array<std::vector<tk::real>, 3>& dBdx, const std::vector<std::array<tk::real, 3>>& fl, Fields& R)

Update the rhs by adding the source term integrals.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
ndof in Maximum number of degrees of freedom
ndof_el in Number of degrees of freedom for local element
wt in Weight of gauss quadrature point
in Element index
dBdx in Vector of basis function derivatives
fl in Vector of numerical flux
in/out Right-hand side vector computed

void tk::intLeastSq_P0P1(ncomp_t ncomp, ncomp_t offset, const std::size_t rdof, const inciter::FaceData& fd, const Fields& geoElem, const Fields& U, std::vector<std::array<std::array<real, 3>, 3>>& lhs_ls, std::vector<std::vector<std::array<real, 3>>>& rhs_ls)

Compute internal surface contributions to the least-squares reconstruction.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
rdof in Maximum number of reconstructed degrees of freedom
fd in Face connectivity and boundary conditions object
geoElem in Element geometry array
in Solution vector at recent time step
lhs_ls in/out LHS reconstruction matrix
rhs_ls in/out RHS reconstruction vector

void tk::bndLeastSq_P0P1(ncomp_t system, ncomp_t ncomp, ncomp_t offset, std::size_t rdof, const std::vector<bcconf_t>& bcconfig, const inciter::FaceData& fd, const Fields& geoFace, const Fields& geoElem, real t, const StateFn& state, const Fields& U, std::vector<std::array<std::array<real, 3>, 3>>& lhs_ls, std::vector<std::vector<std::array<real, 3>>>& rhs_ls, std::size_t nprim = 0)

Compute boundary face contributions to the least-squares reconstruction.

Parameters
system in Equation system index
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
rdof in Maximum number of reconstructed degrees of freedom
bcconfig in BC configuration vector for multiple side sets
fd in Face connectivity and boundary conditions object
geoFace in Face geometry array
geoElem in Element geometry array
in Physical time
state in Function to evaluate the left and right solution state at boundaries
in Solution vector at recent time step
lhs_ls in/out LHS reconstruction matrix
rhs_ls in/out RHS reconstruction vector
nprim in Number of primitive quantities stored for this PDE system. A default is set to 0, so that calling code for systems that do not store primitive quantities does not need to specify this argument.

void tk::solveLeastSq_P0P1(ncomp_t ncomp, ncomp_t offset, const std::size_t rdof, const std::vector<std::array<std::array<real, 3>, 3>>& lhs, const std::vector<std::vector<std::array<real, 3>>>& rhs, Fields& U)

Solve 3x3 system for least-squares reconstruction.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Offset this PDE system operates from
rdof in Maximum number of reconstructed degrees of freedom
lhs in LHS reconstruction matrix
rhs in RHS reconstruction vector
in/out Solution vector at recent time step

void tk::transform_P0P1(ncomp_t ncomp, ncomp_t offset, std::size_t rdof, std::size_t nelem, const std::vector<std::size_t>& inpoel, const UnsMesh::Coords& coord, Fields& U)

Transform the reconstructed P1-derivatives to the Dubiner dofs.

Parameters
ncomp in Number of scalar components in this PDE system
offset in Index for equation systems
rdof in Total number of reconstructed dofs
nelem in Total number of elements
inpoel in Element-node connectivity
coord in Array of nodal coordinates
in/out Second-order solution vector which gets transformed to the Dubiner reference space

void tk::getMultiMatPrimitives_P0P1(ncomp_t offset, std::size_t nmat, std::size_t rdof, std::size_t nelem, const Fields& U, Fields& P)

Reconstruct the vector of high-order primitives.

Parameters
offset in Index for equation systems
nmat in Number of materials in this equation system
rdof in Total number of reconstructed dofs
nelem in Total number of elements
in Second-order solution vector
in/out Second-order vector of primitives which gets computed from the second-order solution vector

std::pair<int, std::unique_ptr<char[]>> tk::serialize(const std::vector<tk::UniPDF>& u)

Serialize univariate PDF to raw memory stream.

Parameters
in Univariate PDFs
Returns Pair of the length and the raw stream containing the serialized PDFs

CkReductionMsg* tk::mergeUniPDFs(int nmsg, CkReductionMsg** msgs)

Charm++ custom reducer for merging a univariate PDF during reduction across PEs.

Parameters
nmsg in Number of messages in msgs
msgs in Charm++ reduction message containing the serialized PDF
Returns Aggregated PDF built for further aggregation if needed

std::pair<int, std::unique_ptr<char[]>> tk::serialize(const std::vector<tk::UniPDF>& u, const std::vector<tk::BiPDF>& b, const std::vector<tk::TriPDF>& t)

Serialize vectors of PDFs to raw memory stream.

Parameters
in Vector of univariate PDFs
in Vector of bivariate PDFs
in Vector of trivariate PDFs
Returns Pair of the length and the raw stream containing the serialized PDFs

CkReductionMsg* tk::mergePDF(int nmsg, CkReductionMsg** msgs)

Charm++ custom reducer for merging PDFs during reduction across PEs.

Parameters
nmsg in Number of messages in msgs
msgs in Charm++ reduction message containing the serialized PDFs
Returns Aggregated PDFs built for further aggregation if needed

static std::ostream& tk::operator<<(std::ostream& os, const tk::UniPDF& p)

Parameters
os in/out Stream to output to
in PDF to output
Returns Updated stream

Output univariate PDF to output stream

Variable documentation

const std::array<std::size_t, 2> tk::ExoNnpe

ExodusII mesh cell number of nodes

List of number of nodes per element for different element types supported in the order of tk::ExoElemType

const std::array<std::array<std::size_t, 3>, 4> tk::expofa

ExodusII face-node numbering for tetrahedron side sets

const std::array<UnsMesh::Face, 4> tk::lpofa

Const array defining the node ordering convention for a tetrahedron cell

This two-dimensional array stores the naming/ordering convention of the node indices of a tetrahedron (tet) element. The dimensions are 4x3 as a tetrahedron has a total of 4 nodes and each (triangle) face has 3 nodes. Thus the array below associates tet node 0 with nodes {1,2,3}, tet node 1 with {2,0,3}, tet node 2 with {3,0,1}, and tet node 3 with {0,2,1}. Note that not only these mappings are important, but also the order of the nodes within the triplets as this specific order also defines the outwards normal of each face.

static highwayhash::HH_U64 tk::hh_key constexpr

Highway hash "secret" key