parallel_sort.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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 00026 // C++ Includes 00027 #include <vector> 00028 00029 namespace libMesh 00030 { 00031 00032 00033 namespace Parallel 00034 { 00046 template <typename KeyType, typename IdxType=unsigned int> 00047 class Sort 00048 { 00049 public: 00058 Sort (std::vector<KeyType>& d, 00059 const processor_id_type n_procs = libMesh::n_processors(), 00060 const processor_id_type proc_id = libMesh::processor_id()); 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
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: