MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2006 Sandia National Laboratories. Developed at the 00005 University of Wisconsin--Madison under SNL contract number 00006 624796. The U.S. Government and the University of Wisconsin 00007 retain certain rights to 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 /** \file IdealElements.cpp 00028 * \brief 00029 * \author Jason Kraftcheck 00030 */ 00031 00032 #include "Mesquite.hpp" 00033 #include "IdealElements.hpp" 00034 #include "Vector3D.hpp" 00035 00036 namespace MBMesquite 00037 { 00038 00039 static Vector3D unit_quad[4] = { Vector3D( -0.5, -0.5, 0.0 ), Vector3D( 0.5, -0.5, 0.0 ), Vector3D( 0.5, 0.5, 0.0 ), 00040 Vector3D( -0.5, 0.5, 0.0 ) }; 00041 00042 static Vector3D unit_hex[8] = { Vector3D( 0.5, -0.5, -0.5 ), Vector3D( 0.5, 0.5, -0.5 ), Vector3D( -0.5, 0.5, -0.5 ), 00043 Vector3D( -0.5, -0.5, -0.5 ), Vector3D( 0.5, -0.5, 0.5 ), Vector3D( 0.5, 0.5, 0.5 ), 00044 Vector3D( -0.5, 0.5, 0.5 ), Vector3D( -0.5, -0.5, 0.5 ) }; 00045 00046 static Vector3D unit_edge_tri[3]; 00047 static Vector3D unit_edge_tet[4]; 00048 static Vector3D unit_edge_pyr[5]; 00049 static Vector3D unit_edge_wdg[6]; 00050 static Vector3D unit_height_pyr[5]; 00051 00052 static Vector3D unit_tri[3]; 00053 static Vector3D unit_tet[4]; 00054 static Vector3D unit_pyr[5]; 00055 static Vector3D unit_wdg[6]; 00056 static Vector3D unit_hex_pyr[5]; 00057 00058 static void init_tri( Vector3D* coords, double side ); 00059 static void init_tet( Vector3D* coords, double side ); 00060 static void init_pyr( Vector3D* coords, double side ); 00061 static void init_wdg( Vector3D* coords, double side ); 00062 static void init_hex_pyr( Vector3D* coords, double height ); 00063 00064 static const Vector3D* const* init_unit_edge( Vector3D** ); 00065 static const Vector3D* const* init_unit_elem( Vector3D** ); 00066 00067 const Vector3D* unit_edge_element( EntityTopology ptype, bool punit_pyr ) 00068 { 00069 static Vector3D* values[MIXED + 1]; 00070 static const Vector3D* const* data = init_unit_edge( values ); 00071 return ( ptype == PYRAMID && punit_pyr ) ? data[MIXED] : data[ptype]; 00072 } 00073 00074 const Vector3D* unit_element( EntityTopology ptype, bool punit_pyr ) 00075 { 00076 static Vector3D* values[MIXED + 1]; 00077 static const Vector3D* const* data = init_unit_elem( values ); 00078 return ( ptype == PYRAMID && punit_pyr ) ? data[MIXED] : data[ptype]; 00079 } 00080 00081 static const Vector3D* const* init_unit_edge( Vector3D** ptr ) 00082 { 00083 for( unsigned i = 0; i < MIXED; ++i ) 00084 ptr[i] = 0; 00085 00086 init_tri( unit_edge_tri, 1.0 ); 00087 init_tet( unit_edge_tet, 1.0 ); 00088 init_pyr( unit_edge_pyr, 1.0 ); 00089 init_wdg( unit_edge_wdg, 1.0 ); 00090 init_hex_pyr( unit_height_pyr, 1.0 ); 00091 00092 ptr[TRIANGLE] = unit_edge_tri; 00093 ptr[QUADRILATERAL] = unit_quad; 00094 ptr[TETRAHEDRON] = unit_edge_tet; 00095 ptr[PYRAMID] = unit_edge_pyr; 00096 ptr[PRISM] = unit_edge_wdg; 00097 ptr[HEXAHEDRON] = unit_hex; 00098 ptr[MIXED] = unit_height_pyr; 00099 return ptr; 00100 } 00101 00102 static const Vector3D* const* init_unit_elem( Vector3D** ptr ) 00103 { 00104 for( unsigned i = 0; i < MIXED; ++i ) 00105 ptr[i] = 0; 00106 00107 init_tri( unit_tri, 2.0 * pow( 3.0, -0.25 ) ); 00108 init_tet( unit_tet, MBMesquite::cbrt( 3.0 ) * sqrt( 2.0 ) ); 00109 init_pyr( unit_pyr, pow( 18.0, 1.0 / 6.0 ) ); 00110 init_wdg( unit_wdg, MBMesquite::cbrt( 4.0 ) * pow( 3.0, -1.0 / 6.0 ) ); 00111 init_hex_pyr( unit_hex_pyr, MBMesquite::cbrt( 3.0 ) ); 00112 00113 ptr[TRIANGLE] = unit_tri; 00114 ptr[QUADRILATERAL] = unit_quad; 00115 ptr[TETRAHEDRON] = unit_tet; 00116 ptr[PYRAMID] = unit_pyr; 00117 ptr[PRISM] = unit_wdg; 00118 ptr[HEXAHEDRON] = unit_hex; 00119 ptr[MIXED] = unit_hex_pyr; 00120 return ptr; 00121 } 00122 00123 static void init_tri( Vector3D* coords, double side ) 00124 { 00125 const double third_height = side * sqrt( 3.0 ) / 6.0; 00126 coords[1] = Vector3D( -0.5 * side, -third_height, 0.0 ); 00127 coords[2] = Vector3D( 0.5 * side, -third_height, 0.0 ); 00128 coords[0] = Vector3D( 0.0, 2 * third_height, 0.0 ); 00129 } 00130 00131 static void init_tet( Vector3D* coords, double side ) 00132 { 00133 const double height = side * sqrt( 2.0 / 3.0 ); 00134 const double third_base = side * sqrt( 3.0 ) / 6.0; 00135 coords[0] = Vector3D( -0.5 * side, -third_base, -0.25 * height ); 00136 coords[1] = Vector3D( 0.5 * side, -third_base, -0.25 * height ); 00137 coords[2] = Vector3D( 0.0, 2 * third_base, -0.25 * height ); 00138 coords[3] = Vector3D( 0.0, 0.0, 0.75 * height ); 00139 } 00140 00141 static void init_pyr( Vector3D* coords, double side ) 00142 { 00143 const double height = side * sqrt( 2.0 ) * 0.5; 00144 coords[0] = Vector3D( 0.5 * side, -0.5 * side, -0.25 * height ); 00145 coords[1] = Vector3D( 0.5 * side, 0.5 * side, -0.25 * height ); 00146 coords[2] = Vector3D( -0.5 * side, 0.5 * side, -0.25 * height ); 00147 coords[3] = Vector3D( -0.5 * side, -0.5 * side, -0.25 * height ); 00148 coords[4] = Vector3D( 0.0, 0.0, 0.75 * height ); 00149 } 00150 00151 static void init_wdg( Vector3D* coords, double side ) 00152 { 00153 const double third_height = side * sqrt( 3.0 ) / 6.0; 00154 coords[0] = Vector3D( -0.5 * side, -third_height, -0.5 * side ); 00155 coords[1] = Vector3D( 0.5 * side, -third_height, -0.5 * side ); 00156 coords[2] = Vector3D( 0.0, 2 * third_height, -0.5 * side ); 00157 coords[3] = Vector3D( -0.5 * side, -third_height, 0.5 * side ); 00158 coords[4] = Vector3D( 0.5 * side, -third_height, 0.5 * side ); 00159 coords[5] = Vector3D( 0.0, 2 * third_height, 0.5 * side ); 00160 } 00161 00162 static void init_hex_pyr( Vector3D* coords, double side ) 00163 { 00164 coords[0] = Vector3D( 0.5 * side, -0.5 * side, -0.25 * side ); 00165 coords[1] = Vector3D( 0.5 * side, 0.5 * side, -0.25 * side ); 00166 coords[2] = Vector3D( -0.5 * side, 0.5 * side, -0.25 * side ); 00167 coords[3] = Vector3D( -0.5 * side, -0.5 * side, -0.25 * side ); 00168 coords[4] = Vector3D( 0.0, 0.0, 0.75 * side ); 00169 } 00170 00171 } // namespace MBMesquite