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