PDEOptPointData.hpp
Go to the documentation of this file.
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  * PointData is a utility class that helps create the Sundance objects required
00012  * to include point measurements in an inversion problem. 
00013  */
00014 class PointData 
00015 {
00016 public:
00017   /** Create a point data object given a set of sensor locations and
00018    * corresponding sensor readings */
00019   PointData(const Array<Point>& locations, const Array<double>& values,
00020     const double& pointComparisonTolerance);
00021 
00022   /** Create a point data object given a set of sensor locations and
00023    * a field to probe at those points */
00024   PointData(const Array<Point>& locations, const Expr& field,
00025     const double& pointComparisonTolerance);
00026 
00027   /** Read point data from an XML file */
00028   PointData(const XMLObject& xml, const Mesh& mesh);
00029 
00030     
00031 
00032   /** Return an expr that, when called at one of the measurement locations,
00033    * returns the value of the measurement there. */
00034   Expr sensorValues() const {return sensorVals_;}
00035 
00036   /** Return a cell filter that identifies the sensor points */
00037   CellFilter sensorLocations() const {return sensorLocations_;}
00038 
00039 
00040   /** Adjust a set of points to the nearest vertices on a mesh */
00041   static Array<Point> snapToMesh(const Mesh& mesh, const Array<Point>& locations) ;
00042 
00043   /** Find the vertex nearest to a specified point */
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  * Do lexigraphic comparison on points, including a bit of sloppiness 
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  * This is a functor that allows the sensor readings to be obtained through
00073  * a Sundance user-defined expression.
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  * This is a functor that allows a positional cell predicate to test
00096  * against the locations of the sensors.
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

Site Contact