fei_NodeDatabase.hpp

00001 #ifndef _NodeDatabase_hpp_
00002 #define _NodeDatabase_hpp_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 #include "fei_macros.hpp"
00013 #include "fei_fwd.hpp"
00014 #include "fei_defs.h"
00015 #include "fei_NodeDescriptor.hpp"
00016 #include "fei_Pool_alloc.hpp"
00017 #include "fei_mpi.h"
00018 
00019 #include <map>
00020 
00066 class NodeDatabase {
00067  public:
00069   NodeDatabase(std::map<int,int>* fieldDatabase,
00070          NodeCommMgr* nodeCommMgr);
00071 
00073   virtual ~NodeDatabase();
00074 
00078   int getNumNodeDescriptors() const { return( nodePtrs_.size() ); };
00079 
00083   std::map<GlobalID,int>& getNodeIDs() { return( nodeIDs_ ); };
00084 
00094   int getNodeWithID(GlobalID nodeID, const NodeDescriptor*& node) const;
00095   int getNodeWithID(GlobalID nodeID, NodeDescriptor*& node);
00096 
00106   int getNodeWithNumber(int nodeNumber, const NodeDescriptor*& node) const;
00107 
00114   int getNodeWithEqn(int eqnNumber, const NodeDescriptor*& node) const;
00115 
00121   int getNodeAtIndex(int i, const NodeDescriptor*& node) const;
00122   int getNodeAtIndex(int i, NodeDescriptor*& node);
00123 
00129   int countLocalNodalEqns(int localRank);
00130 
00137   int countLocalNodeDescriptors(int localRank);
00138 
00144   int getIndexOfID(GlobalID nodeID) const;
00145 
00153   int initNodeID(GlobalID nodeID);
00154 
00162   int initNodeIDs(GlobalID* nodeIDs, int numNodes);
00163 
00177   int synchronize(int firstLocalNodeNumber,
00178       int firstLocalEqn,
00179       int localRank,
00180       MPI_Comm comm);
00181 
00185   int getAssociatedNodeNumber(int eqnNumber);
00186 
00190   int getAssociatedFieldID(int eqnNumber);
00191 
00193   bool isSynchronized() { return( synchronized_ ); };
00194 
00195  private:
00196   NodeDatabase(const NodeDatabase& src);
00197   NodeDatabase& operator=(const NodeDatabase& src);
00198 
00199   void deleteMemory();
00200 
00201   std::vector<NodeDescriptor*> nodePtrs_;
00202 
00203   std::vector<int> eqnNumbers_;  //eqnNumbers_ will be a sorted list of the
00204                                   //first global equation number at each node
00205                                   //in nodePtrs_.
00206                                   //the relationship between eqnNumbers_ and
00207   std::vector<int> eqnNodeIndices_;  //eqnNodeIndices_ is like this:
00208                                   //if eqn == eqnNumbers_[i], then
00209                                   //  nodePtrs_[eqnNodeIndices_[i]] points to
00210                                   //  the node with 'eqn'
00211 
00212   std::map<GlobalID,int> nodeIDs_; //nodeIDs_ maps node-ID to an index into
00213                                 //the nodePtrs_ array of NodeDescriptors.
00214 
00215   std::map<int,int> nodeNumbers_;
00216 
00217   bool synchronized_;
00218   bool need_to_alloc_and_sync_;
00219 
00220   std::map<int,int>* fieldDB_;
00221   NodeCommMgr* nodeCommMgr_;
00222 
00223   int numLocalNodes_;
00224   int firstLocalNodeNumber_, lastLocalNodeNumber_;
00225 
00226   fei_Pool_alloc<NodeDescriptor> nodePool_;
00227 };
00228 
00229 #endif

Generated on Tue Jul 13 09:27:45 2010 for FEI by  doxygen 1.4.7