fei_NodeCommMgr.hpp

00001 #ifndef _NodeCommMgr_hpp_
00002 #define _NodeCommMgr_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_fwd.hpp>
00013 
00014 #include <fei_CommUtils.hpp>
00015 
00037 class NodeCommMgr : public fei::MessageHandler<int> {
00038  public:
00039    enum { STRICTLY_LOW_PROC, PROC_WITH_LOCAL_ELEM };
00040 
00041    NodeCommMgr(MPI_Comm comm, int sharedNodeOwnership=STRICTLY_LOW_PROC);
00042    virtual ~NodeCommMgr();
00043 
00044    size_t getNumSharedNodes() {return(sharedNodeIDs.size());}
00045    std::vector<GlobalID>& getLocalNodeIDs() {return(localNodeIDs);}
00046    std::vector<GlobalID>& getSharedNodeIDs() {return(sharedNodeIDs);}
00047    std::vector<int>& getSharedNodeNumbers() {return(sharedNodeNumbers);}
00048 
00049    int getSharedNodeIndex_num(int nodeNumber);
00050 
00051    int addSharedNodes(const GlobalID* nodeIDs, int numNodes,
00052           const int* const* procs, const int* numProcs);
00053 
00054    int initComplete(NodeDatabase& nodeDB, bool safetyCheck);
00055 
00056    int informLocal(const NodeDescriptor& node);
00057 
00058    int exchangeEqnInfo();
00059 
00060    int getSharedNodeIndex(GlobalID nodeID);
00061 
00062    int getSharedNodeNumSubdomains(GlobalID nodeID);
00063    std::vector<int>* getSharedNodeSubdomainList(GlobalID nodeID);
00064 
00065    NodeDescriptor& getSharedNodeAtIndex(int index)
00066      {return(*(sharedNodes_[index]));}
00067 
00068    std::vector<int>& getSharedNodeProcs(int index) 
00069      {return(*(sharingProcs_[index]));};
00070 
00071    void setSharedOwnershipRule(int ownershipRule)
00072      { sharedNodeOwnership_ = ownershipRule; }
00073 
00074    std::vector<int>& getSendProcs();
00075    std::vector<int>& getRecvProcs();
00076 
00077    int getSendMessageLength(int destProc, int& messageLength);
00078    int getSendMessage(int destProc, std::vector<int>& message);
00079    int processRecvMessage(int srcProc, std::vector<int>& message);
00080 
00081  private:
00082    NodeCommMgr(const NodeCommMgr& src);
00083    NodeCommMgr& operator=(const NodeCommMgr& src);
00084 
00085    int allocateNodeDescriptorPtrs(NodeDatabase& nodeDB);
00086 
00087    int storeNodeProcs(int index, std::vector<std::vector<int>*>& procTable,
00088           const int* procs, int numProcs);
00089 
00090    int checkSharedNodeInfo();
00091 
00092    int checkCommArrays(const char* whichCheck,
00093            std::vector<int>& globalRemoteProcs,
00094            std::vector<int>& globalNodesPerRemoteProc,
00095            std::vector<int>& globalRemoteProcLengths,
00096            std::vector<int>& nodesPerRemoteProc,
00097            std::vector<int>& remoteProcs);
00098 
00099    void setNodeNumbersArray();
00100 
00101    void packLocalNodesAndData(int* data, int proc,
00102                              int numNodes, int len);
00103    void packRemoteNodesAndData(GlobalID* data, int proc,
00104                              int numNodes, int len);
00105 
00106    int adjustSharedOwnership();
00107 
00108    int createProcLists();
00109 
00110    int createProcList(std::vector<int>& itemsPerProc,
00111            std::vector<int>& procs);
00112 
00113    int exchangeSharedRemoteFieldsBlks();
00114 
00115    int getGlobalMaxFieldsBlocks(int& maxFields, int& maxBlocks);
00116 
00117    int getGlobalMaxFieldsBlocksSubdomains();
00118 
00119    NodeDescriptor** sharedNodes_;
00120    bool sharedNodesAllocated_;
00121 
00122    int sharedNodeOwnership_;
00123 
00124    std::vector<GlobalID> localNodeIDs;
00125    std::vector<GlobalID> remoteNodeIDs;
00126 
00127    std::vector<GlobalID> sharedNodeIDs; //global node identifiers
00128 
00129    std::vector<std::vector<int> > sharedNodeSubdomains;
00130                                           //subdomains each shared node
00131                                           //appears in.
00132    std::vector<int> trivialSubdomainList;
00133 
00134    std::vector<std::vector<int>*> sharingProcs_;//table, i-th row is a list of procs
00135                                           //associated with i-th shared node
00136 
00137    std::vector<int> sharedNodeNumbers;
00138 
00139    std::vector<int> remoteOwnerProcs_, remoteSharingProcs_;
00140    std::vector<int> nodesPerOwnerProc_, nodesPerSharingProc_;
00141 
00142    MPI_Comm comm_;
00143    int numProcs_, localProc_;
00144 
00145    int maxFields_;
00146    int maxBlocks_;
00147    int maxSubdomains_;
00148 
00149    bool initCompleteCalled_;
00150 };
00151 
00152 #endif
00153 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:24 2011 for FEI by  doxygen 1.6.3