00001 /* @HEADER@ */ 00002 // ************************************************************************ 00003 // 00004 // Sundance 00005 // Copyright 2011 Sandia Corporation 00006 // 00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00008 // the U.S. Government retains certain rights in this software. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu) 00038 // 00039 00040 /* @HEADER@ */ 00041 00042 #ifndef SUNDANCE_CELLFILTERBASE_H 00043 #define SUNDANCE_CELLFILTERBASE_H 00044 00045 #include "SundanceDefs.hpp" 00046 #include "SundanceCellFilterStub.hpp" 00047 #include "SundanceCellFilter.hpp" 00048 #include "SundanceCellSet.hpp" 00049 #include "SundanceMap.hpp" 00050 #include "PlayaHandleable.hpp" 00051 #include "PlayaPrintable.hpp" 00052 #include "Teuchos_Describable.hpp" 00053 00054 namespace Sundance 00055 { 00056 using namespace Teuchos; 00057 00058 /** 00059 * Base class for CellFilter objects. 00060 * 00061 * <h4> Notes for subclass implementors </h4> 00062 * 00063 * Derived classes must implement the methods 00064 * <ul> 00065 * <li> internalGetCells() -- returns the set of cells that 00066 * pass through this filter 00067 * <li> dimension() -- returns the dimension of the cells that 00068 * will pass through this filter 00069 * <li> toXML() -- writes an XML description of the filter 00070 * <li> lessThan() -- compares to another cell filter. Used to store 00071 * cell filters in STL containers. 00072 * <li> typeName() -- returns the name of the subclass. Used in ordering. 00073 * </ul> 00074 */ 00075 class CellFilterBase : public CellFilterStub 00076 { 00077 public: 00078 /** Empty ctor */ 00079 CellFilterBase(); 00080 00081 /** virtual dtor */ 00082 virtual ~CellFilterBase(); 00083 00084 /** Find the cells passing this filter on the given mesh. This 00085 * method will cache the cell sets it computes for each mesh */ 00086 CellSet getCells(const Mesh& mesh) const ; 00087 00088 /** Return the dimension of the cells that will be identified 00089 * by this filter when acting on the given mesh */ 00090 virtual int dimension(const Mesh& mesh) const = 0 ; 00091 00092 /** */ 00093 void registerSubset(const CellFilter& sub) const ; 00094 00095 /** */ 00096 void registerLabeledSubset(int label, const CellFilter& sub) const ; 00097 00098 /** */ 00099 void registerDisjoint(const CellFilter& sub) const ; 00100 00101 /** */ 00102 const Set<CellFilter>& knownSubsets() const ; 00103 00104 /** */ 00105 const Set<CellFilter>& knownDisjoints() const ; 00106 00107 /** */ 00108 virtual std::string toString() const {return name_;} 00109 00110 /** Print to a stream */ 00111 virtual std::string description() const 00112 {return toString();} 00113 00114 /** */ 00115 void setName(const std::string& name) {name_ = name;} 00116 00117 /** empties the cache of the filter */ 00118 void flushCache() const; 00119 00120 protected: 00121 00122 /** */ 00123 virtual CellSet internalGetCells(const Mesh& mesh) const = 0 ; 00124 00125 private: 00126 /** cache of previously computed cell sets */ 00127 mutable Sundance::Map<int, CellSet> cellSetCache_; 00128 00129 /** */ 00130 std::string name_; 00131 00132 }; 00133 } 00134 00135 00136 #endif