MOAB: Mesh Oriented datABase  (version 5.2.1)
Core.hpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain 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  */
00015 
00016 #ifndef MOAB_IMPL_GENERAL_HPP
00017 #define MOAB_IMPL_GENERAL_HPP
00018 
00019 #include "moab/Interface.hpp"
00020 #include "moab/ReaderIface.hpp"
00021 #include <map>
00022 #include <list>
00023 
00024 namespace moab
00025 {
00026 
00027 class WriteUtil;
00028 class ReadUtil;
00029 class ScdInterface;
00030 class AEntityFactory;
00031 class SequenceManager;
00032 class Error;
00033 class HomCoord;
00034 class ReaderWriterSet;
00035 class EntitySequence;
00036 class FileOptions;
00037 class SetIterator;
00038 
00039 #ifdef MOAB_HAVE_AHF
00040 class HalfFacetRep;
00041 #endif
00042 
00043 /**\class Core
00044  * \brief Implementation of MOAB Interface
00045  * Implementation of the MOAB Interface class.  You shouldn't call functions directly
00046  * on an object of type Core (use Interface instead), unless you really have to access
00047  * non-API functionality.
00048  */
00049 class Core : public Interface
00050 {
00051 
00052   public:
00053     friend class SetIterator;
00054 
00055     //! constructor
00056     Core();
00057 
00058     //! destructor
00059     ~Core();
00060 
00061     //! Get a pointer to an internal MOAB interface
00062     //!\return NULL if not found, iterface pointer otherwise
00063     virtual ErrorCode query_interface_type( const std::type_info& interface_type, void*& ptr );
00064 
00065     //! Release reference to MB interface
00066     virtual ErrorCode release_interface_type( const std::type_info& interface_type, void* iface );
00067 
00068     virtual int QueryInterface( const MBuuid& uuid, UnknownInterface** iface );
00069 
00070     //! Returns the major.minor version number of the implementation
00071     /**
00072        \param iface_name If non-NULL, will be filled in with a string, possibly
00073        containing implementation-specific information
00074     */
00075     virtual float impl_version( std::string* version_string = NULL );
00076 
00077     //! get the type from a handle, returns type
00078     virtual EntityType type_from_handle( const EntityHandle handle ) const;
00079 
00080     //! get the id from a handle, returns id
00081     virtual EntityID id_from_handle( const EntityHandle handle ) const;
00082 
00083     //! get a handle from an id and type
00084     virtual ErrorCode handle_from_id( const EntityType type, const EntityID id, EntityHandle& handle ) const;
00085 
00086     virtual int dimension_from_handle( const EntityHandle ) const;
00087 
00088     //! load mesh from data in file
00089     //! NOTE: if there is mesh already present, the new mesh will be added
00090     virtual ErrorCode load_mesh( const char* file_name, const int* active_block_id_list = NULL,
00091                                  const int num_blocks = 0 );
00092 
00093     /**Load or import a file. */
00094     virtual ErrorCode load_file( const char* file_name, const EntityHandle* file_set = 0, const char* options = 0,
00095                                  const char* set_tag_name = 0, const int* set_tag_vals = 0, int num_set_tag_vals = 0 );
00096 
00097     /**Load or import a file. */
00098     ErrorCode serial_load_file( const char* file_name, const EntityHandle* file_set, const FileOptions& opts,
00099                                 const ReaderIface::SubsetList* subsets = 0, const Tag* file_id_tag = 0 );
00100 
00101     ErrorCode serial_read_tag( const char* file_name, const char* tag_name, const FileOptions& opts,
00102                                std::vector< int >& tag_vals, const ReaderIface::SubsetList* subsets = 0 );
00103 
00104     virtual ErrorCode write_mesh( const char* file_name, const EntityHandle* output_list = NULL,
00105                                   const int num_sets = 0 );
00106     /** Write or export a file. */
00107     virtual ErrorCode write_file( const char* file_name, const char* file_type = 0, const char* options = 0,
00108                                   const EntityHandle* output_sets = 0, int num_output_sets = 0, const Tag* tag_list = 0,
00109                                   int num_tags = 0 );
00110 
00111     /** Write or export a file */
00112     virtual ErrorCode write_file( const char* file_name, const char* file_type, const char* options,
00113                                   const Range& output_sets, const Tag* tag_list = 0, int num_tags = 0 );
00114 
00115     //! deletes all mesh entities from this datastore
00116     virtual ErrorCode delete_mesh();
00117 
00118     //! get overall geometric dimension
00119     virtual ErrorCode get_dimension( int& dim ) const;
00120 
00121     //! set overall geometric dimension
00122     /** Returns error if setting to 3 dimensions, mesh has been created, and
00123      *  there are only 2 dimensions on that mesh
00124      */
00125     virtual ErrorCode set_dimension( const int dim );
00126 
00127     //! get blocked vertex coordinates for all vertices
00128     /** Blocked = all x, then all y, etc.
00129      */
00130     virtual ErrorCode get_vertex_coordinates( std::vector< double >& coords ) const;
00131 
00132     //! get pointers to coordinate data
00133     virtual ErrorCode coords_iterate( Range::const_iterator iter, Range::const_iterator end, double*& xcoords_ptr,
00134                                       double*& ycoords_ptr, double*& zcoords_ptr, int& count );
00135 
00136     //! get the coordinate information for this handle if it is of type Vertex
00137     //! otherwise, return an error
00138     virtual ErrorCode get_coords( const Range& entities, double* coords ) const;
00139 
00140     virtual ErrorCode get_coords( const EntityHandle* entities, const int num_entities, double* coords ) const;
00141 
00142     virtual ErrorCode get_coords( const EntityHandle entity_handle, const double*& x, const double*& y,
00143                                   const double*& z ) const;
00144 
00145     virtual ErrorCode get_coords( const Range& entities, double* x_coords, double* y_coords, double* z_coords ) const;
00146 
00147     //! set the coordinate information for this handle if it is of type Vertex
00148     //! otherwise, return an error
00149     virtual ErrorCode set_coords( const EntityHandle* entity_handles, const int num_entities, const double* coords );
00150 
00151     //! set the coordinate information for this handle if it is of type Vertex
00152     //! otherwise, return an error
00153     virtual ErrorCode set_coords( Range entity_handles, const double* coords );
00154 
00155     //! get global connectivity array for specified entity type
00156     /**  Assumes just vertices, no higher order nodes
00157      */
00158     virtual ErrorCode get_connectivity_by_type( const EntityType type, std::vector< EntityHandle >& connect ) const;
00159 
00160     //! get pointer to connectivity data
00161     virtual ErrorCode connect_iterate( Range::const_iterator iter, Range::const_iterator end, EntityHandle*& connect,
00162                                        int& verts_per_entity, int& count );
00163 
00164     //! Gets the connectivity for an element EntityHandle.
00165     /** For non-element handles (ie, MeshSets),
00166      * returns an error. Connectivity data is copied from the database into the vector
00167      *   <em>connectivity</em>. The nodes in <em>connectivity</em> are properly ordered.
00168      *  \param entity_handle EntityHandle to get connectivity of.
00169      *  \param connectivity Vector in which connectivity of <em>entity_handle</em> is returned.
00170      *   Should contain MeshVertices.
00171      *  \param corners_only If true, returns only corner vertices, otherwise returns all of them
00172      * (including any higher-order vertices)
00173      *
00174      *   Example: \code
00175      *   std::vector<EntityHandle> conn;
00176      *   get_connectivity( entity_handle, conn ); \endcode
00177      */
00178     virtual ErrorCode get_connectivity( const EntityHandle* entity_handles, const int num_handles,
00179                                         std::vector< EntityHandle >& connectivity, bool corners_only = false,
00180                                         std::vector< int >* offsets = NULL ) const;
00181 
00182     //! Gets the connectivity for a vector of elements
00183     /** Same as vector-based version except range is returned (unordered!)
00184      */
00185     virtual ErrorCode get_connectivity( const EntityHandle* entity_handles, const int num_handles, Range& connectivity,
00186                                         bool corners_only = false ) const;
00187 
00188     //! Gets the connectivity for elements
00189     /** Same as vector-based version except range is returned (unordered!)
00190      */
00191     virtual ErrorCode get_connectivity( const Range& from_entities, Range& adj_entities,
00192                                         bool corners_only = false ) const;
00193 
00194     //! Gets a pointer to constant connectivity data of <em>entity_handle</em>
00195     /** Sets <em>number_nodes</em> equal to the number of nodes of the <em>
00196         entity_handle </em>.  Faster then the other <em>get_connectivity</em> function.
00197         The nodes in 'connectivity' are properly ordered.
00198         \param entity_handle EntityHandle to get connectivity of.
00199         \param connectivity Array in which connectivity of <em>entity_handle</em> is returned.
00200         Should contain MBVERTEX's.
00201         \param num_nodes Number of MeshVertices in array <em>connectivity</em>.
00202 
00203         Example: \code
00204         const EntityHandle* conn;
00205         int number_nodes = 0;
00206         get_connectivity( entity_handle, conn, number_nodes ); \endcode
00207 
00208         Example2: \code
00209         std::vector<EntityHandle> sm_storage;
00210         const EntityHandle* conn;
00211         int number_nodes;
00212         get_connectivity( handle, conn, number_nodes, false, &sm_storage );
00213         if (conn == &sm_storage[0])
00214           std::cout << "Structured mesh element" << std::endl;
00215         \endcode
00216       */
00217     virtual ErrorCode get_connectivity( const EntityHandle entity_handle, const EntityHandle*& connectivity,
00218                                         int& number_nodes, bool corners_only = false,
00219                                         std::vector< EntityHandle >* storage = 0 ) const;
00220 
00221     //! Sets the connectivity for an EntityHandle.  For non-element handles, return an error.
00222     /** Connectivity is stored exactly as it is ordered in vector <em>connectivity</em>.
00223         \param entity_handle EntityHandle to set connectivity of.
00224         \param connect Vector containing new connectivity of <em>entity_handle</em>.
00225         \param num_connect Number of vertices in <em>connect</em>
00226 
00227         Example: \code
00228         std::vector<EntityHandle> conn(3);
00229         conn[0] = node1;
00230         conn[1] = node2;
00231         conn[2] = node3;
00232         set_connectivity( entity_handle, conn, 3 ); \endcode */
00233     virtual ErrorCode set_connectivity( const EntityHandle entity_handle, EntityHandle* connect,
00234                                         const int num_connect );
00235 
00236     //! get the adjacencies associated with a set of entities
00237     /** \param from_entities vector of EntityHandle to get adjacencies of.
00238         \param to_dimension Dimension of desired adjacency information.
00239         \param adj_entities Vector in which adjacent EntityHandles are returned.
00240         \param operation_type enum of INTERSECT or UNION.  Defines whether to take
00241         the intersection or union of the set of adjacencies recovered for the from_entities.
00242 
00243         The adjacent entities in vector <em>adjacencies</em> are not in any particular
00244         order.
00245 
00246         Example: \code
00247           // get the set of edges that are adjacent to all entities in the from_entities list
00248           std::vector<EntityHandle> from_entities = {hex1, hex2};
00249           std::vector<EntityHandle> adjacencies;
00250           get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies );
00251           \endcode */
00252 
00253     virtual ErrorCode get_adjacencies( const EntityHandle* from_entities, const int num_entities,
00254                                        const int to_dimension, const bool create_if_missing,
00255                                        std::vector< EntityHandle >& adj_entities,
00256                                        const int operation_type = Interface::INTERSECT );
00257 
00258     virtual ErrorCode get_adjacencies( const EntityHandle* from_entities, const int num_entities,
00259                                        const int to_dimension, const bool create_if_missing, Range& adj_entities,
00260                                        const int operation_type = Interface::INTERSECT );
00261 
00262     virtual ErrorCode get_adjacencies( const Range& from_entities, const int to_dimension, const bool create_if_missing,
00263                                        Range& adj_entities, const int operation_type = Interface::INTERSECT );
00264 
00265     /**\brief Get a ptr to adjacency lists
00266      * Get a pointer to adjacency lists.  These lists are std::vector<EntityHandle>, which are
00267      * pointed to by adjs[i].  Adjacencies are not guaranteed to be in order of increasing
00268      * dimension.  Only a const version of this function is given, because adjacency data is managed
00269      * more carefully in MOAB and should be treated as read-only by applications.  If adjacencies
00270      * have not yet been initialized, adjs_ptr will be NULL (i.e. adjs_ptr == NULL).  There may also
00271      * be NULL entries for individual entities, i.e. adjs_ptr[i] == NULL. \param iter Iterator to
00272      * beginning of entity range desired \param end End iterator for which adjacencies are requested
00273      * \param adjs_ptr Pointer to pointer to const std::vector<EntityHandle>; each member of that
00274      * array is the vector of adjacencies for this entity \param count Number of entities in the
00275      * contiguous chunk starting from *iter
00276      */
00277     ErrorCode adjacencies_iterate( Range::const_iterator iter, Range::const_iterator end,
00278                                    const std::vector< EntityHandle >**& adjs_ptr, int& count );
00279 
00280     /**\brief Get all vertices for input entities
00281      *
00282      * Special case of get_adjacencies where to_dimension == 0
00283      * and operation_type == Interface::UNION.
00284      *\Note This is not a variation of get_connectivity because
00285      *      the behavior is different for polyhedra.
00286      */
00287     virtual ErrorCode get_vertices( const Range& from_entities, Range& vertices );
00288 
00289     //! Adds adjacencies
00290     /** \param from_handle entities
00291         \param both_ways add the adjacency information to both the
00292         to_handle and and the from_from :handle
00293 
00294         Example: \code
00295     */
00296     virtual ErrorCode add_adjacencies( const EntityHandle entity_handle, const EntityHandle* adjacencies,
00297                                        const int num_handles, bool both_ways );
00298 
00299     //! Adds adjacencies; same as vector-based, but with range instead
00300     virtual ErrorCode add_adjacencies( const EntityHandle entity_handle, Range& adjacencies, bool both_ways );
00301 
00302     //! Removes adjacencies
00303     /** \param handle EntityHandle to get adjacencies of.
00304 
00305     Example: \code
00306     */
00307     virtual ErrorCode remove_adjacencies( const EntityHandle entity_handle, const EntityHandle* adjacencies,
00308                                           const int num_handles );
00309 
00310     //! Retrieves all entities in the database of given dimension.
00311     /** \param dimension Dimension of entities desired.
00312         \param entities Range in which entities of dimension <em>dimension</em> are returned.
00313 
00314         Example: \code
00315         int dimension = 2;
00316         Range entities;
00317         get_entities_by_dimension( dimension, entities ); //get 2D EntityHandles in the database
00318         \endcode */
00319     virtual ErrorCode get_entities_by_dimension( const EntityHandle meshset, const int dimension, Range& entities,
00320                                                  const bool recursive = false ) const;
00321 
00322     virtual ErrorCode get_entities_by_dimension( const EntityHandle meshset, const int dimension,
00323                                                  std::vector< EntityHandle >& entities,
00324                                                  const bool recursive = false ) const;
00325 
00326     //! Retrieves all entities in the data base of given type.
00327     /** \param type EntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
00328         \param entities Range in which entities of EntityType <em>type</em> are returned.
00329 
00330         Example: \code
00331         EntityType type = MBTET;
00332         Range entities;
00333         get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database
00334         \endcode */
00335     virtual ErrorCode get_entities_by_type( const EntityHandle meshset, const EntityType type, Range& entities,
00336                                             const bool recursive = false ) const;
00337 
00338     //! Retrieves all entities in the data base of given type.
00339     /** \param type EntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
00340         \param entities Range in which entities of EntityType <em>type</em> are returned.
00341 
00342         Example: \code
00343         EntityType type = MBTET;
00344         Range entities;
00345         get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database
00346         \endcode */
00347     virtual ErrorCode get_entities_by_type( const EntityHandle meshset, const EntityType type,
00348                                             std::vector< EntityHandle >& entities, const bool recursive = false ) const;
00349 
00350     virtual ErrorCode get_entities_by_type_and_tag( const EntityHandle meshset, const EntityType type, const Tag* tags,
00351                                                     const void* const* values, const int num_tags, Range& entities,
00352                                                     const int condition  = Interface::INTERSECT,
00353                                                     const bool recursive = false ) const;
00354 
00355     //! Retrieves all entities in the data base
00356     /** \param entities Range in which entities of EntityType <em>type</em> are returned.
00357 
00358     Example: \code
00359     Range entities;
00360     get_entities( entities ); //get MBTET type EntityHandles in the database
00361     \endcode */
00362     virtual ErrorCode get_entities_by_handle( const EntityHandle meshset, Range& entities,
00363                                               const bool recursive = false ) const;
00364 
00365     //! Retrieves all entities in the data base
00366     /** \param entities Range in which entities of EntityType <em>type</em> are returned.
00367 
00368     Example: \code
00369     Range entities;
00370     get_entities( entities ); //get MBTET type EntityHandles in the database
00371     \endcode */
00372     virtual ErrorCode get_entities_by_handle( const EntityHandle meshset, std::vector< EntityHandle >& entities,
00373                                               const bool recursive = false ) const;
00374 
00375     //! Retrieves all entities in the database of given dimension.
00376     /** \param dimension Dimension of entities desired.
00377         \param entities Range in which entities of dimension <em>dimension</em> are returned.
00378 
00379         Example: \code
00380         int dimension = 2;
00381         Range entities;
00382         get_entities_by_dimension( dimension, entities ); //get 2D EntityHandles in the database
00383         \endcode */
00384     virtual ErrorCode get_number_entities_by_dimension( const EntityHandle meshset, const int dimension, int& number,
00385                                                         const bool recursive = false ) const;
00386 
00387     //! Retrieves all entities in the data base of given type.
00388     /** \param type EntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
00389         \param entities Range in which entities of EntityType <em>type</em> are returned.
00390 
00391         Example: \code
00392         EntityType type = MBTET;
00393         Range entities;
00394         get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database
00395         \endcode */
00396     virtual ErrorCode get_number_entities_by_type( const EntityHandle meshset, const EntityType type, int& num_entities,
00397                                                    const bool recursive = false ) const;
00398 
00399     virtual ErrorCode get_number_entities_by_type_and_tag( const EntityHandle meshset, const EntityType type,
00400                                                            const Tag* tag_handles, const void* const* values,
00401                                                            const int num_tags, int& num_entities,
00402                                                            const int condition  = Interface::INTERSECT,
00403                                                            const bool recursive = false ) const;
00404 
00405     //! Retrieves all entities in the data base
00406     /** \param entities Range in which entities of EntityType <em>type</em> are returned.
00407 
00408     Example: \code
00409     Range entities;
00410     get_entities( entities ); //get MBTET type EntityHandles in the database
00411     \endcode */
00412     virtual ErrorCode get_number_entities_by_handle( const EntityHandle meshset, int& num_entities,
00413                                                      const bool recursive = false ) const;
00414 
00415     //! Creates an element based on the type and connectivity.
00416     /** If connectivity vector is not correct for EntityType <em>type</em> (ie, a vector with
00417         3 vertices is passed in to make an MBQUAD), the function returns MB_FAILURE.
00418         \param type Type of element to create. (MBTET, MBTRI, MBKNIFE, etc.)
00419         \param connectivity Vector containing connectivity of element to create.
00420         \param handle EntityHandle representing the newly created element in the database.
00421 
00422         Example: \code
00423         EntityType type = MBQUAD;
00424         std::vector<EntityHandle> connectivity(4);
00425         quad_conn[0] = vertex0;
00426         quad_conn[1] = vertex1;
00427         quad_conn[2] = vertex2;
00428         quad_conn[3] = vertex3;
00429         EntityHandle element_handle;
00430         create_element( type, connectivity, element_handle ); \endcode */
00431     virtual ErrorCode create_element( const EntityType type, const EntityHandle* connectivity, const int num_nodes,
00432                                       EntityHandle& element_handle );
00433 
00434     //! Creates a vertex based on coordinates.
00435     /**
00436        \param coordinates Array that has 3 doubles in it.
00437        \param entity_handle EntityHandle representing the newly created vertex in the database.
00438 
00439        Example: \code
00440        double *coordinates = double[3];
00441        coordinates[0] = 1.034;
00442        coordinates[1] = 23.23;
00443        coordinates[2] = -0.432;
00444        EntityHandle entity_handle = 0;
00445        create_vertex( coordinates, entity_handle ); \endcode */
00446     virtual ErrorCode create_vertex( const double coords[3], EntityHandle& entity_handle );
00447 
00448     //! Create a set of vertices with the specified coordinates
00449     /**
00450        \param coordinates Array that has 3*n doubles in it.
00451        \param nverts Number of vertices to create
00452        \param entity_handles Range passed back with new vertex handles
00453     */
00454     virtual ErrorCode create_vertices( const double* coordinates, const int nverts, Range& entity_handles );
00455 
00456     //! merges two entities
00457     virtual ErrorCode merge_entities( EntityHandle entity_to_keep, EntityHandle entity_to_remove, bool auto_merge,
00458                                       bool delete_removed_entity );
00459 
00460     //! Removes entities in a vector from the data base.
00461     /** If any of the entities are contained in any meshsets, it is removed from those meshsets
00462         which were created with MESHSET_TRACK_OWNER option bit set.  Tags for <em>entity<\em> are
00463         removed as part of this function.
00464         \param entities 1d vector of entities to delete
00465         \param num_entities Number of entities in 1d vector
00466     */
00467     virtual ErrorCode delete_entities( const EntityHandle* entities, const int num_entities );
00468 
00469     //! Removes entities in a range from the data base.
00470     /** If any of the entities are contained in any meshsets, it is removed from those meshsets
00471         which were created with MESHSET_TRACK_OWNER option bit set.  Tags for <em>entity<\em> are
00472         removed as part of this function.
00473         \param entities Range of entities to delete
00474     */
00475     virtual ErrorCode delete_entities( const Range& range );
00476 
00477     virtual ErrorCode list_entities( const Range& temp_range ) const;
00478 
00479     virtual ErrorCode list_entities( const EntityHandle* entities, const int num_entities ) const;
00480 
00481     virtual ErrorCode list_entity( const EntityHandle entity ) const;
00482 
00483     typedef unsigned long long type_memstorage;
00484 
00485     //! function object for recieving events from MB of higher order nodes
00486     //! added to entities
00487     class HONodeAddedRemoved
00488     {
00489       public:
00490         HONodeAddedRemoved() {}
00491         virtual ~HONodeAddedRemoved() {}
00492         //! node_added called when a node was added to an element's connectivity array
00493         //! note: connectivity array of element may be incomplete (corner nodes will exist always)
00494         virtual void node_added( EntityHandle node, EntityHandle element );
00495         virtual void node_removed( EntityHandle node );
00496     };
00497 
00498     virtual ErrorCode convert_entities( const EntityHandle meshset, const bool mid_side, const bool mid_face,
00499                                         const bool mid_volume, Interface::HONodeAddedRemoved* function_object = 0 );
00500 
00501     //! function to get the side number given two elements; returns
00502     //! MB_FAILURE if child not related to parent; does *not* create adjacencies
00503     //! between parent and child
00504     virtual ErrorCode side_number( const EntityHandle parent, const EntityHandle child, int& sd_number, int& sense,
00505                                    int& offset ) const;
00506 
00507     //! given an entity and the connectivity and type of one of its subfacets, find the
00508     //! high order node on that subfacet, if any
00509     virtual ErrorCode high_order_node( const EntityHandle parent_handle, const EntityHandle* subfacet_conn,
00510                                        const EntityType subfacet_type, EntityHandle& hon ) const;
00511 
00512     //! given an entity and a target dimension & side number, get that entity
00513     virtual ErrorCode side_element( const EntityHandle source_entity, const int dim, const int sd_number,
00514                                     EntityHandle& target_entity ) const;
00515 
00516     //-------------------------Tag Stuff-------------------------------------//
00517 
00518     /**\brief Get a tag handle, possibly creating the tag
00519      *
00520      * Get a handle used to associate application-defined values
00521      * with MOAB entities.  If the tag does not already exist then
00522      * \c flags should contain exactly one of \c MB_TAG_SPARSE,
00523      * \c MB_TAG_DENSE, \c MB_TAG_MESH unless \c type is MB_TYPE_BIT,
00524      * which implies \c MB_TAG_BIT storage.
00525      * .
00526      *\param name          The tag name
00527      *\param size          Tag size as number of values of of data type per entity
00528      *                     (or number of bytes if \c MB_TAG_BYTES is passed in flags).  If \c
00529      *MB_TAG_VARLEN is specified, this value is taken to be the size of the default value if one is
00530      *specified and is otherwise ignored. \param type          The type of the data (used for IO)
00531      *\param tag_handle    Output: the resulting tag handle.
00532      *\param flags         Bitwise OR of values from \c TagType
00533      *\param default_value Optional default value for tag.
00534      *\param created       Optional returned boolean indicating that the tag
00535      *                     was created.
00536      *\return - \c MB_ALREADY_ALLOCATED     if tag exists and \c MB_TAG_EXCL is specified, or
00537      *default values do not match (and \c MB_TAG_ANY or \c MB_TAG_DFTOK not specified).
00538      *        - \c MB_TAG_NOT_FOUND         if tag does not exist and \c MB_TAG_CREAT is not
00539      *specified
00540      *        - \c MB_INVALID_SIZE          if tag value size is not a multiple of the size of the
00541      *data type (and \c MB_TAG_ANY not specified).
00542      *        - \c MB_TYPE_OUT_OF_RANGE     invalid or inconsistent parameter
00543      *        - \c MB_VARIABLE_DATA_LENGTH  if \c MB_TAG_VARLEN and \c default_value is non-null and
00544      *                                      \c default_value_size is not specified.
00545      */
00546     virtual ErrorCode tag_get_handle( const char* name, int size, DataType type, Tag& tag_handle, unsigned flags = 0,
00547                                       const void* default_value = 0, bool* created = 0 );
00548 
00549     /**\brief same as non-const version, except that TAG_CREAT flag is ignored. */
00550     virtual ErrorCode tag_get_handle( const char* name, int size, DataType type, Tag& tag_handle, unsigned flags = 0,
00551                                       const void* default_value = 0 ) const;
00552 
00553     //! Gets the tag name string of the tag_handle.
00554     /** \param tag_handle Tag you want the name of.
00555         \param tag_name Name string of <em>tag_handle</em>.
00556 
00557         Example: \code
00558         Tag tag_handle = 0;
00559         std::string tag_name = "my_special_tag";
00560         tag_get_name( tag_handle, tag_name );  //gets the Tag from the tag's name string
00561         \endcode */
00562     virtual ErrorCode tag_get_name( const Tag tag_handle, std::string& tag_name ) const;
00563 
00564     /**\brief Gets the tag handle corresponding to a name
00565      *
00566      * If a tag of that name does not exist, returns MB_TAG_NOT_FOUND
00567      *   \param tag_name Name of the desired tag.
00568      *   \param tag_handle Tag handle corresponding to <em>tag_name</em>
00569      */
00570     virtual ErrorCode tag_get_handle( const char* tag_name, Tag& tag_handle ) const;
00571 
00572     //! Get handles for all tags defined on this entity
00573     virtual ErrorCode tag_get_tags_on_entity( const EntityHandle entity, std::vector< Tag >& tag_handles ) const;
00574 
00575     //! Get the size of the specified tag in bytes
00576     virtual ErrorCode tag_get_bytes( const Tag tag, int& tag_size ) const;
00577 
00578     //! Get the array length of a tag
00579     virtual ErrorCode tag_get_length( const Tag tag, int& tag_size ) const;
00580 
00581     //! Get the default value of the specified tag
00582     virtual ErrorCode tag_get_default_value( const Tag tag, void* def_val ) const;
00583     virtual ErrorCode tag_get_default_value( Tag tag, const void*& ptr, int& size ) const;
00584 
00585     //! get type of tag (sparse, dense, etc.; 0 = dense, 1 = sparse, 2 = bit, 3 = mesh)
00586     virtual ErrorCode tag_get_type( const Tag, TagType& tag_type ) const;
00587 
00588     /** \brief Get data type of tag.
00589      *
00590      * Get the type of the tag data.  The tag is data is assumed to
00591      * be a vector of this type.  If the tag data vetcor contains
00592      * more than one value, then the tag size must be a multiple of
00593      * the size of this type.
00594      * \param tag  The tag
00595      * \param type The type of the specified tag (output).
00596      */
00597     virtual ErrorCode tag_get_data_type( const Tag handle, DataType& type ) const;
00598 
00599     //! get handles for all tags defined
00600     virtual ErrorCode tag_get_tags( std::vector< Tag >& tag_handles ) const;
00601 
00602     virtual ErrorCode tag_get_data( const Tag tag_handle, const EntityHandle* entity_handles, const int num_entities,
00603                                     void* tag_data ) const;
00604 
00605     virtual ErrorCode tag_get_data( const Tag tag_handle, const Range& entity_handles, void* tag_data ) const;
00606 
00607     //! Sets the data of a given EntityHandle and Tag.
00608     /** If the <em>tag_handle</em> and the entity type of <em>entity_handle</em> are not
00609         compatible, data of <em>entity_handle</em> never existed and MB_FAILURE
00610         is returned.
00611         \param tag_handle Tag indicating what data is to be set.
00612         \param entity_handle EntityHandle on which to set tag's data.
00613         \param tag_data Data to set the <em>entity_handle</em>'s tag data to.
00614 
00615         Example: \code
00616         int tag_data = 1004;
00617         tag_set_data( tag_handle, entity_handle, &tag_data ); \endcode */
00618     virtual ErrorCode tag_set_data( Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
00619                                     const void* tag_data );
00620 
00621     virtual ErrorCode tag_set_data( Tag tag_handle, const Range& entity_handles, const void* tag_data );
00622 
00623     /**\brief Get pointers to tag data
00624      *
00625      * For a tag, get the values for a list of passed entity handles.
00626      *\note  This function may not be used for bit tags.
00627      *\param tag_handle     The tag
00628      *\param entity_handles An array of entity handles for which to retreive tag values.
00629      *\param num_entities   The length of the 'entity_handles' array.
00630      *\param tag_data       An array of 'const void*'.  Array must be at least
00631      *                      'num_entitities' long.  Array is populated (output)
00632      *                      with pointers to the internal storage for the
00633      *                      tag value corresponding to each entity handle.
00634      *\param tag_sizes      The length of each tag value.  Optional for
00635      *                      fixed-length tags.  Required for variable-length tags.
00636      */
00637     virtual ErrorCode tag_get_by_ptr( const Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
00638                                       const void** tag_data, int* tag_sizes = 0 ) const;
00639 
00640     /**\brief Get pointers to tag data
00641      *
00642      * For a tag, get the values for a list of passed entity handles.
00643      *\note  This function may not be used for bit tags.
00644      *\param tag_handle     The tag
00645      *\param entity_handles The entity handles for which to retreive tag values.
00646      *\param tag_data       An array of 'const void*'.  Array is populated (output)
00647      *                      with pointers to the internal storage for the
00648      *                      tag value corresponding to each entity handle.
00649      *\param tag_sizes      The length of each tag value.  Optional for
00650      *                      fixed-length tags.  Required for variable-length tags.
00651      */
00652     virtual ErrorCode tag_get_by_ptr( const Tag tag_handle, const Range& entity_handles, const void** tag_data,
00653                                       int* tag_sizes = 0 ) const;
00654 
00655     /**\brief Set tag data given an array of pointers to tag values.
00656      *
00657      * For a tag, set the values for a list of passed entity handles.
00658      *\note  This function may not be used for bit tags.
00659      *\param tag_handle     The tag
00660      *\param entity_handles An array of entity handles for which to set tag values.
00661      *\param num_entities   The length of the 'entity_handles' array.
00662      *\param tag_data       An array of 'const void*'.  Array must be at least
00663      *                      'num_entitities' long.  Array is expected to
00664      *                      contain pointers to tag values for the corresponding
00665      *                      EntityHandle in 'entity_handles'.
00666      *\param tag_sizes      The length of each tag value.  Optional for
00667      *                      fixed-length tags.  Required for variable-length tags.
00668      */
00669     virtual ErrorCode tag_set_by_ptr( Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
00670                                       void const* const* tag_data, const int* tag_sizes = 0 );
00671 
00672     /**\brief Set tag data given an array of pointers to tag values.
00673      *
00674      * For a tag, set the values for a list of passed entity handles.
00675      *\note  This function may not be used for bit tags.
00676      *\param tag_handle     The tag
00677      *\param entity_handles The entity handles for which to set tag values.
00678      *\param tag_data       An array of 'const void*'.  Array is expected to
00679      *                      contain pointers to tag values for the corresponding
00680      *                      EntityHandle in 'entity_handles'.
00681      *\param tag_sizes      The length of each tag value.  Optional for
00682      *                      fixed-length tags.  Required for variable-length tags.
00683      */
00684     virtual ErrorCode tag_set_by_ptr( Tag tag_handle, const Range& entity_handles, void const* const* tag_data,
00685                                       const int* tag_sizes = 0 );
00686 
00687     /**\brief Set tag data given value.
00688      *
00689      * For a tag, set the values for a list of passed entity handles to
00690      * the same, specified value.
00691      *
00692      *\param tag_handle     The tag
00693      *\param entity_handles The entity handles for which to set tag values.
00694      *\param tag_data       A pointer to the tag value.
00695      *\param tag_sizes      For variable-length tags, the lenght of the
00696      *                      tag value.  This argument will be ignored for
00697      *                      fixed-length tags.
00698      */
00699     virtual ErrorCode tag_clear_data( Tag tag_handle, const Range& entity_handles, const void* tag_data,
00700                                       int tag_size = 0 );
00701 
00702     /**\brief Set tag data given value.
00703      *
00704      * For a tag, set the values for a list of passed entity handles to
00705      * the same, specified value.
00706      *
00707      *\param tag_handle     The tag
00708      *\param entity_handles The entity handles for which to set tag values.
00709      *\param tag_data       A pointer to the tag value.
00710      *\param tag_sizes      For variable-length tags, the lenght of the
00711      *                      tag value.  This argument will be ignored for
00712      *                      fixed-length tags.
00713      */
00714     virtual ErrorCode tag_clear_data( Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
00715                                       const void* tag_data, int tag_size = 0 );
00716 
00717     //! Delete the data of a vector of entity handles and sparse tag
00718     /** Delete the data of a tag on a vector of entity handles.  Only sparse tag data are deleted
00719        with this function; dense tags are deleted by deleting the tag itself using tag_delete.
00720         \param tag_handle Handle of the (sparse) tag being deleted from entity
00721         \param entity_handles 1d vector of entity handles from which the tag is being deleted
00722         \param num_handles Number of entity handles in 1d vector
00723     */
00724     virtual ErrorCode tag_delete_data( Tag tag_handle, const EntityHandle* entity_handles, int num_entities );
00725 
00726     //! Delete the data of a range of entity handles and sparse tag
00727     /** Delete the data of a tag on a range of entity handles.  Only sparse tag data are deleted
00728        with this function; dense tags are deleted by deleting the tag itself using tag_delete.
00729         \param tag_handle Handle of the (sparse) tag being deleted from entity
00730         \param entity_range Range of entities from which the tag is being deleted
00731     */
00732     virtual ErrorCode tag_delete_data( Tag tag_handle, const Range& entity_handles );
00733 
00734     //! Removes the tag from the database and deletes all of its associated data.
00735     virtual ErrorCode tag_delete( Tag tag_handle );
00736 
00737     /**\brief Access tag data via direct pointer into contiguous blocks
00738      *
00739      * Iteratively obtain direct access to contiguous blocks of tag
00740      * storage.  This function cannot be used with bit tags because
00741      * of the compressed bit storage.  This function cannot be used
00742      * with variable length tags because it does not provide a mechanism
00743      * to determine the length of the value for each entity.  This
00744      * function may be used with sparse tags, but if it is used, it
00745      * will return data for a single entity at a time.
00746      *
00747      *\param tag_handle  The handle of the tag for which to access data
00748      *\param iter        The first entity for which to return data.
00749      *\param end         One past the last entity for which data is desired.
00750      *\param count       The number of entities for which data was returned
00751      *\param data_ptr    Output: pointer to tag storage.
00752      *\param allocate    If true, space for this tag will be allocated, if not it wont
00753      *
00754      *\Note If this function is called for entities for which no tag value
00755      *      has been set, but for which a default value exists, it will
00756      *      force the allocation of explicit storage for each such entity
00757      *      even though MOAB would normally not explicitly store tag values
00758      *      for such entities.
00759      *
00760      *\Example:
00761      *\code
00762      * Range ents; // range to iterate over
00763      * Tag tag; // tag for which to access data
00764      * int bytes;
00765      * ErrorCode err = mb.tag_get_size( tag, bytes );
00766      * if (err) { ... }
00767      *
00768      * ...
00769      * Range::iterator iter = ents.begin();
00770      * while (iter != ents.end()) {
00771      *   int count;
00772      *    // get contiguous block of tag dat
00773      *   void* ptr;
00774      *   err = mb.tag_iterate( tag, iter, ents.end(), count, ptr );
00775      *   if (err) { ... }
00776      *    // do something with tag data
00777      *   process_Data( ptr, count );
00778      *    // advance to next block of data
00779      *   iter += count;
00780      * }
00781      *\endcode
00782      */
00783     virtual ErrorCode tag_iterate( Tag tag_handle, Range::const_iterator iter, Range::const_iterator end, int& count,
00784                                    void*& data_ptr, bool allocate = true );
00785 
00786     //! creates a mesh set
00787     virtual ErrorCode create_meshset( const unsigned int options, EntityHandle& ms_handle, int start_id = 0 );
00788 
00789     //! Empty a vector of mesh set
00790     /** Empty a mesh set.
00791         \param ms_handles 1d vector of handles of sets being emptied
00792         \param num_meshsets Number of entities in 1d vector
00793     */
00794     virtual ErrorCode clear_meshset( const EntityHandle* ms_handles, const int num_meshsets );
00795 
00796     //! Empty a range of mesh set
00797     /** Empty a mesh set.
00798         \param ms_handles Range of handles of sets being emptied
00799     */
00800     virtual ErrorCode clear_meshset( const Range& ms_handles );
00801 
00802     //! get the options of a mesh set
00803     virtual ErrorCode get_meshset_options( const EntityHandle ms_handle, unsigned int& options ) const;
00804 
00805     //! set the options of a mesh set
00806     virtual ErrorCode set_meshset_options( const EntityHandle ms_handle, const unsigned int options );
00807 
00808     //! subtracts meshset2 from meshset1 - modifies meshset1
00809     virtual ErrorCode subtract_meshset( EntityHandle meshset1, const EntityHandle meshset2 );
00810 
00811     //! intersects meshset2 with meshset1 - modifies meshset1
00812     virtual ErrorCode intersect_meshset( EntityHandle meshset1, const EntityHandle meshset2 );
00813 
00814     //! unites meshset2 with meshset1 - modifies meshset1
00815     virtual ErrorCode unite_meshset( EntityHandle meshset1, const EntityHandle meshset2 );
00816 
00817     //! add entities to meshset
00818     virtual ErrorCode add_entities( EntityHandle meshset, const Range& entities );
00819 
00820     //! add entities to meshset
00821     virtual ErrorCode add_entities( EntityHandle meshset, const EntityHandle* entities, const int num_entities );
00822 
00823     //! remove entities from meshset
00824     virtual ErrorCode remove_entities( EntityHandle meshset, const Range& entities );
00825 
00826     //! remove entities from meshset
00827     virtual ErrorCode remove_entities( EntityHandle meshset, const EntityHandle* entities, const int num_entities );
00828 
00829     //! return true if all entities are contained in set
00830     virtual bool contains_entities( EntityHandle meshset, const EntityHandle* entities, int num_entities,
00831                                     const int operation_type = Interface::INTERSECT );
00832 
00833     //! replace entities
00834     virtual ErrorCode replace_entities( EntityHandle meshset, const EntityHandle* old_entities,
00835                                         const EntityHandle* new_entities, int num_entities );
00836 
00837     //------MeshSet Parent/Child functions------
00838 
00839     //! get parent meshsets
00840     virtual ErrorCode get_parent_meshsets( const EntityHandle meshset, std::vector< EntityHandle >& parents,
00841                                            const int num_hops = 1 ) const;
00842 
00843     //! get parent meshsets
00844     virtual ErrorCode get_parent_meshsets( const EntityHandle meshset, Range& parents, const int num_hops = 1 ) const;
00845 
00846     //! get child meshsets
00847     virtual ErrorCode get_child_meshsets( const EntityHandle meshset, std::vector< EntityHandle >& children,
00848                                           const int num_hops = 1 ) const;
00849 
00850     //! get child meshsets
00851     virtual ErrorCode get_child_meshsets( const EntityHandle meshset, Range& children, const int num_hops = 1 ) const;
00852 
00853     //! get contained meshsets
00854     virtual ErrorCode get_contained_meshsets( const EntityHandle meshset, std::vector< EntityHandle >& children,
00855                                               const int num_hops = 1 ) const;
00856 
00857     //! get contained meshsets
00858     virtual ErrorCode get_contained_meshsets( const EntityHandle meshset, Range& children,
00859                                               const int num_hops = 1 ) const;
00860 
00861     //! gets number of parent meshsets
00862     virtual ErrorCode num_parent_meshsets( const EntityHandle meshset, int* number, const int num_hops = 1 ) const;
00863 
00864     //! gets number of child meshsets
00865     virtual ErrorCode num_child_meshsets( const EntityHandle meshset, int* number, const int num_hops = 1 ) const;
00866 
00867     //! gets number of contained meshsets
00868     virtual ErrorCode num_contained_meshsets( const EntityHandle meshset, int* number, const int num_hops = 1 ) const;
00869 
00870     //! add a parent meshset
00871     virtual ErrorCode add_parent_meshset( EntityHandle meshset, const EntityHandle parent_meshset );
00872 
00873     //! add parent meshsets
00874     virtual ErrorCode add_parent_meshsets( EntityHandle meshset, const EntityHandle* parents, int count );
00875 
00876     //! add a child meshset
00877     virtual ErrorCode add_child_meshset( EntityHandle meshset, const EntityHandle child_meshset );
00878 
00879     //! add parent meshsets
00880     virtual ErrorCode add_child_meshsets( EntityHandle meshset, const EntityHandle* children, int count );
00881 
00882     //! adds 'parent' to child's parent list and adds 'child' to parent's child list
00883     virtual ErrorCode add_parent_child( EntityHandle parent, EntityHandle child );
00884 
00885     //! removes 'parent' to child's parent list and removes 'child' to parent's child list
00886     virtual ErrorCode remove_parent_child( EntityHandle parent, EntityHandle child );
00887 
00888     //! remove parent meshset
00889     virtual ErrorCode remove_parent_meshset( EntityHandle meshset, const EntityHandle parent_meshset );
00890 
00891     //! remove child meshset
00892     virtual ErrorCode remove_child_meshset( EntityHandle meshset, const EntityHandle child_meshset );
00893 
00894     // ************************  tag  information ***************
00895 
00896     //! return various specific tag handles
00897     Tag material_tag();
00898     Tag neumannBC_tag();
00899     Tag dirichletBC_tag();
00900     Tag globalId_tag();
00901     Tag geom_dimension_tag();
00902 
00903     //! get/set the number of nodes
00904     // int total_num_nodes() const;
00905     // void total_num_nodes(const int val);
00906 
00907     //! get/set the number of elements
00908     // int total_num_elements() const;
00909     // void total_num_elements(const int val);
00910 
00911     // ************************  structured sequence  information ***************
00912 
00913     //! return a reference to the sequence manager
00914     SequenceManager* sequence_manager()
00915     {
00916         return sequenceManager;
00917     }
00918     const SequenceManager* sequence_manager() const
00919     {
00920         return sequenceManager;
00921     }
00922 
00923     /// create structured sequence
00924     ErrorCode create_scd_sequence( const HomCoord& coord_min, const HomCoord& coord_max, EntityType type,
00925                                    EntityID start_id_hint, EntityHandle& first_handle_out,
00926                                    EntitySequence*& sequence_out );
00927 
00928     ErrorCode add_vsequence( EntitySequence* vert_seq, EntitySequence* elem_seq, const HomCoord& p1, const HomCoord& q1,
00929                              const HomCoord& p2, const HomCoord& q2, const HomCoord& p3, const HomCoord& q3,
00930                              bool bb_input = false, const HomCoord* bb_min = NULL, const HomCoord* bb_max = NULL );
00931 
00932     //! return the a_entity_factory pointer
00933     AEntityFactory* a_entity_factory()
00934     {
00935         return aEntityFactory;
00936     }
00937     const AEntityFactory* a_entity_factory() const
00938     {
00939         return aEntityFactory;
00940     }
00941 
00942 #ifdef MOAB_HAVE_AHF
00943     HalfFacetRep* a_half_facet_rep()
00944     {
00945         return ahfRep;
00946     }
00947     const HalfFacetRep* a_half_facet_rep() const
00948     {
00949         return ahfRep;
00950     }
00951 #endif
00952 
00953     //! return set of registered IO tools
00954     ReaderWriterSet* reader_writer_set()
00955     {
00956         return readerWriterSet;
00957     }
00958 
00959     //-----------------MeshSet Interface Functions------------------//
00960 
00961     void print( const EntityHandle handle, const char* prefix, bool first_call = true ) const;
00962 
00963     ErrorCode print_entity_tags( std::string indent_prefix, const EntityHandle handle, TagType tp ) const;
00964 
00965     virtual ErrorCode get_last_error( std::string& info ) const;
00966 
00967     virtual std::string get_error_string( const ErrorCode code ) const;
00968 
00969     //! check all adjacencies for consistency
00970     ErrorCode check_adjacencies();
00971 
00972     //! check some adjacencies for consistency
00973     ErrorCode check_adjacencies( const EntityHandle* ents, int num_ents );
00974 
00975     //! return whether the input handle is valid or not
00976     bool is_valid( const EntityHandle this_ent ) const;
00977 
00978     /** \brief Create an iterator over the set
00979      * Create a new iterator that iterates over entities with the specified type or dimension.
00980      * Only one of ent_type or dim can be set; use dim=-1 or ent_type=MBMAXTYPE for the other.
00981      * Iterators for list-type (ordered) sets are stable over set modification, unless entity
00982      * removed or deleted is the one at the current position of the iterator.  If the check_valid
00983      * parameter is passed as true, entities are checked for validity before being passed back by
00984      * get_next_entities function (checking entity validity can have a non-negligible cost).
00985      *
00986      * Iterators returned by this function can be deleted using the normal C++ delete function.
00987      * After creating the iterator through this function, further interactions are through methods
00988      * on the SetIterator class.
00989      * \param meshset The entity set associated with this iterator (use 0 for whole instance)
00990      * \param ent_type Entity type associated with this iterator
00991      * \param ent_dim Dimension associated with this iterator
00992      * \param chunk_size Chunk size of the iterator
00993      * \param check_valid If true, entities are checked for validity before being returned
00994      */
00995     virtual ErrorCode create_set_iterator( EntityHandle meshset, EntityType ent_type, int ent_dim, int chunk_size,
00996                                            bool check_valid, SetIterator*& set_iter );
00997 
00998     /** \brief Remove the set iterator from the instance's list
00999      * \param set_iter Set iterator being removed
01000      */
01001     ErrorCode remove_set_iterator( SetIterator* set_iter );
01002 
01003     /** \brief Get all set iterators associated with the set passed in
01004      * \param meshset Meshset for which iterators are requested
01005      * \param set_iters Set iterators for the set
01006      */
01007     ErrorCode get_set_iterators( EntityHandle meshset, std::vector< SetIterator* >& set_iters );
01008 
01009     //-----------------Memory Functions------------------//
01010 
01011     /**\brief Calculate amount of memory used to store MOAB data
01012      *
01013      * This function calculates the amount of memory used to store
01014      * MOAB data.
01015      *
01016      * There are two possible values for each catagory of memory use.
01017      * The exact value and the amortized value.  The exact value is the
01018      * amount of memory used to store the data for the specified entities.
01019      * The amortized value includes the exact value and an amortized
01020      * estimate of the memory consumed in overhead for storing the values
01021      * (indexing structures, access structures, etc.)
01022      *
01023      * Note: If ent_array is NULL, the total memory used by MOAB for storing
01024      *       data will be returned in the address pointed to by
01025      *       total_amortized_storage, if total_amortized_storage is not NULL.
01026      *
01027      *\param ent_array Array of entities for which to estimate the memory use.
01028      *                 If NULL, estimate is done for all entities.
01029      *\param num_ents The length of ent_array.  Not used if ent_rray is NULL.
01030      *\param total_(amortized_)storage The sum of the memory entity, adjacency, and all tag storage.
01031      *\param (amortized_)entity_storage The storage for the entity definitions
01032      *                 (connectivity arrays for elements, coordinates for vertices,
01033      *                  list storage within sets, etc.)
01034      *\param (amortized_)adjacency_storage The storage for adjacency data.
01035      *\param tag_array  An array of tags for which to calculate the memory use.
01036      *\param num_tags   The lenght of tag_array
01037      *\param (amortized_)tag_storage If tag_array is not NULL, then one value
01038      *                   for each tag specifying the memory used for storing that
01039      *                   tag.  If tag_array is NULL and this value is not, the
01040      *                   location at which to store the total memory used for
01041      *                   all tags.
01042      */
01043     void estimated_memory_use( const EntityHandle* ent_array = 0, unsigned long num_ents = 0,
01044                                unsigned long long* total_storage = 0, unsigned long long* total_amortized_storage = 0,
01045                                unsigned long long* entity_storage = 0, unsigned long long* amortized_entity_storage = 0,
01046                                unsigned long long* adjacency_storage           = 0,
01047                                unsigned long long* amortized_adjacency_storage = 0, const Tag* tag_array = 0,
01048                                unsigned num_tags = 0, unsigned long long* tag_storage = 0,
01049                                unsigned long long* amortized_tag_storage = 0 );
01050 
01051     /**\brief Calculate amount of memory used to store MOAB data
01052      *
01053      * This function calculates the amount of memory used to store
01054      * MOAB data.
01055      *
01056      * There are two possible values for each catagory of memory use.
01057      * The exact value and the amortized value.  The exact value is the
01058      * amount of memory used to store the data for the specified entities.
01059      * The amortized value includes the exact value and an amortized
01060      * estimate of the memory consumed in overhead for storing the values
01061      * (indexing structures, access structures, etc.)
01062      *
01063      *\param ents      Entities for which to estimate the memory use.
01064      *\param total_(amortized_)storage The sum of the memory entity, adjacency, and all tag storage.
01065      *\param (amortized_)entity_storage The storage for the entity definitions
01066      *                 (connectivity arrays for elements, coordinates for vertices,
01067      *                  list storage within sets, etc.)
01068      *\param (amortized_)adjacency_storage The storage for adjacency data.
01069      *\param tag_array  An array of tags for which to calculate the memory use.
01070      *\param num_tags   The lenght of tag_array
01071      *\param (amortized_)tag_storage If tag_array is not NULL, then one value
01072      *                   for each tag specifying the memory used for storing that
01073      *                   tag.  If tag_array is NULL and this value is not, the
01074      *                   location at which to store the total memory used for
01075      *                   all tags.
01076      */
01077     void estimated_memory_use( const Range& ents, unsigned long long* total_storage = 0,
01078                                unsigned long long* total_amortized_storage = 0, unsigned long long* entity_storage = 0,
01079                                unsigned long long* amortized_entity_storage    = 0,
01080                                unsigned long long* adjacency_storage           = 0,
01081                                unsigned long long* amortized_adjacency_storage = 0, const Tag* tag_array = 0,
01082                                unsigned num_tags = 0, unsigned long long* tag_storage = 0,
01083                                unsigned long long* amortized_tag_storage = 0 );
01084 
01085     void print_database() const;
01086 
01087     /** \name Sequence Option controllers */
01088 
01089     /**@{*/
01090 
01091     /** \brief Interface to control memory allocation for sequences
01092      * Provide a factor that controls the size of the sequence that gets allocated.
01093      * This is typically useful in the parallel setting when a-priori, the number of ghost entities
01094      * and the memory required for them within the same sequence as the owned entities are unknown.
01095      * The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
01096      * have broken sequences.
01097      */
01098     virtual double get_sequence_multiplier() const;
01099 
01100     /** \brief Interface to control memory allocation for sequences
01101      * Provide a factor that controls the size of the sequence that gets allocated.
01102      * This is typically useful in the parallel setting when a-priori, the number of ghost entities
01103      * and the memory required for them within the same sequence as the owned entities are unknown.
01104      * The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
01105      * have broken sequences.
01106      *
01107      * \param meshset User specified multiplier (should be greater than 1.0)
01108      */
01109     virtual void set_sequence_multiplier( double factor );
01110 
01111     /**@}*/
01112 
01113   private:
01114     /**\brief Do not allow copying */
01115     Core( const Core& copy );
01116     /**\brief Do not allow copying */
01117     Core& operator=( const Core& copy );
01118 
01119     void estimated_memory_use_internal( const Range* ents, unsigned long long* total_storage,
01120                                         unsigned long long* total_amortized_storage, unsigned long long* entity_storage,
01121                                         unsigned long long* amortized_entity_storage,
01122                                         unsigned long long* adjacency_storage,
01123                                         unsigned long long* amortized_adjacency_storage, const Tag* tag_array,
01124                                         unsigned num_tags, unsigned long long* tag_storage,
01125                                         unsigned long long* amortized_tag_storage );
01126 
01127     //! database init and de-init routines
01128     ErrorCode initialize();
01129     void deinitialize();
01130 
01131     //! return the entity set representing the whole mesh
01132     EntityHandle get_root_set();
01133 
01134     //!\brief Clean up after a file reader returns failure.
01135     //!
01136     //! Delete all entities not contained in initial_entities
01137     //! and all tags not contained in initial_tags.
01138     void clean_up_failed_read( const Range& initial_ents, std::vector< Tag > initial_tags );
01139 
01140     // other interfaces for MB
01141     WriteUtil* mMBWriteUtil;
01142     ReadUtil* mMBReadUtil;
01143     ScdInterface* scdInterface;
01144 
01145     //! store the total number of elements defined in this interface
01146     // int totalNumElements;
01147 
01148     //! store the total number of nodes defined in this interface
01149     // int totalNumNodes;
01150 
01151     //! the overall geometric dimension of this mesh
01152     int geometricDimension;
01153 
01154     Tag materialTag;
01155     Tag neumannBCTag;
01156     Tag dirichletBCTag;
01157     Tag geomDimensionTag;
01158     Tag globalIdTag;
01159 
01160     //! tag server for this interface
01161     std::list< TagInfo* > tagList;
01162     inline bool valid_tag_handle( const TagInfo* t ) const
01163     {
01164         return std::find( tagList.begin(), tagList.end(), t ) != tagList.end();
01165     }
01166 
01167     SequenceManager* sequenceManager;
01168 
01169     AEntityFactory* aEntityFactory;
01170 
01171     ReaderWriterSet* readerWriterSet;
01172 
01173     Error* mError;
01174     bool mpiFinalize;
01175     int writeMPELog;
01176     bool initErrorHandlerInCore;
01177 
01178     //! list of iterators
01179     std::vector< SetIterator* > setIterators;
01180 
01181 #ifdef MOAB_HAVE_AHF
01182     HalfFacetRep* ahfRep;
01183     bool mesh_modified;
01184 #endif
01185 };
01186 
01187 }  // namespace moab
01188 
01189 #endif  // MOAB_IMPL_GENERAL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines