MOAB: Mesh Oriented datABase  (version 5.3.0)
ReadUtilIface.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_READ_UTIL_IFACE_HPP
00017 #define MOAB_READ_UTIL_IFACE_HPP
00018 
00019 #include <vector>
00020 #include <string>
00021 #include "moab/Types.hpp"
00022 #include "moab/Compiler.hpp"
00023 
00024 namespace moab
00025 {
00026 
00027 class Range;
00028 
00029 //! Interface implemented in MOAB which provides memory for mesh reading utilities
00030 class ReadUtilIface
00031 {
00032   public:
00033     //! Constructor
00034     ReadUtilIface() {}
00035 
00036     //! Destructor
00037     virtual ~ReadUtilIface() {}
00038 
00039     //! Given a requested number of vertices and number of coordinates, returns
00040     //! memory space which will be used to store vertex coordinates and information
00041     //! about what handles those new vertices are assigned; allows direct read of
00042     //! coordinate data into memory
00043     //! \param num_arrays Number of node position arrays requested
00044     //! \param num_nodes Number of nodes
00045     //! \param preferred_start_id Preferred integer id starting value
00046     //! \param actual_start_handle Actual starting id value
00047     //! \param arrays STL vector of double*'s, point to memory storage to be used for
00048     //!     these vertices
00049     //! \param sequence_size If specified, allocate this sequence size instead of
00050     //!      SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE
00051     //! \return status Success/failure of this call
00052     virtual ErrorCode get_node_coords( const int num_arrays, const int num_nodes, const int preferred_start_id,
00053                                        EntityHandle& actual_start_handle, std::vector< double* >& arrays,
00054                                        const int sequence_size = -1 ) = 0;
00055 
00056     //! Given requested number of elements, element type, and number of
00057     //! elements, returns pointer to memory space allocated to store connectivity
00058     //! of those elements; allows direct read of connectivity data into memory
00059     //! \param num_elements Number of elements being requested
00060     //! \param verts_per_element Number of vertices per element (incl. higher-order nodes)
00061     //! \param mdb_type Element type
00062     //! \param preferred_start_id Preferred integer id for first element
00063     //! \param actual_start_handle Actual integer id for first element (returned)
00064     //! \param array Pointer to memory allocated for storing connectivity for these elements
00065     //! \param sequence_size If specified, allocate this sequence size instead of
00066     //!      SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE
00067     //! \return status Success/failure of this call
00068     virtual ErrorCode get_element_connect( const int num_elements, const int verts_per_element,
00069                                            const EntityType mdb_type, const int preferred_start_id,
00070                                            EntityHandle& actual_start_handle, EntityHandle*& array,
00071                                            int sequence_size = -1 ) = 0;
00072 
00073     /**
00074      *\brief Gather entities related to those in the partition
00075      * Gather entities related to those in the input partition. Related
00076      * means down-adjacent to, contained in, etc.
00077      * \param partition Entities for which to gather related entities
00078      * \param related_ents Related entities
00079      * \param file_set If non-NULL, entity sets contained in this set will be checked;
00080      *        otherwise, all sets in the instance will be checked
00081      */
00082     virtual ErrorCode gather_related_ents( Range& partition, Range& related_ents, EntityHandle* file_set = NULL ) = 0;
00083 
00084     virtual ErrorCode create_entity_sets( EntityID num_sets, const unsigned* set_flags, EntityID preffered_start_id,
00085                                           EntityHandle& actual_start_handle ) = 0;
00086 
00087     //! Update adjacencies
00088     //! Given information about new elements, adjacency information will be updated
00089     //! in MOAB. Think of this function as a way of Readers telling MOAB what elements are
00090     //! new because we aren't using the Interface to create elements.
00091     //! \param start_handle Handle of first new element
00092     //! \param number_elements Number of new elements
00093     //! \param number_vertices_per_element Number of vertices in each new element
00094     //! \param conn_array Connectivity of new elements
00095     //! \return status Success/failure of this call
00096     virtual ErrorCode update_adjacencies( const EntityHandle start_handle, const int number_elements,
00097                                           const int number_vertices_per_element, const EntityHandle* conn_array ) = 0;
00098 
00099     /**\brief Re-order incoming element connectivity
00100      *
00101      * Permute the connectivity of each element such that the node
00102      * order is that of MBCN rather than the target file format.
00103      *\param order The permutation to use.  Must be an array of 'node_per_elem'
00104      *             integers and be a permutation of the values [0..node_per_elem-1].
00105      *             Such that for a single element:
00106      *             mbcn_conn[order[i]] == target_conn[i]
00107      *\param conn  The connectivity array to re-order
00108      *\param num_elem  The number of elements in the connectivity array
00109      *\param node_per_elem The number of nodes in each element's connectivity list.
00110      */
00111     static inline void reorder( const int* order, EntityHandle* conn, int num_elem, int node_per_elem );
00112 
00113     //! Given an ordered list of bounding entities and the sense of
00114     //! those entities, return an ordered list of vertices
00115     virtual ErrorCode get_ordered_vertices( EntityHandle* bound_ents, int* sense, int num_bound, int dim,
00116                                             EntityHandle* bound_verts, EntityType& etype ) = 0;
00117 
00118     //! Assign sequential IDS to entities in range and store IDs in tag
00119     virtual ErrorCode assign_ids( Tag id_tag, const Range& ents, int start = 0 ) = 0;
00120 
00121     //! Assign to each entity in an array the ID that is its position
00122     //! in the array plus the value of 'start'.  For any non-zero handles
00123     //! in the array, store the ID value in the passed tag.
00124     virtual ErrorCode assign_ids( Tag id_tag, const EntityHandle* ents, size_t num_ents, int start = 0 ) = 0;
00125 
00126     //! Create a new gather set with tag GATHER_SET
00127     virtual ErrorCode create_gather_set( EntityHandle& gather_set ) = 0;
00128 
00129     //! Get entity handle of an existing gather set
00130     virtual ErrorCode get_gather_set( EntityHandle& gather_set ) = 0;
00131 };
00132 
00133 inline void ReadUtilIface::reorder( const int* order, EntityHandle* conn, int num_elem, int node_per_elem )
00134 {
00135     std::vector< EntityHandle > elem( node_per_elem );
00136     EntityHandle* const end = conn + num_elem * node_per_elem;
00137     while( conn != end )
00138     {
00139         std::copy( conn, conn + node_per_elem, elem.begin() );
00140         for( int j = 0; j < node_per_elem; ++j )
00141             conn[order[j]] = elem[j];
00142         conn += node_per_elem;
00143     }
00144 }
00145 
00146 }  // namespace moab
00147 
00148 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines