t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_cmesh_types.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 
23 #ifndef T8_CMESH_TYPES_H
24 #define T8_CMESH_TYPES_H
25 
26 #include <t8.h>
27 #include <t8_refcount.h>
28 #include <t8_data/t8_shmem.h>
30 #include "t8_cmesh_stash.h"
31 #include "t8_element.h"
32 
37 typedef struct t8_part_tree *t8_part_tree_t;
38 typedef struct t8_cmesh_trees *t8_cmesh_trees_t;
39 typedef struct t8_cprofile t8_cprofile_t; /* Defined below */
40 
41 /* TODO: no longer needed.
42  * User may use set_derived_from, then set_from is non-NULL.
43  * When refinement is desired, level shall be set positive.
44  * When partition is desired, we expect set_partition to be true.
45  * Any combination can be called.
46  * In t8_commit we check whether the parameters are consistent,
47  * and whether a combination is currently supported,
48  * and provide informative error messages both in debug and non-debug.
49  */
50 
51 /* Definitions for attribute identifiers that are reserved for a special purpose.
52  * T8_CMESH_NEXT_POSSIBLE_KEY is the first unused key, hence it can be repurposed for different attributes.*/
53 #define T8_CMESH_VERTICES_ATTRIBUTE_KEY 0 /* Used to store vertex coordinates. */
54 #define T8_CMESH_GEOMETRY_ATTRIBUTE_KEY 1 /* Used to store the name of a tree's geometry. */
55 #define T8_CMESH_CAD_EDGE_ATTRIBUTE_KEY 2 /* Used to store which edge is linked to which geometry */
56 #define T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY 3 /* Used to store edge parameters */
57 #define T8_CMESH_CAD_FACE_ATTRIBUTE_KEY \
58  T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY \
59  +T8_ECLASS_MAX_EDGES /* Used to store which face is linked to which surface */
60 #define T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY \
61  T8_CMESH_CAD_FACE_ATTRIBUTE_KEY + 1 /* Used to store face parameters */
62 #define T8_CMESH_LAGRANGE_POLY_DEGREE T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_FACES
63 #define T8_CMESH_NEXT_POSSIBLE_KEY \
64  T8_CMESH_LAGRANGE_POLY_DEGREE + 1 /* The next free value for a t8code attribute key */
65 
87 typedef struct t8_cmesh
88 {
89  /* TODO: make the comments more legible */
90  int committed;
91  int dimension;
103  struct t8_cmesh *set_from;
107  int mpirank;
108  int mpisize;
115  /* TODO: wouldnt a local num_trees_per_eclass be better?
116  * only as an additional info. we need the global count. i.e. for forest_maxlevel computation.
117  */
140 #ifdef T8_ENABLE_DEBUG
145 #endif
149 
150 /* TODO: cghost could be the same type as ctree.
151  * treeid for ghosts then negative?!
152  * 1. typedef cghost ctree
153  * 2. completely replace
154  */
155 /* TODO: document */
156 typedef struct t8_cghost
157 {
160  size_t neigh_offset;
162  size_t att_offset;
164  /* TODO: Could be a size_t */
167 
188 typedef struct t8_ctree
189 {
191  /* TODO: The local id of a tree should be clear from context, the entry can
192  * be optimized out. */
194  size_t neigh_offset;
196  size_t att_offset;
198  /* TODO: Could be a size_t */
201 
213 typedef struct t8_attribute_info
214 {
217  int key;
223  /* TODO: eventually remove the size */
227 
228 /* TODO: document, process is a bad naming, since it does not refer to MPI ranks here */
229 typedef struct t8_cmesh_trees
230 {
231  sc_array_t *from_proc; /* array of t8_part_tree, one for each process */
232  int *tree_to_proc; /* for each tree its process */
233  int *ghost_to_proc; /* for each ghost its process */
234  sc_hash_t *ghost_globalid_to_local_id; /* A hash table storing the map
235  global_id -> local_id for the ghost trees.
236  The local_id is the local ghost id starting at num_local_trees */
237  sc_mempool_t *global_local_mempool; /* Memory pool for the entries in the hash table */
239 
240 /* TODO: document */
241 typedef struct t8_part_tree
242 {
243  char *first_tree; /* Stores the trees, the ghosts and the attributes.
244  The last 2*sizeof(t8_locidx) bytes store num_trees and num_ghosts */
245  t8_locidx_t first_tree_id; /* local tree_id of the first tree. -1 if num_trees = 0 */
246  t8_locidx_t first_ghost_id; /* TODO: document. -1 if num_ghost=0, 0 for the first part, (not num_local_trees!)
247  0 <= first_ghost_id < num_ghosts */
248  t8_locidx_t num_trees;
249  t8_locidx_t num_ghosts;
251 
252 /* TODO: Extend this structure with meaningful entries.
253  * Maybe the number of shipped trees per process is useful?
254  */
260 typedef struct t8_cprofile
261 {
276  double commit_runtime;
280 
282 #define T8_CPROFILE_NUM_STATS 11
283 
284 #endif /* !T8_CMESH_TYPES_H */
This structure holds the information associated to an attribute of a tree.
Definition: t8_cmesh_types.h:214
int package_id
The identifier of the application layer that added this attribute.
Definition: t8_cmesh_types.h:215
int key
The (tree unique) key of the attribute within this AL.
Definition: t8_cmesh_types.h:217
size_t attribute_size
The size in bytes of the attribute.
Definition: t8_cmesh_types.h:224
size_t attribute_offset
The offset of the attribute data from the first attribute info of the tree.
Definition: t8_cmesh_types.h:219
Definition: t8_cmesh_types.h:157
size_t att_offset
Offset to the array of face neighbors of this ghost.
Definition: t8_cmesh_types.h:162
int num_attributes
The number of attributes at this ghost.
Definition: t8_cmesh_types.h:165
t8_eclass_t eclass
The eclass of this ghost.
Definition: t8_cmesh_types.h:159
t8_gloidx_t treeid
The global number of this ghost.
Definition: t8_cmesh_types.h:158
Definition: t8_cmesh_types.h:230
This structure holds the connectivity data of the coarse mesh.
Definition: t8_cmesh_types.h:88
t8_cprofile_t * profile
Used to measure runtimes and statistics of the cmesh algorithms.
Definition: t8_cmesh_types.h:147
t8_locidx_t num_ghosts
If partitioned the number of neighbor trees owned by different processes.
Definition: t8_cmesh_types.h:113
t8_refcount_t rc
The reference count of the cmesh.
Definition: t8_cmesh_types.h:109
int set_partition
If nonzero the cmesh is partitioned.
Definition: t8_cmesh_types.h:93
int face_knowledge
If partitioned the level of face knowledge that is expected.
Definition: t8_cmesh_types.h:95
int dimension
The dimension of the cmesh.
Definition: t8_cmesh_types.h:91
t8_locidx_t num_local_trees
If partitioned the number of trees on this process.
Definition: t8_cmesh_types.h:111
t8_scheme_cxx_t * set_partition_scheme
If the cmesh is to be partitioned according to a uniform level, the scheme that describes the refinem...
Definition: t8_cmesh_types.h:99
t8_cmesh_trees_t trees
structure that holds all local trees and ghosts
Definition: t8_cmesh_types.h:125
int mpirank
Number of this MPI process.
Definition: t8_cmesh_types.h:107
t8_shmem_array_t tree_offsets
If partitioned for each process the global index of its first local tree or -(first local tree) - 1 i...
Definition: t8_cmesh_types.h:133
t8_gloidx_t num_trees
The global number of trees.
Definition: t8_cmesh_types.h:110
int8_t set_partition_level
Non-negative if the cmesh should be partitioned from an already existing cmesh with an assumed level ...
Definition: t8_cmesh_types.h:101
t8_stash_t stash
Used as temporary storage for the trees before commit.
Definition: t8_cmesh_types.h:146
t8_locidx_t inserted_ghosts
Count the number of inserted ghosts to check at commit if it equals the total number.
Definition: t8_cmesh_types.h:143
int mpisize
Number of MPI processes.
Definition: t8_cmesh_types.h:108
t8_geometry_handler_c * geometry_handler
Handles all geometries that are used by trees in this cmesh.
Definition: t8_cmesh_types.h:138
t8_locidx_t num_local_trees_per_eclass[T8_ECLASS_COUNT]
After commit the number of local trees for each eclass.
Definition: t8_cmesh_types.h:118
int committed
Flag that specifies whether the cmesh is committed or not.
Definition: t8_cmesh_types.h:90
t8_gloidx_t first_tree
The global index of the first local tree on this process.
Definition: t8_cmesh_types.h:127
int8_t first_tree_shared
If partitioned true if the first tree on this process is also the last tree on the next process.
Definition: t8_cmesh_types.h:130
t8_gloidx_t num_trees_per_eclass[T8_ECLASS_COUNT]
After commit the number of global trees for each eclass.
Definition: t8_cmesh_types.h:122
struct t8_cmesh * set_from
If this cmesh shall be derived from an existing cmesh by copy or more elaborate modification,...
Definition: t8_cmesh_types.h:103
t8_locidx_t inserted_trees
Count the number of inserted trees to check at commit if it equals the total number.
Definition: t8_cmesh_types.h:141
This struct is used to profile cmesh algorithms.
Definition: t8_cmesh_types.h:261
t8_locidx_t partition_ghosts_recv
The number of ghosts this process has received from other in the last partition call.
Definition: t8_cmesh_types.h:268
int first_tree_shared
1 if this processes' first tree is shared.
Definition: t8_cmesh_types.h:274
int partition_procs_sent
The number of different processes this process has send local trees or ghosts to in the last partitio...
Definition: t8_cmesh_types.h:272
t8_locidx_t partition_trees_shipped
The number of trees this process has sent to other in the last partition call.
Definition: t8_cmesh_types.h:262
double geometry_evaluate_num_calls
The number of calls to t8_geometry_evaluate.
Definition: t8_cmesh_types.h:277
t8_locidx_t partition_ghosts_shipped
The number of ghosts this process has sent to other in the last partition call.
Definition: t8_cmesh_types.h:264
size_t partition_bytes_sent
The total number of bytes sent to other processes in the last partition call.
Definition: t8_cmesh_types.h:270
t8_locidx_t partition_trees_recv
The number of trees this process has received from other in the last partition call.
Definition: t8_cmesh_types.h:266
double commit_runtime
The runtime of the last call to t8_cmesh_commit.
Definition: t8_cmesh_types.h:276
double geometry_evaluate_runtime
The accumulated runtime of calls to t8_geometry_evaluate.
Definition: t8_cmesh_types.h:278
double partition_runtime
The runtime of the last call to t8_cmesh_partition.
Definition: t8_cmesh_types.h:275
This structure holds the data of a local tree including the information about face neighbors.
Definition: t8_cmesh_types.h:189
t8_eclass_t eclass
The eclass of this tree.
Definition: t8_cmesh_types.h:193
size_t neigh_offset
Adding this offset to the address of the tree yields the array of face_neighbor entries.
Definition: t8_cmesh_types.h:194
size_t att_offset
Adding this offset to the address of the tree yields the array of attribute_info entries.
Definition: t8_cmesh_types.h:196
t8_locidx_t treeid
The local number of this tree.
Definition: t8_cmesh_types.h:190
int num_attributes
The number of attributes at this tree.
Definition: t8_cmesh_types.h:199
Definition: t8_geometry_handler.hxx:37
Definition: t8_cmesh_types.h:242
The scheme holds implementations for one or more element classes.
Definition: t8_element.h:51
Shared memory array structure.
Definition: t8_shmem.c:35
The stash data structure is used to store information about the cmesh before it is committed.
Definition: t8_cmesh_stash.h:81
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
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:89
We define the data structures and routines for temporary storage before commit.
struct t8_cmesh t8_cmesh_struct_t
This structure holds the connectivity data of the coarse mesh.
struct t8_attribute_info t8_attribute_info_struct_t
This structure holds the information associated to an attribute of a tree.
struct t8_cprofile t8_cprofile_struct_t
This struct is used to profile cmesh algorithms.
struct t8_ctree t8_ctree_struct_t
This structure holds the data of a local tree including the information about face neighbors.
enum t8_eclass t8_eclass_t
This enumeration contains all possible element classes.
@ T8_ECLASS_COUNT
This is no element class but can be used as the number of element classes.
Definition: t8_eclass.h:58
This file defines basic operations on an element in a refinement tree.
Typedef for the t8_geometry class in order to be usable as a pointer from .c files.
We inherit the reference counting mechanism from libsc.
sc_refcount_t t8_refcount_t
We can reuse the reference counter type from libsc.
Definition: t8_refcount.h:39
We define basic shared memory routines.