t8  1.2.0
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_OCC_EDGE_ATTRIBUTE_KEY 2 /* Used to store which edge is linked to which geometry */
56 #define T8_CMESH_OCC_EDGE_PARAMETERS_ATTRIBUTE_KEY 3 /* Used to store edge parameters */
57 #define T8_CMESH_OCC_FACE_ATTRIBUTE_KEY T8_CMESH_OCC_EDGE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_EDGES /* Used to store wich face is linked to which surface */
58 #define T8_CMESH_OCC_FACE_PARAMETERS_ATTRIBUTE_KEY T8_CMESH_OCC_FACE_ATTRIBUTE_KEY + 1 /* Used to store face parameters */
59 #define T8_CMESH_NEXT_POSSIBLE_KEY T8_CMESH_OCC_FACE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_FACES /* The next free value for a t8code attribute key */
60 
82 typedef struct t8_cmesh
83 {
84  /* TODO: make the comments more legible */
85  int committed;
86  int dimension;
93  /* TODO: Define a maximum allowed refinemet level */
102  struct t8_cmesh *set_from;
106  int mpirank;
107  int mpisize;
113  /* TODO: wouldnt a local num_trees_per_eclass be better?
114  * only as an additional info. we need the global count. i.e. for forest_maxlevel computation.
115  */
138 #ifdef T8_ENABLE_DEBUG
139  t8_locidx_t inserted_trees;
141  t8_locidx_t inserted_ghosts;
143 #endif
146 }
148 
149 /* TODO: cghost could be the same type as ctree.
150  * treeid for ghosts then negative?!
151  * 1. typedef cghost ctree
152  * 2. completely replace
153  */
154 /* TODO: document */
155 typedef struct t8_cghost
156 {
159  size_t neigh_offset;
161  size_t att_offset;
163  /* TODO: Could be a size_t */
165 }
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 */
200 }
202 
214 typedef struct t8_attribute_info
215 {
218  int key;
224  /* TODO: eventually remove the size */
228 
229 /* TODO: document, process is a bad naming, since it does not refer to MPI ranks here */
230 typedef struct t8_cmesh_trees
231 {
232  sc_array_t *from_proc; /* array of t8_part_tree, one for each process */
233  int *tree_to_proc; /* for each tree its process */
234  int *ghost_to_proc; /* for each ghost its process */
235  sc_hash_t *ghost_globalid_to_local_id; /* A hash table storing the map
236  global_id -> local_id for the ghost trees.
237  The local_id is the local ghost id starting at num_local_trees */
238  sc_mempool_t *global_local_mempool; /* Memory pool for the entries in the hash table */
239 }
241 
242 /* TODO: document */
243 typedef struct t8_part_tree
244 {
245  char *first_tree; /* Stores the trees, the ghosts and the attributes.
246  The last 2*sizeof(t8_locidx) bytes store num_trees and num_ghosts */
247  t8_locidx_t first_tree_id; /* local tree_id of the first tree. -1 if num_trees = 0 */
248  t8_locidx_t first_ghost_id; /* TODO: document. -1 if num_ghost=0, 0 for the first part, (not num_local_trees!)
249  0 <= first_ghost_id < num_ghosts */
250  t8_locidx_t num_trees;
251  t8_locidx_t num_ghosts;
252 }
254 
255 /* TODO: Extend this structure with meaningful entries.
256  * Maybe the number of shipped trees per process is useful?
257  */
263 typedef struct t8_cprofile
264 {
279  double commit_runtime;
282 }
284 
286 #define T8_CPROFILE_NUM_STATS 11
287 
288 #endif /* !T8_CMESH_TYPES_H */
This structure holds the information associated to an attribute of a tree.
Definition: t8_cmesh_types.h:215
int package_id
The identifier of the application layer that added this attribute.
Definition: t8_cmesh_types.h:216
int key
The (tree unique) key of the attribute whithin this AL.
Definition: t8_cmesh_types.h:218
size_t attribute_size
The size in bytes of the attribute.
Definition: t8_cmesh_types.h:225
size_t attribute_offset
The offset of the attribute data from the first attribute info of the tree.
Definition: t8_cmesh_types.h:220
Definition: t8_cmesh_types.h:156
size_t att_offset
Offset to the array of face neighbors of this ghost.
Definition: t8_cmesh_types.h:161
int num_attributes
The number of attributes at this ghost.
Definition: t8_cmesh_types.h:164
t8_eclass_t eclass
The eclass of this ghost.
Definition: t8_cmesh_types.h:158
t8_gloidx_t treeid
The global number of this ghost.
Definition: t8_cmesh_types.h:157
Definition: t8_cmesh_types.h:231
This structure holds the connectivity data of the coarse mesh.
Definition: t8_cmesh_types.h:83
t8_cprofile_t * profile
Used to measure runtimes and statistics of the cmesh algorithms.
Definition: t8_cmesh_types.h:145
t8_locidx_t num_ghosts
If partitioned the number of neighbor trees owned by different processes.
Definition: t8_cmesh_types.h:111
t8_refcount_t rc
The reference count of the cmesh.
Definition: t8_cmesh_types.h:108
int set_partition
If nonzero the cmesh is partitioned.
Definition: t8_cmesh_types.h:88
t8_geometry_handler_t * geometry_handler
Handles all geometries that are used by trees in this cmesh.
Definition: t8_cmesh_types.h:136
int face_knowledge
If partitioned the level of face knowledge that is expected.
Definition: t8_cmesh_types.h:90
int dimension
The dimension of the cmesh.
Definition: t8_cmesh_types.h:86
t8_locidx_t num_local_trees
If partitioned the number of trees on this process.
Definition: t8_cmesh_types.h:110
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:98
t8_cmesh_trees_t trees
structure that holds all local trees and ghosts
Definition: t8_cmesh_types.h:123
int mpirank
Number of this MPI process.
Definition: t8_cmesh_types.h:106
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:131
t8_gloidx_t num_trees
The global number of trees.
Definition: t8_cmesh_types.h:109
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:100
int8_t set_refine_level
If the cmesh is derived from a second cmesh, a refinement level is specified here.
Definition: t8_cmesh_types.h:94
t8_stash_t stash
Used as temporary storage for the trees before commit.
Definition: t8_cmesh_types.h:144
int mpisize
Number of MPI processes.
Definition: t8_cmesh_types.h:107
t8_scheme_cxx_t * set_refine_scheme
If the cmesh is to be refined, the scheme that describes the refinement pattern.
Definition: t8_cmesh_types.h:96
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:116
int committed
Flag that specifies whether the cmesh is committed or not.
Definition: t8_cmesh_types.h:85
t8_gloidx_t first_tree
The global index of the first local tree on this process.
Definition: t8_cmesh_types.h:125
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:128
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:120
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:102
This struct is used to profile cmesh algorithms.
Definition: t8_cmesh_types.h:264
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:271
int first_tree_shared
1 if this processes' first tree is shared.
Definition: t8_cmesh_types.h:277
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:275
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:265
double geometry_evaluate_num_calls
The number of calls to t8_geometry_evaluate.
Definition: t8_cmesh_types.h:280
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:267
size_t partition_bytes_sent
The total number of bytes sent to other processes in the last partition call.
Definition: t8_cmesh_types.h:273
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:269
double commit_runtime
The runtime of the last call to t8_cmesh_commit.
Definition: t8_cmesh_types.h:279
double geometry_evaluate_runtime
The accumulated runtime of calls to t8_geometry_evaluate.
Definition: t8_cmesh_types.h:281
double partition_runtime
The runtime of the last call to t8_cmesh_partition.
Definition: t8_cmesh_types.h:278
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 adress 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 adress 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.h:45
Definition: t8_cmesh_types.h:244
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 commited.
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:105
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:94
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:59
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.