Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshPointIdToGlobalIdMap.hpp
Go to the documentation of this file.
1 
9 #ifndef MESHPOINTIDTOGLOBALIDMAP_HPP_
10 #define MESHPOINTIDTOGLOBALIDMAP_HPP_
11 
12 #include <map>
13 #include <utility>
14 
15 namespace Rocstar { namespace Rocin { namespace Utilities {
16 
17 
18 
20  {
21  private:
22  std::map< std::pair< int, int >, int > local2global;
23 
24  public:
25 
31 
35  ~MeshPointIdToGlobalIdMap( ){ this ->local2global.clear( ); }
36 
44  inline bool exists( const int meshPaneId, const int meshPointId )
45  {
46  std::pair< int, int > keyPair = std::make_pair( meshPaneId, meshPointId );
47  if( this ->local2global.find( keyPair ) != this ->local2global.end( ) )
48  return true;
49  else
50  return false;
51  }
52 
61  inline int getGlobalId( const int meshPaneId, const int meshPointId )
62  {
63  std::pair< int, int > keyPair = std::make_pair( meshPaneId, meshPointId );
64  if( this ->local2global.find( keyPair ) != this ->local2global.end( ) )
65  return( this ->local2global[ keyPair ] );
66  else
67  return(-1);
68  }
69 
80  inline void insert( const int meshPaneId, const int meshPointId, const int globalId )
81  {
82 
83 // std::cout << "Mesh Pane Id: " << meshPaneId << " ";
84 // std::cout << "Mesh Point Id: " << meshPointId << " ";
85 // std::cout << std::endl;
86 // std::cout.flush( );
87 
88  #ifdef ASSERT_ON
89  assert( globalId >= 0 );
90  assert( meshPointId >= 0);
91  assert( !this ->exists( meshPaneId, meshPointId ) );
92  #endif
93 
94  std::pair< int, int > keyPair = std::make_pair( meshPaneId, meshPointId );
95  this ->local2global[ keyPair ] = globalId;
96 
97  #ifdef ASSERT_ON
98  assert( this ->exists( meshPaneId, meshPointId ) );
99  #endif
100 
101  }
102 
108  inline int size( ) const { return this ->local2global.size( ); }
109 
110 
111  };
112 
113 } } }
114 
115 #endif /* MESHPOINTIDTOGLOBALIDMAP_HPP_ */
bool exists(const int meshPaneId, const int meshPointId)
Checks if the point meshPointId of the mesh associated with the provided meshPaneId exists in this Me...
int getGlobalId(const int meshPaneId, const int meshPointId)
Returns the assigned global id to meshPointId of the mesh associated with the provided meshPaneId...
void insert(const int meshPaneId, const int meshPointId, const int globalId)
This method constructs a new key-pair for the meshPaneId and meshPointId which maps into globalId and...
Definition: Rocin.h:64