/** \file BackgroundMesh.h */ #ifndef BACKGROUND_MESH_H #define BACKGROUND_MESH_H // AMDiS-includes #include "DOFVector.h" // DOFVector #include "FiniteElemSpace.h" // FiniteElemSpace #include "FixVec.h" // WorldVector #include "Global.h" // DegreeOfFreedom #ifndef USE_EXPERIMENTAL #define USE_EXPERIMENTAL #endif namespace experimental { using namespace AMDiS; typedef WorldVector PointType; inline double distance(const PointType &x, const PointType &y, unsigned int n) { double d = 0.0; for (unsigned int i = 0; i < n; i++) d += sqr(x[i]-y[i]); return sqrt(d); } inline double distance2(const PointType &x, const PointType &y, unsigned int n) { double d = 0.0; for (unsigned int i = 0; i < n; i++) d += sqr(x[i]-y[i]); return d; } typedef std::pair DataType; struct Box { Box(int DOW_, std::vector N_); Box(int DOW_, PointType min_corner_, PointType max_corner_, std::vector N_); void init(); void fillBox(const FiniteElemSpace* feSpace); void clearBox(); void clearBoxData(); int getMaxBoxSize(); bool inBox(const PointType& x); int getBox(const PointType& x); bool getNearestData(const PointType& x, DataType& data); bool getNearestData(const PointType& x, std::vector& data, int nData); /** * strategies: * 0 .. get nearest point to x and eval DOFVector at this DOF-index * 1 .. get n nearest points, calc weighted sum of data at these points * 2 .. get n nearest points, calc regression plane and eval at x * 3 .. get n nearest points, calc weighted regression plane and eval at x **/ template T evalAtPoint(const DOFVector& vec, const PointType& x, int strategy = 0, int nrOfPoints = -1); static Box* provideBackgroundMesh(const FiniteElemSpace* feSpace); static void delete_all(); void addData(PointType x, DataType data); protected: template T evalAtPoint_simple(const DOFVector& vec, const PointType& x); template T evalAtPoint_weighted_sum(const DOFVector& vec, const PointType& x, int nrOfPoints); template T evalAtPoint_regression(const DOFVector& vec, const PointType& x, int nrOfPoints); template T evalAtPoint_weighted_regression(const DOFVector& vec, const PointType& x, int nrOfPoints); inline int idx2nr(std::vector& idx); inline void nr2idx(int nr, std::vector& idx); void getSurroundingBoxes(int nr, std::set &surrounding_nrs); void getSurroundingBoxes(int center, int radius, std::set &nrs); void getSurroundingBoxes(std::set &nrs, std::set &surrounding_nrs); /// berechne die minimale Entfernung der Ränder der Box zu x double getBoxBoundaryDist(int nr, const PointType& x); static std::map > boxMap; private: int DOW; std::vector N; bool boxFilled; PointType min_corner; PointType max_corner; std::vector > boxData; }; } // end namespace experimental #include "BackgroundMesh.hh" #endif // BACKGROUND_MESH_H