00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SUNDANCE_POSITIONALCELLPREDICATE_H
00033 #define SUNDANCE_POSITIONALCELLPREDICATE_H
00034
00035
00036 #include "SundanceDefs.hpp"
00037 #include "SundanceCellPredicateBase.hpp"
00038
00039 namespace Sundance
00040 {
00041 using namespace Teuchos;
00042
00043 #define NEW_CELL_PREDICATE(name) \
00044 class name : public CellPredicateFunctorBase, \
00045 public Playa::Handleable<CellPredicateFunctorBase> \
00046 { \
00047 public: \
00048 name() : CellPredicateFunctorBase(#name) {} \
00049 virtual ~name() {} \
00050 virtual bool operator()(const Point& x) const; \
00051 GET_RCP(CellPredicateFunctorBase); \
00052 }; \
00053 \
00054 bool name::operator()(const Point& x) const
00055
00056
00057 #define CELL_PREDICATE_(name, code) \
00058 class name : public CellPredicateFunctorBase, \
00059 public Playa::Handleable<CellPredicateFunctorBase> \
00060 { \
00061 public:\
00062 name() : CellPredicateFunctorBase(#name){;} \
00063 virtual ~name(){;}\
00064 virtual bool operator()(const Point& x) const code \
00065 GET_RCP(CellPredicateFunctorBase);\
00066 }
00067
00068
00069 #define CELL_PREDICATE(name, code) CELL_PREDICATE_(name, code);
00070
00071
00072
00073
00074
00075 class CellPredicateFunctorBase
00076 {
00077 public:
00078
00079 CellPredicateFunctorBase(const std::string& name="Functor(" + Teuchos::toString(topID()) + ")")
00080 : name_(name) {;}
00081
00082
00083 virtual ~CellPredicateFunctorBase(){;}
00084
00085
00086 virtual bool operator()(const Point& x) const = 0 ;
00087
00088
00089 virtual std::string description() const {return name_;}
00090 private:
00091 static int& topID() {static int rtn=0; rtn++; return rtn;}
00092 std::string name_;
00093 };
00094
00095
00096
00097
00098
00099
00100 class PositionalCellPredicate : public CellPredicateBase
00101 {
00102 public:
00103
00104
00105 PositionalCellPredicate(const RCP<CellPredicateFunctorBase>& func)
00106 : CellPredicateBase(), func_(func)
00107 {;}
00108
00109
00110 virtual ~PositionalCellPredicate(){;}
00111
00112
00113 virtual void testBatch(const Array<int>& cellLID,
00114 Array<int>& results) const ;
00115
00116
00117 virtual XMLObject toXML() const ;
00118
00119
00120 virtual bool lessThan(const CellPredicateBase* other) const ;
00121
00122
00123 virtual std::string description() const {return func_->description();}
00124
00125
00126 GET_RCP(CellPredicateBase);
00127
00128 private:
00129 RCP<CellPredicateFunctorBase> func_;
00130 };
00131
00132
00133
00134
00135
00136
00137 class PointCellPredicateFunctor
00138 : public CellPredicateFunctorBase
00139 {
00140 public:
00141
00142 PointCellPredicateFunctor(const Point& x, const double& tol=1.0e-12)
00143 : x_(x), tol_(tol){}
00144
00145
00146 bool operator()(const Point& x) const ;
00147
00148 private:
00149 Point x_;
00150 double tol_;
00151 };
00152
00153
00154
00155
00156 class CoordinateValueCellPredicateFunctor
00157 : public CellPredicateFunctorBase
00158 {
00159 public:
00160
00161 CoordinateValueCellPredicateFunctor(
00162 int direction, const double& value, const double& tol=1.0e-12)
00163 : direction_(direction), value_(value), tol_(tol) {}
00164
00165
00166 bool operator()(const Point& x) const ;
00167
00168 private:
00169 int direction_;
00170 double value_;
00171 double tol_;
00172 };
00173
00174
00175 class PointCellPredicate : public PositionalCellPredicate
00176 {
00177 public:
00178
00179 PointCellPredicate(const Point& x, const double& tol=1.0e-12)
00180 : PositionalCellPredicate(rcp(new PointCellPredicateFunctor(x,tol)))
00181 {}
00182
00183
00184 GET_RCP(CellPredicateBase);
00185 };
00186
00187
00188 class CoordinateValueCellPredicate : public PositionalCellPredicate
00189 {
00190 public:
00191
00192 CoordinateValueCellPredicate(int direction,
00193 const double& value, const double& tol=1.0e-12)
00194 : PositionalCellPredicate(
00195 rcp(new CoordinateValueCellPredicateFunctor(direction,value,tol)))
00196 {}
00197
00198
00199 GET_RCP(CellPredicateBase);
00200 };
00201
00202
00203 }
00204
00205
00206 #endif