MOAB: Mesh Oriented datABase  (version 5.2.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     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   \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[], std::vector< bool >& fixed_flag_array,
00098                                           size_t num_vtx, MsqError& err );
00099 
00100     void vertices_set_fixed_flag( const VertexHandle vert_array[], const bool fixed_flag_array[], size_t num_vtx,
00101                                   MsqError& err );
00102 
00103     virtual void vertices_get_slaved_flag( const VertexHandle vert_array[], std::vector< bool >& slaved_flag_array,
00104                                            size_t num_vtx, MsqError& err );
00105 
00106     // Get/set location of a vertex
00107     virtual void vertices_get_coordinates( const Mesh::VertexHandle vert_array[], MBMesquite::MsqVertex* coordinates,
00108                                            size_t num_vtx, MsqError& err );
00109     virtual void vertex_set_coordinates( VertexHandle vertex, const Vector3D& coordinates, MsqError& err );
00110 
00111     // Each vertex has a byte-sized flag that can be used to store
00112     // flags.  This byte's value is neither set nor used by the mesh
00113     // implementation.  It is intended to be used by Mesquite algorithms.
00114     // Until a vertex's byte has been explicitly set, its value is 0.
00115     virtual void vertex_set_byte( VertexHandle vertex, unsigned char byte, MsqError& err );
00116     virtual void vertices_set_byte( const VertexHandle* vert_array, const unsigned char* byte_array, size_t array_size,
00117                                     MsqError& err );
00118 
00119     // Retrieve the byte value for the specified vertex or vertices.
00120     // The byte value is 0 if it has not yet been set via one of the
00121     // *_set_byte() functions.
00122     virtual void vertex_get_byte( const VertexHandle vertex, unsigned char* byte, MsqError& err );
00123     virtual void vertices_get_byte( const VertexHandle* vertex, unsigned char* byte_array, size_t array_size,
00124                                     MsqError& err );
00125 
00126     //**************** Vertex Topology *****************
00127 
00128     /** \brief get elements adjacent to vertices
00129      *
00130      * Get adjacency data for vertices
00131      *
00132      *\param vertex_array    Array of vertex handles specifying the
00133      *                       list of vertices to retrieve adjacency
00134      *                       data for.
00135      *\param num_vertex      Number of vertex handles in #vertex_array
00136      *\param elements     The array in which to place the handles of
00137      *                       elements adjacent to the input vertices.
00138      *\param offsets    For each vertex in #vertex_array, the
00139      *                       value in the corresponding position in this
00140      *                       array is the index into #elem_array at
00141      *                       which the adjacency list begins for that
00142      *                       vertex.
00143      */
00144     virtual void vertices_get_attached_elements( const VertexHandle* vertex_array, size_t num_vertex,
00145                                                  std::vector< ElementHandle >& elements, std::vector< size_t >& offsets,
00146                                                  MsqError& err );
00147 
00148     //*************** Element Topology *************
00149 
00150     /** \brief Get element connectivity
00151      *
00152      * Get the connectivity (ordered list of vertex handles) for
00153      * each element in the input array.
00154      *
00155      *\param elem_handles  The array of element handles for which to
00156      *                     retrieve the connectivity list.
00157      *\param num_elems     The length of #elem_handles
00158      *\param vert_handles  Array in which to place the vertex handles
00159      *                     in each elements connectivity.
00160      *\param offsets       For each element in #elem_handles, the
00161      *                     value in the same position in this array
00162      *                     is the index into #vert_handles at which
00163      *                     the connectivity list for that element begins.
00164      */
00165     virtual void elements_get_attached_vertices( const ElementHandle* elem_handles, size_t num_elems,
00166                                                  std::vector< VertexHandle >& vert_handles,
00167                                                  std::vector< size_t >& offsets, MsqError& err );
00168 
00169     // Returns the topologies of the given entities.  The "entity_topologies"
00170     // array must be at least "num_elements" in size.
00171     virtual void elements_get_topologies( const ElementHandle* element_handle_array, EntityTopology* element_topologies,
00172                                           size_t num_elements, MsqError& err );
00173 
00174     //*************** Tags  ***********
00175 
00176     /** \brief Create a tag
00177      *
00178      * Create a user-defined data type that can be attached
00179      * to any element or vertex in the mesh.  For an opaque or
00180      * undefined type, use type=BYTE and length=sizeof(..).
00181      *
00182      * \param tag_name  A unique name for the data object
00183      * \param type      The type of the data
00184      * \param length    Number of values per entity (1->scalar, >1 ->vector)
00185      * \param default_value Default value to assign to all entities - may be NULL
00186      * \return - Handle for tag definition
00187      */
00188     virtual TagHandle tag_create( const std::string& tag_name, TagType type, unsigned length, const void* default_value,
00189                                   MsqError& err );
00190 
00191     /** \brief Remove a tag and all corresponding data
00192      *
00193      * Delete a tag.
00194      */
00195     virtual void tag_delete( TagHandle handle, MsqError& err );
00196 
00197     /** \brief Get handle for existing tag, by name. */
00198     virtual TagHandle tag_get( const std::string& name, MsqError& err );
00199 
00200     /** \brief Get properites of tag
00201      *
00202      * Get data type and number of values per entity for tag.
00203      * \param handle     Tag to get properties of.
00204      * \param name_out   Passed back tag name.
00205      * \param type_out   Passed back tag type.
00206      * \param length_out Passed back number of values per entity.
00207      */
00208     virtual void tag_properties( TagHandle handle, std::string& name_out, TagType& type_out, unsigned& length_out,
00209                                  MsqError& err );
00210 
00211     /** \brief Set tag values on elements
00212      *
00213      * Set the value of a tag for a list of mesh elements.
00214      * \param handle     The tag
00215      * \param num_elems  Length of elem_array
00216      * \param elem_array Array of elements for which to set the tag value.
00217      * \param tag_data   Tag data for each element, contiguous in memory.
00218      *                   This data is expected to be
00219      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00220      */
00221     virtual void tag_set_element_data( TagHandle handle, size_t num_elems, const ElementHandle* elem_array,
00222                                        const void* tag_data, MsqError& err );
00223 
00224     /** \brief Set tag values on vertices
00225      *
00226      * Set the value of a tag for a list of mesh vertices.
00227      * \param handle     The tag
00228      * \param num_elems  Length of node_array
00229      * \param node_array Array of vertices for which to set the tag value.
00230      * \param tag_data   Tag data for each element, contiguous in memory.
00231      *                   This data is expected to be
00232      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00233      */
00234     virtual void tag_set_vertex_data( TagHandle handle, size_t num_elems, const VertexHandle* node_array,
00235                                       const void* tag_data, MsqError& err );
00236 
00237     /** \brief Get tag values on elements
00238      *
00239      * Get the value of a tag for a list of mesh elements.
00240      * \param handle     The tag
00241      * \param num_elems  Length of elem_array
00242      * \param elem_array Array of elements for which to get the tag value.
00243      * \param tag_data   Return buffer in which to copy tag data, contiguous
00244      *                   in memory.  This data is expected to be
00245      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00246      */
00247     virtual void tag_get_element_data( TagHandle handle, size_t num_elems, const ElementHandle* elem_array,
00248                                        void* tag_data, MsqError& err );
00249 
00250     /** \brief Get tag values on vertices.
00251      *
00252      * Get the value of a tag for a list of mesh vertices.
00253      * \param handle     The tag
00254      * \param num_elems  Length of elem_array
00255      * \param elem_array Array of vertices for which to get the tag value.
00256      * \param tag_data   Return buffer in which to copy tag data, contiguous
00257      *                   in memory.  This data is expected to be
00258      *                   num_elems*tag_length*sizeof(tag_type) bytes.
00259      */
00260     virtual void tag_get_vertex_data( TagHandle handle, size_t num_elems, const VertexHandle* node_array,
00261                                       void* tag_data, MsqError& err );
00262 
00263     //**************** Memory Management ****************
00264     // Tells the mesh that the client is finished with a given
00265     // entity handle.
00266     virtual void release_entity_handles( const EntityHandle* handle_array, size_t num_handles, MsqError& err );
00267 
00268     // Instead of deleting a Mesh when you think you are done,
00269     // call release().  In simple cases, the implementation could
00270     // just call the destructor.  More sophisticated implementations
00271     // may want to keep the Mesh object to live longer than Mesquite
00272     // is using it.
00273     virtual void release();
00274 
00275   private:
00276     Mesh* myMesh;
00277     void* gid_tag;
00278     void* pid_tag;
00279 };
00280 }  // namespace MBMesquite
00281 
00282 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines