FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_NodeCommMgr.hpp
1 #ifndef _NodeCommMgr_hpp_
2 #define _NodeCommMgr_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_fwd.hpp>
13 
14 #include <fei_CommUtils.hpp>
15 
37 class NodeCommMgr : public fei::MessageHandler<int> {
38  public:
39  enum { STRICTLY_LOW_PROC, PROC_WITH_LOCAL_ELEM, CALLER_SPECIFIES };
40 
41  NodeCommMgr(MPI_Comm comm, const SNL_FEI_Structure& problemStructure, int sharedNodeOwnership=STRICTLY_LOW_PROC);
42  virtual ~NodeCommMgr();
43 
44  size_t getNumSharedNodes() {return(sharedNodeIDs.size());}
45  std::vector<GlobalID>& getLocalNodeIDs() {return(localNodeIDs);}
46  std::vector<GlobalID>& getSharedNodeIDs() {return(sharedNodeIDs);}
47  std::vector<int>& getSharedNodeNumbers() {return(sharedNodeNumbers);}
48 
49  int getSharedNodeIndex_num(int nodeNumber);
50 
51  int addSharedNodes(const GlobalID* nodeIDs, int numNodes,
52  const int* const* procs, const int* numProcs);
53 
54  int initComplete(NodeDatabase& nodeDB, bool safetyCheck);
55 
56  int informLocal(const NodeDescriptor& node);
57 
58  int exchangeEqnInfo();
59 
60  int getSharedNodeIndex(GlobalID nodeID);
61 
62  int getSharedNodeNumSubdomains(GlobalID nodeID);
63  std::vector<int>* getSharedNodeSubdomainList(GlobalID nodeID);
64 
65  NodeDescriptor& getSharedNodeAtIndex(int index)
66  {return(*(sharedNodes_[index]));}
67 
68  std::vector<int>& getSharedNodeProcs(int index)
69  {return(*(sharingProcs_[index]));};
70 
71  void setSharedOwnershipRule(int ownershipRule)
72  { sharedNodeOwnership_ = ownershipRule; }
73 
74  std::vector<int>& getSendProcs();
75  std::vector<int>& getRecvProcs();
76 
77  int getSendMessageLength(int destProc, int& messageLength);
78  int getSendMessage(int destProc, std::vector<int>& message);
79  int processRecvMessage(int srcProc, std::vector<int>& message);
80 
81  private:
82  NodeCommMgr(const NodeCommMgr& src);
83  NodeCommMgr& operator=(const NodeCommMgr& src);
84 
85  int allocateNodeDescriptorPtrs(NodeDatabase& nodeDB);
86 
87  int storeNodeProcs(int index, std::vector<std::vector<int>*>& procTable,
88  const int* procs, int numProcs);
89 
90  int checkSharedNodeInfo();
91 
92  int checkCommArrays(const char* whichCheck,
93  std::vector<int>& globalRemoteProcs,
94  std::vector<int>& globalNodesPerRemoteProc,
95  std::vector<int>& globalRemoteProcLengths,
96  std::vector<int>& nodesPerRemoteProc,
97  std::vector<int>& remoteProcs);
98 
99  void setNodeNumbersArray();
100 
101  void packLocalNodesAndData(int* data, int proc,
102  int numNodes, int len);
103  void packRemoteNodesAndData(GlobalID* data, int proc,
104  int numNodes, int len);
105 
106  int adjustSharedOwnership();
107 
108  int createProcLists();
109 
110  int createProcList(std::vector<int>& itemsPerProc,
111  std::vector<int>& procs);
112 
113  int exchangeSharedRemoteFieldsBlks();
114 
115  int getGlobalMaxFieldsBlocks(int& maxFields, int& maxBlocks);
116 
117  int getGlobalMaxFieldsBlocksSubdomains();
118 
119  NodeDescriptor** sharedNodes_;
120  bool sharedNodesAllocated_;
121 
122  int sharedNodeOwnership_;
123 
124  std::vector<GlobalID> localNodeIDs;
125  std::vector<GlobalID> remoteNodeIDs;
126 
127  std::vector<GlobalID> sharedNodeIDs; //global node identifiers
128 
129  std::vector<std::vector<int> > sharedNodeSubdomains;
130  //subdomains each shared node
131  //appears in.
132  std::vector<int> trivialSubdomainList;
133 
134  std::vector<std::vector<int>*> sharingProcs_;//table, i-th row is a list of procs
135  //associated with i-th shared node
136 
137  std::vector<int> sharedNodeNumbers;
138 
139  std::vector<int> remoteOwnerProcs_, remoteSharingProcs_;
140  std::vector<int> nodesPerOwnerProc_, nodesPerSharingProc_;
141 
142  MPI_Comm comm_;
143  int numProcs_, localProc_;
144 
145  int maxFields_;
146  int maxBlocks_;
147  int maxSubdomains_;
148 
149  bool initCompleteCalled_;
150  const SNL_FEI_Structure& probStruc;
151 };
152 
153 #endif
154 
std::vector< int > & getSendProcs()
int getSendMessage(int destProc, std::vector< int > &message)
std::vector< int > & getRecvProcs()
int getSendMessageLength(int destProc, int &messageLength)
int processRecvMessage(int srcProc, std::vector< int > &message)