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 00032 #ifndef SUNDANCE_CELLPREDICATEBASE_H 00033 #define SUNDANCE_CELLPREDICATEBASE_H 00034 00035 00036 #include "SundanceDefs.hpp" 00037 #include "SundanceMesh.hpp" 00038 #include "PlayaHandleable.hpp" 00039 #include "Teuchos_XMLObject.hpp" 00040 #include "PlayaPrintable.hpp" 00041 #include "Teuchos_Describable.hpp" 00042 #include "SundanceObjectWithVerbosity.hpp" 00043 #include <typeinfo> 00044 00045 namespace Sundance 00046 { 00047 using namespace Teuchos; 00048 00049 /** 00050 * CellPredicateBase is the base class for predicate objects 00051 * that test cells 00052 * against some condition. A simulation developer needing 00053 * some specialized method for identifying cells might implement 00054 * a custom cell predicate by extending this function. However, 00055 * the most common cases, selection by cell label or cell position, 00056 * have already been implemented 00057 * in LabelCellPredicate and PositionalCellPredicate. 00058 */ 00059 class CellPredicateBase 00060 : public Playa::Handleable<CellPredicateBase>, 00061 public Noncopyable, 00062 public ObjectWithClassVerbosity<CellPredicateBase> 00063 { 00064 public: 00065 /** Empty ctor */ 00066 CellPredicateBase(); 00067 00068 /** virtual dtor */ 00069 virtual ~CellPredicateBase(); 00070 00071 /** Test the predicate on a batch of cells */ 00072 virtual void testBatch(const Array<int>& cellLID, 00073 Array<int>& results) const = 0 ; 00074 00075 00076 /** Set the current mesh and dimension on which cells are to be tested */ 00077 virtual void setMesh(const Mesh& mesh, int cellDim) const 00078 {mesh_ = mesh; cellDim_ = cellDim;} 00079 00080 /** Write to XML */ 00081 virtual XMLObject toXML() const = 0 ; 00082 00083 /** */ 00084 virtual bool lessThan(const CellPredicateBase* other) const = 0 ; 00085 00086 /** */ 00087 virtual std::string description() const = 0 ; 00088 00089 00090 /** */ 00091 virtual std::string typeName() const {return typeid(*this).name();} 00092 protected: 00093 00094 /** */ 00095 const Mesh& mesh() const {return mesh_;} 00096 00097 00098 /** */ 00099 int cellDim() const {return cellDim_;} 00100 00101 private: 00102 mutable Mesh mesh_; 00103 00104 mutable int cellDim_; 00105 00106 00107 00108 }; 00109 00110 } 00111 00112 #endif