SundanceCellFilterBase.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_CELLFILTERBASE_H
00032 #define SUNDANCE_CELLFILTERBASE_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceCellFilterStub.hpp"
00036 #include "SundanceCellFilter.hpp"
00037 #include "SundanceCellSet.hpp"
00038 #include "SundanceMap.hpp"
00039 #include "PlayaHandleable.hpp"
00040 #include "PlayaPrintable.hpp"
00041 #include "Teuchos_Describable.hpp"
00042 
00043 namespace Sundance
00044 {
00045 using namespace Teuchos;
00046   
00047 /** 
00048  * Base class for CellFilter objects.
00049  *
00050  * <h4> Notes for subclass implementors </h4>
00051  * 
00052  * Derived classes must implement the methods
00053  * <ul>
00054  * <li> internalGetCells() -- returns the set of cells that 
00055  * pass through this filter
00056  * <li> dimension() -- returns the dimension of the cells that
00057  * will pass through this filter
00058  * <li> toXML() -- writes an XML description of the filter
00059  * <li> lessThan() -- compares to another cell filter. Used to store
00060  * cell filters in STL containers. 
00061  * <li> typeName() -- returns the name of the subclass. Used in ordering.
00062  * </ul>
00063  */
00064 class CellFilterBase : public CellFilterStub
00065 {
00066 public:
00067   /** Empty ctor */
00068   CellFilterBase();
00069 
00070   /** virtual dtor */
00071   virtual ~CellFilterBase();
00072 
00073   /** Find the cells passing this filter on the given mesh. This
00074    * method will cache the cell sets it computes for each mesh  */
00075   CellSet getCells(const Mesh& mesh) const ;
00076 
00077   /** Return the dimension of the cells that will be identified
00078    * by this filter when acting on the given mesh */
00079   virtual int dimension(const Mesh& mesh) const = 0 ;
00080 
00081   /** */
00082   void registerSubset(const CellFilter& sub) const ;
00083 
00084   /** */
00085   void registerLabeledSubset(int label, const CellFilter& sub) const ;
00086 
00087   /** */
00088   void registerDisjoint(const CellFilter& sub) const ;
00089 
00090   /** */
00091   const Set<CellFilter>& knownSubsets() const ;
00092 
00093   /** */
00094   const Set<CellFilter>& knownDisjoints() const ;
00095 
00096   /** */
00097   virtual std::string toString() const {return name_;}
00098 
00099   /** Print to a stream */
00100   virtual std::string description() const 
00101     {return toString();}
00102 
00103   /** */
00104   void setName(const std::string& name) {name_ = name;}
00105 
00106   /** empties the cache of the filter */
00107   void flushCache() const;
00108 
00109 protected:
00110 
00111   /** */
00112   virtual CellSet internalGetCells(const Mesh& mesh) const = 0 ;
00113 
00114 private:
00115   /** cache of previously computed cell sets */
00116   mutable Sundance::Map<int, CellSet> cellSetCache_;
00117 
00118   /** */
00119   std::string name_;
00120 
00121 };
00122 }
00123 
00124 
00125 #endif

Site Contact