MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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, 00053 const int num_nodes, 00054 const int preferred_start_id, 00055 EntityHandle& actual_start_handle, 00056 std::vector< double* >& arrays, 00057 const int sequence_size = -1 ) = 0; 00058 00059 //! Given requested number of elements, element type, and number of 00060 //! elements, returns pointer to memory space allocated to store connectivity 00061 //! of those elements; allows direct read of connectivity data into memory 00062 //! \param num_elements Number of elements being requested 00063 //! \param verts_per_element Number of vertices per element (incl. higher-order nodes) 00064 //! \param mdb_type Element type 00065 //! \param preferred_start_id Preferred integer id for first element 00066 //! \param actual_start_handle Actual integer id for first element (returned) 00067 //! \param array Pointer to memory allocated for storing connectivity for these elements 00068 //! \param sequence_size If specified, allocate this sequence size instead of 00069 //! SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE 00070 //! \return status Success/failure of this call 00071 virtual ErrorCode get_element_connect( const int num_elements, 00072 const int verts_per_element, 00073 const EntityType mdb_type, 00074 const int preferred_start_id, 00075 EntityHandle& actual_start_handle, 00076 EntityHandle*& array, 00077 int sequence_size = -1 ) = 0; 00078 00079 /** 00080 *\brief Gather entities related to those in the partition 00081 * Gather entities related to those in the input partition. Related 00082 * means down-adjacent to, contained in, etc. 00083 * \param partition Entities for which to gather related entities 00084 * \param related_ents Related entities 00085 * \param file_set If non-NULL, entity sets contained in this set will be checked; 00086 * otherwise, all sets in the instance will be checked 00087 */ 00088 virtual ErrorCode gather_related_ents( Range& partition, Range& related_ents, EntityHandle* file_set = NULL ) = 0; 00089 00090 virtual ErrorCode create_entity_sets( EntityID num_sets, 00091 const unsigned* set_flags, 00092 EntityID preffered_start_id, 00093 EntityHandle& actual_start_handle ) = 0; 00094 00095 //! Update adjacencies 00096 //! Given information about new elements, adjacency information will be updated 00097 //! in MOAB. Think of this function as a way of Readers telling MOAB what elements are 00098 //! new because we aren't using the Interface to create elements. 00099 //! \param start_handle Handle of first new element 00100 //! \param number_elements Number of new elements 00101 //! \param number_vertices_per_element Number of vertices in each new element 00102 //! \param conn_array Connectivity of new elements 00103 //! \return status Success/failure of this call 00104 virtual ErrorCode update_adjacencies( const EntityHandle start_handle, 00105 const int number_elements, 00106 const int number_vertices_per_element, 00107 const EntityHandle* conn_array ) = 0; 00108 00109 /**\brief Re-order incoming element connectivity 00110 * 00111 * Permute the connectivity of each element such that the node 00112 * order is that of MBCN rather than the target file format. 00113 *\param order The permutation to use. Must be an array of 'node_per_elem' 00114 * integers and be a permutation of the values [0..node_per_elem-1]. 00115 * Such that for a single element: 00116 * mbcn_conn[order[i]] == target_conn[i] 00117 *\param conn The connectivity array to re-order 00118 *\param num_elem The number of elements in the connectivity array 00119 *\param node_per_elem The number of nodes in each element's connectivity list. 00120 */ 00121 static inline void reorder( const int* order, EntityHandle* conn, int num_elem, int node_per_elem ); 00122 00123 //! Given an ordered list of bounding entities and the sense of 00124 //! those entities, return an ordered list of vertices 00125 virtual ErrorCode get_ordered_vertices( EntityHandle* bound_ents, 00126 int* sense, 00127 int num_bound, 00128 int dim, 00129 EntityHandle* bound_verts, 00130 EntityType& etype ) = 0; 00131 00132 //! Assign sequential IDS to entities in range and store IDs in tag 00133 virtual ErrorCode assign_ids( Tag id_tag, const Range& ents, int start = 0 ) = 0; 00134 00135 //! Assign to each entity in an array the ID that is its position 00136 //! in the array plus the value of 'start'. For any non-zero handles 00137 //! in the array, store the ID value in the passed tag. 00138 virtual ErrorCode assign_ids( Tag id_tag, const EntityHandle* ents, size_t num_ents, int start = 0 ) = 0; 00139 00140 //! Create a new gather set with tag GATHER_SET 00141 virtual ErrorCode create_gather_set( EntityHandle& gather_set ) = 0; 00142 00143 //! Get entity handle of an existing gather set 00144 virtual ErrorCode get_gather_set( EntityHandle& gather_set ) = 0; 00145 }; 00146 00147 inline void ReadUtilIface::reorder( const int* order, EntityHandle* conn, int num_elem, int node_per_elem ) 00148 { 00149 std::vector< EntityHandle > elem( node_per_elem ); 00150 EntityHandle* const end = conn + num_elem * node_per_elem; 00151 while( conn != end ) 00152 { 00153 std::copy( conn, conn + node_per_elem, elem.begin() ); 00154 for( int j = 0; j < node_per_elem; ++j ) 00155 conn[order[j]] = elem[j]; 00156 conn += node_per_elem; 00157 } 00158 } 00159 00160 } // namespace moab 00161 00162 #endif