Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : 19 : 20 : #ifndef LIBMESH_FACE_QUAD4_H 21 : #define LIBMESH_FACE_QUAD4_H 22 : 23 : // Local includes 24 : #include "libmesh/libmesh_common.h" 25 : #include "libmesh/face_quad.h" 26 : 27 : namespace libMesh 28 : { 29 : 30 : /** 31 : * The \p QUAD4 is an element in 2D composed of 4 nodes. 32 : * It is numbered like this: 33 : * 34 : * \verbatim 35 : * 3 2 36 : * QUAD4: o-----------o 37 : * | | eta 38 : * | | ^ 39 : * | | | 40 : * | | | 41 : * | | o---> xi 42 : * o-----------o 43 : * 0 1 44 : * \endverbatim 45 : * 46 : * (xi, eta) in [-1,1]^2 are the reference element coordinates associated with 47 : * the given numbering. 48 : * 49 : * \author Benjamin S. Kirk 50 : * \date 2002 51 : * \brief A 2D quadrilateral element with 4 nodes. 52 : */ 53 : class Quad4 : public Quad 54 : { 55 : public: 56 : 57 : /** 58 : * Constructor. By default this element has no parent. 59 : */ 60 : explicit 61 1833252683 : Quad4 (Elem * p=nullptr) : 62 1833252683 : Quad(num_nodes, p, _nodelinks_data) {} 63 : 64 : Quad4 (Quad4 &&) = delete; 65 : Quad4 (const Quad4 &) = delete; 66 : Quad4 & operator= (const Quad4 &) = delete; 67 : Quad4 & operator= (Quad4 &&) = delete; 68 1847892231 : virtual ~Quad4() = default; 69 : 70 : /** 71 : * \returns \p QUAD4. 72 : */ 73 2050848130 : virtual ElemType type () const override { return QUAD4; } 74 : 75 : /** 76 : * \returns 1. 77 : */ 78 29874535 : virtual unsigned int n_sub_elem() const override { return 1; } 79 : 80 : /** 81 : * \returns \p true if the specified (local) node number is a vertex. 82 : */ 83 : virtual bool is_vertex(const unsigned int i) const override; 84 : 85 : /** 86 : * \returns \p true if the specified (local) node number is an edge. 87 : */ 88 : virtual bool is_edge(const unsigned int i) const override; 89 : 90 : /** 91 : * \returns \p true if the specified (local) node number is a face. 92 : */ 93 : virtual bool is_face(const unsigned int i) const override; 94 : 95 : /** 96 : * \returns \p true if the specified (local) node number is on the 97 : * specified side. 98 : */ 99 : virtual bool is_node_on_side(const unsigned int n, 100 : const unsigned int s) const override; 101 : 102 : virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override; 103 : 104 : virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override; 105 : 106 : /** 107 : * \returns \p true if the specified (local) node number is on the 108 : * specified edge (== is_node_on_side in 2D). 109 : */ 110 67772 : virtual bool is_node_on_edge(const unsigned int n, 111 : const unsigned int e) const override 112 67772 : { return this->is_node_on_side(n,e); } 113 : 114 : /** 115 : * \returns \p true if the element map is definitely affine within 116 : * numerical tolerances. 117 : */ 118 : virtual bool has_affine_map () const override; 119 : 120 : /** 121 : * \returns \p true if the element convex, false otherwise. 122 : */ 123 : virtual bool has_invertible_map(Real tol) const override; 124 : 125 : /** 126 : * \returns FIRST. 127 : */ 128 : virtual Order default_order() const override; 129 : 130 : virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override; 131 : 132 : /** 133 : * Rebuilds an EDGE2 coincident with face i. 134 : */ 135 : virtual void build_side_ptr (std::unique_ptr<Elem> & elem, 136 : const unsigned int i) override; 137 : 138 : // Avoid hiding deprecated version with different signature 139 : using Elem::build_side_ptr; 140 : 141 : virtual void connectivity(const unsigned int sf, 142 : const IOPackage iop, 143 : std::vector<dof_id_type> & conn) const override; 144 : 145 : /** 146 : * Geometric constants for Quad4. 147 : */ 148 : static const int num_nodes = 4; 149 : static const int nodes_per_side = 2; 150 : 151 : /** 152 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to 153 : * element node numbers. 154 : */ 155 : static const unsigned int side_nodes_map[num_sides][nodes_per_side]; 156 : 157 : /** 158 : * An optimized method for computing the centroid of a 159 : * 4-node quad with straight sides. 160 : */ 161 : virtual Point true_centroid () const override; 162 : 163 : /** 164 : * An optimized method for computing the area of a 165 : * 4-node quad with straight sides, but not necessarily a 166 : * parallelogram. 167 : */ 168 : virtual Real volume () const override; 169 : 170 : /** 171 : * Builds a bounding box out of the nodal positions 172 : */ 173 : virtual BoundingBox loose_bounding_box () const override; 174 : 175 : virtual void permute(unsigned int perm_num) override final; 176 : 177 : virtual void flip(BoundaryInfo *) override final; 178 : 179 : ElemType side_type (const unsigned int s) const override final; 180 : 181 : protected: 182 : 183 : /** 184 : * Data for links to nodes. 185 : */ 186 : Node * _nodelinks_data[num_nodes]; 187 : 188 : 189 : 190 : #ifdef LIBMESH_ENABLE_AMR 191 : 192 : /** 193 : * Matrix used to create the elements children. 194 : */ 195 7497660 : virtual Real embedding_matrix (const unsigned int i, 196 : const unsigned int j, 197 : const unsigned int k) const override 198 7497660 : { return _embedding_matrix[i][j][k]; } 199 : 200 : /** 201 : * Matrix that computes new nodal locations/solution values 202 : * from current nodes/solution. 203 : */ 204 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes]; 205 : 206 29773684 : LIBMESH_ENABLE_TOPOLOGY_CACHES; 207 : 208 : #endif // LIBMESH_ENABLE_AMR 209 : 210 : }; 211 : 212 : 213 : } // namespace libMesh 214 : 215 : #endif // LIBMESH_FACE_QUAD4_H