// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == crystal growth group == // == == // == Stiftung caesar == // == Ludwig-Erhard-Allee 2 == // == 53175 Bonn == // == germany == // == == // ============================================================================ // == == // == http://www.caesar.de/cg/AMDiS == // == == // ============================================================================ /** \file ElementFunction.h */ #ifndef AMDIS_ELEMENTFUNCTION_H #define AMDIS_ELEMENTFUNCTION_H #include "AbstractFunction.h" #include "DOFVector.h" #include "BasisFunction.h" namespace AMDiS { // ============================================================================ // ===== class ElementFunction ================================================ // ============================================================================ /** \brief * Abstract access to functions living on elements. */ template<typename T> class ElementFunction : public AbstractFunction<T, DimVec<double> > { public: /** \brief * constructor. */ ElementFunction() : elInfo_(NULL) {}; /** \brief * destructor. */ virtual ~ElementFunction() {}; /** \brief * sets \ref elInfo_; */ inline void setElInfo(const ElInfo *elInfo) { elInfo_ = elInfo; }; protected: /** \brief * ElInfo the function currently lives on. */ const ElInfo *elInfo_; }; // ============================================================================ // ===== class ElementFunctionAnalytic ======================================== // ============================================================================ /** \brief * ElementFunction wich encapsulates the evaluation of an analytical function. */ template<typename T> class ElementFunctionAnalytic : public ElementFunction<T> { public: /** \brief * constructor */ ElementFunctionAnalytic(const AbstractFunction<T, WorldVector<double> > *fct) : ElementFunction<T>(), fct_(fct) {}; /** \brief * evaluation at given coordinates. */ const T& operator()(const DimVec<double>& bary) const { const WorldVector<double> *worldCoords = this->elInfo_->coordToWorld(bary, NULL); return (*fct_)(*worldCoords); }; protected: /** \brief * function to be avaluated at world coordinates. */ const AbstractFunction<T, WorldVector<double> > *fct_; }; // ============================================================================ // ===== class ElementFunctionDOFVec ========================================== // ============================================================================ /** \brief * ElementFunction wich encapsulates the interpolation of an DOFVector. */ template<typename T> class ElementFunctionDOFVec : public ElementFunction<T> { public: /** \brief * constructor. */ ElementFunctionDOFVec(const DOFVector<T> *dofVector) : ElementFunction<T>(), dofVector_(dofVector) {}; /** \brief * evaluation at given coordinates. */ const T& operator()(const DimVec<double>& bary) const { static T t; const T* localVec = dofVector_->getLocalVector(this->elInfo_->getElement(), NULL); t = dofVector_->getFESpace()->getBasisFcts()->evalUh(bary, localVec); return t; }; protected: /** \brief * DOFVector to be interpolated. */ const DOFVector<T> *dofVector_; }; } #endif