SundanceSerialPartitionerBase.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_SERIALPARTITIONERBASE_H
00032 #define SUNDANCE_SERIALPARTITIONERBASE_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMap.hpp"
00036 #include "SundanceMesh.hpp"
00037 #include "SundanceMeshType.hpp"
00038 #include "PlayaHandle.hpp"
00039 
00040 namespace Sundance
00041 {
00042 
00043 
00044 /**
00045  * Base class for mesh partitioners that run in serial
00046  */
00047 class SerialPartitionerBase
00048 {
00049 public:
00050   /** */
00051   SerialPartitionerBase(bool ignoreGhosts=false)
00052     : ignoreGhosts_(ignoreGhosts){}
00053   
00054   /** */
00055   virtual ~SerialPartitionerBase(){;}
00056 
00057   /** */
00058   void getNeighbors(const Mesh& mesh, 
00059     Array<Array<int> >& neighbors, int& nEdges) const ;
00060 
00061   /** */
00062   Set<int> arrayToSet(const Array<int>& a) const ;
00063 
00064   /** */
00065   virtual void getAssignments(const Mesh& mesh, int np, 
00066     Array<int>& assignments) const = 0 ;
00067 
00068   /** */
00069   Array<Mesh> makeMeshParts(const Mesh& mesh, int np,
00070     Array<Sundance::Map<int, int> >& oldElemLIDToNewLIDMap,
00071     Array<Sundance::Map<int, int> >& oldVertLIDToNewLIDMap
00072     ) const ;
00073 
00074   /** */
00075   void getOffProcData(int p, 
00076     const Array<int>& elemAssignments,
00077     const Array<int>& nodeAssignments,
00078     Set<int>& offProcNodes,
00079     Set<int>& offProcElems) const ;
00080 
00081   /** 
00082    * 
00083    */
00084   void getNodeAssignments(int nProc, 
00085     const Array<int>& elemAssignments,
00086     Array<int>& nodeAssignments,
00087     Array<int>& nodeOwnerElems,
00088     Array<int>& nodesPerProc) const ;
00089 
00090   /** */
00091   void getElemsPerProc(int nProc, 
00092     const Array<int>& elemAssignments,
00093     Array<int>& elemsPerProc) const ;
00094 
00095   /** Remap global element or node 
00096    * numberings so that each processor owns sequentially-numbered
00097    * global indexes. */
00098   void remapEntities(const Array<int>& assignments, int nProc,
00099     Array<int>& entityMap) const ;
00100 
00101 
00102 private:
00103 
00104   bool ignoreGhosts_;
00105   int max(const Set<int>& s) const ;
00106   mutable Array<Set<int> > elemVerts_;
00107   mutable Array<Set<int> > elemEdgewiseNbors_;
00108   mutable Array<Set<int> > vertElems_;
00109 };
00110 }
00111 
00112 #endif

Site Contact