MOAB: Mesh Oriented datABase  (version 5.4.1)
ParallelMeshImpl.hpp
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     [email protected], [email protected], [email protected],
00024     [email protected], [email protected], [email protected]  ,
00025     [email protected]
00026 
00027   ***************************************************************** */
00028 /*!
00029   \file   ParallelMeshImpl.hpp
00030   \brief
00031 
00032   \author Darryl Melander
00033   \author Thomas Leurent
00034   \author Jason Kraftcheck
00035   \author Martin Isenburg
00036   \date   2003-04-17
00037 */
00038 
00039 #ifndef PARALLEL_MESQUITE_MESH_IMPL_HPP
00040 #define PARALLEL_MESQUITE_MESH_IMPL_HPP
00041 
00042 #include "ParallelMeshInterface.hpp"
00043 
00044 namespace MBMesquite
00045 {
00046 /*!  \class ParallelMeshImpl
00047 \brief ParallelMeshImpl is a Mesquite implementation of the ParallelMesh
00048 interface. It inherits all of the implementation from MeshImpl and only
00049 implements any additional functionality.
00050 */
00051 
00052 class MESQUITE_EXPORT ParallelMeshImpl : public ParallelMesh
00053 {
00054   public:
00055     ParallelMeshImpl( Mesh* myMesh, const char* gid_name = 0, const char* pid_name = 0 );
00056 
00057     void set_global_id_tag( const char* name, MsqError& err );
00058     void set_processor_id_tag( const char* name, MsqError& err );
00059 
00060     void vertices_set_global_id( const VertexHandle vert_array[], size_t gid[], size_t num_vtx, MsqError& err );
00061 
00062     void vertices_set_processor_id( const VertexHandle vert_array[], int pid[], size_t num_vtx, MsqError& err );
00063 
00064     //**************** Inherited Methods from ParallelMesh ******************************
00065 
00066     /*! Get global ids for given vertices.
00067      */
00068     virtual void vertices_get_global_id( const VertexHandle vert_array[], size_t gid[], size_t num_vtx, MsqError& err );
00069 
00070     /*! Get processor ids for given vertices.
00071      */
00072     virtual void vertices_get_processor_id( const VertexHandle vert_array[], int pid[], size_t num_vtx, MsqError& err );
00073 
00074     //**************** Inherited Methods from Mesh ******************************
00075 
00076     // Returns whether this mesh lies in a 2D or 3D coordinate system.
00077     virtual int get_geometric_dimension( MsqError& err );
00078 
00079     /** \brief Get all elements in mesh
00080      *
00081      * Get the handles of every element in the active mesh.
00082      */
00083     virtual void get_all_elements( std::vector< ElementHandle >& handles, MsqError& err );
00084 
00085     /** \brief Get all vertices in mesh
00086      *
00087      * Get the handles of every vertex in the active mesh
00088      */
00089     virtual void get_all_vertices( std::vector< VertexHandle >& vertices, MsqError& err );
00090 
00091     //************ Vertex Properties ********************
00092     //! Returns true or false, indicating whether the vertex
00093     //! is allowed to be repositioned.  True indicates that the vertex
00094     //! is fixed and cannot be moved.  Note that this is a read-only
00095     //! property; this flag can't be modified by users of the
00096     //! MBMesquite::Mesh interface.
00097     virtual void vertices_get_fixed_flag( const VertexHandle vert_array[],
00098                                           std::vector< bool >& fixed_flag_array,
00099                                           size_t num_vtx,
00100                                           MsqError& err );
00101 
00102     void vertices_set_fixed_flag( const VertexHandle vert_array[],
00103                                   const bool fixed_flag_array[],
00104                                   size_t num_vtx,
00105                                   MsqError& err );
00106 
00107     virtual void vertices_get_slaved_flag( const VertexHandle vert_array[],
00108                                            std::vector< bool >& slaved_flag_array,
00109                                            size_t num_vtx,
00110                                            MsqError& err );
00111 
00112     // Get/set location of a vertex
00113     virtual void vertices_get_coordinates( const Mesh::VertexHandle vert_array[],
00114                                            MBMesquite::MsqVertex* coordinates,
00115                                            size_t num_vtx,
00116                                            MsqError& err );
00117     virtual void vertex_set_coordinates( VertexHandle vertex, const Vector3D& coordinates, MsqError& err );
00118 
00119     // Each vertex has a byte-sized flag that can be used to store
00120     // flags.  This byte's value is neither set nor used by the mesh
00121     // implementation.  It is intended to be used by Mesquite algorithms.
00122     // Until a vertex's byte has been explicitly set, its value is 0.
00123     virtual void vertex_set_byte( VertexHandle vertex, unsigned char byte, MsqError& err );
00124     virtual void vertices_set_byte( const VertexHandle* vert_array,
00125                                     const unsigned char* byte_array,
00126                                     size_t array_size,
00127                                     MsqError& err );
00128 
00129     // Retrieve the byte value for the specified vertex or vertices.
00130     // The byte value is 0 if it has not yet been set via one of the
00131     // *_set_byte() functions.
00132     virtual void vertex_get_byte( const VertexHandle vertex, unsigned char* byte, MsqError& err );
00133     virtual void vertices_get_byte( const VertexHandle* vertex,
00134                                     unsigned char* byte_array,
00135                                     size_t array_size,
00136                                     MsqError& err );
00137 
00138     //**************** Vertex Topology *****************
00139 
00140     /** \brief get elements adjacent to vertices
00141      *
00142      * Get adjacency data for vertices
00143      *
00144      *\param vertex_array    Array of vertex handles specifying the
00145      *                       list of vertices to retrieve adjacency
00146      *                       data for.
00147      *\param num_vertex      Number of vertex handles in #vertex_array
00148      *\param elements     The array in which to place the handles of
00149      *                       elements adjacent to the input vertices.
00150      *\param offsets    For each vertex in #vertex_array, the
00151      *                       value in the corresponding position in this
00152      *                       array is the index into #elem_array at
00153      *                       which the adjacency list begins for that
00154      *                       vertex.
00155      */
00156     virtual void vertices_get_attached_elements( const VertexHandle* vertex_array,
00157                                                  size_t num_vertex,
00158                                                  std::vector< ElementHandle >& elements,
00159                                                  std::vector< size_t >& offsets,
00160                                                  MsqError& err );
00161 
00162     //*************** Element Topology *************
00163 
00164     /** \brief Get element connectivity
00165      *
00166      * Get the connectivity (ordered list of vertex handles) for
00167      * each element in the input array.
00168      *
00169      *\param elem_handles  The array of element handles for which to
00170      *                     retrieve the connectivity list.
00171      *\param num_elems     The length of #elem_handles
00172      *\param vert_handles  Array in which to place the vertex handles
00173      *                     in each elements connectivity.
00174      *\param offsets       For each element in #elem_handles, the
00175      *                     value in the same position in this array
00176      *                     is the index into #vert_handles at which
00177      *                     the connectivity list for that element begins.
00178      */
00179     virtual void elements_get_attached_vertices( const ElementHandle* elem_handles,
00180                                                  size_t num_elems,
00181                                                  std::vector< VertexHandle >& vert_handles,
00182                                                  std::vector< size_t >& offsets,
00183                                                  MsqError& err );
00184 
00185     // Returns the topologies of the given entities.  The "entity_topologies"
00186     // array must be at least "num_elements" in size.
00187     virtual void elements_get_topologies( const ElementHandle* element_handle_array,
00188                                           EntityTopology* element_topologies,
00189                                           size_t num_elements,
00190                                           MsqError& err );
00191 
00192     //*************** Tags  ***********
00193 
00194     /** \brief Create a tag
00195      *
00196      * Create a user-defined data type that can be attached
00197      * to any element or vertex in the mesh.  For an opaque or
00198      * undefined type, use type=BYTE and length=sizeof(..).
00199      *
00200      * \param tag_name  A unique name for the data object
00201      * \param type      The type of the data
00202      * \param length    Number of values per entity (1->scalar, >1 ->vector)
00203      * \param default_value Default value to assign to all entities - may be NULL
00204      * \return - Handle for tag definition
00205      */
00206     virtual TagHandle tag_create( const std::string& tag_name,
00207                                   TagType type,
00208                                   unsigned length,
00209                                   const void* default_value,
00210                                   MsqError& err );
00211 
00212     /** \brief Remove a tag and all corresponding data
00213      *
00214      * Delete a tag.
00215      */
00216     virtual void tag_delete( TagHandle handle, MsqError& err );
00217 
00218     /** \brief Get handle for existing tag, by name. */
00219     virtual TagHandle tag_get( const std::string& name, MsqError& err );
00220 
00221     /** \brief Get properites of tag
00222      *
00223      * Get data type and number of values per entity for tag.
00224      * \param handle     Tag to get properties of.
00225      * \param name_out   Passed back tag name.
00226      * \param type_out   Passed back tag type.
00227      * \param length_out Passed back number of values per entity.
00228      */
00229     virtual void tag_properties( TagHandle handle,
00230                                  std::string& name_out,
00231                                  TagType& type_out,
00232                                  unsigned& length_out,
00233                                  MsqError& err );
00234 
00235     /** \brief Set tag values on elements
00236      *
00237      * Set the value of a tag for a list of mesh elements.
00238      * \param handle     The tag
00239      * \param num_elems  Length of elem_array
00240      * \param elem_array Array of elements for which to set the tag value.
00241      * \param tag_data   Tag data for each element, contiguous in memory.
00242      *                   This data is expected to be
00243      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00244      */
00245     virtual void tag_set_element_data( TagHandle handle,
00246                                        size_t num_elems,
00247                                        const ElementHandle* elem_array,
00248                                        const void* tag_data,
00249                                        MsqError& err );
00250 
00251     /** \brief Set tag values on vertices
00252      *
00253      * Set the value of a tag for a list of mesh vertices.
00254      * \param handle     The tag
00255      * \param num_elems  Length of node_array
00256      * \param node_array Array of vertices for which to set the tag value.
00257      * \param tag_data   Tag data for each element, contiguous in memory.
00258      *                   This data is expected to be
00259      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00260      */
00261     virtual void tag_set_vertex_data( TagHandle handle,
00262                                       size_t num_elems,
00263                                       const VertexHandle* node_array,
00264                                       const void* tag_data,
00265                                       MsqError& err );
00266 
00267     /** \brief Get tag values on elements
00268      *
00269      * Get the value of a tag for a list of mesh elements.
00270      * \param handle     The tag
00271      * \param num_elems  Length of elem_array
00272      * \param elem_array Array of elements for which to get the tag value.
00273      * \param tag_data   Return buffer in which to copy tag data, contiguous
00274      *                   in memory.  This data is expected to be
00275      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00276      */
00277     virtual void tag_get_element_data( TagHandle handle,
00278                                        size_t num_elems,
00279                                        const ElementHandle* elem_array,
00280                                        void* tag_data,
00281                                        MsqError& err );
00282 
00283     /** \brief Get tag values on vertices.
00284      *
00285      * Get the value of a tag for a list of mesh vertices.
00286      * \param handle     The tag
00287      * \param num_elems  Length of elem_array
00288      * \param elem_array Array of vertices for which to get the tag value.
00289      * \param tag_data   Return buffer in which to copy tag data, contiguous
00290      *                   in memory.  This data is expected to be
00291      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00292      */
00293     virtual void tag_get_vertex_data( TagHandle handle,
00294                                       size_t num_elems,
00295                                       const VertexHandle* node_array,
00296                                       void* tag_data,
00297                                       MsqError& err );
00298 
00299     //**************** Memory Management ****************
00300     // Tells the mesh that the client is finished with a given
00301     // entity handle.
00302     virtual void release_entity_handles( const EntityHandle* handle_array, size_t num_handles, MsqError& err );
00303 
00304     // Instead of deleting a Mesh when you think you are done,
00305     // call release().  In simple cases, the implementation could
00306     // just call the destructor.  More sophisticated implementations
00307     // may want to keep the Mesh object to live longer than Mesquite
00308     // is using it.
00309     virtual void release();
00310 
00311   private:
00312     Mesh* myMesh;
00313     void* gid_tag;
00314     void* pid_tag;
00315 };
00316 }  // namespace MBMesquite
00317 
00318 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines