t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_cmesh_stash.h
Go to the documentation of this file.
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
27 #ifndef T8_CMESH_STASH_H
28 #define T8_CMESH_STASH_H
29 
30 #include <t8.h>
31 #include <t8_eclass.h>
32 
33 typedef struct t8_stash *t8_stash_t;
34 
35 /* TODO: could store class information in an offset array instead of
36  * for each single tree. Especially for non-hybrid meshes this
37  * would massively reduce our memory footprint */
38 
41 typedef struct t8_stash_class
42 {
46 
49 typedef struct t8_stash_joinface
50 {
53  int face1;
54  int face2;
57 
62 typedef struct t8_stash_attribute
63 {
65  size_t attr_size;
66  void *attr_data;
67  int is_owned;
68  int package_id;
69  int key;
71 
80 typedef struct t8_stash
81 {
82  sc_array_t classes;
83  sc_array_t joinfaces;
84  sc_array_t attributes;
86 
87 T8_EXTERN_C_BEGIN ();
88 
92 void
93 t8_stash_init (t8_stash_t *pstash);
94 
99 void
100 t8_stash_destroy (t8_stash_t *pstash);
101 
107 void
109 
118 void
119 t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int face1, int face2, int orientation);
120 
125 void
127 
136 ssize_t
138 
142 void
144 
156 void
157 t8_stash_add_attribute (t8_stash_t stash, t8_gloidx_t id, int package_id, int key, size_t size, void *attr, int copy);
158 
164 size_t
165 t8_stash_get_attribute_size (t8_stash_t stash, size_t index);
166 
172 void *
173 t8_stash_get_attribute (t8_stash_t stash, size_t index);
174 
181 t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index);
182 
188 int
189 t8_stash_get_attribute_key (t8_stash_t stash, size_t index);
190 
196 int
197 t8_stash_get_attribute_id (t8_stash_t stash, size_t index);
198 
206 int
207 t8_stash_attribute_is_owned (t8_stash_t stash, size_t index);
208 
213 void
215 
228 t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, size_t elem_counts[3]);
229 
230 /* TODO: specify equivalence relation. is a different order of data allowed? */
237 int
238 t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b);
239 
240 T8_EXTERN_C_END ();
241 
242 #endif /* !T8_CMESH_STASH_H */
The attribute information that is stored before a cmesh is committed.
Definition: t8_cmesh_stash.h:63
int key
The key used by the package to identify this attribute.
Definition: t8_cmesh_stash.h:69
t8_gloidx_t id
The global tree id.
Definition: t8_cmesh_stash.h:64
int package_id
The id of the package that set this attribute.
Definition: t8_cmesh_stash.h:68
int is_owned
True if the data was copied, false if the data is still owned by user.
Definition: t8_cmesh_stash.h:67
void * attr_data
Array of size bytes storing the attributes data.
Definition: t8_cmesh_stash.h:66
size_t attr_size
The size (in bytes) of this attribute.
Definition: t8_cmesh_stash.h:65
The eclass information that is stored before a cmesh is committed.
Definition: t8_cmesh_stash.h:42
t8_gloidx_t id
The global tree id.
Definition: t8_cmesh_stash.h:43
t8_eclass_t eclass
The eclass of that tree.
Definition: t8_cmesh_stash.h:44
The face-connection information that is stored before a cmesh is committed.
Definition: t8_cmesh_stash.h:50
t8_gloidx_t id1
The global tree id of the first tree in the connection.
Definition: t8_cmesh_stash.h:51
int face2
The face number of the second face.
Definition: t8_cmesh_stash.h:54
t8_gloidx_t id2
The global tree id of the second tree.
Definition: t8_cmesh_stash.h:52
int orientation
The orientation of the face connection.
Definition: t8_cmesh_stash.h:55
int face1
The face number of the first of the connected faces.
Definition: t8_cmesh_stash.h:53
The stash data structure is used to store information about the cmesh before it is committed.
Definition: t8_cmesh_stash.h:81
sc_array_t attributes
Stores the attributes.
Definition: t8_cmesh_stash.h:84
sc_array_t joinfaces
Stores the face-connections.
Definition: t8_cmesh_stash.h:83
sc_array_t classes
Stores the eclasses of the trees.
Definition: t8_cmesh_stash.h:82
This is the administrative header file for t8code.
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:100
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.
Definition: t8_cmesh_stash.c:91
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.
Definition: t8_cmesh_stash.c:320
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.
Definition: t8_cmesh_stash.c:287
void t8_stash_add_class(t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass)
Set the eclass of a tree.
Definition: t8_cmesh_stash.c:66
struct t8_stash_class t8_stash_class_struct_t
The eclass information that is stored before a cmesh is committed.
void t8_stash_destroy(t8_stash_t *pstash)
Free all memory associated in a stash structure.
Definition: t8_cmesh_stash.c:44
struct t8_stash_joinface t8_stash_joinface_struct_t
The face-connection information that is stored before a cmesh is committed.
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.
Definition: t8_cmesh_stash.c:155
int t8_stash_get_attribute_id(t8_stash_t stash, size_t index)
Return the package_id of a given attribute.
Definition: t8_cmesh_stash.c:197
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.
Definition: t8_cmesh_stash.c:173
void t8_stash_init(t8_stash_t *pstash)
Initialize a stash data structure.
Definition: t8_cmesh_stash.c:32
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.
Definition: t8_cmesh_stash.c:116
struct t8_stash_attribute t8_stash_attribute_struct_t
The attribute information that is stored before a cmesh is committed.
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.
Definition: t8_cmesh_stash.c:110
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.
Definition: t8_cmesh_stash.c:185
void t8_stash_joinface_sort(t8_stash_t stash)
Sort then entries in the facejoin array in order of the first treeid.
Definition: t8_cmesh_stash.c:147
int t8_stash_get_attribute_key(t8_stash_t stash, size_t index)
Return the key of a given attribute.
Definition: t8_cmesh_stash.c:191
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...
Definition: t8_cmesh_stash.c:203
void t8_stash_attribute_sort(t8_stash_t stash)
Sort the attributes array of a stash in the order (treeid, packageid, key) *.
Definition: t8_cmesh_stash.c:231
void * t8_stash_get_attribute(t8_stash_t stash, size_t index)
Return the pointer to an attribute in the stash.
Definition: t8_cmesh_stash.c:179
struct t8_stash t8_stash_struct_t
The stash data structure is used to store information about the cmesh before it is committed.
We define all possible element classes that occur in hybrid meshes.
enum t8_eclass t8_eclass_t
This enumeration contains all possible element classes.