centroid_partitioner.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_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 AutoPtr<Partitioner> clone () const { 00080 AutoPtr<Partitioner> cloned_partitioner 00081 (new CentroidPartitioner(sort_method())); 00082 return cloned_partitioner; 00083 } 00084 00088 CentroidSortMethod sort_method () const { return _sort_method; } 00089 00093 void set_sort_method (const CentroidSortMethod sm) {_sort_method = sm; } 00094 00095 00096 protected: 00101 virtual void _do_partition (MeshBase& mesh, 00102 const unsigned int n); 00103 00104 private: 00105 00111 void compute_centroids (MeshBase& mesh); 00112 00119 static bool sort_x (const std::pair<Point, Elem*>& lhs, 00120 const std::pair<Point, Elem*>& rhs); 00121 00128 static bool sort_y (const std::pair<Point, Elem*>& lhs, 00129 const std::pair<Point, Elem*>& rhs); 00130 00137 static bool sort_z (const std::pair<Point, Elem*>& lhs, 00138 const std::pair<Point, Elem*>& rhs); 00139 00140 00147 static bool sort_radial (const std::pair<Point, Elem*>& lhs, 00148 const std::pair<Point, Elem*>& rhs); 00149 00154 CentroidSortMethod _sort_method; 00155 00160 std::vector<std::pair<Point, Elem*> > _elem_centroids; 00161 }; 00162 00163 } // namespace libMesh 00164 00165 00166 #endif // LIBMESH_CENTROID_PARTITIONER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:45 UTC
Hosted By: