$extrastylesheet
edge_edge3.C
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 // Local includes
00021 #include "libmesh/edge_edge3.h"
00022 
00023 namespace libMesh
00024 {
00025 
00026 #ifdef LIBMESH_ENABLE_AMR
00027 
00028 const float Edge3::_embedding_matrix[2][3][3] =
00029   {
00030     // embedding matrix for child 0
00031     {
00032       // 0    1    2
00033       {1.0, 0.0, 0.0}, // left
00034       {0.0, 0.0, 1.0}, // right
00035       {0.375,-0.125,0.75} // middle
00036     },
00037 
00038     // embedding matrix for child 1
00039     {
00040       // 0    1    2
00041       {0.0, 0.0, 1.0}, // left
00042       {0.0, 1.0, 0.0},  // right
00043       {-0.125,0.375,0.75} // middle
00044     }
00045   };
00046 
00047 #endif
00048 
00049 bool Edge3::is_vertex(const unsigned int i) const
00050 {
00051   if (i < 2)
00052     return true;
00053   return false;
00054 }
00055 
00056 bool Edge3::is_edge(const unsigned int i) const
00057 {
00058   if (i < 2)
00059     return false;
00060   return true;
00061 }
00062 
00063 bool Edge3::is_face(const unsigned int ) const
00064 {
00065   return false;
00066 }
00067 
00068 bool Edge3::is_node_on_side(const unsigned int n,
00069                             const unsigned int s) const
00070 {
00071   libmesh_assert_less (s, 2);
00072   libmesh_assert_less (n, 3);
00073   return (s == n);
00074 }
00075 
00076 bool Edge3::is_node_on_edge(const unsigned int,
00077                             const unsigned int libmesh_dbg_var(e)) const
00078 {
00079   libmesh_assert_equal_to (e, 0);
00080   return true;
00081 }
00082 
00083 
00084 
00085 bool Edge3::has_affine_map() const
00086 {
00087   return (this->point(2).relative_fuzzy_equals
00088           ((this->point(0) + this->point(1))/2));
00089 }
00090 
00091 
00092 
00093 void Edge3::connectivity(const unsigned int sc,
00094                          const IOPackage iop,
00095                          std::vector<dof_id_type>& conn) const
00096 {
00097   libmesh_assert_less_equal (sc, 1);
00098   libmesh_assert_less (sc, this->n_sub_elem());
00099   libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
00100 
00101   // Create storage
00102   conn.resize(2);
00103 
00104   switch (iop)
00105     {
00106     case TECPLOT:
00107       {
00108         switch (sc)
00109           {
00110           case 0:
00111             conn[0] = this->node(0)+1;
00112             conn[1] = this->node(2)+1;
00113             return;
00114 
00115           case 1:
00116             conn[0] = this->node(2)+1;
00117             conn[1] = this->node(1)+1;
00118             return;
00119 
00120           default:
00121             libmesh_error_msg("Invalid sc = " << sc);
00122           }
00123       }
00124 
00125 
00126     case VTK:
00127       {
00128         conn.resize(3);
00129         conn[0] = this->node(0);
00130         conn[1] = this->node(1);
00131         conn[2] = this->node(2);
00132         return;
00133 
00134         /*
00135           switch (sc)
00136           {
00137           case 0:
00138           conn[0] = this->node(0);
00139           conn[1] = this->node(2);
00140 
00141           return;
00142 
00143           case 1:
00144           conn[0] = this->node(2);
00145           conn[1] = this->node(1);
00146 
00147           return;
00148 
00149           default:
00150           libmesh_error_msg("Invalid sc = " << sc);
00151           }
00152         */
00153       }
00154 
00155     default:
00156       libmesh_error_msg("Unsupported IO package " << iop);
00157     }
00158 }
00159 
00160 
00161 
00162 std::pair<unsigned short int, unsigned short int>
00163 Edge3::second_order_child_vertex (const unsigned int) const
00164 {
00165   return std::pair<unsigned short int, unsigned short int>(0,0);
00166 }
00167 
00168 
00169 
00170 Real Edge3::volume () const
00171 {
00172   // Finding the (exact) length of a general quadratic element
00173   // is a surprisingly complicated formula.
00174   Point A = this->point(0) + this->point(1) - 2*this->point(2);
00175   Point B = (this->point(1) - this->point(0))/2;
00176 
00177   const Real a = A.size_sq();
00178   const Real b = 2.*(A*B);
00179   const Real c = B.size_sq();
00180 
00181   // Degenerate straight line case
00182   if (a < TOLERANCE*TOLERANCE*TOLERANCE)
00183     return (this->point(1) - this->point(0)).size();
00184 
00185   const Real ba=b/a;
00186   const Real ca=c/a;
00187 
00188   libmesh_assert (1.-ba+ca>0.);
00189 
00190   const Real s1 = std::sqrt(1. - ba + ca);
00191   const Real s2 = std::sqrt(1. + ba + ca);
00192 
00193   return 0.5*std::sqrt(a)*((1.-0.5*ba)*s1 +
00194                            (1.+0.5*ba)*s2 +
00195                            (ca - 0.25*ba*ba)*std::log( (1.-0.5*ba+s1)/(-1.-0.5*ba+s2) )
00196                            );
00197 }
00198 
00199 } // namespace libMesh