MOAB: Mesh Oriented datABase  (version 5.4.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 [email protected]   [email protected]
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 [email protected]
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,
00052                       iMeshP_PartitionHandle partition,
00053                       iBase_EntitySetHandle meshset,
00054                       iBase_EntityType type,
00055                       MsqError& err,
00056                       const iBase_TagHandle* fixed_tag,
00057                       const iBase_TagHandle* slaved_tag )
00058     : MsqIMesh( mesh, meshset, type, err, fixed_tag, slaved_tag ), partitionInstance( partition )
00059 {
00060 }
00061 
00062 MsqIMeshP::MsqIMeshP( iMesh_Instance mesh,
00063                       iMeshP_PartitionHandle partition,
00064                       iBase_EntityType element_dimension,
00065                       MsqError& err,
00066                       const iBase_TagHandle* fixed_tag,
00067                       const iBase_TagHandle* slaved_tag )
00068     : MsqIMesh( mesh, element_dimension, err, fixed_tag, slaved_tag ), partitionInstance( partition )
00069 {
00070 }
00071 
00072 MsqIMeshP::~MsqIMeshP() {}
00073 
00074 //**************** Parallel Methods ******************************
00075 
00076 void MsqIMeshP::vertices_get_global_id( const VertexHandle vert_array[],
00077                                         size_t gid[],
00078                                         size_t num_vtx,
00079                                         MsqError& /*err*/ )
00080 {
00081     int itaps_err;
00082     // get a local part id
00083     iMeshP_PartHandle* parts = 0;
00084     int parts_allocated      = 0;
00085     int parts_size           = 0;
00086     iMeshP_getLocalParts( meshInstance, partitionInstance, &parts, &parts_allocated, &parts_size, &itaps_err );
00087     iMeshP_Part part_id;
00088     iMeshP_getPartIdFromPartHandle( meshInstance, partitionInstance, parts[0], &part_id, &itaps_err );
00089     if( parts_allocated ) free( parts );
00090     // get rank of local part
00091     int rank;
00092     iMeshP_getRankOfPart( meshInstance, partitionInstance, part_id, &rank, &itaps_err );
00093     // get global ids for all vertex handles
00094     for( unsigned i = 0; i < num_vtx; i++ )
00095     {
00096         iMeshP_getEntOwnerPart( meshInstance, partitionInstance, (iBase_EntityHandle)( vert_array[i] ), &part_id,
00097                                 &itaps_err );
00098         int part_rank;
00099         iMeshP_getRankOfPart( meshInstance, partitionInstance, part_id, &part_rank, &itaps_err );
00100         if( part_rank == rank )
00101         {
00102             gid[i] = (size_t)( vert_array[i] );
00103         }
00104         else
00105         {
00106             iBase_EntityHandle handle;
00107             iMeshP_getOwnerCopy( meshInstance, partitionInstance, (iBase_EntityHandle)( vert_array[i] ), &part_id,
00108                                  &handle, &itaps_err );
00109             gid[i] = (size_t)handle;
00110         }
00111     }
00112 }
00113 
00114 void MsqIMeshP::vertices_get_processor_id( const VertexHandle vert_array[],
00115                                            int pid[],
00116                                            size_t num_vtx,
00117                                            MsqError& /*err*/ )
00118 {
00119     int itaps_err;
00120     for( unsigned i = 0; i < num_vtx; i++ )
00121     {
00122         iMeshP_Part part_id;
00123         iMeshP_getEntOwnerPart( meshInstance, partitionInstance, (iBase_EntityHandle)( vert_array[i] ), &part_id,
00124                                 &itaps_err );
00125         iMeshP_getRankOfPart( meshInstance, partitionInstance, part_id, &( pid[i] ), &itaps_err );
00126     }
00127 }
00128 
00129 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines