Path: blob/main/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_partition.h
921 views
/*1This file is part of t8code.2t8code is a C library to manage a collection (a forest) of multiple3connected adaptive space-trees of general element classes in parallel.45Copyright (C) 2015 the developers67t8code is free software; you can redistribute it and/or modify8it under the terms of the GNU General Public License as published by9the Free Software Foundation; either version 2 of the License, or10(at your option) any later version.1112t8code is distributed in the hope that it will be useful,13but WITHOUT ANY WARRANTY; without even the implied warranty of14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15GNU General Public License for more details.1617You should have received a copy of the GNU General Public License18along with t8code; if not, write to the Free Software Foundation, Inc.,1951 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.20*/2122/** \file t8_cmesh_partition.h23* Functionality related to the partitioning of a cmesh.24*/2526#ifndef T8_CMESH_PARTITION_H27#define T8_CMESH_PARTITION_H2829#include <t8.h>30#include <t8_cmesh/t8_cmesh.h>31#include <t8_cmesh/t8_cmesh_internal/t8_cmesh_types.h>3233T8_EXTERN_C_BEGIN ();3435/** Given a cmesh which is to be partitioned, execute the partition task.36* This includes partitioning by uniform level and partitioning from a second cmesh37* \param [in,out] cmesh The cmesh to be partitioned38* \param [in] comm The MPI communicator39* This function is usually called within \ref t8_cmesh_commit */40void41t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm);4243/** From num_local_trees_per_eclass compute num_trees_per_eclass.44* This function is collective.45* \param [in,out] cmesh The cmesh whose num_trees_per_eclass values should be created.46* Must be partitioned and committed.47* \param [in] comm Mpi communicator used to create the offset array.48* \warning This function does not perform a check whether \a cmesh is committed.49* Use with caution.50*/51void52t8_cmesh_gather_trees_per_eclass (t8_cmesh_t cmesh, sc_MPI_Comm comm);5354/** Create the offset array for a partitioned cmesh.55* This function is collective.56* \param [in,out] cmesh The cmesh whose array should be created.57* Must be partitioned and committed.58* \param [in] comm Mpi communicator used to create the offset array.59* \note if the offset array (cmesh->tree_offsets) already exists, it is not changed.60*/61void62t8_cmesh_gather_treecount (t8_cmesh_t cmesh, sc_MPI_Comm comm);6364/** Perform the same task as \ref t8_cmesh_gather_treecount, but do65* not perform the debugging check whether cmesh is committed.66* \warning Use with caution and only if you know what you are doing.67* Prefer \ref t8_cmesh_gather_treecount.68* This function is collective.69* \param [in,out] cmesh The cmesh whose array should be created.70* Must be partitioned and first and last local tree71* as well as the total number of tree must be set.72* \param [in] comm Mpi communicator used to create the offset array.73* \note if the offset array (cmesh->tree_offsets) already exists, it is not changed.74*/75void76t8_cmesh_gather_treecount_nocommit (t8_cmesh_t cmesh, sc_MPI_Comm comm);7778/**79* Print the offset array of a cmesh to stdout.80* This function is used for debugging purposes only.81* \warning The function definition will be empty if not in debug mode!82* \param [in] cmesh A cmesh that is committed and partitioned.83* \param [in] comm A valid MPI communicator for cmesh.84*/85void86t8_cmesh_offset_print (t8_cmesh_t cmesh, sc_MPI_Comm comm);8788/** Create a valid partition table that concentrates all trees at a given89* process.90* \param[in] proc The processor that should get all trees.91* \param[in] comm The communicator to use.92* \param[in] num_trees The number of global trees in the partition.93* \return A valid partition table for a cmesh with \a num_trees trees94* and communicator \a comm, where each tree is on process \a proc.95* \note This function is MPI collective.96*/97t8_shmem_array_t98t8_cmesh_offset_concentrate (int proc, sc_MPI_Comm comm, t8_gloidx_t num_trees);99100/** Create a random partition table.101* The use of this function is only reasonable for debugging.102* \param[in] comm The communicator to use.103* \param[in] num_trees The number of global trees in the partition.104* \param[in] shared If true than there will be shared trees in the generated partition table.105* \param[in] seed A seed to be used for the random number generator. If zero, a random106* seed is chosen. \a seed has to be the same on each process.107* \return A valid partition table for a cmesh with \a num_trees trees108* and communicator \a comm, where each processor gets a random number109* of trees. The number of trees per processor is roughly uniformly distributed.110* \note This function is MPI collective.111*/112t8_shmem_array_t113t8_cmesh_offset_random (sc_MPI_Comm comm, t8_gloidx_t num_trees, int shared, unsigned seed);114115/** Create a repartition array, where each process sends half of its116* trees to the next process. The last process does not send any trees.117* \param [in] cmesh A cmesh that is committed and partitioned.118* \param [in] comm A valid MPI communicator for cmesh.119* \return A shared memory offset array storing the new offsets.120* Its associated communicator is \a comm.121* \note This function is MPI collective.122*/123t8_shmem_array_t124t8_cmesh_offset_half (t8_cmesh_t cmesh, sc_MPI_Comm comm);125126/** Create a repartition array, where each process sends a percentage of its127* trees to the next process. The last process does not send any trees.128* \param [in] cmesh A cmesh that is committed and partitioned.129* \param [in] comm A valid MPI communicator for cmesh.130* \param [in] percent The percentage of trees that this process should send131* to the next one. Must satisfy 0 <= \a percent <= 100 and132* be the same on each process.133* \return A shared memory offset array storing the new offsets.134* Its associated communicator is \a comm.135* \note This function is MPI collective.136*/137t8_shmem_array_t138t8_cmesh_offset_percent (t8_cmesh_t cmesh, sc_MPI_Comm comm, int percent);139140T8_EXTERN_C_END ();141142#endif /* !T8_CMESH_PARTITION_H */143144145