t8  1.2.0
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
Data Structures | Typedefs | Functions
t8_cmesh_stash.h File Reference

We define the data structures and routines for temporary storage before commit. More...

#include <t8.h>
#include <t8_eclass.h>

Go to the source code of this file.

Data Structures

struct  t8_stash_class
 The eclass information that is stored before a cmesh is committed. More...
 
struct  t8_stash_joinface
 The face-connection information that is stored before a cmesh is committed. More...
 
struct  t8_stash_attribute
 The attribute information that is stored before a cmesh is committed. More...
 
struct  t8_stash
 The stash data structure is used to store information about the cmesh before it is commited. More...
 

Typedefs

typedef struct t8_stasht8_stash_t
 
typedef struct t8_stash_class t8_stash_class_struct_t
 The eclass information that is stored before a cmesh is committed.
 
typedef struct t8_stash_joinface t8_stash_joinface_struct_t
 The face-connection information that is stored before a cmesh is committed.
 
typedef struct t8_stash_attribute t8_stash_attribute_struct_t
 The attribute information that is stored before a cmesh is committed. More...
 
typedef struct t8_stash t8_stash_struct_t
 The stash data structure is used to store information about the cmesh before it is commited. More...
 

Functions

void t8_stash_init (t8_stash_t *pstash)
 Initialize a stash data structure. More...
 
void t8_stash_destroy (t8_stash_t *pstash)
 Free all memory associated in a stash structure. More...
 
void t8_stash_add_class (t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass)
 Set the eclass of a tree. More...
 
void t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int face1, int face2, int orientation)
 Add a face connection to a stash. More...
 
void t8_stash_class_sort (t8_stash_t stash)
 Sort the entries in the class array by the order given in the enum definition of t8_eclass. More...
 
ssize_t t8_stash_class_bsearch (t8_stash_t stash, t8_gloidx_t tree_id)
 Search for an entry with a given tree index in the class-stash. More...
 
void t8_stash_joinface_sort (t8_stash_t stash)
 Sort then entries in the facejoin array in order of the first treeid. More...
 
void t8_stash_add_attribute (t8_stash_t stash, t8_gloidx_t id, int package_id, int key, size_t size, void *attr, int copy)
 Add an attribute to a tree. More...
 
size_t t8_stash_get_attribute_size (t8_stash_t stash, size_t index)
 Return the size (in bytes) of an attribute in the stash. More...
 
void * t8_stash_get_attribute (t8_stash_t stash, size_t index)
 Return the pointer to an attribute in the stash. More...
 
t8_gloidx_t t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index)
 Return the id of the tree a given attribute belongs to. More...
 
int t8_stash_get_attribute_key (t8_stash_t stash, size_t index)
 Return the key of a given attribute. More...
 
int t8_stash_get_attribute_id (t8_stash_t stash, size_t index)
 Return the package_id of a given attribute. More...
 
int t8_stash_attribute_is_owned (t8_stash_t stash, size_t index)
 Return true if an attribute in the stash is owned by the stash, that is, it was copied in the call to t8_stash_add_attribute. More...
 
void t8_stash_attribute_sort (t8_stash_t stash)
 Sort the attributes array of a stash in the order (treeid, packageid, key) *. More...
 
t8_stash_t t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, size_t elem_counts[3])
 Broadcast a stash on the root process to all processes in a communicator. More...
 
int t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b)
 Check two stashes for equal content and return true if so. More...
 

Detailed Description

We define the data structures and routines for temporary storage before commit.

Typedef Documentation

◆ t8_stash_attribute_struct_t

The attribute information that is stored before a cmesh is committed.

The pair (package_id, key) serves as a lookup key to identify the data.

◆ t8_stash_struct_t

typedef struct t8_stash t8_stash_struct_t

The stash data structure is used to store information about the cmesh before it is commited.

In particular we store the eclasses of the trees, the face-connections and the tree attributes. Using the stash structure allows us to have a very flexible interface. When constructing a new mesh, the user can specify all these mesh entities in arbitrary order. As soon as the cmesh is commited the information is copied from the stash to the cmesh in an order mannered.

Function Documentation

◆ t8_stash_add_attribute()

void t8_stash_add_attribute ( t8_stash_t  stash,
t8_gloidx_t  id,
int  package_id,
int  key,
size_t  size,
void *  attr,
int  copy 
)

Add an attribute to a tree.

Parameters
[in]stashThe stash structure to be modified.
[in]idThe global index of the tree to which the attribute is added.
[in]package_idThe unique id of the current package.
[in]keyAn integer value used to identify this attribute.
[in]sizeThe size (in bytes) of the attribute.
[in]attrPoints to size bytes of memory that should be stored as the attribute.
[in]copyIf true the attribute data is copied from attr to an internal storage. If false only the pointer attr is stored and the data is only copied if the cmesh is committed. (More memory efficient).

◆ t8_stash_add_class()

void t8_stash_add_class ( t8_stash_t  stash,
t8_gloidx_t  id,
t8_eclass_t  eclass 
)

Set the eclass of a tree.

Parameters
[in,out]stashThe stash to be updated.
[in]idThe global id of the tree whose eclass should be set.
[in]eclassThe eclass of tree with id id.

◆ t8_stash_add_facejoin()

void t8_stash_add_facejoin ( t8_stash_t  stash,
t8_gloidx_t  gid1,
t8_gloidx_t  gid2,
int  face1,
int  face2,
int  orientation 
)

Add a face connection to a stash.

Parameters
[in,out]stashThe stash to be updated.
[in]id1The global id of the first tree.
[in]id2The global id of the second tree,
[in]face1The face number of the face of the first tree.
[in]face2The face number of the face of the second tree.
[in]orientationThe orientation of the faces to each other.

◆ t8_stash_attribute_is_owned()

int t8_stash_attribute_is_owned ( t8_stash_t  stash,
size_t  index 
)

Return true if an attribute in the stash is owned by the stash, that is, it was copied in the call to t8_stash_add_attribute.

Returns false if the attribute is not owned by the stash.

Parameters
[in]stashThe stash to be considered.
[in]indexThe index of the attribute in the attribute array of stash.
Returns
True of false.

◆ t8_stash_attribute_sort()

void t8_stash_attribute_sort ( t8_stash_t  stash)

Sort the attributes array of a stash in the order (treeid, packageid, key) *.

Parameters
[in,out]stashThe stash to be considered.

◆ t8_stash_bcast()

t8_stash_t t8_stash_bcast ( t8_stash_t  stash,
int  root,
sc_MPI_Comm  comm,
size_t  elem_counts[3] 
)

Broadcast a stash on the root process to all processes in a communicator.

The number of entries in the classes, joinfaces and attributes arrays must be known on the receiving processes before calling this function.

Parameters
[in,out]stashOn root the stash that is to be broadcasted. On the other process an initialized stash. Its entries will get overwritten by the entries in the root stash.
[in]rootThe mpirank of the root process.
[in]commThe mpi communicator which is used fpr broadcast.
[in]elem_countsAn array with three entries giving the number of elements in the classes, joinfaces and attributes arrays.

◆ t8_stash_class_bsearch()

ssize_t t8_stash_class_bsearch ( t8_stash_t  stash,
t8_gloidx_t  tree_id 
)

Search for an entry with a given tree index in the class-stash.

The stash must be sorted beforehand.

Parameters
[in]stashThe stash to be searched for.
[in]tree_idThe global tree id.
Returns
The index of an element in the classes array of stash corresponding to tree_id. -1 if not found.

◆ t8_stash_class_sort()

void t8_stash_class_sort ( t8_stash_t  stash)

Sort the entries in the class array by the order given in the enum definition of t8_eclass.

Parameters
[in,out]stashThe stash whose class array is sorted.

◆ t8_stash_destroy()

void t8_stash_destroy ( t8_stash_t pstash)

Free all memory associated in a stash structure.

Parameters
[in,out]pstashA pointer to the stash to be destroyed. The pointer is set to NULL after the function call.

◆ t8_stash_get_attribute()

void* t8_stash_get_attribute ( t8_stash_t  stash,
size_t  index 
)

Return the pointer to an attribute in the stash.

Parameters
[in]stashThe stash to be considered.
[in]indexThe index of the attribute in the attribute array of stash.
Returns
A void pointer to the memory region where the attribute is stored.

◆ t8_stash_get_attribute_id()

int t8_stash_get_attribute_id ( t8_stash_t  stash,
size_t  index 
)

Return the package_id of a given attribute.

Parameters
[in]stashThe stash to be considered.
[in]indexThe index of the attribute in the attribute array of stash.
Returns
The attribute's package_id.

◆ t8_stash_get_attribute_key()

int t8_stash_get_attribute_key ( t8_stash_t  stash,
size_t  index 
)

Return the key of a given attribute.

Parameters
[in]stashThe stash to be considered.
[in]indexThe index of the attribute in the attribute array of stash.
Returns
The attribute's key.

◆ t8_stash_get_attribute_size()

size_t t8_stash_get_attribute_size ( t8_stash_t  stash,
size_t  index 
)

Return the size (in bytes) of an attribute in the stash.

Parameters
[in]stashThe stash to be considered.
[in]indexThe index of the attribute in the attribute array of stash.
Returns
The size in bytes of the attribute.

◆ t8_stash_get_attribute_tree_id()

t8_gloidx_t t8_stash_get_attribute_tree_id ( t8_stash_t  stash,
size_t  index 
)

Return the id of the tree a given attribute belongs to.

Parameters
[in]stashThe stash to be considered.
[in]indexThe index of the attribute in the attribute array of stash.
Returns
The tree id.

◆ t8_stash_init()

void t8_stash_init ( t8_stash_t pstash)

Initialize a stash data structure.

Parameters
[in,out]pstashA pointer to the stash to be initialized.

◆ t8_stash_is_equal()

int t8_stash_is_equal ( t8_stash_t  stash_a,
t8_stash_t  stash_b 
)

Check two stashes for equal content and return true if so.

Parameters
[in]stash_aThe first stash to be considered.
[in]stash_bThe first stash to be considered.
Returns
True if both stashes hold copies of the same data. False otherwise.

◆ t8_stash_joinface_sort()

void t8_stash_joinface_sort ( t8_stash_t  stash)

Sort then entries in the facejoin array in order of the first treeid.

Parameters
[in,out]stashThe stash whose facejoin array is sorted.