MOAB: Mesh Oriented datABase
(version 5.2.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2004 Sandia Corporation and Argonne National 00005 Laboratory. Under the terms of Contract DE-AC04-94AL85000 00006 with Sandia Corporation, the U.S. Government 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 diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov, 00024 pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov, 00025 kraftche@cae.wisc.edu 00026 00027 ***************************************************************** */ 00028 // 00029 // SUMMARY: 00030 // USAGE: 00031 // 00032 // ORIG-DATE: 26-March-08 at 10:26:21 00033 // LAST-MOD: 15-Nov-04 by kraftche@cae.wisc.edu 00034 // 00035 /*! \file ParallelMeshImpl.cpp 00036 00037 \brief This files contains a parallel mesh implementation that can be used 00038 to run mesquite by default. 00039 00040 \author Jason Kraftcheck 00041 \author Martin Isenburg 00042 \date 2008-3-26 00043 */ 00044 00045 #include "ParallelMeshImpl.hpp" 00046 #include "MeshImplData.hpp" 00047 #include "MeshImplTags.hpp" 00048 #include "MsqError.hpp" 00049 #include "MsqDebug.hpp" 00050 00051 namespace MBMesquite 00052 { 00053 00054 ParallelMeshImpl::ParallelMeshImpl( Mesh* p_myMesh, const char* gid_name, const char* pid_name ) 00055 { 00056 MsqError err; 00057 00058 this->myMesh = p_myMesh; 00059 this->helper = 0; 00060 00061 if( gid_name ) 00062 gid_tag = myMesh->tag_get( gid_name, err ); 00063 else 00064 gid_tag = 0; 00065 00066 if( pid_name ) 00067 pid_tag = myMesh->tag_get( pid_name, err ); 00068 else 00069 pid_tag = 0; 00070 } 00071 00072 void ParallelMeshImpl::set_global_id_tag( const char* name, MsqError& err ) 00073 { 00074 gid_tag = myMesh->tag_get( name, err ); 00075 } 00076 00077 void ParallelMeshImpl::set_processor_id_tag( const char* name, MsqError& err ) 00078 { 00079 pid_tag = myMesh->tag_get( name, err ); 00080 } 00081 00082 //**************** Parallel Methods ****************************** 00083 00084 void ParallelMeshImpl::vertices_get_global_id( const VertexHandle vert_array[], size_t gid[], size_t num_vtx, 00085 MsqError& err ) 00086 { 00087 if( gid_tag ) 00088 { 00089 myMesh->tag_get_vertex_data( gid_tag, num_vtx, vert_array, gid, err );MSQ_CHKERR( err ); 00090 } 00091 else 00092 { 00093 MSQ_SETERR( err )( "Parallel mesh does not have Global IDs.", MsqError::INVALID_STATE ); 00094 } 00095 } 00096 00097 void ParallelMeshImpl::vertices_set_global_id( const VertexHandle vert_array[], size_t gid[], size_t num_vtx, 00098 MsqError& err ) 00099 { 00100 if( gid_tag == 0 ) 00101 { 00102 const char GLOBAL_ID_NAME[] = "GLOBAL_ID"; 00103 00104 int default_gid = -1; 00105 gid_tag = tag_create( GLOBAL_ID_NAME, HANDLE, 1, &default_gid, err ); 00106 // the 'HANDLE' is the type of data to store 00107 // the '1' is for one value per vertex 00108 // NULL for no default value, if you want them all 00109 // initialized to something, pass in a pointer to an int 00110 // with the value. 00111 MSQ_CHKERR( err ); 00112 } 00113 00114 tag_set_vertex_data( gid_tag, num_vtx, vert_array, gid, err );MSQ_CHKERR( err ); 00115 } 00116 00117 void ParallelMeshImpl::vertices_get_processor_id( const VertexHandle vert_array[], int pid[], size_t num_vtx, 00118 MsqError& err ) 00119 { 00120 if( pid_tag ) 00121 { 00122 tag_get_vertex_data( pid_tag, num_vtx, vert_array, pid, err );MSQ_CHKERR( err ); 00123 } 00124 else 00125 { 00126 MSQ_SETERR( err )( "Parallel mesh does not have Processor IDs.", MsqError::INVALID_STATE ); 00127 } 00128 } 00129 00130 void ParallelMeshImpl::vertices_set_processor_id( const VertexHandle vert_array[], int pid[], size_t num_vtx, 00131 MsqError& err ) 00132 { 00133 if( pid_tag == 0 ) 00134 { 00135 const char PROCESSOR_ID_NAME[] = "PROCESSOR_ID"; 00136 00137 int default_pid = -1; 00138 pid_tag = tag_create( PROCESSOR_ID_NAME, INT, 1, &default_pid, err ); 00139 // the 'INT' is the type of data to store 00140 // the '1' is for one value per vertex 00141 // NULL for no default value, if you want them all 00142 // initialized to something, pass in a pointer to an int 00143 // with the value. 00144 MSQ_CHKERR( err ); 00145 } 00146 00147 tag_set_vertex_data( pid_tag, num_vtx, vert_array, pid, err );MSQ_CHKERR( err ); 00148 } 00149 00150 int ParallelMeshImpl::get_geometric_dimension( MsqError& err ) 00151 { 00152 return myMesh->get_geometric_dimension( err ); 00153 } 00154 00155 void ParallelMeshImpl::get_all_elements( std::vector< ElementHandle >& elems, MsqError& err ) 00156 { 00157 myMesh->get_all_elements( elems, err ); 00158 } 00159 00160 void ParallelMeshImpl::get_all_vertices( std::vector< VertexHandle >& verts, MsqError& err ) 00161 { 00162 myMesh->get_all_vertices( verts, err ); 00163 } 00164 00165 void ParallelMeshImpl::vertices_get_fixed_flag( const VertexHandle vert_array[], std::vector< bool >& flag_array, 00166 size_t num_vtx, MsqError& err ) 00167 { 00168 myMesh->vertices_get_fixed_flag( vert_array, flag_array, num_vtx, err ); 00169 } 00170 00171 void ParallelMeshImpl::vertices_get_coordinates( const Mesh::VertexHandle vert_array[], MsqVertex* coordinates, 00172 size_t num_vtx, MsqError& err ) 00173 { 00174 myMesh->vertices_get_coordinates( vert_array, coordinates, num_vtx, err ); 00175 } 00176 00177 void ParallelMeshImpl::vertices_get_slaved_flag( const VertexHandle vert_array[], std::vector< bool >& flag_array, 00178 size_t num_vtx, MsqError& err ) 00179 { 00180 myMesh->vertices_get_slaved_flag( vert_array, flag_array, num_vtx, err ); 00181 } 00182 00183 void ParallelMeshImpl::vertex_set_coordinates( VertexHandle vertex, const Vector3D& coordinates, MsqError& err ) 00184 { 00185 myMesh->vertex_set_coordinates( vertex, coordinates, err ); 00186 } 00187 00188 void ParallelMeshImpl::vertex_set_byte( VertexHandle vertex, unsigned char byte, MsqError& err ) 00189 { 00190 myMesh->vertex_set_byte( vertex, byte, err ); 00191 } 00192 00193 void ParallelMeshImpl::vertices_set_byte( const VertexHandle* vert_array, const unsigned char* byte_array, 00194 size_t array_size, MsqError& err ) 00195 { 00196 myMesh->vertices_set_byte( vert_array, byte_array, array_size, err ); 00197 } 00198 00199 void ParallelMeshImpl::vertex_get_byte( const VertexHandle vertex, unsigned char* byte, MsqError& err ) 00200 { 00201 myMesh->vertex_get_byte( vertex, byte, err ); 00202 } 00203 00204 void ParallelMeshImpl::vertices_get_byte( const VertexHandle* vert_array, unsigned char* byte_array, size_t array_size, 00205 MsqError& err ) 00206 { 00207 myMesh->vertices_get_byte( vert_array, byte_array, array_size, err ); 00208 } 00209 00210 void ParallelMeshImpl::vertices_get_attached_elements( const VertexHandle* vertices, size_t num_vertices, 00211 std::vector< ElementHandle >& elements, 00212 std::vector< size_t >& offsets, MsqError& err ) 00213 { 00214 myMesh->vertices_get_attached_elements( vertices, num_vertices, elements, offsets, err ); 00215 } 00216 00217 void ParallelMeshImpl::elements_get_attached_vertices( const ElementHandle* elements, size_t num_elems, 00218 std::vector< VertexHandle >& vertices, 00219 std::vector< size_t >& offsets, MsqError& err ) 00220 { 00221 myMesh->elements_get_attached_vertices( elements, num_elems, vertices, offsets, err ); 00222 } 00223 00224 void ParallelMeshImpl::elements_get_topologies( const ElementHandle* element_handle_array, 00225 EntityTopology* element_topologies, size_t num_elements, MsqError& err ) 00226 { 00227 myMesh->elements_get_topologies( element_handle_array, element_topologies, num_elements, err ); 00228 } 00229 00230 TagHandle ParallelMeshImpl::tag_create( const std::string& name, TagType type, unsigned length, const void* defval, 00231 MsqError& err ) 00232 { 00233 return myMesh->tag_create( name, type, length, defval, err ); 00234 } 00235 00236 void ParallelMeshImpl::tag_delete( TagHandle handle, MsqError& err ) 00237 { 00238 myMesh->tag_delete( handle, err ); 00239 } 00240 00241 TagHandle ParallelMeshImpl::tag_get( const std::string& name, MsqError& err ) 00242 { 00243 return myMesh->tag_get( name, err ); 00244 } 00245 00246 void ParallelMeshImpl::tag_properties( TagHandle handle, std::string& name, TagType& type, unsigned& length, 00247 MsqError& err ) 00248 { 00249 myMesh->tag_properties( handle, name, type, length, err ); 00250 } 00251 00252 void ParallelMeshImpl::tag_set_element_data( TagHandle handle, size_t num_elems, const ElementHandle* elem_array, 00253 const void* values, MsqError& err ) 00254 { 00255 myMesh->tag_set_element_data( handle, num_elems, elem_array, values, err ); 00256 } 00257 00258 void ParallelMeshImpl::tag_get_element_data( TagHandle handle, size_t num_elems, const ElementHandle* elem_array, 00259 void* values, MsqError& err ) 00260 { 00261 myMesh->tag_get_element_data( handle, num_elems, elem_array, values, err ); 00262 } 00263 00264 void ParallelMeshImpl::tag_set_vertex_data( TagHandle handle, size_t num_verts, const VertexHandle* vert_array, 00265 const void* values, MsqError& err ) 00266 { 00267 myMesh->tag_set_vertex_data( handle, num_verts, vert_array, values, err ); 00268 } 00269 00270 void ParallelMeshImpl::tag_get_vertex_data( TagHandle handle, size_t num_verts, const VertexHandle* vert_array, 00271 void* values, MsqError& err ) 00272 { 00273 myMesh->tag_get_vertex_data( handle, num_verts, vert_array, values, err ); 00274 } 00275 00276 void ParallelMeshImpl::release_entity_handles( const EntityHandle* handle_array, size_t num_handles, MsqError& err ) 00277 00278 { 00279 myMesh->release_entity_handles( handle_array, num_handles, err ); 00280 } 00281 00282 void ParallelMeshImpl::release() 00283 { 00284 myMesh->release(); 00285 } 00286 00287 } // namespace MBMesquite