MOAB: Mesh Oriented datABase  (version 5.2.1)
MsqIMeshP.cpp
Go to the documentation of this file.
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     (c) 2009 isenburg@cs.unc.edu   kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 //
00027 //   SUMMARY:
00028 //     USAGE:
00029 //
00030 // ORIG-DATE: 26-March-08 at 10:26:21
00031 //  LAST-MOD: 15-Nov-04 by kraftche@cae.wisc.edu
00032 //
00033 /*! \file ParallelMeshImpl.cpp
00034 
00035 \brief This files contains a parallel mesh implementation that can be used
00036 to run mesquite by default.
00037 
00038     \author Jason Kraftcheck
00039     \author Martin Isenburg
00040     \date 2008-3-26
00041  */
00042 
00043 #include "MsqIMeshP.hpp"
00044 #include "MsqError.hpp"
00045 #include "MsqDebug.hpp"
00046 #include <cstdlib>
00047 
00048 namespace MBMesquite
00049 {
00050 
00051 MsqIMeshP::MsqIMeshP( iMesh_Instance mesh, iMeshP_PartitionHandle partition, iBase_EntitySetHandle meshset,
00052                       iBase_EntityType type, MsqError& err, const iBase_TagHandle* fixed_tag,
00053                       const iBase_TagHandle* slaved_tag )
00054     : MsqIMesh( mesh, meshset, type, err, fixed_tag, slaved_tag ), partitionInstance( partition )
00055 {
00056 }
00057 
00058 MsqIMeshP::MsqIMeshP( iMesh_Instance mesh, iMeshP_PartitionHandle partition, iBase_EntityType element_dimension,
00059                       MsqError& err, const iBase_TagHandle* fixed_tag, const iBase_TagHandle* slaved_tag )
00060     : MsqIMesh( mesh, element_dimension, err, fixed_tag, slaved_tag ), partitionInstance( partition )
00061 {
00062 }
00063 
00064 MsqIMeshP::~MsqIMeshP() {}
00065 
00066 //**************** Parallel Methods ******************************
00067 
00068 void MsqIMeshP::vertices_get_global_id( const VertexHandle vert_array[], size_t gid[], size_t num_vtx,
00069                                         MsqError& /*err*/ )
00070 {
00071     int itaps_err;
00072     // get a local part id
00073     iMeshP_PartHandle* parts = 0;
00074     int parts_allocated      = 0;
00075     int parts_size           = 0;
00076     iMeshP_getLocalParts( meshInstance, partitionInstance, &parts, &parts_allocated, &parts_size, &itaps_err );
00077     iMeshP_Part part_id;
00078     iMeshP_getPartIdFromPartHandle( meshInstance, partitionInstance, parts[0], &part_id, &itaps_err );
00079     if( parts_allocated ) free( parts );
00080     // get rank of local part
00081     int rank;
00082     iMeshP_getRankOfPart( meshInstance, partitionInstance, part_id, &rank, &itaps_err );
00083     // get global ids for all vertex handles
00084     for( unsigned i = 0; i < num_vtx; i++ )
00085     {
00086         iMeshP_getEntOwnerPart( meshInstance, partitionInstance, ( iBase_EntityHandle )( vert_array[i] ), &part_id,
00087                                 &itaps_err );
00088         int part_rank;
00089         iMeshP_getRankOfPart( meshInstance, partitionInstance, part_id, &part_rank, &itaps_err );
00090         if( part_rank == rank ) { gid[i] = ( size_t )( vert_array[i] ); }
00091         else
00092         {
00093             iBase_EntityHandle handle;
00094             iMeshP_getOwnerCopy( meshInstance, partitionInstance, ( iBase_EntityHandle )( vert_array[i] ), &part_id,
00095                                  &handle, &itaps_err );
00096             gid[i] = (size_t)handle;
00097         }
00098     }
00099 }
00100 
00101 void MsqIMeshP::vertices_get_processor_id( const VertexHandle vert_array[], int pid[], size_t num_vtx,
00102                                            MsqError& /*err*/ )
00103 {
00104     int itaps_err;
00105     for( unsigned i = 0; i < num_vtx; i++ )
00106     {
00107         iMeshP_Part part_id;
00108         iMeshP_getEntOwnerPart( meshInstance, partitionInstance, ( iBase_EntityHandle )( vert_array[i] ), &part_id,
00109                                 &itaps_err );
00110         iMeshP_getRankOfPart( meshInstance, partitionInstance, part_id, &( pid[i] ), &itaps_err );
00111     }
00112 }
00113 
00114 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines