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 | Macros | Functions
t8_cmesh_trees.h File Reference

TODO: document this file. More...

#include <t8.h>
#include <t8_cmesh.h>
#include "t8_cmesh_types.h"

Go to the source code of this file.

Data Structures

struct  t8_trees_glo_lo_hash_t
 This struct is an entry of the trees global_id to local_id hash table for ghost trees. More...
 

Macros

#define T8_TREE_FIRST_ATT(t)   ((char *)(t) + (t)->att_offset)
 
#define T8_TREE_ATTR_INFO(t, i)
 
#define T8_TREE_ATTR(t, ai)   (T8_TREE_FIRST_ATT(t) + (ai)->attribute_offset)
 
#define T8_TREE_FACE(t)   ((char *) (t) + (t)->neigh_offset)
 
#define T8_TREE_TTF(t)
 
#define T8_GHOST_FIRST_ATT(g)   T8_TREE_FIRST_ATT (g)
 
#define T8_GHOST_ATTR_INFO(g, i)   T8_TREE_ATTR_INFO (g, i)
 
#define T8_GHOST_ATTR(g, ai)   T8_TREE_ATTR(g,ai)
 
#define T8_GHOST_FACE(g)   T8_TREE_FACE(g)
 
#define T8_GHOST_TTF(g)
 

Functions

void t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, int num_procs, t8_locidx_t num_trees, t8_locidx_t num_ghosts)
 Initialize a trees structure and allocate its parts. More...
 
t8_part_tree_t t8_cmesh_trees_get_part (t8_cmesh_trees_t trees, int proc)
 Return one part of a specified tree array. More...
 
void t8_cmesh_trees_start_part (t8_cmesh_trees_t trees, int proc, t8_locidx_t lfirst_tree, t8_locidx_t num_trees, t8_locidx_t lfirst_ghost, t8_locidx_t num_ghosts, int alloc)
 Allocate the first_tree array of a given tree_part in a tree struct with a given number of trees and ghosts. More...
 
void t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc)
 After all classes of trees and ghosts have been set and after the number of tree attributes was set and their total size (per tree) stored temporarily in the att_offset variable we grow the part array by the needed amount of memory and set the offsets appropiately. More...
 
void t8_cmesh_trees_copy_toproc (t8_cmesh_trees_t trees_dest, t8_cmesh_trees_t trees_src, t8_locidx_t lnum_trees, t8_locidx_t lnum_ghosts)
 Copy the tree_to_proc and ghost_to_proc arrays of one tree structure to another one. More...
 
void t8_cmesh_trees_copy_part (t8_cmesh_trees_t trees_dest, int part_dest, t8_cmesh_trees_t trees_src, int part_src)
 Copy the trees array from one part to another. More...
 
void t8_cmesh_trees_add_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int proc, t8_eclass_t eclass)
 Add a tree to a trees structure. More...
 
void t8_cmesh_trees_add_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost_index, t8_gloidx_t gtree_id, int proc, t8_eclass_t eclass, t8_locidx_t num_local_trees)
 Add a ghost to a trees structure. More...
 
void t8_cmesh_trees_set_all_boundary (t8_cmesh_t cmesh, t8_cmesh_trees_t trees)
 Set all neighbor fields of all local trees and ghosts to boundary. More...
 
void t8_cmesh_trees_get_part_data (t8_cmesh_trees_t trees, int proc, t8_locidx_t *first_tree, t8_locidx_t *num_trees, t8_locidx_t *first_ghost, t8_locidx_t *num_ghosts)
 
t8_ctree_t t8_cmesh_trees_get_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree)
 Return a pointer to a specific tree in a trees struct. More...
 
t8_ctree_t t8_cmesh_trees_get_tree_ext (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, t8_locidx_t **face_neigh, int8_t **ttf)
 Return a pointer to a specific tree in a trees struct plus pointers to its face_neighbor and tree_to_face arrays. More...
 
t8_locidx_t t8_cmesh_trees_get_face_info (t8_cmesh_trees_t trees, t8_locidx_t ltreeid, int face, int8_t *ttf)
 Return the face neigbor of a tree at a given face and return the tree_to_face info. More...
 
t8_locidx_t t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face)
 Given a coarse tree and a face number, return the local id of the neighbor tree. More...
 
t8_locidx_t t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int8_t *ttf)
 Given a coarse tree and a face number, return the local id of the neighbor tree together with its tree-to-face info. More...
 
t8_gloidx_t t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int face, int8_t *ttf)
 Given a coarse ghost and a face number, return the local id of the neighbor tree together with its tree-to-face info. More...
 
t8_cghost_t t8_cmesh_trees_get_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost)
 Return a pointer to a specific ghost in a trees struct. More...
 
t8_cghost_t t8_cmesh_trees_get_ghost_ext (t8_cmesh_trees_t trees, t8_locidx_t lghost_id, t8_gloidx_t **face_neigh, int8_t **ttf)
 Return a pointer to a specific ghost in a trees struct plus pointers to its face_neighbor and tree_to_face arrays. More...
 
t8_locidx_t t8_cmesh_trees_get_ghost_local_id (t8_cmesh_trees_t trees, t8_gloidx_t global_id)
 Given the global tree id of a ghost tree in a trees structure, return its local ghost id. More...
 
size_t t8_cmesh_trees_size (t8_cmesh_trees_t trees)
 
void t8_cmesh_trees_init_attributes (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, size_t num_attributes, size_t attr_bytes)
 For one tree in a trees structure set the number of attributes and temporarily store the total size of all of this tree's attributes. More...
 
void * t8_cmesh_trees_get_attribute (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int package_id, int key, size_t *size, int is_ghost)
 Return an attribute that is stored at a tree. More...
 
size_t t8_cmesh_trees_attribute_size (t8_ctree_t tree)
 Return the total size of all attributes stored at a specified tree. More...
 
size_t t8_cmesh_trees_ghost_attribute_size (t8_cghost_t ghost)
 Return the total size of all attributes stored at a specified ghost. More...
 
void t8_cmesh_trees_add_attribute (t8_cmesh_trees_t trees, int proc, t8_stash_attribute_struct_t *attr, t8_locidx_t tree_id, size_t index)
 
size_t t8_cmesh_trees_get_numproc (t8_cmesh_trees_t trees)
 Return the number of parts of a trees structure. More...
 
int8_t t8_cmesh_tree_to_face_encode (const int dimension, const t8_locidx_t face, const int orientation)
 Compute the tree-to-face information given a face and orientation value of a face connection. More...
 
void t8_cmesh_tree_to_face_decode (const int dimension, const int8_t tree_to_face, int *face, int *orientation)
 Given a tree-to-face value, get its encoded face number and orientation. More...
 
void t8_cmesh_trees_print (t8_cmesh_t cmesh, t8_cmesh_trees_t trees)
 Print the trees,ghosts and their neighbors in ASCII format t stdout. More...
 
void t8_cmesh_trees_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm)
 Brodcast an existing valid trees structure from a root rank to all other ranks. More...
 
int t8_cmesh_trees_is_face_consistend (t8_cmesh_t cmesh, t8_cmesh_trees_t trees)
 Check whether the face connection of a trees structure are consistent. More...
 
int t8_cmesh_trees_is_equal (t8_cmesh_t cmesh, t8_cmesh_trees_t trees_a, t8_cmesh_trees_t trees_b)
 
void t8_cmesh_trees_destroy (t8_cmesh_trees_t *trees)
 Free all memory allocated with a trees structure. More...
 

Detailed Description

TODO: document this file.

Macro Definition Documentation

◆ T8_GHOST_TTF

#define T8_GHOST_TTF (   g)
Value:
(int8_t *) (T8_GHOST_FACE(g) + \
t8_eclass_num_faces[(g)->eclass] * sizeof(t8_gloidx_t))
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:105

◆ T8_TREE_ATTR_INFO

#define T8_TREE_ATTR_INFO (   t,
 
)
Value:
((char*)(t) + (t)->att_offset + \
(i) * sizeof (t8_attribute_info_struct_t)))
This structure holds the information associated to an attribute of a tree.
Definition: t8_cmesh_types.h:215

◆ T8_TREE_TTF

#define T8_TREE_TTF (   t)
Value:
(T8_TREE_FACE(t) + \
t8_eclass_num_faces[(t)->eclass] * sizeof(t8_locidx_t))
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:94

Function Documentation

◆ t8_cmesh_tree_to_face_decode()

void t8_cmesh_tree_to_face_decode ( const int  dimension,
const int8_t  tree_to_face,
int *  face,
int *  orientation 
)

Given a tree-to-face value, get its encoded face number and orientation.

Parameters
[in]dimensionThe dimension of the corresponding eclasses.
[in]tree_to_faceA tree-to-face value
[out]faceOn output filled with the stored face value.
[out]orientationOn output filled with the stored orientation value.
Note
This function is the invers operation of t8_cmesh_tree_to_face_encode If F = t8_eclass_max_num_faces[dimension], we get orientation = tree_to_face / F face = tree_to_face % F

◆ t8_cmesh_tree_to_face_encode()

int8_t t8_cmesh_tree_to_face_encode ( const int  dimension,
const t8_locidx_t  face,
const int  orientation 
)

Compute the tree-to-face information given a face and orientation value of a face connection.

Parameters
[in]dimensionThe dimension of the corresponding eclasses.
[in]faceA face number
[in]orientationA face-to-face orientation.
Returns
The tree-to-face entry corresponding to the face/orientation combination. It is computed as t8_eclass_max_num_faces[dimension] * orientation + face

◆ t8_cmesh_trees_add_ghost()

void t8_cmesh_trees_add_ghost ( t8_cmesh_trees_t  trees,
t8_locidx_t  lghost_index,
t8_gloidx_t  gtree_id,
int  proc,
t8_eclass_t  eclass,
t8_locidx_t  num_local_trees 
)

Add a ghost to a trees structure.

Parameters
[in,out]treesThe trees structure to be updated.
[in]ghost_indexThe index in the part array of the ghost to be inserted.
[in]tree_idThe global index of the ghost.
[in]procThe mpirank of the process from which the ghost was received.
[in]eclassThe ghost's element class.
[in]num_local_treesThe number of local trees in the cmesh.

◆ t8_cmesh_trees_add_tree()

void t8_cmesh_trees_add_tree ( t8_cmesh_trees_t  trees,
t8_locidx_t  ltree_id,
int  proc,
t8_eclass_t  eclass 
)

Add a tree to a trees structure.

Parameters
[in,out]treesThe trees structure to be updated.
[in]tree_idThe local id of the tree to be inserted.
[in]procThe mpirank of the process from which the tree was received.
[in]eclassThe tree's element class.

◆ t8_cmesh_trees_attribute_size()

size_t t8_cmesh_trees_attribute_size ( t8_ctree_t  tree)

Return the total size of all attributes stored at a specified tree.

Parameters
[in]treeA tree structure.
Returns
The total size (in bytes) of the attributes of tree.

◆ t8_cmesh_trees_bcast()

void t8_cmesh_trees_bcast ( t8_cmesh_t  cmesh_in,
int  root,
sc_MPI_Comm  comm 
)

Brodcast an existing valid trees structure from a root rank to all other ranks.

The trees structure must belong to cmeshes whose meta_information is already set. t8_cmesh_bcast.

Parameters
[in]cmesh_inOn root a committed, replicated cmesh. On the other ranks an initialized cmesh with the same number of trees as on root.
[in]rootThe rank that broadcasts cmesh_in to all other ranks.
[in]commMPI communicator to use.

◆ t8_cmesh_trees_copy_part()

void t8_cmesh_trees_copy_part ( t8_cmesh_trees_t  trees_dest,
int  part_dest,
t8_cmesh_trees_t  trees_src,
int  part_src 
)

Copy the trees array from one part to another.

Parameters
[in,out]trees_destThe trees struct of the destination part.
[in]part_destThe index of the destination part. Must be initialized by t8_cmesh_trees_start_part with alloc = 0.
[in]trees_srcThe trees struct of the source part.
[in]part_srcThe index of the destination part. Must be a valid part, thus t8_cmesh_trees_finish_part must have been called.

◆ t8_cmesh_trees_copy_toproc()

void t8_cmesh_trees_copy_toproc ( t8_cmesh_trees_t  trees_dest,
t8_cmesh_trees_t  trees_src,
t8_locidx_t  lnum_trees,
t8_locidx_t  lnum_ghosts 
)

Copy the tree_to_proc and ghost_to_proc arrays of one tree structure to another one.

Parameters
[in,out]trees_destThe destination trees structure.
[in]trees_srcThe source trees structure.
[in]lnum_treesThe total number of trees stored in trees_src.
[in]lnum_ghostsThe total number of ghosts stored in trees_src.

◆ t8_cmesh_trees_destroy()

void t8_cmesh_trees_destroy ( t8_cmesh_trees_t trees)

Free all memory allocated with a trees structure.

This means that all coarse trees and ghosts, their face neighbor entries and attributes and the additional structures of trees are freed.

Parameters
[in,out]treesThe tree structure to be destroyed. Set to NULL on output.

◆ t8_cmesh_trees_finish_part()

void t8_cmesh_trees_finish_part ( t8_cmesh_trees_t  trees,
int  proc 
)

After all classes of trees and ghosts have been set and after the number of tree attributes was set and their total size (per tree) stored temporarily in the att_offset variable we grow the part array by the needed amount of memory and set the offsets appropiately.

The workflow should be: call t8_cmesh_trees_start_part, set tree and ghost classes maually via t8_cmesh_trees_add_tree and t8_cmesh_trees_add_ghost, call t8_cmesh_trees_init_attributes, then call this function. Afterwards successively call t8_cmesh_trees_add_attribute for each attribute and also set all face neighbors (TODO: write function).

Parameters
[in,out]treesThe trees structure to be updated.
[in]procThe number of the part to be finished.

◆ t8_cmesh_trees_get_attribute()

void* t8_cmesh_trees_get_attribute ( t8_cmesh_trees_t  trees,
t8_locidx_t  ltree_id,
int  package_id,
int  key,
size_t *  size,
int  is_ghost 
)

Return an attribute that is stored at a tree.

Parameters
[in]treesThe trees structure.
[in]ltree_idThe local id of the tree whose attribute is querid.
[in]package_idThe package identifier of the attribute.
[in]keyThe key of the attribute within all attributes of the same package identifier.
[out]sizeIf not NULL, the size (in bytes) of the attribute will be stored here.
[in]is_ghostIf true, then ltree_id is interpreted as the local_id of a ghost.
Returns
A pointer to the queried attribute, NULL if the attribute does not exist.

◆ t8_cmesh_trees_get_face_info()

t8_locidx_t t8_cmesh_trees_get_face_info ( t8_cmesh_trees_t  trees,
t8_locidx_t  ltreeid,
int  face,
int8_t *  ttf 
)

Return the face neigbor of a tree at a given face and return the tree_to_face info.

Parameters
[in]treesThe trees structure where the tree is to be looked up.
[in]ltreeidThe local id of the tree.
[in]faceA face of the tree.
[out]ttfIf not NULL the tree_to_face value of the face connection.
Returns
The face neighbor that is stored for this face

◆ t8_cmesh_trees_get_face_neighbor()

t8_locidx_t t8_cmesh_trees_get_face_neighbor ( const t8_ctree_t  tree,
const int  face 
)

Given a coarse tree and a face number, return the local id of the neighbor tree.

Parameters
[in]tree.The coarse tree.
[in]face.The face number.
Returns
The local id of the neighbor tree.

◆ t8_cmesh_trees_get_face_neighbor_ext()

t8_locidx_t t8_cmesh_trees_get_face_neighbor_ext ( const t8_ctree_t  tree,
const int  face,
int8_t *  ttf 
)

Given a coarse tree and a face number, return the local id of the neighbor tree together with its tree-to-face info.

Parameters
[in]treeThe coarse tree.
[in]faceThe face number.
[out]ttfIf not NULL it is filled with the tree-to-face value for this face.
Returns
The local id of the neighbor tree.

◆ t8_cmesh_trees_get_ghost()

t8_cghost_t t8_cmesh_trees_get_ghost ( t8_cmesh_trees_t  trees,
t8_locidx_t  lghost 
)

Return a pointer to a specific ghost in a trees struct.

Parameters
[in]treesThe tress structure where the tree is to be looked up.
[in]lghostThe local id of the ghost.
Returns
A pointer to the ghost with local id ghost.

◆ t8_cmesh_trees_get_ghost_ext()

t8_cghost_t t8_cmesh_trees_get_ghost_ext ( t8_cmesh_trees_t  trees,
t8_locidx_t  lghost_id,
t8_gloidx_t **  face_neigh,
int8_t **  ttf 
)

Return a pointer to a specific ghost in a trees struct plus pointers to its face_neighbor and tree_to_face arrays.

Parameters
[in]treesThe trees structure where the ghost is to be looked up.
[in]lghost_idThe local id of the ghost.
[out]face_neighIf not NULL a pointer to the ghosts face_neighbor array is stored here on return.
[out]ttfIf not NULL a pointer to the ghosts tree_to_face array is stored here on return.
Returns
A pointer to the tree with local id tree.

◆ t8_cmesh_trees_get_ghost_face_neighbor_ext()

t8_gloidx_t t8_cmesh_trees_get_ghost_face_neighbor_ext ( const t8_cghost_t  ghost,
const int  face,
int8_t *  ttf 
)

Given a coarse ghost and a face number, return the local id of the neighbor tree together with its tree-to-face info.

Parameters
[in]ghostThe coarse ghost.
[in]faceThe face number.
[out]ttfIf not NULL it is filled with the tree-to-face value for this face.
Returns
The global id of the neighbor tree.

◆ t8_cmesh_trees_get_ghost_local_id()

t8_locidx_t t8_cmesh_trees_get_ghost_local_id ( t8_cmesh_trees_t  trees,
t8_gloidx_t  global_id 
)

Given the global tree id of a ghost tree in a trees structure, return its local ghost id.

Parameters
[in]treesThe trees structure.
[in]global_idA global tree id.
Returns
The local id of the tree global_id if it is a ghost in trees. A negative number if it isn't. The local id is a number l with num_local_trees <= l < num_local_trees + num_ghosts

◆ t8_cmesh_trees_get_numproc()

size_t t8_cmesh_trees_get_numproc ( t8_cmesh_trees_t  trees)

Return the number of parts of a trees structure.

Parameters
[in]treesThe trees structure.
Returns
The number of parts in trees.

◆ t8_cmesh_trees_get_part()

t8_part_tree_t t8_cmesh_trees_get_part ( t8_cmesh_trees_t  trees,
int  proc 
)

Return one part of a specified tree array.

Parameters
[in]treesThe tree array to be queried
[in]procAn index specifying the part to be returned.
Returns
The part number proc of trees.

◆ t8_cmesh_trees_get_tree()

t8_ctree_t t8_cmesh_trees_get_tree ( t8_cmesh_trees_t  trees,
t8_locidx_t  ltree 
)

Return a pointer to a specific tree in a trees struct.

Parameters
[in]treesThe tress structure where the tree is to be looked up.
[in]ltreeThe local id of the tree.
Returns
A pointer to the tree with local id tree.

◆ t8_cmesh_trees_get_tree_ext()

t8_ctree_t t8_cmesh_trees_get_tree_ext ( t8_cmesh_trees_t  trees,
t8_locidx_t  ltree_id,
t8_locidx_t **  face_neigh,
int8_t **  ttf 
)

Return a pointer to a specific tree in a trees struct plus pointers to its face_neighbor and tree_to_face arrays.

Parameters
[in]treesThe trees structure where the tree is to be looked up.
[in]ltree_idThe local id of the tree.
[out]face_neighIf not NULL a pointer to the trees face_neighbor array is stored here on return.
[out]ttfIf not NULL a pointer to the trees tree_to_face array is stored here on return.
Returns
A pointer to the tree with local id tree.

◆ t8_cmesh_trees_ghost_attribute_size()

size_t t8_cmesh_trees_ghost_attribute_size ( t8_cghost_t  ghost)

Return the total size of all attributes stored at a specified ghost.

Parameters
[in]ghostA ghost structure.
Returns
The total size (in bytes) of the attributes of ghost.

◆ t8_cmesh_trees_init()

void t8_cmesh_trees_init ( t8_cmesh_trees_t ptrees,
int  num_procs,
t8_locidx_t  num_trees,
t8_locidx_t  num_ghosts 
)

Initialize a trees structure and allocate its parts.

This function allocates the from_procs array without filling it, it also allocates the tree_to_proc and ghost_to_proc arrays. No memory for trees or ghosts is allocated.

Parameters
[in,ouptrees The trees structure to be initialized.
[in]num_procsThe number of entries of its from_proc array (can be different for each process).
[in]num_treesThe number of trees that will be stored in this structure.
[in]num_ghostsThe number of ghosts that will be stored in this structure.

◆ t8_cmesh_trees_init_attributes()

void t8_cmesh_trees_init_attributes ( t8_cmesh_trees_t  trees,
t8_locidx_t  ltree_id,
size_t  num_attributes,
size_t  attr_bytes 
)

For one tree in a trees structure set the number of attributes and temporarily store the total size of all of this tree's attributes.

This temporary value is used in t8_cmesh_trees_finish_part.

Parameters
[in,out]treesThe trees structure to be updated.
[in]ltree_idThe local id of one tree in trees.
[in]num_attributesThe number of attributes of this tree.
[in]attr_bytesThe total number of bytes of all attributes of this tree.

◆ t8_cmesh_trees_is_face_consistend()

int t8_cmesh_trees_is_face_consistend ( t8_cmesh_t  cmesh,
t8_cmesh_trees_t  trees 
)

Check whether the face connection of a trees structure are consistent.

That is if tree1 lists tree2 as neighbor at face i with ttf entries (or,face j), then tree2 must list tree1 as neighbor at face j with ttf entries (or, face i).

Parameters
[in]cmeshA cmesh structure to be checked.
[in]treesThe cmesh's trees struct.
Returns
True if the face connections are consistent, False if not.

◆ t8_cmesh_trees_print()

void t8_cmesh_trees_print ( t8_cmesh_t  cmesh,
t8_cmesh_trees_t  trees 
)

Print the trees,ghosts and their neighbors in ASCII format t stdout.

This function is used for debugging purposes.

Parameters
[in]cmeshA coarse mesh structure that must be committed.
[in]treesThe trees structure of cmesh.

◆ t8_cmesh_trees_set_all_boundary()

void t8_cmesh_trees_set_all_boundary ( t8_cmesh_t  cmesh,
t8_cmesh_trees_t  trees 
)

Set all neighbor fields of all local trees and ghosts to boundary.

Parameters
[in,out]cmesh,Theassociated cmesh.
[in,out]trees,Thetrees structure. A face f of tree t counts as boundary if the face-neighbor is also t at face f.

◆ t8_cmesh_trees_start_part()

void t8_cmesh_trees_start_part ( t8_cmesh_trees_t  trees,
int  proc,
t8_locidx_t  lfirst_tree,
t8_locidx_t  num_trees,
t8_locidx_t  lfirst_ghost,
t8_locidx_t  num_ghosts,
int  alloc 
)

Allocate the first_tree array of a given tree_part in a tree struct with a given number of trees and ghosts.

This function allocates the memory for the trees and the ghosts but not for their face neighbor entries or attributes. These must be allocated later when the eclasses of the trees and ghosts are known t8_cmesh_trees_finish_part.

Parameters
[in,out]treesThe trees structure to be updated.
[in]procThe index of the part to be updated.
[in]lfirst_treeThe local id of the first tree of that part.
[in]num_treesThe number of trees of that part.
[in]lfirst_ghostThe local id of the first ghost of that part.
[in]num_ghostsThe number of ghosts of that part.
[in]allocIf true then the first_tree array is allocated for the number of trees and ghosts. When a cmesh is copied we do not want this, so in we pass alloc = 0 then.