$extrastylesheet
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_CENTROID_PARTITIONER_H 00020 #define LIBMESH_CENTROID_PARTITIONER_H 00021 00022 // Local includes 00023 #include "libmesh/partitioner.h" 00024 #include "libmesh/point.h" 00025 00026 // C++ includes 00027 #include <utility> // pair 00028 #include <vector> 00029 00030 namespace libMesh 00031 { 00032 00033 00034 // Forward declarations 00035 class Elem; 00036 00037 00051 // CentroidPartitioner class definition 00052 class CentroidPartitioner : public Partitioner 00053 { 00054 public: 00055 00056 00062 enum CentroidSortMethod {X=0, 00063 Y, 00064 Z, 00065 RADIAL, 00066 INVALID_METHOD}; 00067 00072 explicit 00073 CentroidPartitioner (const CentroidSortMethod sm=X) : _sort_method(sm) {} 00074 00079 virtual UniquePtr<Partitioner> clone () const 00080 { 00081 return UniquePtr<Partitioner>(new CentroidPartitioner(sort_method())); 00082 } 00083 00087 CentroidSortMethod sort_method () const { return _sort_method; } 00088 00092 void set_sort_method (const CentroidSortMethod sm) {_sort_method = sm; } 00093 00094 00095 protected: 00100 virtual void _do_partition (MeshBase& mesh, 00101 const unsigned int n); 00102 00103 private: 00104 00110 void compute_centroids (MeshBase& mesh); 00111 00118 static bool sort_x (const std::pair<Point, Elem*>& lhs, 00119 const std::pair<Point, Elem*>& rhs); 00120 00127 static bool sort_y (const std::pair<Point, Elem*>& lhs, 00128 const std::pair<Point, Elem*>& rhs); 00129 00136 static bool sort_z (const std::pair<Point, Elem*>& lhs, 00137 const std::pair<Point, Elem*>& rhs); 00138 00139 00146 static bool sort_radial (const std::pair<Point, Elem*>& lhs, 00147 const std::pair<Point, Elem*>& rhs); 00148 00153 CentroidSortMethod _sort_method; 00154 00159 std::vector<std::pair<Point, Elem*> > _elem_centroids; 00160 }; 00161 00162 } // namespace libMesh 00163 00164 00165 #endif // LIBMESH_CENTROID_PARTITIONER_H