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_partition.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_partition.h
24
* Functionality related to the partitioning of a cmesh.
25
*/
26
27
#ifndef T8_CMESH_PARTITION_H
28
#define T8_CMESH_PARTITION_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
/** Given a cmesh which is to be partitioned, execute the partition task.
37
* This includes partitioning by uniform level and partitioning from a second cmesh
38
* \param [in,out] cmesh The cmesh to be partitioned
39
* \param [in] comm The MPI communicator
40
* This function is usually called within \ref t8_cmesh_commit */
41
void
42
t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm);
43
44
/** From num_local_trees_per_eclass compute num_trees_per_eclass.
45
* This function is collective.
46
* \param [in,out] cmesh The cmesh whose num_trees_per_eclass values should be created.
47
* Must be partitioned and committed.
48
* \param [in] comm Mpi communicator used to create the offset array.
49
* \warning This function does not perform a check whether \a cmesh is committed.
50
* Use with caution.
51
*/
52
void
53
t8_cmesh_gather_trees_per_eclass (t8_cmesh_t cmesh, sc_MPI_Comm comm);
54
55
/** Create the offset array for a partitioned cmesh.
56
* This function is collective.
57
* \param [in,out] cmesh The cmesh whose array should be created.
58
* Must be partitioned and committed.
59
* \param [in] comm Mpi communicator used to create the offset array.
60
* \note if the offset array (cmesh->tree_offsets) already exists, it is not changed.
61
*/
62
void
63
t8_cmesh_gather_treecount (t8_cmesh_t cmesh, sc_MPI_Comm comm);
64
65
/** Perform the same task as \ref t8_cmesh_gather_treecount, but do
66
* not perform the debugging check whether cmesh is committed.
67
* \warning Use with caution and only if you know what you are doing.
68
* Prefer \ref t8_cmesh_gather_treecount.
69
* This function is collective.
70
* \param [in,out] cmesh The cmesh whose array should be created.
71
* Must be partitioned and first and last local tree
72
* as well as the total number of tree must be set.
73
* \param [in] comm Mpi communicator used to create the offset array.
74
* \note if the offset array (cmesh->tree_offsets) already exists, it is not changed.
75
*/
76
void
77
t8_cmesh_gather_treecount_nocommit (t8_cmesh_t cmesh, sc_MPI_Comm comm);
78
79
/**
80
* Print the offset array of a cmesh to stdout.
81
* This function is used for debugging purposes only.
82
* \warning The function definition will be empty if not in debug mode!
83
* \param [in] cmesh A cmesh that is committed and partitioned.
84
* \param [in] comm A valid MPI communicator for cmesh.
85
*/
86
void
87
t8_cmesh_offset_print (t8_cmesh_t cmesh, sc_MPI_Comm comm);
88
89
/** Create a valid partition table that concentrates all trees at a given
90
* process.
91
* \param[in] proc The processor that should get all trees.
92
* \param[in] comm The communicator to use.
93
* \param[in] num_trees The number of global trees in the partition.
94
* \return A valid partition table for a cmesh with \a num_trees trees
95
* and communicator \a comm, where each tree is on process \a proc.
96
* \note This function is MPI collective.
97
*/
98
t8_shmem_array_t
99
t8_cmesh_offset_concentrate (int proc, sc_MPI_Comm comm, t8_gloidx_t num_trees);
100
101
/** Create a random partition table.
102
* The use of this function is only reasonable for debugging.
103
* \param[in] comm The communicator to use.
104
* \param[in] num_trees The number of global trees in the partition.
105
* \param[in] shared If true than there will be shared trees in the generated partition table.
106
* \param[in] seed A seed to be used for the random number generator. If zero, a random
107
* seed is chosen. \a seed has to be the same on each process.
108
* \return A valid partition table for a cmesh with \a num_trees trees
109
* and communicator \a comm, where each processor gets a random number
110
* of trees. The number of trees per processor is roughly uniformly distributed.
111
* \note This function is MPI collective.
112
*/
113
t8_shmem_array_t
114
t8_cmesh_offset_random (sc_MPI_Comm comm, t8_gloidx_t num_trees, int shared, unsigned seed);
115
116
/** Create a repartition array, where each process sends half of its
117
* trees to the next process. The last process does not send any trees.
118
* \param [in] cmesh A cmesh that is committed and partitioned.
119
* \param [in] comm A valid MPI communicator for cmesh.
120
* \return A shared memory offset array storing the new offsets.
121
* Its associated communicator is \a comm.
122
* \note This function is MPI collective.
123
*/
124
t8_shmem_array_t
125
t8_cmesh_offset_half (t8_cmesh_t cmesh, sc_MPI_Comm comm);
126
127
/** Create a repartition array, where each process sends a percentage of its
128
* trees to the next process. The last process does not send any trees.
129
* \param [in] cmesh A cmesh that is committed and partitioned.
130
* \param [in] comm A valid MPI communicator for cmesh.
131
* \param [in] percent The percentage of trees that this process should send
132
* to the next one. Must satisfy 0 <= \a percent <= 100 and
133
* be the same on each process.
134
* \return A shared memory offset array storing the new offsets.
135
* Its associated communicator is \a comm.
136
* \note This function is MPI collective.
137
*/
138
t8_shmem_array_t
139
t8_cmesh_offset_percent (t8_cmesh_t cmesh, sc_MPI_Comm comm, int percent);
140
141
T8_EXTERN_C_END ();
142
143
#endif /* !T8_CMESH_PARTITION_H */
144
145