18 #define fei_file "fei_NodeDatabase.cpp"
26 eqnNumbers_(0), eqnNodeIndices_(),
30 need_to_alloc_and_sync_(true),
31 fieldDB_(fieldDatabase),
32 nodeCommMgr_(nodeCommMgr),
34 firstLocalNodeNumber_(-1), lastLocalNodeNumber_(-1),
48 for(
size_t i=0; i<
nodePtrs_.size(); ++i) {
85 std::map<int,int>::const_iterator iter =
nodeNumbers_.find(nodeNumber);
93 int index = iter->second;
102 int insertPoint = -1;
108 else if (insertPoint > 0) {
122 if (numNodeFields <= 0)
return(-1);
126 int lastFieldSize = (*fieldDB_)[lastFieldOnNode];
131 if (eqnNumber <= lastEqnOnNode)
return(0);
140 if (i>=0 && i < nnodes) {
152 if (i>=0 && i < nnodes) {
165 for(
size_t i=0; i<
nodePtrs_.size(); i++) {
172 for(
int j=0; j<numFields; j++) {
173 int numParams = (*fieldDB_)[fieldIDList[j]];
175 numEqns += numParams;
187 for(
size_t i=0; i<
nodePtrs_.size(); i++) {
188 if (
nodePtrs_[i]->getOwnerProc() == localRank) numLocal++;
197 std::map<GlobalID,int>::const_iterator
200 if (iter ==
nodeIDs_.end())
return(-1);
202 return( iter->second );
211 std::map<GlobalID,int>::iterator
212 iter =
nodeIDs_.lower_bound(nodeID);
214 if (iter ==
nodeIDs_.end() || iter->first != nodeID) {
215 nodeIDs_.insert(iter, std::make_pair(nodeID,index));
235 for(
int i=0; i<numNodes; i++) {
255 int nodeNumber = firstLocalNodeNumber;
261 std::map<GlobalID,int>::iterator
264 for(; iter!=iter_end; ++iter) {
265 int i = iter->second;
268 if (node==NULL)
continue;
274 int firstEqnNumber, eqnNumber;
276 for(
int j=0; j<numFields; j++) {
277 int numFieldParams = (*fieldDB_)[fieldIDList[j]];
278 numNodalDOF += numFieldParams;
281 eqnNumber = firstLocalEqn + numEqns;
282 if (j==0) firstEqnNumber = eqnNumber;
284 numEqns += numFieldParams;
295 if (insertPoint == -2)
ERReturn(-2);
318 for(
int i=0; i<numSharedNodes; i++) {
330 if (insertPoint == -2)
ERReturn(-2);
334 nodeNumbers_.insert(std::make_pair(thisNodeNumber, index));
346 int insertPoint = -1;
353 if (insertPoint > 0) {
359 int lastEqn = fieldEqnNumbers[numFields-1];
362 std::map<int,int>::const_iterator f_iter
363 =
fieldDB_->find(fieldIDList[numFields-1]);
365 fieldSize = (*f_iter).second;
369 if (eqnNumber >= fieldEqnNumbers[0] && (lastEqn+fieldSize - 1) >= eqnNumber) {
382 int insertPoint = -1;
386 if (index2 < 0) index2 = insertPoint-1;
396 int lastEqn = fieldEqnNumbers[numFields-1];
399 std::map<int,int>::const_iterator f_iter
400 =
fieldDB_->find(fieldIDList[numFields-1]);
402 fieldSize = (*f_iter).second;
406 if (eqnNumber < fieldEqnNumbers[0] || eqnNumber > lastEqn+fieldSize) {
411 for(
int i=0; i<numFields-1; i++) {
412 if (eqnNumber >= fieldEqnNumbers[i] && eqnNumber < fieldEqnNumbers[i+1]) {
413 return(fieldIDList[i]);
419 return(fieldIDList[numFields-1]);
bool need_to_alloc_and_sync_
int sortedListInsert(const T &item, std::vector< T > &list)
int countLocalNodeDescriptors(int localRank)
std::vector< NodeDescriptor * > nodePtrs_
int getNodeWithNumber(int nodeNumber, const NodeDescriptor *&node) const
int getNumNodalDOF() const
int initNodeID(GlobalID nodeID)
NodeCommMgr * nodeCommMgr_
const int * getFieldIDList() const
std::map< GlobalID, int > nodeIDs_
void construct(U *p, const U &val)
const int * getFieldEqnNumbers() const
void setFieldEqnNumber(int fieldID, int eqn)
std::vector< int > eqnNumbers_
NodeDescriptor & getSharedNodeAtIndex(int index)
void deallocate(pointer p, size_type n)
int binarySearch(const T &item, const T *list, int len)
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
void setGlobalNodeID(GlobalID node)
pointer allocate(size_type n, const void *hint=NULL)
GlobalID getGlobalNodeID() const
std::vector< int > eqnNodeIndices_
void setNumNodalDOF(int dof)
int countLocalNodalEqns(int localRank)
std::map< int, int > * fieldDB_
void setNodeNumber(int nn)
int getAssociatedFieldID(int eqnNumber)
int firstLocalNodeNumber_
int getAssociatedNodeNumber(int eqnNumber)
int getNodeWithID(GlobalID nodeID, const NodeDescriptor *&node) const
size_t getNumSharedNodes()
fei_Pool_alloc< NodeDescriptor > nodePool_
int getNodeNumber() const
std::map< int, int > nodeNumbers_
int initNodeIDs(GlobalID *nodeIDs, int numNodes)