$extrastylesheet
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/quadrature_grid.h" 00022 00023 namespace libMesh 00024 { 00025 00026 00027 void QGrid::init_3D(const ElemType type_in, 00028 unsigned int) 00029 { 00030 #if LIBMESH_DIM == 3 00031 00032 //----------------------------------------------------------------------- 00033 // 3D quadrature rules 00034 00035 // We ignore p - the grid rule is just for experimentation 00036 switch (type_in) 00037 { 00038 //--------------------------------------------- 00039 // Hex quadrature rules 00040 case HEX8: 00041 case HEX20: 00042 case HEX27: 00043 { 00044 // We compute the 3D quadrature rule as a tensor 00045 // product of the 1D quadrature rule. 00046 QGrid q1D(1,_order); 00047 q1D.init(EDGE2); 00048 00049 tensor_product_hex( q1D ); 00050 00051 return; 00052 } 00053 00054 00055 00056 //--------------------------------------------- 00057 // Tetrahedral quadrature rules 00058 case TET4: 00059 case TET10: 00060 { 00061 const unsigned int np = (_order+1)*(_order+2)*(_order+3)/6; 00062 // Master tet has 1x1 triangle base, height 1, so volume = 1/6 00063 const Real weight = Real(1)/Real(6)/np; 00064 const Real dx = 1.0/(_order+1); 00065 _points.resize(np); 00066 _weights.resize(np); 00067 00068 unsigned int pt = 0; 00069 for (int i = 0; i != _order + 1; ++i) 00070 { 00071 for (int j = 0; j != _order + 1 - i; ++j) 00072 { 00073 for (int k = 0; k != _order + 1 - i - j; ++k) 00074 { 00075 _points[pt](0) = (i+0.5)*dx; 00076 _points[pt](1) = (j+0.5)*dx; 00077 _points[pt](2) = (k+0.5)*dx; 00078 _weights[pt] = weight; 00079 pt++; 00080 } 00081 } 00082 } 00083 return; 00084 } 00085 00086 00087 // Prism quadrature rules 00088 case PRISM6: 00089 case PRISM15: 00090 case PRISM18: 00091 { 00092 // We compute the 3D quadrature rule as a tensor 00093 // product of the 1D quadrature rule and a 2D 00094 // triangle quadrature rule 00095 00096 QGrid q1D(1,_order); 00097 QGrid q2D(2,_order); 00098 00099 // Initialize 00100 q1D.init(EDGE2); 00101 q2D.init(TRI3); 00102 00103 tensor_product_prism(q1D, q2D); 00104 00105 return; 00106 } 00107 00108 00109 00110 //--------------------------------------------- 00111 // Pyramid 00112 case PYRAMID5: 00113 case PYRAMID13: 00114 case PYRAMID14: 00115 { 00116 const unsigned int np = (_order+1)*(_order+2)*(_order+3)/6; 00117 _points.resize(np); 00118 _weights.resize(np); 00119 // Master pyramid has 2x2 base, height 1, so volume = 4/3 00120 const Real weight = Real(4)/Real(3)/np; 00121 const Real dx = 2.0/(_order+1); 00122 const Real dz = 1.0/(_order+1); 00123 00124 unsigned int pt = 0; 00125 for (int k = 0; k != _order + 1; ++k) 00126 { 00127 for (int i = 0; i != _order + 1 - k; ++i) 00128 { 00129 for (int j = 0; j != _order + 1 - k; ++j) 00130 { 00131 _points[pt](0) = (i+0.5)*dx-1.0 + 00132 (k+0.5)*dz; 00133 _points[pt](1) = (j+0.5)*dx-1.0 + 00134 (k+0.5)*dz; 00135 _points[pt](2) = (k+0.5)*dz; 00136 _weights[pt] = weight; 00137 pt++; 00138 } 00139 } 00140 } 00141 return; 00142 } 00143 00144 00145 00146 //--------------------------------------------- 00147 // Unsupported type 00148 default: 00149 libmesh_error_msg("ERROR: Unsupported type: " << type_in); 00150 } 00151 #endif 00152 } 00153 00154 } // namespace libMesh