quadrature_grid_3D.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 // 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 _points.resize((_order+1)*(_order+2)*(_order+3)/6); 00062 _weights.resize((_order+1)*(_order+2)*(_order+3)/6); 00063 00064 unsigned int pt = 0; 00065 for (int i = 0; i != _order + 1; ++i) 00066 { 00067 for (int j = 0; j != _order + 1 - i; ++j) 00068 { 00069 for (int k = 0; k != _order + 1 - i - j; ++k) 00070 { 00071 _points[pt](0) = (double)i / (double)_order; 00072 _points[pt](1) = (double)j / (double)_order; 00073 _points[pt](2) = (double)k / (double)_order; 00074 _weights[pt] = 1.0 / (double)(_order+1) / 00075 (double)(_order+2) / (double)(_order+3); 00076 pt++; 00077 } 00078 } 00079 } 00080 return; 00081 } 00082 00083 00084 // Prism quadrature rules 00085 case PRISM6: 00086 case PRISM15: 00087 case PRISM18: 00088 { 00089 // We compute the 3D quadrature rule as a tensor 00090 // product of the 1D quadrature rule and a 2D 00091 // triangle quadrature rule 00092 00093 QGrid q1D(1,_order); 00094 QGrid q2D(2,_order); 00095 00096 // Initialize 00097 q1D.init(EDGE2); 00098 q2D.init(TRI3); 00099 00100 tensor_product_prism(q1D, q2D); 00101 00102 return; 00103 } 00104 00105 00106 00107 //--------------------------------------------- 00108 // Pyramid 00109 case PYRAMID5: 00110 { 00111 _points.resize((_order+1)*(_order+2)*(_order+3)/6); 00112 _weights.resize((_order+1)*(_order+2)*(_order+3)/6); 00113 00114 unsigned int pt = 0; 00115 for (int k = 0; k != _order + 1; ++k) 00116 { 00117 for (int i = 0; i != _order + 1 - k; ++i) 00118 { 00119 for (int j = 0; j != _order + 1 - k; ++j) 00120 { 00121 _points[pt](0) = 2.0 * (double)i / (double)_order 00122 - 1.0 + (double)k / (double)_order; 00123 _points[pt](1) = 2.0 * (double)j / (double)_order 00124 - 1.0 + (double)k / (double)_order; 00125 _points[pt](2) = (double)k / (double)_order; 00126 _weights[pt] = 1.0 / (double)(_order+1) / 00127 (double)(_order+2) / (double)(_order+3); 00128 pt++; 00129 } 00130 } 00131 } 00132 return; 00133 } 00134 00135 00136 00137 //--------------------------------------------- 00138 // Unsupported type 00139 default: 00140 { 00141 libMesh::err << "ERROR: Unsupported type: " << type_in << std::endl; 00142 libmesh_error(); 00143 } 00144 } 00145 00146 libmesh_error(); 00147 00148 return; 00149 00150 #endif 00151 } 00152 00153 } // namespace libMesh
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: