libMesh
edge_edge2.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 // Local includes
21 #include "libmesh/edge_edge2.h"
22 #include "libmesh/enum_io_package.h"
23 #include "libmesh/enum_order.h"
24 
25 namespace libMesh
26 {
27 
28 
29 // Edge2 class static member initializations
30 const int Edge2::num_nodes;
31 const int Edge2::num_sides;
32 const int Edge2::num_edges;
33 const int Edge2::num_children;
34 const int Edge2::nodes_per_side;
35 const int Edge2::nodes_per_edge;
36 
37 #ifdef LIBMESH_ENABLE_AMR
38 
40  {
41  // embedding matrix for child 0
42  {
43  // 0 1
44  {1.0, 0.0}, // 0
45  {0.5, 0.5} // 1
46  },
47 
48  // embedding matrix for child 1
49  {
50  // 0 1
51  {0.5, 0.5}, // 0
52  {0.0, 1.0} // 1
53  }
54  };
55 
56 #endif
57 
58 bool Edge2::is_vertex(const unsigned int) const
59 {
60  return true;
61 }
62 
63 bool Edge2::is_edge(const unsigned int) const
64 {
65  return false;
66 }
67 
68 bool Edge2::is_face(const unsigned int) const
69 {
70  return false;
71 }
72 
73 bool Edge2::is_node_on_side(const unsigned int n,
74  const unsigned int s) const
75 {
76  libmesh_assert_less (s, Edge2::num_nodes);
77  return (s == n);
78 }
79 
80 bool Edge2::is_node_on_edge(const unsigned int,
81  const unsigned int libmesh_dbg_var(e)) const
82 {
83  libmesh_assert_equal_to (e, 0);
84  return true;
85 }
86 
87 
88 
90 {
91  return FIRST;
92 }
93 
94 
95 
97 {
98  return this->volume() > tol;
99 }
100 
101 
102 
103 void Edge2::connectivity(const unsigned int libmesh_dbg_var(sc),
104  const IOPackage iop,
105  std::vector<dof_id_type> & conn) const
106 {
107  libmesh_assert_equal_to (sc, 0);
108  libmesh_assert_less (sc, this->n_sub_elem());
109  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
110 
111  // Create storage
112  conn.resize(2);
113 
114  switch (iop)
115  {
116  case TECPLOT:
117  {
118  conn[0] = this->node_id(0)+1;
119  conn[1] = this->node_id(1)+1;
120  return;
121  }
122 
123  case VTK:
124  {
125  conn[0] = this->node_id(0);
126  conn[1] = this->node_id(1);
127  return;
128  }
129 
130  default:
131  libmesh_error_msg("Unsupported IO package " << iop);
132  }
133 }
134 
135 
137 {
138  return Real(0.5) * (this->point(0) + this->point(1));
139 }
140 
142 {
143  // OK, so this is probably overkill, since it is equivalent to
144  // Elem::hmax() for the Edge2, but here it is nonetheless...
145  return (this->point(1) - this->point(0)).norm();
146 }
147 
148 
149 
151 {
152  return this->compute_key(this->node_id(0),
153  this->node_id(1));
154 }
155 
156 
157 void Edge2::flip(BoundaryInfo * boundary_info)
158 {
159  swap2nodes(0,1);
160  swap2neighbors(0,1);
161  swap2boundarysides(0,1,boundary_info);
162 }
163 
164 
165 } // namespace libMesh
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
static const int num_children
Definition: edge_edge2.h:176
static const int nodes_per_side
Definition: edge_edge2.h:177
IOPackage
libMesh interfaces with several different software packages for the purposes of creating, reading, and writing mesh files.
void swap2boundarysides(unsigned short s1, unsigned short s2, BoundaryInfo *boundary_info) const
Swaps two sides in boundary_info, if it is non-null.
Definition: elem.C:3155
static const int num_sides
Definition: edge_edge2.h:174
The libMesh namespace provides an interface to certain functionality in the library.
virtual dof_id_type key() const override
Definition: edge_edge2.C:150
void swap2nodes(unsigned int n1, unsigned int n2)
Swaps two node_ptrs.
Definition: elem.h:1933
static const int num_edges
Definition: edge_edge2.h:175
virtual bool is_face(const unsigned int i) const override
Definition: edge_edge2.C:68
virtual Point true_centroid() const override
An optimized method for computing the centroid of a 2-node edge.
Definition: edge_edge2.C:136
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
static const Real _embedding_matrix[num_children][num_nodes][num_nodes]
Matrix that computes new nodal locations/solution values from current nodes/solution.
Definition: edge_edge2.h:205
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const override
Definition: edge_edge2.C:73
virtual bool is_vertex(const unsigned int i) const override
Definition: edge_edge2.C:58
static const int num_nodes
Geometric constants for Edge2.
Definition: edge_edge2.h:173
virtual bool has_invertible_map(Real tol) const override
Definition: edge_edge2.C:96
virtual bool is_edge(const unsigned int i) const override
Definition: edge_edge2.C:63
virtual Order default_order() const override
Definition: edge_edge2.C:89
void swap2neighbors(unsigned int n1, unsigned int n2)
Swaps two neighbor_ptrs.
Definition: elem.h:1943
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void connectivity(const unsigned int sc, const IOPackage iop, std::vector< dof_id_type > &conn) const override
Definition: edge_edge2.C:103
virtual unsigned int n_sub_elem() const override
Definition: edge_edge2.h:76
static const int nodes_per_edge
Definition: edge_edge2.h:178
virtual Real volume() const override
An optimized method for computing the length of a 2-node edge.
Definition: edge_edge2.C:141
static dof_id_type compute_key(dof_id_type n0)
Definition: elem.h:3131
virtual void flip(BoundaryInfo *) override final
Flips the element (by swapping node and neighbor pointers) to have a mapping Jacobian of opposite sig...
Definition: edge_edge2.C:157
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:2299
const Point & point(const unsigned int i) const
Definition: elem.h:2277
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const override
Definition: edge_edge2.C:80
uint8_t dof_id_type
Definition: id_types.h:67