Node

Node definition

template <std::size_t Dim, typename value_type = std::size_t>
struct definitions

Public Static Attributes

const int size = sizeof(value_type)*8

size of Node in digits.

const int nbfreebits = 5

number of freebits used for MR.

const int nblevelbits = max_level(dim, nbfreebits, size)

number of digit for level.

const int nlevels = (size-nbfreebits-nblevelbits)/dim

max number of tree levels.

const int treetype = 1<<dim

bin (1d), quad(2d), octo (3d) trees.

const int nfaces = 2*dim

number of faces of each element

const int nbbef = 1<<(dim-1)

number of elements when you refine once on each face (1d: 1, 2d: 2, 3d: 4).

const int nbd = ipow(2, dim) << dim

number max of bound. elements (1d: 2, 2d: 12, 3d: 56).

const int levelshift = size-nblevelbits

amount of right shift needed to get level in the tree.

constexpr value_type levelone = one<<levelshift

first digit marking levels:

const value_type levelmask = AllSet2One<dim, nblevelbits, value_type>::value

mask for extracting level:

const value_type levelzone = (levelmask)<<levelshift

mask the part used to store level

constexpr value_type maskpos = AllSet2One<dim, dim*nlevels, value_type>::value

mask for what is used for position:

const int nbneighb = ipow(3, dim)

how many neighbors for one Node (including itself).

const value_type Xbit = one<<(dim*nlevels-1)

bits used in nodes computations (Zbit not used -2d problem!-)

leftmost digit for x position

const value_type Ybit = (dim==1)? 0: (Xbit>>1)

leftmost digit for y position

const value_type Zbit = (dim==3)? (Xbit>>2): 0

! not used (for compatibility with the 3-d case).

const value_type IntOne = one

! 1!

const value_type AllExceptVoidbit = allone - voidbit

mask for extracting all, but the void bit:

Node class

template <std::size_t Dim, typename Value = std::size_t>
struct Node

Inherits from definitions< Dim, Value >

Public Functions

bool is_max(direction d) const

test if the node as max coordinate

Parameters
  • d: the direction.

bool is_min(direction d) const

test if the node as min coordinate

Parameters
  • d: direction.

std::size_t lastlevel() const

get the last level digits of a node in an int (flushed right).

Note
this can be applied to hashed and non hashed Nodes.
Parameters
  • node:

bool is_minimal() const

is a Node minimal (ie has minimal abscissa) in his set of Brothers?

void setTags(Node &n) const

set the tag part of a Node

Note
we do not check V.
Parameters
  • N: pointer to the Node.
  • V: tag value

Node hash() const

return the hash code for nodes.

Note
we do not test if x is already hashed, except if DEBUG is set.
Parameters

Node unhash() const

For a given hasehd representation of a Node, we return the non hashed representation.

Parameters

bool isHashed() const

Is a node hashed?

Node family

Functions

template <std::size_t dim, typename value_type>
Node<dim, value_type> firstSon(Node<dim, value_type> const &node)

return the son of a Node which has the smallest absissa (ie, the 1rst one in the son’s brotherhood.

Note
we return a non hashed Node.
Parameters

template <typename Node_type>
Node_type lastSon(Node_type const &node)

return the son of a Node which has the largestlest absissa (ie, the last one in the son’s brotherhood.

Note
we return a non hashed Node.
Parameters

template <typename Node_type>
Node_type father(Node_type const &node)

compute the father of a node

Parameters
  • node: node.

template <typename Node_type>
bool isAncestor(Node_type A, Node_type X)

test if a Node A is an ancestor of a Node X.

Note
each Node is its own ancestor, too.
Parameters

template <typename Node_type>
bool shareAncestor(Node_type A, Node_type B, std::size_t lv)

Do 2 Nodes share the same ancestor of a given level ?

Parameters

template <typename Node_type, typename Node_array>
void brothers_impl(Node_type const &node, Node_array &Brothers, std::integral_constant<std::size_t, 1>)
template <typename Node_type, typename Node_array>
void brothers_impl(Node_type const &node, Node_array &Brothers, std::integral_constant<std::size_t, 2>)
template <typename Node_type, typename Node_array>
void brothers_impl(Node_type const &node, Node_array &Brothers, std::integral_constant<std::size_t, 3>)
template <typename Node_type, typename Node_array>
void brothers(Node_type const &node, Node_array &Brothers)

Make the list of the brothers of a minimal node in a brothers set.

Note
node must be minimal in his brothers set. NOT TESTED, except if DEBUG is set.
Note
Brothers[0] == node.
Note
the output array Brothers is ordered.
Parameters
  • node: the node for which we build the list.
  • Brothers: the list of brothers.

Node neighbors

Functions

template <typename Node_type, std::size_t nx>
void neighbors(Node_type const &node, std::array<Node_type, nx> &node_array, std::array<int, nx> const &stencilx)
template <typename Node_type, std::size_t nx, std::size_t ny>
void neighbors(Node_type const &node, std::array<Node_type, nx *ny> &node_array, std::array<int, nx> const &stencilx, std::array<int, ny> const &stencily)
template <typename Node_type, std::size_t ns>
void neighbors(Node_type const &node, std::array<Node_type, ns> &node_array, std::array<std::array<int, 2>, ns> const &stencil)
template <typename Node_type, std::size_t ns>
void neighbors(Node_type const &node, std::array<Node_type, ns> &node_array, std::array<std::array<int, 3>, ns> const &stencil)
template <typename Node_type, std::size_t nx, std::size_t ny, std::size_t nz>
void neighbors(Node_type const &node, std::array<Node_type, nx *ny *nz> &node_array, std::array<int, nx> const &stencilx, std::array<int, ny> const &stencily, std::array<int, nz> const &stencilz)
template <std::size_t stencil, typename Node_type, typename Node_array>
void boxNeighbors_impl(Node_type const &n, Node_array &node_array, std::integral_constant<std::size_t, 1>)
template <std::size_t stencil, typename Node_type, typename Node_array>
void boxNeighbors_impl(Node_type const &n, Node_array &node_array, std::integral_constant<std::size_t, 2>)
template <std::size_t stencil, typename Node_type, typename Node_array>
void boxNeighbors_impl(Node_type const &n, Node_array &node_array, std::integral_constant<std::size_t, 3>)
template <std::size_t stencil, typename Node_type, typename Node_array>
void boxNeighbors(Node_type const &n, Node_array &node_array)

find a potential neighbor, depending on the position of u.

Parameters
  • u: node.
  • P[]: returned list(vector)

template <int stencil, typename Node_type, typename Node_array>
void starNeighbors_impl(Node_type const &n, Node_array &node_array, std::integral_constant<std::size_t, 1>)
template <int stencil, typename Node_type, typename Node_array>
void starNeighbors_impl(Node_type const &n, Node_array &node_array, std::integral_constant<std::size_t, 2>)
template <int stencil, typename Node_type, typename Node_array>
void starNeighbors_impl(Node_type const &n, Node_array &node_array, std::integral_constant<std::size_t, 3>)
template <int stencil, typename Node_type, typename Node_array>
void starNeighbors(Node_type const &n, Node_array &node_array)

find a potential neighbor, depending on the position of u.

Parameters
  • u: node.
  • P[]: returned list(vector)

Node refinment

Functions

template <typename Node_type, typename Node_array>
void refine(Node_type const &n, Node_array &refined)

refine n.

Results in refined[0: treetype-1].

Parameters
  • n: node.
  • refined[]: the refined nodes.