$extrastylesheet
parallel_sort.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 #ifndef LIBMESH_PARALLEL_SORT_H
00020 #define LIBMESH_PARALLEL_SORT_H
00021 
00022 // Local Includes
00023 #include "libmesh/parallel.h"
00024 #include "libmesh/libmesh_common.h"
00025 #include "libmesh/parallel_object.h"
00026 
00027 // C++ Includes
00028 #include <vector>
00029 
00030 namespace libMesh
00031 {
00032 
00033 
00034 namespace Parallel
00035 {
00047 template <typename KeyType, typename IdxType=unsigned int>
00048 class Sort : public ParallelObject
00049 {
00050 public:
00059   Sort (const Parallel::Communicator &comm,
00060         std::vector<KeyType>& d);
00061 
00062 
00069   void sort();
00070 
00076   const std::vector<KeyType>& bin();
00077 
00078 private:
00079 
00083   const processor_id_type _n_procs;
00084 
00088   const processor_id_type _proc_id;
00089 
00093   bool _bin_is_sorted;
00094 
00100   std::vector<KeyType>& _data;
00101 
00107   std::vector<IdxType> _local_bin_sizes;
00108 
00115   std::vector<KeyType> _my_bin;
00116 
00122   void binsort ();
00123 
00130   void communicate_bins();
00131 
00137   void sort_local_bin();
00138 
00139 };
00140 }
00141 
00142 } // namespace libMesh
00143 
00144 #endif // LIBMESH_PARALLEL_SORT_H