edge_edge3.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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_edge3.h"
22 
23 namespace libMesh
24 {
25 
26 #ifdef LIBMESH_ENABLE_AMR
27 
28 const float Edge3::_embedding_matrix[2][3][3] =
29 {
30  // embedding matrix for child 0
31  {
32  // 0 1 2
33  {1.0, 0.0, 0.0}, // left
34  {0.0, 0.0, 1.0}, // right
35  {0.375,-0.125,0.75} // middle
36  },
37 
38  // embedding matrix for child 1
39  {
40  // 0 1 2
41  {0.0, 0.0, 1.0}, // left
42  {0.0, 1.0, 0.0}, // right
43  {-0.125,0.375,0.75} // middle
44  }
45 };
46 
47 #endif
48 
49 bool Edge3::is_vertex(const unsigned int i) const
50 {
51  if (i < 2)
52  return true;
53  return false;
54 }
55 
56 bool Edge3::is_edge(const unsigned int i) const
57 {
58  if (i < 2)
59  return false;
60  return true;
61 }
62 
63 bool Edge3::is_face(const unsigned int ) const
64 {
65  return false;
66 }
67 
68 bool Edge3::is_node_on_side(const unsigned int n,
69  const unsigned int s) const
70 {
71  libmesh_assert_less (s, 2);
72  libmesh_assert_less (n, 3);
73  return (s == n);
74 }
75 
76 bool Edge3::is_node_on_edge(const unsigned int,
77  const unsigned int libmesh_dbg_var(e)) const
78 {
79  libmesh_assert_equal_to (e, 0);
80  return true;
81 }
82 
83 
84 
86 {
87  return (this->point(2).relative_fuzzy_equals
88  ((this->point(0) + this->point(1))/2));
89 }
90 
91 
92 
93 void Edge3::connectivity(const unsigned int sc,
94  const IOPackage iop,
95  std::vector<dof_id_type>& conn) const
96 {
97  libmesh_assert_less_equal (sc, 1);
98  libmesh_assert_less (sc, this->n_sub_elem());
99  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
100 
101  // Create storage
102  conn.resize(2);
103 
104  switch (iop)
105  {
106  case TECPLOT:
107  {
108  switch (sc)
109  {
110  case 0:
111  conn[0] = this->node(0)+1;
112  conn[1] = this->node(2)+1;
113  return;
114 
115  case 1:
116  conn[0] = this->node(2)+1;
117  conn[1] = this->node(1)+1;
118  return;
119 
120  default:
121  libmesh_error();
122  }
123  }
124 
125 
126  case VTK:
127  {
128  conn.resize(3);
129  conn[0] = this->node(0);
130  conn[1] = this->node(1);
131  conn[2] = this->node(2);
132  return;
133 
134  /*
135  switch (sc)
136  {
137  case 0:
138  conn[0] = this->node(0);
139  conn[1] = this->node(2);
140 
141  return;
142 
143  case 1:
144  conn[0] = this->node(2);
145  conn[1] = this->node(1);
146 
147  return;
148 
149  default:
150  libmesh_error();
151  }
152  */
153  }
154 
155  default:
156  {
157  libmesh_error();
158  }
159  }
160 }
161 
162 
163 
164 std::pair<unsigned short int, unsigned short int>
165 Edge3::second_order_child_vertex (const unsigned int) const
166 {
167  return std::pair<unsigned short int, unsigned short int>(0,0);
168 }
169 
170 
171 
173 {
174  // Finding the (exact) length of a general quadratic element
175  // is a surprisingly complicated formula.
176  Point A = this->point(0) + this->point(1) - 2*this->point(2);
177  Point B = (this->point(1) - this->point(0))/2;
178 
179  const Real a = A.size_sq();
180  const Real b = 2.*(A*B);
181  const Real c = B.size_sq();
182 
183  // Degenerate straight line case
184  if (a < TOLERANCE*TOLERANCE*TOLERANCE)
185  return (this->point(1) - this->point(0)).size();
186 
187  const Real ba=b/a;
188  const Real ca=c/a;
189 
190  libmesh_assert (1.-ba+ca>0.);
191 
192  const Real s1 = std::sqrt(1. - ba + ca);
193  const Real s2 = std::sqrt(1. + ba + ca);
194 
195  return 0.5*std::sqrt(a)*((1.-0.5*ba)*s1 +
196  (1.+0.5*ba)*s2 +
197  (ca - 0.25*ba*ba)*std::log( (1.-0.5*ba+s1)/(-1.-0.5*ba+s2) )
198  );
199 }
200 
201 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo