MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2006 Lawrence Livermore National Laboratory. Under 00005 the terms of Contract B545069 with the University of Wisconsin -- 00006 Madison, Lawrence Livermore National Laboratory retains certain 00007 rights in this software. 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 (lgpl.txt) along with this library; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 (2006) [email protected] 00024 00025 ***************************************************************** */ 00026 00027 #include "Mesquite.hpp" 00028 #include "MsqError.hpp" 00029 #include "LinearTetrahedron.hpp" 00030 00031 namespace MBMesquite 00032 { 00033 00034 static const char* nonlinear_error = "Attempt to use LinearTetrahedron mapping function for a nonlinear element\n"; 00035 00036 EntityTopology LinearTetrahedron::element_topology() const 00037 { 00038 return TETRAHEDRON; 00039 } 00040 00041 int LinearTetrahedron::num_nodes() const 00042 { 00043 return 4; 00044 } 00045 00046 NodeSet LinearTetrahedron::sample_points( NodeSet ) const 00047 { 00048 NodeSet result; 00049 result.set_mid_region_node(); 00050 return result; 00051 } 00052 00053 static const unsigned faces[][3] = { { 1, 0, 3 }, { 3, 2, 1 }, { 0, 2, 3 }, { 0, 1, 2 } }; 00054 00055 void LinearTetrahedron::coefficients( Sample location, 00056 NodeSet nodeset, 00057 double* coeff_out, 00058 size_t* indices_out, 00059 size_t& num_coeff, 00060 MsqError& err ) const 00061 { 00062 if( nodeset.have_any_mid_node() ) 00063 { 00064 MSQ_SETERR( err )( nonlinear_error, MsqError::UNSUPPORTED_ELEMENT ); 00065 return; 00066 } 00067 00068 switch( location.dimension ) 00069 { 00070 case 0: 00071 num_coeff = 1; 00072 indices_out[0] = location.number; 00073 coeff_out[0] = 1.0; 00074 break; 00075 case 1: 00076 num_coeff = 2; 00077 coeff_out[0] = 0.5; 00078 coeff_out[1] = 0.5; 00079 if( location.number < 3 ) 00080 { 00081 indices_out[0] = location.number; 00082 indices_out[1] = ( location.number + 1 ) % 3; 00083 } 00084 else 00085 { 00086 indices_out[0] = location.number - 3; 00087 indices_out[1] = 3; 00088 } 00089 break; 00090 case 2: 00091 num_coeff = 3; 00092 indices_out[0] = faces[location.number][0]; 00093 indices_out[1] = faces[location.number][1]; 00094 indices_out[2] = faces[location.number][2]; 00095 coeff_out[0] = coeff_out[1] = coeff_out[2] = coeff_out[3] = MSQ_ONE_THIRD; 00096 break; 00097 case 3: 00098 num_coeff = 4; 00099 indices_out[0] = 0; 00100 indices_out[1] = 1; 00101 indices_out[2] = 2; 00102 indices_out[3] = 3; 00103 coeff_out[0] = coeff_out[1] = coeff_out[2] = coeff_out[3] = 0.25; 00104 break; 00105 default: 00106 MSQ_SETERR( err )( "Invalid/unsupported logical dimension", MsqError::INVALID_ARG ); 00107 } 00108 } 00109 00110 void LinearTetrahedron::derivatives( Sample, 00111 NodeSet nodeset, 00112 size_t* vertices, 00113 MsqVector< 3 >* coeff_derivs, 00114 size_t& num_vtx, 00115 MsqError& err ) const 00116 { 00117 if( nodeset.have_any_mid_node() ) 00118 { 00119 MSQ_SETERR( err )( nonlinear_error, MsqError::UNSUPPORTED_ELEMENT ); 00120 return; 00121 } 00122 else 00123 { 00124 num_vtx = 4; 00125 vertices[0] = 0; 00126 vertices[1] = 1; 00127 vertices[2] = 2; 00128 vertices[3] = 3; 00129 00130 coeff_derivs[0][0] = -1.0; 00131 coeff_derivs[0][1] = -1.0; 00132 coeff_derivs[0][2] = -1.0; 00133 00134 coeff_derivs[1][0] = 1.0; 00135 coeff_derivs[1][1] = 0.0; 00136 coeff_derivs[1][2] = 0.0; 00137 00138 coeff_derivs[2][0] = 0.0; 00139 coeff_derivs[2][1] = 1.0; 00140 coeff_derivs[2][2] = 0.0; 00141 00142 coeff_derivs[3][0] = 0.0; 00143 coeff_derivs[3][1] = 0.0; 00144 coeff_derivs[3][2] = 1.0; 00145 } 00146 } 00147 00148 void LinearTetrahedron::ideal( Sample, MsqMatrix< 3, 3 >& J, MsqError& ) const 00149 { 00150 const double a = 1.122462048309373; // 6th root of 2 00151 const double b = 1.7320508075688772; // sqrt(3) 00152 const double c = 1.5874010519681994; // 2 to the 2/3 00153 J( 0, 0 ) = a; 00154 J( 0, 1 ) = 0.5 * a; 00155 J( 0, 2 ) = 0.5 * a; 00156 J( 1, 0 ) = 0.0; 00157 J( 1, 1 ) = 0.5 * a * b; 00158 J( 1, 2 ) = 0.5 * a / b; 00159 J( 2, 0 ) = 0.0; 00160 J( 2, 1 ) = 0.0; 00161 J( 2, 2 ) = c / b; 00162 } 00163 00164 } // namespace MBMesquite