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_EDGE_EDGE4_H 21 : #define LIBMESH_EDGE_EDGE4_H 22 : 23 : // Local includes 24 : #include "libmesh/libmesh_common.h" 25 : #include "libmesh/edge.h" 26 : 27 : namespace libMesh 28 : { 29 : 30 : /** 31 : * The \p Edge4 is an element in 1D composed of 4 nodes. 32 : * 33 : * It is numbered like this: 34 : * 35 : * \verbatim 36 : * EDGE4: o----o----o----o o---> xi 37 : * 0 2 3 1 38 : * \endverbatim 39 : * 40 : * xi in [-1,1] is the reference element coordinate associated with 41 : * the given numbering. 42 : * 43 : * \author David Knezevic 44 : * \date 2005 45 : * \brief A 1D geometric element with 4 nodes. 46 : */ 47 : class Edge4 final : public Edge 48 : { 49 : public: 50 : 51 : /** 52 : * Constructor. By default this element has no parent. 53 : */ 54 : explicit 55 43685 : Edge4 (Elem * p=nullptr) : 56 43685 : Edge(num_nodes, p, _nodelinks_data) {} 57 : 58 : Edge4 (Edge4 &&) = delete; 59 : Edge4 (const Edge4 &) = delete; 60 : Edge4 & operator= (const Edge4 &) = delete; 61 : Edge4 & operator= (Edge4 &&) = delete; 62 45744 : virtual ~Edge4() = default; 63 : 64 : /** 65 : * \returns The \p Point associated with local \p Node \p i, 66 : * in master element rather than physical coordinates. 67 : */ 68 0 : virtual Point master_point (const unsigned int i) const override 69 : { 70 0 : libmesh_assert_less(i, this->n_nodes()); 71 0 : if (i < 2) 72 0 : return Point(2.0f*Real(i)-1.0f,0,0); 73 0 : return Point((Real(2)*Real(i)-5)/3,0,0); 74 : } 75 : 76 : /** 77 : * \returns 4. 78 : */ 79 83912 : virtual unsigned int n_nodes() const override { return num_nodes; } 80 : 81 : /** 82 : * \returns 2. 83 : */ 84 0 : virtual unsigned int n_sub_elem() const override { return 2; } 85 : 86 : /** 87 : * \returns \p true if the specified (local) node number is a vertex. 88 : */ 89 : virtual bool is_vertex(const unsigned int i) const override; 90 : 91 : /** 92 : * \returns \p true if the specified (local) node number is an edge. 93 : */ 94 : virtual bool is_edge(const unsigned int i) const override; 95 : 96 : /** 97 : * \returns \p true if the specified (local) node number is a face. 98 : */ 99 : virtual bool is_face(const unsigned int i) const override; 100 : 101 : /** 102 : * \returns \p true if the specified (local) node number is on the 103 : * specified side. 104 : */ 105 : virtual bool is_node_on_side(const unsigned int n, 106 : const unsigned int s) const override; 107 : 108 : /** 109 : * \returns \p true if the specified (local) node number is on the 110 : * specified edge (always true in 1D). 111 : */ 112 : virtual bool is_node_on_edge(const unsigned int n, 113 : const unsigned int e) const override; 114 : 115 : /** 116 : * \returns \p true if the element map is definitely affine within 117 : * numerical tolerances. 118 : */ 119 : virtual bool has_affine_map () const override; 120 : 121 : /** 122 : * \returns \p true if the scalar quantity j(xi) := dot(dx/dxi(0), 123 : * dx/dxi(xi)) is of single sign (either positive or negative) 124 : * throughout the element. For the Edge4, j(xi) is a quadratic 125 : * function of xi, so the min/max can occur somewhere on the 126 : * interior of the element, and it is therefore not sufficient to 127 : * check only the vertex values. 128 : */ 129 : virtual bool has_invertible_map(Real tol) const override; 130 : 131 : /** 132 : * \returns \p EDGE4. 133 : */ 134 15881 : virtual ElemType type() const override { return EDGE4; } 135 : 136 : /** 137 : * \returns THIRD. 138 : */ 139 : virtual Order default_order() const override; 140 : 141 : virtual void connectivity(const unsigned int sc, 142 : const IOPackage iop, 143 : std::vector<dof_id_type> & conn) const override; 144 : 145 : /** 146 : * FIXME: This function could be generalized to work for Edges. 147 : */ 148 0 : virtual unsigned int n_second_order_adjacent_vertices (const unsigned int) const override 149 0 : { libmesh_not_implemented(); return 0; } 150 : 151 : /** 152 : * FIXME: This function could be generalized to work for Edges. 153 : */ 154 0 : virtual unsigned short int second_order_adjacent_vertex (const unsigned int, 155 : const unsigned int) const override 156 0 : { libmesh_not_implemented(); return 0; } 157 : 158 : /** 159 : * \returns A bounding box (not necessarily the minimal bounding box) 160 : * containing the edge. 161 : */ 162 : virtual BoundingBox loose_bounding_box () const override; 163 : 164 : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 165 : 166 : /** 167 : * \returns \p false. This is a finite element. 168 : */ 169 1145 : virtual bool infinite () const override { return false; } 170 : 171 : #endif 172 : 173 : /** 174 : * Don't hide Edge::key(side) defined in the base class. 175 : */ 176 : using Edge::key; 177 : 178 : /** 179 : * \returns An id associated with the global node ids of this 180 : * element. The id is not necessarily unique, but should be 181 : * close. 182 : */ 183 : virtual dof_id_type key () const override; 184 : 185 : /** 186 : * An optimized method for approximating the length of an 187 : * EDGE4 using quadrature. 188 : */ 189 : virtual Real volume () const override; 190 : 191 : /** 192 : * Geometric constants for Edge4. 193 : */ 194 : static const int num_nodes = 4; 195 : 196 : virtual void flip(BoundaryInfo *) override final; 197 : 198 : protected: 199 : 200 : /** 201 : * Data for links to nodes. 202 : */ 203 : Node * _nodelinks_data[num_nodes]; 204 : 205 : 206 : 207 : #ifdef LIBMESH_ENABLE_AMR 208 : 209 : /** 210 : * Matrix used to create the elements children. 211 : */ 212 0 : virtual Real embedding_matrix (const unsigned int i, 213 : const unsigned int j, 214 : const unsigned int k) const override 215 0 : { return _embedding_matrix[i][j][k]; } 216 : 217 : /** 218 : * Matrix that computes new nodal locations/solution values 219 : * from current nodes/solution. 220 : */ 221 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes]; 222 : 223 0 : LIBMESH_ENABLE_TOPOLOGY_CACHES; 224 : 225 : #endif // LIBMESH_ENABLE_AMR 226 : 227 : }; 228 : 229 : } // namespace libMesh 230 : 231 : 232 : #endif // LIBMESH_EDGE_EDGE4_H