fe_szabab_shape_1D.C
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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 // C++ includes 00021 00022 // Local includes 00023 #include "libmesh/libmesh_config.h" 00024 00025 #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES 00026 00027 #include "libmesh/fe.h" 00028 #include "libmesh/elem.h" 00029 00030 namespace libMesh 00031 { 00032 00033 00034 template <> 00035 Real FE<1,SZABAB>::shape(const ElemType, 00036 const Order libmesh_dbg_var(order), 00037 const unsigned int i, 00038 const Point& p) 00039 { 00040 const Real xi = p(0); 00041 const Real xi2 = xi*xi; 00042 00043 00044 // Use this libmesh_assert rather than a switch with a single entry... 00045 // It will go away in optimized mode, essentially has the same effect. 00046 libmesh_assert_less_equal (order, SEVENTH); 00047 00048 // switch (order) 00049 // { 00050 // case FIRST: 00051 // case SECOND: 00052 // case THIRD: 00053 // case FOURTH: 00054 // case FIFTH: 00055 // case SIXTH: 00056 // case SEVENTH: 00057 00058 switch(i) 00059 { 00060 //nodal shape functions 00061 case 0: return 1./2.-1./2.*xi; 00062 case 1: return 1./2.+1./2.*xi; 00063 case 2: return 1./4. *2.4494897427831780982*(xi2-1.); 00064 case 3: return 1./4. *3.1622776601683793320*(xi2-1.)*xi; 00065 case 4: return 1./16. *3.7416573867739413856*((5.*xi2-6.)*xi2+1.); 00066 case 5: return 3./16. *1.4142135623730950488*(3.+(-10.+7.*xi2)*xi2)*xi; 00067 case 6: return 1./32. *4.6904157598234295546*(-1.+(15.+(-35.+21.*xi2)*xi2)*xi2); 00068 case 7: return 1./32. *5.0990195135927848300*(-5.+(35.+(-63.+33.*xi2)*xi2)*xi2)*xi; 00069 case 8: return 1./256.*5.4772255750516611346*(5.+(-140.+(630.+(-924.+429.*xi2)*xi2)*xi2)*xi2); 00070 00071 default: 00072 libMesh::err << "Invalid shape function index!" << std::endl; 00073 libmesh_error(); 00074 } 00075 00076 // default: 00077 // { 00078 // libMesh::err << "ERROR: Unsupported polynomial order!" << std::endl; 00079 // libmesh_error(); 00080 // } 00081 // } 00082 00083 libmesh_error(); 00084 return 0.; 00085 } 00086 00087 00088 00089 template <> 00090 Real FE<1,SZABAB>::shape(const Elem* elem, 00091 const Order order, 00092 const unsigned int i, 00093 const Point& p) 00094 { 00095 libmesh_assert(elem); 00096 00097 return FE<1,SZABAB>::shape(elem->type(), static_cast<Order>(order + elem->p_level()), i, p); 00098 } 00099 00100 00101 00102 template <> 00103 Real FE<1,SZABAB>::shape_deriv(const ElemType, 00104 const Order libmesh_dbg_var(order), 00105 const unsigned int i, 00106 const unsigned int libmesh_dbg_var(j), 00107 const Point& p) 00108 { 00109 // only d()/dxi in 1D! 00110 libmesh_assert_equal_to (j, 0); 00111 00112 const Real xi = p(0); 00113 const Real xi2 = xi*xi; 00114 00115 // Use this libmesh_assert rather than a switch with a single entry... 00116 // It will go away in optimized mode, essentially has the same effect. 00117 libmesh_assert_less_equal (order, SEVENTH); 00118 00119 // switch (order) 00120 // { 00121 // case FIRST: 00122 // case SECOND: 00123 // case THIRD: 00124 // case FOURTH: 00125 // case FIFTH: 00126 // case SIXTH: 00127 // case SEVENTH: 00128 00129 switch(i) 00130 { 00131 case 0: return -1./2.; 00132 case 1: return 1./2.; 00133 case 2: return 1./2.*2.4494897427831780982*xi; 00134 case 3: return -1./4.*3.1622776601683793320+3./4.*3.1622776601683793320*xi2; 00135 case 4: return 1./16.*3.7416573867739413856*(-12.+20*xi2)*xi; 00136 case 5: return 9./16.*1.4142135623730950488+(-45./8.*1.4142135623730950488+105./16.*1.4142135623730950488*xi2)*xi2; 00137 case 6: return 1./32.*4.6904157598234295546*(30.+(-140.+126.*xi2)*xi2)*xi; 00138 case 7: return -5./32.*5.0990195135927848300+(105./32.*5.0990195135927848300+(-315./32.*5.0990195135927848300+231./32.*5.0990195135927848300*xi2)*xi2)*xi2; 00139 case 8: return 1./256.*5.4772255750516611346*(-280.+(2520.+(-5544.+3432.*xi2)*xi2)*xi2)*xi; 00140 00141 default: 00142 libMesh::err << "Invalid shape function index!" << std::endl; 00143 libmesh_error(); 00144 } 00145 00146 // default: 00147 // { 00148 // libMesh::err << "ERROR: Unsupported polynomial order!" << std::endl; 00149 // libmesh_error(); 00150 // } 00151 // } 00152 00153 libmesh_error(); 00154 return 0.; 00155 } 00156 00157 00158 00159 template <> 00160 Real FE<1,SZABAB>::shape_deriv(const Elem* elem, 00161 const Order order, 00162 const unsigned int i, 00163 const unsigned int j, 00164 const Point& p) 00165 { 00166 libmesh_assert(elem); 00167 00168 return FE<1,SZABAB>::shape_deriv(elem->type(), 00169 static_cast<Order>(order + elem->p_level()), i, j, p); 00170 } 00171 00172 00173 00174 template <> 00175 Real FE<1,SZABAB>::shape_second_deriv(const ElemType, 00176 const Order, 00177 const unsigned int, 00178 const unsigned int, 00179 const Point&) 00180 { 00181 static bool warning_given = false; 00182 00183 if (!warning_given) 00184 libMesh::err << "Second derivatives for Szabab elements " 00185 << " are not yet implemented!" 00186 << std::endl; 00187 00188 warning_given = true; 00189 return 0.; 00190 } 00191 00192 00193 00194 template <> 00195 Real FE<1,SZABAB>::shape_second_deriv(const Elem*, 00196 const Order, 00197 const unsigned int, 00198 const unsigned int, 00199 const Point&) 00200 { 00201 static bool warning_given = false; 00202 00203 if (!warning_given) 00204 libMesh::err << "Second derivatives for Szabab elements " 00205 << " are not yet implemented!" 00206 << std::endl; 00207 00208 warning_given = true; 00209 return 0.; 00210 } 00211 00212 } // namespace libMesh 00213 00214 00215 #endif //LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:46 UTC
Hosted By: