00001 #ifndef PDEOPT_POINTDATA_H
00002 #define PDEOPT_POINTDATA_H
00003
00004 #include "Sundance.hpp"
00005 #include <fstream>
00006
00007
00008 namespace Sundance
00009 {
00010
00011
00012
00013
00014 class PointData
00015 {
00016 public:
00017
00018
00019 PointData(const Array<Point>& locations, const Array<double>& values,
00020 const double& pointComparisonTolerance);
00021
00022
00023
00024 PointData(const Array<Point>& locations, const Expr& field,
00025 const double& pointComparisonTolerance);
00026
00027
00028 PointData(const XMLObject& xml, const Mesh& mesh);
00029
00030
00031
00032
00033
00034 Expr sensorValues() const {return sensorVals_;}
00035
00036
00037 CellFilter sensorLocations() const {return sensorLocations_;}
00038
00039
00040
00041 static Array<Point> snapToMesh(const Mesh& mesh, const Array<Point>& locations) ;
00042
00043
00044 static Point nearestMeshPoint(const Mesh& mesh, const Point& x);
00045
00046
00047 private:
00048 void init(const Array<Point>& locations, const Array<double>& values,
00049 const double& pointComparisonTolerance);
00050
00051 Expr sensorVals_;
00052 CellFilter sensorLocations_;
00053 };
00054
00055
00056
00057
00058
00059
00060 class SloppyPointComparitor : public std::binary_function<Point, Point, bool>
00061 {
00062 public:
00063 SloppyPointComparitor(const double& tol) : tol_(tol) {;}
00064
00065 bool operator()(const Point& p1, const Point& p2) const ;
00066 private:
00067 double tol_;
00068 };
00069
00070
00071
00072
00073
00074
00075 class PointDataExprFunctor : public PointwiseUserDefFunctor0
00076 {
00077 public:
00078
00079 PointDataExprFunctor(const Array<Point>& locations,
00080 const Array<double>& values,
00081 const double& pointComparisonTolerance);
00082
00083
00084 virtual void eval0(const double* in, double* out) const ;
00085
00086
00087 int numArgs() const {return dim_;}
00088
00089 private:
00090 std::map<Point, double, SloppyPointComparitor> pointToValueMap_;
00091 int dim_;
00092 };
00093
00094
00095
00096
00097
00098 class PointDataCellPredicateFunctor : public CellPredicateFunctorBase,
00099 public Playa::Handleable<CellPredicateFunctorBase>
00100 {
00101 public:
00102
00103 PointDataCellPredicateFunctor(const Array<Point>& locations,
00104 const double& pointComparisonTolerance);
00105
00106
00107 virtual bool operator()(const Point& x) const ;
00108
00109 GET_RCP(CellPredicateFunctorBase);
00110
00111 private:
00112 std::set<Point, SloppyPointComparitor> pointSet_;
00113 };
00114
00115
00116 }
00117
00118 #endif