Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_trees.h
921 views
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
23
/** \file t8_cmesh_trees.h
24
* Interface for the data layout of the coarse trees.
25
*/
26
27
#ifndef T8_CMESH_PART_TREE_H
28
#define T8_CMESH_PART_TREE_H
29
30
#include <t8.h>
31
#include <t8_cmesh/t8_cmesh.h>
32
#include <t8_cmesh/t8_cmesh_internal/t8_cmesh_types.h>
33
34
T8_EXTERN_C_BEGIN ();
35
36
/* Interface for the data layout of the coarse trees.
37
*
38
* The layout is the same for replicated and partitioned meshes.
39
* Each process stores a meta array of data arrays. In the replicated case this meta
40
* array has only one entry whereas in the partitioned case there is one data array for
41
* each processor from which local trees were received in the last partition step
42
* (and only one meta array if the cmesh arose from a partitioned commit).
43
*
44
* Each dara arrays stores the local trees, the ghosts, face neighbor information
45
* of the ghosts, face neihbor information of the trees and the attributes of the trees.
46
* Furthermore we store for each tree and for each ghost to which data array they belong to.
47
* So the data looks like:
48
*
49
* TODO: would be more logical to switch Ghost and Tree faces
50
*
51
* M_0: | Trees | Ghosts | Ghost faces | Tree faces | Tree attributes | Ghost attributes
52
* M_1: | Trees | Ghosts | Ghost faces | Tree faces | Tree attributes | Ghost attributes
53
* . . . . . .
54
* M_n: | Trees | Ghosts | Ghost faces | Tree faces | Tree attributes | Ghost attributes
55
*
56
* tree_to_proc: | 0 | 0 | 1 | ... | n | these are just random examples here
57
* ghost_to_proc: | 0 | 1 | 2 | ... | n |
58
*
59
*
60
* Each tree T stores an offset to its Tree faces, such that (char*)&T + offset is
61
* a pointer to the faces array.
62
* The same holds for the ghost.
63
* Also each tree stores the number of attributes and an offset relative to itself
64
* to the first attribute entry of that tree.
65
*
66
* Tree faces:
67
*
68
* For each tree the data of the tree faces (where F is the number of faces of the tree) looks like this:
69
*
70
* | Treeid1 Treeid2 ... TreeidF | ttf1 ttf2 ... ttfN | padding |
71
*
72
* Where padding is a number of unused bytes that makes the whole block a multiple
73
* of 4 Bytes.
74
* Treeid is a t8_locidx_t storing the local tree id for local tree neighbors and
75
* the local ghost id + num_local_trees for ghost neighbors.
76
* For the encoding of ttf (tree to face) see \ref t8_ctree_struct_t, ttf entries are int8_t
77
* and the offset of ttf1 can be calculated from the Tree faces offset and the
78
* class of the tree.
79
*
80
* Ghost faces:
81
*
82
* | Treeid1 Treeid2 ... TreeidF | ttf1 ttf2 ... ttfF | padding |
83
*
84
* Where padding is a number of unused bytes that makes the whole block a multiple
85
* of sizeof (void*) Bytes.
86
* Treeidj is a t8_gloidx_t storing the global tree id for all neighbors.
87
* For the encoding of ttf (tree to face) see \ref t8_ctree_struct_t, ttf entries are int8_t
88
* and the offset of ttf1 can be calculated from the Tree faces offset and the
89
* class of the tree.
90
* Tree attributes:
91
*
92
* The data of Tree attributes looks like, where N is the total number of attributes:
93
* The Attributes do not necessarily need to be sorted in a particular way, as they are
94
* accessed by offsets in the Att_descr.
95
*
96
* | Att00_descr | Att01_descr | ... Att0 A_0_descr| Att10_descr | ... | AttrT A_T | Att0_data | Att2_data | ... AttN_data|
97
* TODO: maybe insert padding here ||
98
* Where Attij_descr is a descriptor of the j-th attribute data of tree i storing
99
* - an offset to Attk_data starting from Attij_descr, where k is the index in the dataarray.
100
* The actual data is put there in the order of the attribute descriptors, but this is not necessitated by the layout.
101
* - package id of the attribute (int)
102
* - key of the attribute (int)
103
* The data type is t8_attribute_info_struct_t
104
*
105
* Attrend_descr only stores the offset of the end of this attributes block
106
* (like an imaginary very last attribute);
107
* using this info the size of each attribute can be computed as the difference
108
* of the sizes of two consecutive attributes.
109
*
110
* padding is a number of nonused bytes to make the size of the descr block
111
* a multiple of four.
112
*
113
* TODO: maybe padding after the last Att_data is useful too
114
* TODO: We may also need padding between the attributes.
115
*
116
*/
117
118
/* allocate a t8_cmesh_tree struct and allocate memory for its entries.
119
* No memory for ctrees or ghosts is allocated here */
120
/* TODO: document */
121
122
/** Given a tree return the beginning of its attributes block */
123
#define T8_TREE_FIRST_ATT_INFO(t) ((char *) (t) + (t)->att_offset)
124
125
/** Given a tree and an index i return the i-th attribute index of that tree */
126
#define T8_TREE_ATTR_INFO(t, i) \
127
((t8_attribute_info_struct_t *) ((char *) (t) + (t)->att_offset + (i) * sizeof (t8_attribute_info_struct_t)))
128
129
/** Given a tree and an attribute info return the attribute */
130
#define T8_TREE_ATTR(t, ai) (T8_TREE_FIRST_ATT_INFO (t) + (ai)->attribute_offset)
131
132
/** Given a tree return its face_neighbor array */
133
#define T8_TREE_FACE(t) ((char *) (t) + (t)->neigh_offset)
134
135
/** Given a tree return irs tree_to_face array */
136
#define T8_TREE_TTF(t) (T8_TREE_FACE (t) + t8_eclass_num_faces[(t)->eclass] * sizeof (t8_locidx_t))
137
138
/** Given a ghost return the beginning of its attribute block */
139
#define T8_GHOST_FIRST_ATT_INFO(g) T8_TREE_FIRST_ATT_INFO (g)
140
141
/** Given a ghost and an index i return the i-th attribute index of that ghost */
142
#define T8_GHOST_ATTR_INFO(g, i) T8_TREE_ATTR_INFO (g, i)
143
144
/** Given a ghost and an attribute info return the attribute */
145
#define T8_GHOST_ATTR(g, ai) T8_TREE_ATTR (g, ai)
146
147
/** Given a ghost return its face_neighbor array */
148
#define T8_GHOST_FACE(g) T8_TREE_FACE (g)
149
150
/** Given a ghost return its tree_to_face array */
151
#define T8_GHOST_TTF(g) (int8_t *) (T8_GHOST_FACE (g) + t8_eclass_num_faces[(g)->eclass] * sizeof (t8_gloidx_t))
152
153
/** This struct is an entry of the trees global_id to local_id
154
* hash table for ghost trees. */
155
typedef struct
156
{
157
t8_gloidx_t global_id; /**< The global id */
158
t8_locidx_t local_id; /**< The local id */
159
} t8_trees_glo_lo_hash_t;
160
161
/** Initialize a trees structure and allocate its parts.
162
* This function allocates the from_procs array without filling it, it
163
* also allocates the tree_to_proc and ghost_to_proc arrays.
164
* No memory for trees or ghosts is allocated.
165
* \param [in,out] ptrees The trees structure to be initialized.
166
* \param [in] num_procs The number of entries of its from_proc array
167
* (can be different for each process).
168
* \param [in] num_trees The number of trees that will be stored in this
169
* structure.
170
* \param [in] num_ghosts The number of ghosts that will be stored in this
171
* structure.
172
*/
173
void
174
t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, int num_procs, t8_locidx_t num_trees, t8_locidx_t num_ghosts);
175
176
/** Return one part of a specified tree array.
177
* \param [in] trees The tree array to be queried
178
* \param [in] proc An index specifying the part to be returned.
179
* \return The part number \a proc of \a trees.
180
*/
181
t8_part_tree_t
182
t8_cmesh_trees_get_part (const t8_cmesh_trees_t trees, const int proc);
183
184
/* !!! This does only allocate memory for the trees and ghosts
185
* not yet for the face data and the attributes. See below !!!
186
*/
187
/** Allocate the first_tree array of a given tree_part in a tree struct
188
* with a given number of trees and ghosts.
189
* This function allocates the memory for the trees and the ghosts
190
* but not for their face neighbor entries or attributes. These must
191
* be allocated later when the eclasses of the trees and ghosts are known
192
* \ref t8_cmesh_trees_finish_part.
193
* \param [in,out] trees The trees structure to be updated.
194
* \param [in] proc The index of the part to be updated.
195
* \param [in] lfirst_tree The local id of the first tree of that part.
196
* \param [in] num_trees The number of trees of that part.
197
* \param [in] lfirst_ghost The local id of the first ghost of that part.
198
* \param [in] num_ghosts The number of ghosts of that part.
199
* \param [in] alloc If true then the first_tree array is allocated for
200
* the number of trees and ghosts.
201
* When a cmesh is copied we do not want this, so in we pass alloc = 0 then.
202
*/
203
void
204
t8_cmesh_trees_start_part (t8_cmesh_trees_t trees, int proc, t8_locidx_t lfirst_tree, t8_locidx_t num_trees,
205
t8_locidx_t lfirst_ghost, t8_locidx_t num_ghosts, int alloc);
206
207
/** After all classes of trees and ghosts have been set and after the
208
* number of tree attributes was set and their total size (per tree)
209
* stored temporarily in the att_offset variable
210
* we grow the part array by the needed amount of memory and set the
211
* offsets appropriately.
212
* The workflow should be: call \ref t8_cmesh_trees_start_part,
213
* set tree and ghost classes manually via \ref t8_cmesh_trees_add_tree
214
* and \ref t8_cmesh_trees_add_ghost, call
215
* \ref t8_cmesh_trees_init_attributes, then call this function.
216
* Afterwards successively call \ref t8_cmesh_trees_add_attribute for
217
* each attribute and
218
* also set all face neighbors (TODO: write function).
219
* \param [in,out] trees The trees structure to be updated.
220
* \param [in] proc The number of the part to be finished.
221
*/
222
void
223
t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc);
224
225
/** Copy the tree_to_proc and ghost_to_proc arrays of one tree structure to
226
* another one.
227
* \param [in,out] trees_dest The destination trees structure.
228
* \param [in] trees_src The source trees structure.
229
* \param [in] lnum_trees The total number of trees stored in \a trees_src.
230
* \param [in] lnum_ghosts The total number of ghosts stored in \a trees_src.
231
*/
232
void
233
t8_cmesh_trees_copy_toproc (t8_cmesh_trees_t trees_dest, t8_cmesh_trees_t trees_src, t8_locidx_t lnum_trees,
234
t8_locidx_t lnum_ghosts);
235
236
/** Copy the trees array from one part to another.
237
* \param [in,out] trees_dest The trees struct of the destination part.
238
* \param [in] part_dest The index of the destination part. Must be initialized
239
* by \ref t8_cmesh_trees_start_part with alloc = 0.
240
* \param [in] trees_src The trees struct of the source part.
241
* \param [in] part_src The index of the destination part.
242
* Must be a valid part, thus \ref t8_cmesh_trees_finish_part
243
* must have been called.
244
*/
245
void
246
t8_cmesh_trees_copy_part (t8_cmesh_trees_t trees_dest, int part_dest, t8_cmesh_trees_t trees_src, int part_src);
247
248
/** Add a tree to a trees structure.
249
* \param [in,out] trees The trees structure to be updated.
250
* \param [in] ltree_id The local id of the tree to be inserted.
251
* \param [in] proc The mpirank of the process from which the tree was
252
* received.
253
* \param [in] eclass The tree's element class.
254
*/
255
void
256
t8_cmesh_trees_add_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int proc, t8_eclass_t eclass);
257
258
/** Add a ghost to a trees structure.
259
* \param [in,out] trees The trees structure to be updated.
260
* \param [in] lghost_index The index in the part array of the ghost to be inserted.
261
* \param [in] gtree_id The global index of the ghost.
262
* \param [in] proc The mpirank of the process from which the ghost was
263
* received.
264
* \param [in] eclass The ghost's element class.
265
* \param [in] num_local_trees The number of local trees in the cmesh.
266
*/
267
void
268
t8_cmesh_trees_add_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost_index, t8_gloidx_t gtree_id, int proc,
269
t8_eclass_t eclass, t8_locidx_t num_local_trees);
270
271
/** Set all neighbor fields of all local trees and ghosts to boundary.
272
* \param [in,out] cmesh The associated cmesh.
273
* \param [in,out] trees The trees structure.
274
* A face f of tree t counts as boundary if the face-neighbor is also t
275
* at face f.
276
*/
277
void
278
t8_cmesh_trees_set_all_boundary (t8_cmesh_t cmesh, t8_cmesh_trees_t trees);
279
280
/**
281
* Return the part data of a trees struct.
282
*
283
* \param[in] trees The trees structure to be queried.
284
* \param[in] proc The part number to be queried.
285
* \param[out] first_tree The local id of the first tree in the part.
286
* \param[out] num_trees The number of trees in the part.
287
* \param[out] first_ghost The local id of the first ghost in the part.
288
* \param[out] num_ghosts The number of ghosts in the part.
289
*/
290
void
291
t8_cmesh_trees_get_part_data (t8_cmesh_trees_t trees, int proc, t8_locidx_t *first_tree, t8_locidx_t *num_trees,
292
t8_locidx_t *first_ghost, t8_locidx_t *num_ghosts);
293
294
/* TODO: This function returns NULL if the tree is not present.
295
* So far no error checking is done here. */
296
/** Return a pointer to a specific tree in a trees struct.
297
* \param [in] trees The tress structure where the tree is to be looked up.
298
* \param [in] ltree The local id of the tree.
299
* \return A pointer to the tree with local id \a tree.
300
*/
301
t8_ctree_t
302
t8_cmesh_trees_get_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree);
303
304
/** Return a pointer to a specific tree in a trees struct plus pointers to
305
* its face_neighbor and tree_to_face arrays.
306
* \param [in] trees The trees structure where the tree is to be looked up.
307
* \param [in] ltree_id The local id of the tree.
308
* \param [out] face_neigh If not NULL a pointer to the trees face_neighbor
309
* array is stored here on return.
310
* \param [out] ttf If not NULL a pointer to the trees tree_to_face
311
* array is stored here on return.
312
* \return A pointer to the tree with local id \a tree.
313
*/
314
t8_ctree_t
315
t8_cmesh_trees_get_tree_ext (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, t8_locidx_t **face_neigh, int8_t **ttf);
316
317
/** Return the face neighbor of a tree at a given face and return the tree_to_face info
318
* \param [in] trees The trees structure where the tree is to be looked up.
319
* \param [in] ltreeid The local id of the tree.
320
* \param [in] face A face of the tree.
321
* \param [out] ttf If not NULL the tree_to_face value of the face connection.
322
* \return The face neighbor that is stored for this face
323
*/
324
t8_locidx_t
325
t8_cmesh_trees_get_face_info (t8_cmesh_trees_t trees, t8_locidx_t ltreeid, int face, int8_t *ttf);
326
327
/** Given a coarse tree and a face number, return the local id of the neighbor tree.
328
* \param [in] tree The coarse tree.
329
* \param [in] face The face number.
330
* \return The local id of the neighbor tree. */
331
t8_locidx_t
332
t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face);
333
334
/** Given a coarse tree and a face number, return the local id of the neighbor tree
335
* together with its tree-to-face info.
336
* \param [in] tree The coarse tree.
337
* \param [in] face The face number.
338
* \param [out] ttf If not NULL it is filled with the tree-to-face value
339
* for this face.
340
* \return The local id of the neighbor tree. */
341
t8_locidx_t
342
t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int8_t *ttf);
343
344
/** Given a coarse ghost and a face number, return the local id of the neighbor tree
345
* together with its tree-to-face info.
346
* \param [in] ghost The coarse ghost.
347
* \param [in] face The face number.
348
* \param [out] ttf If not NULL it is filled with the tree-to-face value
349
* for this face.
350
* \return The global id of the neighbor tree. */
351
t8_gloidx_t
352
t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int face, int8_t *ttf);
353
354
/* TODO: This function returns NULL if the ghost is not present.
355
* So far no error checking is done here. */
356
/** Return a pointer to a specific ghost in a trees struct.
357
* \param [in] trees The tress structure where the tree is to be looked up.
358
* \param [in] lghost The local id of the ghost.
359
* \return A pointer to the ghost with local id \a ghost.
360
*/
361
t8_cghost_t
362
t8_cmesh_trees_get_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost);
363
364
/** Return a pointer to a specific ghost in a trees struct plus pointers to
365
* its face_neighbor and tree_to_face arrays.
366
* \param [in] trees The trees structure where the ghost is to be looked up.
367
* \param [in] lghost_id The local id of the ghost.
368
* \param [out] face_neigh If not NULL a pointer to the ghosts face_neighbor
369
* array is stored here on return.
370
* \param [out] ttf If not NULL a pointer to the ghosts tree_to_face
371
* array is stored here on return.
372
* \return A pointer to the tree with local id \a tree.
373
*/
374
t8_cghost_t
375
t8_cmesh_trees_get_ghost_ext (t8_cmesh_trees_t trees, t8_locidx_t lghost_id, t8_gloidx_t **face_neigh, int8_t **ttf);
376
377
/** Given the global tree id of a ghost tree in a trees structure,
378
* return its local ghost id.
379
* \param [in] trees The trees structure.
380
* \param [in] global_id A global tree id.
381
* \return The local id of the tree \a global_id if it is a ghost
382
* in \a trees. A negative number if it isn't.
383
* The local id is a number l with
384
* num_local_trees <= \a l < num_local_trees + num_ghosts
385
*/
386
t8_locidx_t
387
t8_cmesh_trees_get_ghost_local_id (t8_cmesh_trees_t trees, t8_gloidx_t global_id);
388
389
/**
390
* Return the total size in bytes of a trees structure.
391
*
392
* \param [in] trees The trees structure.
393
* \return The total size in bytes of \a trees.
394
*/
395
size_t
396
t8_cmesh_trees_size (t8_cmesh_trees_t trees);
397
398
/** For one tree in a trees structure set the number of attributes
399
* and temporarily store the total size of all of this tree's attributes.
400
* This temporary value is used in \ref t8_cmesh_trees_finish_part.
401
* \param [in,out] trees The trees structure to be updated.
402
* \param [in] ltree_id The local id of one tree in \a trees.
403
* \param [in] num_attributes The number of attributes of this tree.
404
* \param [in] attr_bytes The total number of bytes of all attributes
405
* of this tree.
406
*/
407
void
408
t8_cmesh_trees_init_attributes (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, size_t num_attributes, size_t attr_bytes);
409
410
/** Return an attribute that is stored at a tree.
411
* \param [in] trees The trees structure.
412
* \param [in] ltree_id The local id of the tree whose attribute is querid.
413
* \param [in] package_id The package identifier of the attribute.
414
* \param [in] key The key of the attribute within all attributes of
415
* the same package identifier.
416
* \param [out] size If not NULL, the size (in bytes) of the attribute
417
* will be stored here.
418
* \param [in] is_ghost If true, then \a ltree_id is interpreted as the local_id
419
* of a ghost.
420
* \return A pointer to the queried attribute, NULL if the attribute
421
* does not exist.
422
*/
423
void *
424
t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t ltree_id, const int package_id,
425
const int key, size_t *size, int is_ghost);
426
427
/** Return the total size of all attributes stored at a specified tree.
428
* \param [in] tree A tree structure.
429
* \return The total size (in bytes) of the attributes of \a tree.
430
*/
431
size_t
432
t8_cmesh_trees_attribute_size (t8_ctree_t tree);
433
434
/** Return the total size of all attributes stored at a specified ghost.
435
* \param [in] ghost A ghost structure.
436
* \return The total size (in bytes) of the attributes of \a ghost.
437
*/
438
size_t
439
t8_cmesh_trees_ghost_attribute_size (t8_cghost_t ghost);
440
441
/* TODO: Currently there is a bug that forces us to give each tree an attribute */
442
/* TODO: this uses char * and cmesh_set_attribute uses void *. Unify! */
443
/* attr_tree_index is index of attr in tree's attribute array.
444
* We assume that the attributes are already sorted! */
445
/**
446
* Add an attribute to a tree.
447
*
448
* \param [in,out] trees The trees structure, whose attribute array is updated.
449
* \param [in] proc The process id of the process that owns the tree.
450
* \param [in] attr The stash attribute that is added.
451
* \param [in] tree_id The local id of the tree to which the attribute is added.
452
* \param [in] index The attribute index of the attribute to be added.
453
*/
454
void
455
t8_cmesh_trees_add_attribute (const t8_cmesh_trees_t trees, int proc, const t8_stash_attribute_struct_t *attr,
456
t8_locidx_t tree_id, size_t index);
457
458
/** Add the next ghost attribute from stash to the correct position in the char pointer structure
459
* Since it is created from stash, all attributes are added to part 0.
460
* The following attribute offset gets updated already.
461
* \param [in,out] trees The trees structure, whose char array is updated.
462
* \param [in] attr The stash attribute that is added.
463
* \param [in] local_ghost_id The local ghost id.
464
* \param [in] ghosts_inserted The number of ghost that were already inserted, so that we do not write over the end.
465
* \param [in] index The attribute index of the attribute to be added.
466
*/
467
468
void
469
t8_cmesh_trees_add_ghost_attribute (const t8_cmesh_trees_t trees, const t8_stash_attribute_struct_t *attr,
470
t8_locidx_t local_ghost_id, t8_locidx_t ghosts_inserted, size_t index);
471
472
/** Return the number of parts of a trees structure.
473
* \param [in] trees The trees structure.
474
* \return The number of parts in \a trees.
475
*/
476
size_t
477
t8_cmesh_trees_get_numproc (const t8_cmesh_trees_t trees);
478
479
/** Compute the tree-to-face information given a face and orientation value
480
* of a face connection.
481
* \param [in] dimension The dimension of the corresponding eclasses.
482
* \param [in] face A face number
483
* \param [in] orientation A face-to-face orientation.
484
* \return The tree-to-face entry corresponding to the face/orientation combination.
485
* It is computed as t8_eclass_max_num_faces[dimension] * orientation + face
486
*/
487
int8_t
488
t8_cmesh_tree_to_face_encode (const int dimension, const t8_locidx_t face, const int orientation);
489
490
/** Given a tree-to-face value, get its encoded face number and orientation.
491
* \param [in] dimension The dimension of the corresponding eclasses.
492
* \param [in] tree_to_face A tree-to-face value
493
* \param [out] face On output filled with the stored face value.
494
* \param [out] orientation On output filled with the stored orientation value.
495
* \note This function is the inverse operation of \ref t8_cmesh_tree_to_face_encode
496
* If F = t8_eclass_max_num_faces[dimension], we get
497
* orientation = tree_to_face / F
498
* face = tree_to_face % F
499
*/
500
void
501
t8_cmesh_tree_to_face_decode (const int dimension, const int8_t tree_to_face, int *face, int *orientation);
502
503
// TODO: To fit to the interface a trees struct is given as parameter here,
504
// however we could just take the one associated to the cmesh given.
505
/** Print the trees,ghosts and their neighbors in ASCII format t stdout.
506
* This function is used for debugging purposes.
507
* \param [in] cmesh A coarse mesh structure that must be committed.
508
* \param [in] trees The trees structure of \a cmesh.
509
*/
510
void
511
t8_cmesh_trees_print (t8_cmesh_t cmesh, t8_cmesh_trees_t trees);
512
513
/** Broadcast an existing valid trees structure from a root rank to
514
* all other ranks.
515
* The trees structure must belong to cmeshes whose meta_information is
516
* already set. \ref t8_cmesh_bcast.
517
* \param [in] cmesh_in On \a root a committed, replicated cmesh.
518
* On the other ranks an initialized cmesh with
519
* the same number of trees as on \a root.
520
* \param [in] root The rank that broadcasts \a cmesh_in to all
521
* other ranks.
522
* \param [in] comm MPI communicator to use.
523
*/
524
void
525
t8_cmesh_trees_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm);
526
527
/** Check whether the face connection of a trees structure are consistent.
528
* That is if tree1 lists tree2 as neighbor at face i with ttf entries (or,face j),
529
* then tree2 must list tree1 as neighbor at face j with ttf entries (or, face i).
530
* \param[in] cmesh A cmesh structure to be checked.
531
* \param[in] trees The cmesh's trees struct.
532
* \return True if the face connections are consistent,
533
* False if not.
534
*/
535
int
536
t8_cmesh_trees_is_face_consistent (t8_cmesh_t cmesh, t8_cmesh_trees_t trees);
537
538
/**
539
* Check whether two trees structures are equal.
540
* \param [in] cmesh The coarse mesh structure that contains the trees.
541
* \param [in] trees_a A trees structure to be compared.
542
* \param [in] trees_b A trees structure to be compared.
543
* \return 0 if the trees structures are equal, 1 if they are not equal.
544
*/
545
int
546
t8_cmesh_trees_is_equal (t8_cmesh_t cmesh, t8_cmesh_trees_t trees_a, t8_cmesh_trees_t trees_b);
547
548
/** Free all memory allocated with a trees structure.
549
* This means that all coarse trees and ghosts, their face neighbor entries
550
* and attributes and the additional structures of trees are freed.
551
* \param [in,out] trees The tree structure to be destroyed. Set to NULL on output.
552
*/
553
void
554
t8_cmesh_trees_destroy (t8_cmesh_trees_t *trees);
555
556
T8_EXTERN_C_END ();
557
558
#endif /* !T8_CMESH_PART_TREE_H */
559
560