📄 elem.h
字号:
/** * @returns \p true if \p descendant is a child of \p this, or a * child of a child of \p this, etc. * Always returns \p false if AMR is disabled. */ bool is_ancestor_of(const Elem *descendant) const; /** * @returns a const pointer to the element's parent. Returns \p NULL if * the element was not created via refinement, i.e. was read from file. */ const Elem* parent () const; /** * @returns a pointer to the element's parent. Returns \p NULL if * the element was not created via refinement, i.e. was read from file. */ Elem* parent (); /** * @sets the pointer to the element's parent. * Dangerous to use in high-level code. */ void set_parent (Elem *p); /** * @returns a pointer to the element's top-most (i.e. level-0) parent. * Returns \p this if this is a level-0 element, this element's parent * if this is a level-1 element, this element's grandparent if this is * a level-2 element, etc... */ const Elem* top_parent () const; /** * @returns the magnitude of the distance between nodes n1 and n2. * Useful for computing the lengths of the sides of elements. */ Real length (const unsigned int n1, const unsigned int n2) const; /** * @returns the number of adjacent vertices, that uniquely define * the location of the \f$ n^{th} \f$ @e second-order node. For linear * elements ( \p default_order()==FIRST ), this returns 0. * This method is useful when converting linear elements to quadratic * elements. Note that \p n has to be greater or equal * \p this->n_vertices(). */ virtual unsigned int n_second_order_adjacent_vertices (const unsigned int n) const; /** * @returns the element-local number of the \f$ v^{th} \f$ vertex * that defines the \f$ n^{th} \f$ second-order node. Note that * the return value is always less \p this->n_vertices(), while * \p n has to be greater or equal \p this->n_vertices(). For * linear elements this returns 0. */ virtual unsigned short int second_order_adjacent_vertex (const unsigned int n, const unsigned int v) const; /** * @returns the child number \p c and element-local index \p v of the * \f$ n^{th} \f$ second-order node on the parent element. Note that * the return values are always less \p this->n_children() and * \p this->child(c)->n_vertices(), while \p n has to be greater or equal * to \p * this->n_vertices(). For linear elements this returns 0,0. * On refined second order elements, the return value will satisfy * \p this->get_node(n)==this->child(c)->get_node(v) */ virtual std::pair<unsigned short int, unsigned short int> second_order_child_vertex (const unsigned int n) const; /** * @returns the element type of the associated second-order element, * e.g. when \p this is a \p TET4, then \p TET10 is returned. Returns * \p INVALID_ELEM for second order or other elements that should not * or cannot be converted into higher order equivalents. * * For some elements, there exist two second-order equivalents, e.g. * for \p Quad4 there is \p Quad8 and \p Quad9. When the optional * \p full_ordered is \p true, then \p QUAD9 is returned. When * \p full_ordered is \p false, then \p QUAD8 is returned. */ static ElemType second_order_equivalent_type (const ElemType et, const bool full_ordered=true); /** * @returns the element type of the associated first-order element, * e.g. when \p this is a \p TET10, then \p TET4 is returned. Returns * \p INVALID_ELEM for first order or other elements that should not * or cannot be converted into lower order equivalents. */ static ElemType first_order_equivalent_type (const ElemType et); /** * @returns the refinement level of the current element. If the * element's parent is \p NULL then by convention it is at * level 0, otherwise it is simply at one level greater than * its parent. */ unsigned int level () const; /** * Returns the value of the p refinement level of an active * element, or the minimum value of the p refinement levels * of an ancestor element's descendants */ unsigned int p_level () const;#ifdef ENABLE_AMR /** * Useful ENUM describing the refinement state of * an element. */ enum RefinementState { COARSEN = 0, DO_NOTHING, REFINE, JUST_REFINED, JUST_COARSENED, INACTIVE, COARSEN_INACTIVE }; /** * @returns a pointer to the \f$ i^{th} \f$ child for this element. * Do not call if this element has no children, i.e. is active. */ Elem* child (const unsigned int i) const; /** * This function tells you which child you \p (e) are. * I.e. if c = a->which_child_am_i(e); then * a->child(c) will be e; */ unsigned int which_child_am_i(const Elem *e) const; /** * @returns true iff the specified child is on the * specified side */ virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const = 0; /** * @returns true iff the specified child is on the * specified edge */ virtual bool is_child_on_edge(const unsigned int c, const unsigned int e) const; /** * Adds a child pointer to the array of children of this element. * If this is the first child to be added, this method allocates * memory in the parent's _children array, otherwise, it just sets * the pointer. */ void add_child (Elem* elem); /** * Adds a new child pointer to the specified index in the array of * children of this element. If this is the first child to be added, * this method allocates memory in the parent's _children array, * otherwise, it just sets the pointer. */ void add_child (Elem* elem, unsigned int c); /** * Fills the vector \p family with the children of this element, * recursively. So, calling this method on a twice-refined element * will give you the element itself, its direct children, and their * children, etc... When the optional parameter \p reset is * true then the vector will be cleared before the element and its * descendants are added. */ void family_tree (std::vector<const Elem*>& family, const bool reset=true) const; /** * Same as the \p family_tree() member, but only adds the active * children. Can be thought of as removing all the inactive * elements from the vector created by \p family_tree, but is * implemented more efficiently. */ void active_family_tree (std::vector<const Elem*>& active_family, const bool reset=true) const; /** * Same as the \p family_tree() member, but only adds elements * which are next to \p neighbor. */ void family_tree_by_neighbor (std::vector<const Elem*>& family, const Elem *neighbor, const bool reset=true) const; /** * Same as the \p family_tree() member, but only adds elements * which are next to \p subneighbor. Only applicable when * \p this->has_neighbor(neighbor) and * \p neighbor->is_ancestor(subneighbor) */ void family_tree_by_subneighbor (std::vector<const Elem*>& family, const Elem *neighbor, const Elem *subneighbor, const bool reset=true) const; /** * Same as the \p active_family_tree() member, but only adds elements * which are next to \p neighbor. */ void active_family_tree_by_neighbor (std::vector<const Elem*>& family, const Elem *neighbor, const bool reset=true) const; /** * Returns the value of the refinement flag for the element. */ RefinementState refinement_flag () const; /** * Sets the value of the refinement flag for the element. */ void set_refinement_flag (const RefinementState rflag); /** * Returns the value of the p refinement flag for the element. */ RefinementState p_refinement_flag () const; /** * Sets the value of the p refinement flag for the element. */ void set_p_refinement_flag (const RefinementState pflag); /** * Returns the maximum value of the p refinement levels of * an ancestor element's descendants */ unsigned int max_descendant_p_level () const; /** * Returns the minimum p refinement level of elements which * are descended from this and which share a side with the * active \p neighbor */ unsigned int min_p_level_by_neighbor (const Elem* neighbor, unsigned int current_min) const; /** * Returns the minimum new p refinement level (i.e. after * refinement and coarsening is done) of elements which are * descended from this and which share a side with the * active \p neighbor */ unsigned int min_new_p_level_by_neighbor (const Elem* neighbor, unsigned int current_min) const; /** * Sets the value of the p refinement level for the element * Note that the maximum p refinement level is currently 255 */ void set_p_level (const unsigned int p); /** * Sets the value of the p refinement level for the element * without altering the p level of its ancestors */ void hack_p_level (const unsigned int p); /** * Refine the element. */ virtual void refine (MeshRefinement& mesh_refinement); /** * Coarsen the element. This is not * virtual since it is the same for all * element types. */ void coarsen (); /** * Contract an active element, i.e. remove pointers to any * subactive children. This should only be called via * MeshRefinement::contract, which will also remove subactive * children from the mesh */ void contract ();#endif#ifdef DEBUG /** * This function checks for consistent neighbor links at this * element. */ void libmesh_assert_valid_neighbors() const; /** * This function checks for a valid id and for pointers to nodes * with valid ids at this element. */ void libmesh_assert_valid_node_pointers() const;#endif // DEBUGprotected: /** * The protected nested SideIter class is used to iterate over the * sides of this Elem. It is a specially designed class since * no sides are actually stored by the element. This iterator-like * class has to provide the following three operations * 1) operator* * 2) operator++ * 3) operator== * The definition can be found at the end of this header file. */ class SideIter; public: /** * Useful iterator typedefs */ typedef Predicates::multi_predicate Predicate; //typedef variant_filter_iterator<Elem*, Predicate> side_iterator; /** * Data structure for iterating over sides. Defined at the end of * this header file. */ struct side_iterator; /** * Iterator accessor functions */ side_iterator boundary_sides_begin(); side_iterator boundary_sides_end();private: /** * Side iterator helper functions. Used to replace the begin() * and end() functions of the STL containers. */ SideIter _first_side(); SideIter _last_side(); public: #ifdef ENABLE_INFINITE_ELEMENTS /** * @returns \p true if the element is an infinite element, * \p false otherwise. */ virtual bool infinite () const = 0; /** * @returns the origin for an infinite element. Currently, * @e all infinite elements used in a mesh share the same * origin. Overload this in infinite element classes. * By default, issues an error, because returning the * all zero point would very likely lead to unexpected * behavior. */ virtual Point origin () const { libmesh_error(); return Point(); }#endif /** * Build an element of type \p type. Since this method * allocates memory the new \p Elem is returned in a * \p AutoPtr<> */ static AutoPtr<Elem> build (const ElemType type, Elem* p=NULL);#ifdef ENABLE_AMR /** * Matrix that transforms the parents nodes into the children's * nodes */ virtual float embedding_matrix (const unsigned int i, const unsigned int j, const unsigned int k) const = 0;#endif //-------------------------------------------------------- /** * Convenient way to communicate elements. This struct * packes up an element so that it can easily be communicated through * an MPI array. * * \author Benjamin S. Kirk * \date 2008 */ class PackedElem; protected: //------------------------------------------------------- // These methods compute has keys from the specified // global node numbers // /** * Compute a key from the specified nodes. */ static unsigned int compute_key (unsigned int n0); /** * Compute a key from the specified nodes. */ static unsigned int compute_key (unsigned int n0, unsigned int n1); /** * Compute a key from the specified nodes. */ static unsigned int compute_key (unsigned int n0, unsigned int n1, unsigned int n2); /** * Compute a key from the specified nodes. */ static unsigned int compute_key (unsigned int n0, unsigned int n1, unsigned int n2, unsigned int n3); //------------------------------------------------------- /** * Replaces this element with \p NULL for all of * its neighbors. This is useful when deleting an * element. */ void nullify_neighbors (); /** * Pointers to the nodes we are conneted to. */ Node** _nodes; /** * Pointers to this element's neighbors. */ Elem** _neighbors; /** * A pointer to this element's parent. */ Elem* _parent;#ifdef ENABLE_AMR /** * Pointers to this element's children. */ Elem** _children; /** * h refinement flag. This is stored as an unsigned char * to save space. */ unsigned char _rflag; //RefinementState _rflag; /** * p refinement flag. This is stored as an unsigned char * to save space. */ unsigned char _pflag; //RefinementState _pflag; /** * p refinement level - the difference between the * polynomial degree on this element and the minimum * polynomial degree on the mesh. * This is stored as an unsigned char to save space. * In theory, these last four bytes might have * been padding anyway. */ unsigned char _p_level;#endif /** * The subdomain to which this element belongs. */ unsigned char _sbd_id;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -