00001 #ifndef CELLSUBSET_H 00002 #define CELLSUBSET_H 00003 00004 #include "SundanceDefs.h" 00005 #include "CellSetBase.h" 00006 #include "CellSet.h" 00007 00008 namespace Sundance 00009 { 00010 00011 using namespace TSF; 00012 using std::string; 00013 00014 using std::ostream; 00015 00016 /** \ingroup LowLevelGeometry 00017 * CellSubset filters cells for which a given logical condition 00018 * is satisfied. 00019 */ 00020 00021 class CellSubset : public CellSetBase 00022 { 00023 public: 00024 /** construct with a superset and a filtering expression */ 00025 CellSubset(const CellSet& superset, const LogicalExpr& expr) 00026 : CellSetBase(), superset_(superset), expr_(expr) {;} 00027 00028 /** TUVD */ 00029 virtual ~CellSubset(){;} 00030 00031 /* determine if a cell is contained in this set */ 00032 virtual bool contains(const Cell& cell) const 00033 {return superset_.contains(cell) && expr_.evaluate(cell);} 00034 00035 /** write as XML */ 00036 virtual XMLObject toXML() const ; 00037 00038 /** find the cell dimensions that should be searched to find cells 00039 * in this set */ 00040 virtual int dimension(const Mesh& mesh) const 00041 {return superset_.dimension(mesh);} 00042 00043 /** test equality */ 00044 virtual bool equals(const CellSet& other) const ; 00045 00046 /** test ordering */ 00047 virtual bool lessThan(const CellSet& other) const ; 00048 protected: 00049 00050 /** low-level routine to find a list of cell blocks */ 00051 virtual TSFHashtable<CellTopologyCode, TSFSmartPtr<TSFArray<CellBlock> > > 00052 innerGetCellBlocks(const Mesh& mesh, 00053 TSFNonDupArray<CellTopologyCode>& cellType) const ; 00054 00055 00056 /** low-level routine to find an ordered list of cells */ 00057 virtual TSFSmartPtr<TSFArray<Cell> > 00058 innerGetOrderedCells(const Mesh& mesh) const ; 00059 00060 00061 00062 00063 CellSet superset_; 00064 LogicalExpr expr_; 00065 }; 00066 00067 00068 00069 } 00070 #endif