Skip to content

Add multi-index utilities to treepath

When manipulating multi-indices, it becomes very handy if accumulation, reverse and join are implemented in a generic way (i.e. Hybrid and ADL resolvable). This MR adds these utilities to the tree path.

Accumulate Back/Front

This is useful when generating muti-indices in function spaces. The front/back of the path will be accumulated and promoted in order to hold the new index:

// accumulate_back examples
accumulate_back(treePath(_0,_2),_2) -> treePath(_0,_4)
accumulate_back(treePath(_0,_2), 2) -> treePath(_0, 4)
accumulate_back(treePath(_0, 2),_2) -> treePath(_0, 4)
accumulate_back(treePath(_0, 2), 2) -> treePath(_0, 4)
// accumulate_front examples
accumulate_front(treePath(_0,_2),_2) -> treePath(_2,_2)
accumulate_front(treePath(_0,_2), 2) -> treePath( 2,_2)
accumulate_front(treePath( 0,_2),_2) -> treePath( 2,_2)
accumulate_front(treePath( 0,_2), 2) -> treePath( 2,_2)

Join

Merges two tree paths into one. This is useful when making proxy nodes for sub-spaces or node algorithms that manipulate paths to self nodes and leaf nodes.

join(treePath(0,_2), treePath(_3,4)) -> treepath(0,_2,_3,4)

Reverse

Different algorithms have different requirements on the semantics of the multi-index to access a container. The most prominently case in DUNE, is that dune-functions works with root-to-leaf while dune-pdelab works with leaf-to-root semantics.

reverse(treePath(0,_2)) -> treepath(_2,0)

Capacity

Additionally, when mixing algorithms for hybrid muti-indices and full runtime multi-indices, it is helpful to have two functions: size() and max_size(). Max size is guaranteed to be always a compile-time value, while size will depend on the multi-index type. (AFIU, we always want indices on the stack and is a fair assumption to make). Naturally, for tree path multi-indices, both are always compile-time expressions.

Edited by Santiago Ospina De Los Ríos

Merge request reports