// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == crystal growth group == // == == // == Stiftung caesar == // == Ludwig-Erhard-Allee 2 == // == 53175 Bonn == // == germany == // == == // ============================================================================ // == == // == http://www.caesar.de/cg/AMDiS == // == == // ============================================================================ /** \file ElInfo.h */ #ifndef AMDIS_ELINFO_H #define AMDIS_ELINFO_H // ============================================================================ // ===== includes ============================================================= // ============================================================================ #include "Flag.h" #include "Boundary.h" #include "Global.h" #include "FixVec.h" #include "Element.h" namespace AMDiS { // ============================================================================ // ===== forward declarations ================================================= // ============================================================================ class MacroElement; class Mesh; class Element; class BasisFunction; class Projection; template class AbstractFunction; // ============================================================================ // ===== class ElInfo ========================================================= // ============================================================================ /** \ingroup Traverse * \brief * An ElInfo object holds informations wich are not stored in the corresponding * element. It is filled during mesh traversal by the traversal routines. * A fill flag determines which informations should be filled and which elements * should be visited. Since it is a * pure virtual base class for the dimension speciefic ElInfo classes, it must * not be instantiated directly. * \see ElInfo1d \see ElInfo2d \see ElInfo3d */ class ElInfo { // ===== construtors, destructors ============================================= protected: /** \brief * Protected constructor. Avoids instatiation of the basis class */ ElInfo(); /** \brief * Protected constructor. Avoids instatiation of the basis class. * \param mesh pointer to the corresponding mesh. */ ElInfo(Mesh *mesh); public: /** \brief * Virtual destructor because ElInfo is pure virtual. */ virtual ~ElInfo(); /** \brief * Assignement operator. * \param rhs right hand side. */ ElInfo& operator=(const ElInfo& rhs) { mesh_ = rhs.mesh_; element_ = rhs.element_; parent_ = rhs.parent_; macroElement_ = rhs.macroElement_; fillFlag_ = rhs.fillFlag_; coord_ = rhs.coord_; boundary_ = rhs.boundary_; oppCoord_ = rhs.oppCoord_; neighbour_ = rhs.neighbour_; neighbourCoord_ = rhs.neighbourCoord_; oppVertex_ = rhs.oppVertex_; return *this; }; // ===== getting-methods ====================================================== public: /** \name getting methods * \{ */ /** \brief * Get ElInfo's \ref mesh_ */ inline Mesh* getMesh() const { return mesh_; }; /** \brief * Get ElInfo's \ref macroElement_ */ inline MacroElement* getMacroElement() const { return macroElement_; }; /** \brief * Get ElInfo's \ref element */ inline Element* getElement() const { return element_; }; /** \brief * Get ElInfo's \ref parent_ */ inline Element* getParent() const { return parent_; }; /** \brief * Get ElInfo's \ref fillFlag_ */ inline Flag getFillFlag() const { return fillFlag_; }; /** \brief * Get ElInfo's \ref level_ */ inline unsigned char getLevel() const { return level_; }; /** \brief * Get ElInfo's \ref coord_[i]. This is a WorldVector filled with the * coordinates of the i-th vertex of element \ref el. */ inline WorldVector& getCoord(int i) { return coord_[i]; }; /** \brief * Get ElInfo's \ref coord_[i]. This is a WorldVector filled with the * coordinates of the i-th vertex of element \ref el. */ inline const WorldVector& getCoord(int i) const { return coord_[i]; }; /** \brief * Get ElInfo's \ref coord_. This is a FixVec > filled with the * coordinates of the all vertice of element \ref el. */ inline FixVec, VERTEX>& getCoords() { return coord_; }; /** \brief * Get ElInfo's \ref coord_. This is a FixVec > filled with the * coordinates of the all vertice of element \ref el. */ inline const FixVec, VERTEX>& getCoords() const { return coord_; }; /** \brief * Get ElInfo's \ref oppCoord_[i] */ inline WorldVector& getOppCoord(int i) { return oppCoord_[i]; }; /** \brief * Get ElInfo's \ref boundary_[i] */ virtual BoundaryType getBoundary(int i) const { return boundary_[i]; }; /** \brief * Get boundary type of i-th vertex/edge/face (pos). */ BoundaryType getBoundary(GeoIndex pos, int i); /** \brief * Get ElInfo's \ref neighbour_[i] */ inline Element* getNeighbour(int i) const { return neighbour_[i]; }; /** \brief * Get ElInfo's \ref neighbourCoord_[i] */ inline FixVec, VERTEX> getNeighbourCoord(int i) const { return neighbourCoord_[i]; } /** \brief * Get ElInfo's \ref oppVertex_[i] */ inline unsigned char getOppVertex(int i) const { return oppVertex_[i]; }; virtual int getSideOfNeighbour(int i) { return oppVertex_[i]; }; /** \brief * Get ElInfo's \ref det_ */ inline double getDet() const { return det_; }; /** \brief * Returns \ref grdLambda_ */ inline const DimVec >& getGrdLambda() const { return grdLambda_; }; /** \brief * Returns \ref projection_[i] */ inline Projection *getProjection(int i) const { return projection_[i]; }; /** \brief * Returns \ref parametric_ */ inline bool getParametric() { return parametric_; }; /** \} */ // ===== setting-methods ====================================================== /** \name setting methods * \{ */ /** \brief * Set ElInfo's \ref mesh_ */ inline void setMesh(Mesh* aMesh) { mesh_ = aMesh; }; /** \brief * Set ElInfo's \ref macroElement_ */ inline void setMacroElement(MacroElement* mel) { macroElement_ = mel; }; /** \brief * Set ElInfo's \ref element */ inline void setElement(Element* elem) { element_ = elem; }; /** \brief * Set ElInfo's \ref parent_ */ inline void setParent(Element* elem) { parent_ = elem; }; /** \brief * Set ElInfo's \ref fillFlag_ */ inline void setFillFlag(Flag flag) { fillFlag_ = flag; }; /** \brief * Sets ElInfo's \ref coord_[i]. */ inline void setCoord(int i,WorldVector& coord) { coord_[i] = coord; }; /** \brief * Sets ElInfo's \ref coord. */ inline void setCoords(FixVec,VERTEX >& coords) { coord_ = coords; }; /** \brief * Set ElInfo's \ref level_ */ inline void setLevel(int l) { level_ = l; }; /** \brief * Set ElInfo's \ref boundary_[i] */ inline void setBoundary(int i, BoundaryType t) { boundary_[i] = newBound(boundary_[i], t); }; /** \brief * Set \ref projection_[i] = p */ inline void setProjection(int i, Projection *p) { projection_[i] = p; }; /** \brief * Set \ref det_ = d */ inline void setDet(double d) { det_ = d; }; /** \brief * Set \ref parametric_ = param */ inline void setParametric(bool param) { parametric_ = param; }; /** \} */ // ===== other public methods ================================================= /** \brief * Returns the absolute value of the determinant of the affine linear * parametrization's Jacobian */ virtual double calcDet() const; /** \brief * Used by non static method \ref calcDet(). Calculates the determinant * for a given vector of vertex coordinates. */ static double calcDet(const FixVec, VERTEX> &coords); /** \brief * Checks whether flag is set in ElInfo's \ref fillFlag_. If not, the program * exits. */ void testFlag(const Flag& flag) const; /** \brief * Returns a pointer to a vector, wich contains the world coordinates * of a point in barycentric coordinates lambda with respect to \ref element. * If world is not NULL the world coordinates are stored in this vector. * Otherwise the function itself provides memory for this vector. In this * case the vector is overwritten during the next call of coordToWorld. */ virtual const WorldVector *coordToWorld(const DimVec& lambda, WorldVector* world) const; /** \brief * Fills ElInfo's \ref det_ and \ref grdLambda_ entries. */ virtual void fillDetGrdLambda(); // ===== pure virtual functions. Must be overriden in sub-classes ============ /** \brief * Returns a pointer to a vector, which contains the barycentric coordinates * with respect to \ref element of a point with world coordinates world. * The barycentric coordinates are stored in lambda. * pure virtual => must be overriden in sub-class. */ virtual const int worldToCoord(const WorldVector& world, DimVec* lambda) const = 0; /** \brief * Fills this ElInfo with macro element information of mel. * pure virtual => must be overriden in sub-class. */ virtual void fillMacroInfo(const MacroElement *mel) = 0; /** \brief * Fills this ElInfo for the child ichild using hierarchy information and * parent data parentInfo. * pure virtual => must be overriden in sub-class. */ virtual void fillElInfo(int ichild, const ElInfo *parentInfo) = 0; /** \brief * calculates the Jacobian of the barycentric coordinates on \element and stores * the matrix in grd_lam. The return value of the function is the absolute * value of the determinant of the affine linear paraetrization's Jacobian. * pure virtual => must be overriden in sub-class. */ virtual double calcGrdLambda(DimVec >& grd_lam) const = 0; /** \brief * calculates a normal of the given side (1d,2d: edge, 3d: face) of \ref element. * Returns the absolute value of the determinant of the * transformation to the reference element. * pure virtual => must be overriden in sub-class. */ virtual double getNormal(int side, WorldVector &normal) const = 0; /** \brief * calculates a normal of the element in dim of world = dim + 1. * Returns the absolute value of the determinant of the * transformation to the reference element. * pure virtual => must be overriden in sub-class. */ virtual double getElementNormal(WorldVector &elementNormal) const { FUNCNAME("ElInfo::getElementNormal()"); ERROR("virtual function not implemented in this sub-class "); return(0.0); }; // ===== protected methods ==================================================== protected: /** \brief * Used by ElInfo's coordToWorld(). * \param lambda barycentric coordinates which should be converted. * \param coords coords of element vertices. * \param world world coordinates corresponding to lambda */ static const WorldVector *coordToWorld(const DimVec& lambda, const FixVec, VERTEX> *coords, WorldVector *world); // ===== protected members ==================================================== protected: /** \brief * Pointer to the current mesh */ Mesh *mesh_; /** \brief * Pointer to the current element */ Element *element_; /** \brief * \ref element is child of element parent_ */ Element *parent_; /** \brief * \ref element is an element of the binary tree located at MacroElement * macroElement_ */ MacroElement *macroElement_; /** \brief * Indicates wich elements will be called and wich information should be * present while mesh traversal. */ Flag fillFlag_; /** \brief * Level of the element. The level is zero for macro elements and the level * of the children is (level of the parent + 1). level_ is filled always by * the traversal routines. */ unsigned char level_; /** \brief * \ref coord_[i] is a WorldVector storing the world coordinates of the * i-th vertex of element \ref element. */ FixVec, VERTEX> coord_; /** \brief * boundary_[i] is the BoundaryType of the i-th edge/face * for i=0,...,N_NEIGH - 1. In 3d * (*boundary_)[N_FACES + i] is a pointer to the Boundary * object of the i-th edge, for i=0,..,N_EDGES - 1. It is * a pointer to NULL for an interior edge/face. */ FixVec boundary_; /** \brief * Vector storing pointers to projections for each face, edge, vertex. */ FixVec projection_; /** \brief * oppCoord_[i] coordinates of the i-th neighbour vertex opposite the * common edge/face. */ FixVec, NEIGH> oppCoord_; /** \brief * neighbour_[i] pointer to the element at the edge/face with local index i. * It is a pointer to NULL for boundary edges/faces. */ FixVec neighbour_; /** \brief * neighbourCoord_[i][j] are the coordinate of the j-th vertex of the i-th * neighbour element with the common edge/face. */ FixVec, VERTEX>, NEIGH> neighbourCoord_; /** \brief * oppVertex_[i] is undefined if neighbour_[i] is a pointer to NULL. * Otherwise it is the local index of the neighbour's vertex opposite the * common edge/face. */ FixVec oppVertex_; /** \brief * Elements determinant. */ double det_; /** \brief * Gradient of lambda. */ DimVec > grdLambda_; /** \brief * True, if this elInfo stores parametrized information. False, otherwise. */ bool parametric_; // ===== static public members ================================================ public: /** \brief * child_vertex[el_type][child][i] = father's local vertex index of new * vertex i. 4 stands for the newly generated vertex . */ static const int childVertex[3][2][4]; /** \brief * child_edge[el_type][child][i] = father's local edge index of new edge i. * new edge 2 is half of old edge 0, new edges 4,5 are really new edges, and * value is different: child_edge[][][4,5] = index of same edge in other * child. */ static const int childEdge[3][2][6]; /** \brief * Used to determine to which traverse an ElInfo belongs */ static int traverseId; /** \brief * Used to determine to which traverse an ElInfo belongs */ static int traverseIdCounter; friend class ElInfo1d; friend class ElInfo2d; friend class ElInfo3d; }; } #include "ElInfo1d.h" #include "ElInfo2d.h" #include "ElInfo3d.h" #endif // AMDIS_ELINFO_H