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 "SundanceHandle.hpp"
00039 
00040 namespace Sundance
00041 {
00042 /**
00043  * Base class for mesh partitioners that run in serial
00044  */
00045 class SerialPartitionerBase
00046 {
00047 public:
00048   
00049   /** */
00050   virtual ~SerialPartitionerBase(){;}
00051 
00052   /** */
00053   void getNeighbors(const Mesh& mesh, 
00054     Array<Array<int> >& neighbors, int& nEdges) const ;
00055 
00056   /** */
00057   Set<int> arrayToSet(const Array<int>& a) const ;
00058 
00059   /** */
00060   virtual void getAssignments(const Mesh& mesh, int np, 
00061     Array<int>& assignments) const = 0 ;
00062 
00063   /** */
00064   Array<Mesh> makeMeshParts(const Mesh& mesh, int np,
00065     Array<Sundance::Map<int, int> >& oldElemLIDToNewLIDMap,
00066     Array<Sundance::Map<int, int> >& oldVertLIDToNewLIDMap
00067     ) const ;
00068 
00069   /** */
00070   void getOffProcData(int p, 
00071     const Array<int>& elemAssignments,
00072     const Array<int>& nodeAssignments,
00073     Set<int>& offProcNodes,
00074     Set<int>& offProcElems) const ;
00075 
00076   /** 
00077    * 
00078    */
00079   void getNodeAssignments(int nProc, 
00080     const Array<int>& elemAssignments,
00081     Array<int>& nodeAssignments,
00082     Array<int>& nodeOwnerElems,
00083     Array<int>& nodesPerProc) const ;
00084 
00085   /** */
00086   void getElemsPerProc(int nProc, 
00087     const Array<int>& elemAssignments,
00088     Array<int>& elemsPerProc) const ;
00089 
00090   /** Remap global element or node 
00091    * numberings so that each processor owns sequentially-numbered
00092    * global indexes. */
00093   void remapEntities(const Array<int>& assignments, int nProc,
00094     Array<int>& entityMap) const ;
00095 
00096 
00097 private:
00098 
00099   
00100   int max(const Set<int>& s) const ;
00101   mutable Array<Set<int> > elemVerts_;
00102   mutable Array<Set<int> > vertElems_;
00103 };
00104 }
00105 
00106 #endif

Site Contact