libMesh
Loading...
Searching...
No Matches
edge_edge2.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
25namespace libMesh
26{
27
28
29// ------------------------------------------------------------
30// Edge2 class static member initializations
31const int Edge2::num_nodes;
32
33#ifdef LIBMESH_ENABLE_AMR
34
36 {
37 // embedding matrix for child 0
38 {
39 // 0 1
40 {1.0, 0.0}, // 0
41 {0.5, 0.5} // 1
42 },
43
44 // embedding matrix for child 1
45 {
46 // 0 1
47 {0.5, 0.5}, // 0
48 {0.0, 1.0} // 1
49 }
50 };
51
52#endif
53
54bool Edge2::is_vertex(const unsigned int libmesh_dbg_var(n)) const
55{
56 libmesh_assert_not_equal_to (n, invalid_uint);
57 return true;
58}
59
60bool Edge2::is_edge(const unsigned int) const
61{
62 return false;
63}
64
65bool Edge2::is_face(const unsigned int) const
66{
67 return false;
68}
69
70bool Edge2::is_node_on_side(const unsigned int n,
71 const unsigned int s) const
72{
73 libmesh_assert_less (s, Edge2::num_nodes);
74 return (s == n);
75}
76
77bool Edge2::is_node_on_edge(const unsigned int,
78 const unsigned int libmesh_dbg_var(e)) const
79{
80 libmesh_assert_equal_to (e, 0);
81 return true;
82}
83
84
85
87{
88 return FIRST;
89}
90
91
92
94{
95 return this->volume() > tol;
96}
97
98
99
100void Edge2::connectivity(const unsigned int libmesh_dbg_var(sc),
101 const IOPackage iop,
102 std::vector<dof_id_type> & conn) const
103{
104 libmesh_assert_equal_to (sc, 0);
105 libmesh_assert_less (sc, this->n_sub_elem());
106 libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
107
108 // Create storage
109 conn.resize(2);
110
111 switch (iop)
112 {
113 case TECPLOT:
114 {
115 conn[0] = this->node_id(0)+1;
116 conn[1] = this->node_id(1)+1;
117 return;
118 }
119
120 case VTK:
121 {
122 conn[0] = this->node_id(0);
123 conn[1] = this->node_id(1);
124 return;
125 }
126
127 default:
128 libmesh_error_msg("Unsupported IO package " << iop);
129 }
130}
131
132
134{
135 return Real(0.5) * (this->point(0) + this->point(1));
136}
137
139{
140 // OK, so this is probably overkill, since it is equivalent to
141 // Elem::hmax() for the Edge2, but here it is nonetheless...
142 return (this->point(1) - this->point(0)).norm();
143}
144
145
146Point
147Edge2::side_vertex_average_normal(const unsigned int s) const
148{
149 libmesh_assert_less (s, 2);
150 const auto v = (this->point(0) - this->point(1)).unit();
151 return (s == 0) ? v : -v;
152}
153
154
156{
157 return this->compute_key(this->node_id(0),
158 this->node_id(1));
159}
160
161
162void Edge2::flip(BoundaryInfo * boundary_info)
163{
164 libmesh_assert(boundary_info);
165
166 swap2nodes(0,1);
167 swap2neighbors(0,1);
168 swap2boundarysides(0,1,boundary_info);
169}
170
171
172} // namespace libMesh
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
virtual void connectivity(const unsigned int sc, const IOPackage iop, std::vector< dof_id_type > &conn) const override
Definition edge_edge2.C:100
virtual Point true_centroid() const override
An optimized method for computing the centroid of a 2-node edge.
Definition edge_edge2.C:133
virtual bool has_invertible_map(Real tol) const override
Definition edge_edge2.C:93
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:202
virtual bool is_vertex(const unsigned int i) const override
Definition edge_edge2.C:54
virtual bool is_face(const unsigned int i) const override
Definition edge_edge2.C:65
static const int num_nodes
Geometric constants for Edge2.
Definition edge_edge2.h:175
virtual Order default_order() const override
Definition edge_edge2.C:86
virtual dof_id_type key() const override
Definition edge_edge2.C:155
virtual Point side_vertex_average_normal(const unsigned int s) const override final
Definition edge_edge2.C:147
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const override
Definition edge_edge2.C:77
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:162
virtual bool is_edge(const unsigned int i) const override
Definition edge_edge2.C:60
virtual Real volume() const override
An optimized method for computing the length of a 2-node edge.
Definition edge_edge2.C:138
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const override
Definition edge_edge2.C:70
virtual unsigned int n_sub_elem() const override
Definition edge_edge2.h:76
static const int num_children
Definition edge.h:66
const Point & point(const unsigned int i) const
Definition elem.h:2462
void swap2nodes(unsigned int n1, unsigned int n2)
Swaps two node_ptrs.
Definition elem.h:2101
void swap2neighbors(unsigned int n1, unsigned int n2)
Swaps two neighbor_ptrs.
Definition elem.h:2111
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:3579
static dof_id_type compute_key(dof_id_type n0)
Definition elem.h:3311
dof_id_type node_id(const unsigned int i) const
Definition elem.h:2484
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
auto norm() const
The libMesh namespace provides an interface to certain functionality in the library.
IOPackage
libMesh interfaces with several different software packages for the purposes of creating,...
libmesh_assert(ctx)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real