FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_NodeDatabase.hpp
1 #ifndef _NodeDatabase_hpp_
2 #define _NodeDatabase_hpp_
3 
4 /*--------------------------------------------------------------------*/
5 /* Copyright 2005 Sandia Corporation. */
6 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
7 /* non-exclusive license for use of this work by or on behalf */
8 /* of the U.S. Government. Export of this program may require */
9 /* a license from the United States Government. */
10 /*--------------------------------------------------------------------*/
11 
12 #include "fei_macros.hpp"
13 #include "fei_fwd.hpp"
14 #include "fei_defs.h"
15 #include "fei_NodeDescriptor.hpp"
16 #include "fei_Pool_alloc.hpp"
17 #include "fei_mpi.h"
18 
19 #include <map>
20 
66 class NodeDatabase {
67  public:
69  NodeDatabase(std::map<int,int>* fieldDatabase,
70  NodeCommMgr* nodeCommMgr);
71 
73  virtual ~NodeDatabase();
74 
78  int getNumNodeDescriptors() const { return( nodePtrs_.size() ); };
79 
83  std::map<GlobalID,int>& getNodeIDs() { return( nodeIDs_ ); };
84 
94  int getNodeWithID(GlobalID nodeID, const NodeDescriptor*& node) const;
95  int getNodeWithID(GlobalID nodeID, NodeDescriptor*& node);
96 
106  int getNodeWithNumber(int nodeNumber, const NodeDescriptor*& node) const;
107 
114  int getNodeWithEqn(int eqnNumber, const NodeDescriptor*& node) const;
115 
121  void getNodeAtIndex(int i, const NodeDescriptor*& node) const;
122  void getNodeAtIndex(int i, NodeDescriptor*& node);
123 
129  int countLocalNodalEqns(int localRank);
130 
137  int countLocalNodeDescriptors(int localRank);
138 
144  int getIndexOfID(GlobalID nodeID) const;
145 
153  int initNodeID(GlobalID nodeID);
154 
162  int initNodeIDs(GlobalID* nodeIDs, int numNodes);
163 
177  int synchronize(int firstLocalNodeNumber,
178  int firstLocalEqn,
179  int localRank,
180  MPI_Comm comm);
181 
185  int getAssociatedNodeNumber(int eqnNumber);
186 
190  int getAssociatedFieldID(int eqnNumber);
191 
193  bool isSynchronized() { return( synchronized_ ); };
194 
195  private:
196  NodeDatabase(const NodeDatabase& src);
197  NodeDatabase& operator=(const NodeDatabase& src);
198 
199  void deleteMemory();
200 
201  std::vector<NodeDescriptor*> nodePtrs_;
202 
203  std::vector<int> eqnNumbers_; //eqnNumbers_ will be a sorted list of the
204  //first global equation number at each node
205  //in nodePtrs_.
206  //the relationship between eqnNumbers_ and
207  std::vector<int> eqnNodeIndices_; //eqnNodeIndices_ is like this:
208  //if eqn == eqnNumbers_[i], then
209  // nodePtrs_[eqnNodeIndices_[i]] points to
210  // the node with 'eqn'
211 
212  std::map<GlobalID,int> nodeIDs_; //nodeIDs_ maps node-ID to an index into
213  //the nodePtrs_ array of NodeDescriptors.
214 
215  std::map<int,int> nodeNumbers_;
216 
217  bool synchronized_;
218  bool need_to_alloc_and_sync_;
219 
220  std::map<int,int>* fieldDB_;
221  NodeCommMgr* nodeCommMgr_;
222 
223  int numLocalNodes_;
224  int firstLocalNodeNumber_, lastLocalNodeNumber_;
225 
227 };
228 
229 #endif
virtual ~NodeDatabase()
int countLocalNodeDescriptors(int localRank)
std::map< GlobalID, int > & getNodeIDs()
int getNodeWithNumber(int nodeNumber, const NodeDescriptor *&node) const
int initNodeID(GlobalID nodeID)
int getNodeWithEqn(int eqnNumber, const NodeDescriptor *&node) const
int synchronize(int firstLocalNodeNumber, int firstLocalEqn, int localRank, MPI_Comm comm)
NodeDatabase(std::map< int, int > *fieldDatabase, NodeCommMgr *nodeCommMgr)
int getIndexOfID(GlobalID nodeID) const
void getNodeAtIndex(int i, const NodeDescriptor *&node) const
int countLocalNodalEqns(int localRank)
int getAssociatedFieldID(int eqnNumber)
int getAssociatedNodeNumber(int eqnNumber)
int getNumNodeDescriptors() const
int getNodeWithID(GlobalID nodeID, const NodeDescriptor *&node) const
int initNodeIDs(GlobalID *nodeIDs, int numNodes)