45 #define fei_file "SNL_FEI_Structure.cpp"
56 fieldDatabase_(new std::map<int,int>),
63 activeNodesInitialized_(false),
66 globalBlkEqnOffsets_(),
74 globalNumNodesVanished_(),
75 localVanishedNodeNumbers_(),
83 numLocalNodalEqns_(0),
88 numLocalReducedRows_(0),
94 reducedEqnCounter_(0),
95 reducedRHSCounter_(0),
99 structureFinalized_(false),
100 generateGraph_(true),
101 sysMatIndices_(NULL),
103 numGlobalEqnBlks_(0),
105 numLocalReducedEqnBlks_(0),
107 localReducedBlkOffset_(0),
108 globalMaxBlkSize_(0),
109 firstLocalNodeNumber_(-1),
111 sysBlkMatIndices_(NULL),
112 matIndicesDestroyed_(false),
114 blkEqnMapper_(new snl_fei::PointBlockMap()),
117 checkSharedNodes_(false),
122 dbgOStreamPtr_(NULL),
123 setDbgOutCalled_(true)
149 const char* param = NULL;
153 std::string str(param);
174 numParams,paramStrings);
176 if (!strcmp(param,
"LowNumberedProc")) {
179 if (!strcmp(param,
"ProcWithLocalElem")) {
182 if (!strcmp(param,
"SierraSpecifies")) {
194 delete (*slaveVars_)[j];
228 const char* path,
const char* feiName)
238 if (feiName != NULL) {
256 for(
size_t i=0; i<
blockIDs_.size(); i++) {
281 if (err)
return(NULL);
291 if (err)
return(NULL);
298 int& interleaveStrategy,
int& lumpingStrategy,
299 int& numElemDOF,
int& numElements,
300 int& numNodesPerElem,
int& numEqnsPerElem)
305 interleaveStrategy = -1;
306 lumpingStrategy = -1;
309 numNodesPerElem = -1;
334 fei::console_out() <<
"SNL_FEI_Structure::getEqnNumber: ERROR, node with nodeNumber "
335 << nodeNumber <<
" doesn't have fieldID " << fieldID <<
FEI_ENDL;
341 if (isSlave)
return(-1);
349 if (eqn < 0)
return(-1);
353 for(
int i=0; i<len-1; i++) {
362 const int *fieldSizes,
364 const int *fieldTypes)
370 ostr <<
"FEI: initFields" <<
FEI_ENDL
374 for(nf=0; nf<numFields; nf++) {
375 ostr <<fieldSizes[nf] <<
" ";
377 ostr << FEI_ENDL <<
"#field-ids" <<
FEI_ENDL;
378 for(nf=0; nf<numFields; nf++) {
379 ostr << fieldIDs[nf] <<
" ";
381 if (fieldTypes != NULL) {
382 ostr << FEI_ENDL <<
"#field-types" <<
FEI_ENDL;
383 for(nf=0; nf<numFields; nf++) {
384 ostr << fieldTypes[nf] <<
" ";
390 for (
int i=0; i<numFields; i++) {
391 fieldDatabase_->insert(std::pair<int,int>(fieldIDs[i], fieldSizes[i]));
395 if (fieldIDs[i] >= 0) {
396 if (fieldTypes != NULL) {
411 int numNodesPerElement,
412 const int* numFieldsPerNode,
413 const int*
const* nodalFieldIDs,
414 int numElemDofFieldsPerElement,
415 const int* elemDofFieldIDs,
416 int interleaveStrategy)
424 os <<
"#numNodesPerElement"<< FEI_ENDL <<numNodesPerElement <<
FEI_ENDL;
425 os <<
"#numFieldsPerNode -- one entry per node " <<
FEI_ENDL;
426 for(nn=0; nn<numNodesPerElement; nn++) os << numFieldsPerNode[nn]<<
" ";
427 os << FEI_ENDL <<
"#nodalFieldIDs -- one row per node" <<
FEI_ENDL;
428 for(nn=0; nn<numNodesPerElement; ++nn) {
429 for(nf=0; nf<numFieldsPerNode[nn]; ++nf) os << nodalFieldIDs[nn][nf] <<
" ";
432 os <<
"#numElemDofFieldsPerElement" << FEI_ENDL
433 << numElemDofFieldsPerElement<<
FEI_ENDL;
434 os <<
"#elemDofFieldIDs -- 'numElemDofFieldsPerElement' entries" <<
FEI_ENDL;
435 for(nn=0; nn<numElemDofFieldsPerElement; ++nn) {
436 os << elemDofFieldIDs[nn] <<
" ";
438 if (numElemDofFieldsPerElement > 0) os <<
FEI_ENDL;
439 os <<
"#interleaveStrategy" << FEI_ENDL << interleaveStrategy <<
FEI_ENDL;
456 int numNodalEqns = 0;
458 std::vector<int> distinctFields(0);
460 for(j=0; j<numNodesPerElement; j++) {
463 for(
int k = 0; k < numFieldsPerNode[j]; k++) {
469 nodalFieldIDs[j][k] <<
" has negative size. " <<
FEI_ENDL;
472 countDOF += fieldSize;
475 fieldsPerNodePtr[j] = numFieldsPerNode[j];
476 numNodalEqns += countDOF;
481 int numElemDOFPerElement = 0;
482 for(j=0; j<numElemDofFieldsPerElement; j++) {
485 fei::console_out() <<
"SNL_FEI_Structure::initElemBlock ERROR: elemDoffieldID " <<
486 elemDofFieldIDs[j] <<
" has negative size. " <<
FEI_ENDL;
489 numElemDOFPerElement += fieldSize;
501 for (j = 0; j < numNodesPerElement; j++) {
502 for(
int k = 0; k < numFieldsPerNode[j]; k++) {
503 fieldIDsTablePtr[j][k] = nodalFieldIDs[j][k];
509 if (numElements > 0) {
524 os <<
"#blkID"<<FEI_ENDL<<(int)elemBlockID<<FEI_ENDL<<
"#elmID"<<FEI_ENDL
535 std::map<GlobalID,int>& elemIDList = connTable.
elemIDs;
538 int elemIndex = elemIDList.size();
539 std::map<GlobalID,int>::iterator
540 iter = elemIDList.find(elemID);
542 bool redundantElem =
false;
544 if (iter != elemIDList.end()) {
545 elemIndex = iter->second;
546 redundantElem =
true;
549 elemIDList.insert(std::make_pair(elemID,elemIndex));
557 for(
int nn=0; nn<numNodes; nn++) os << (
int)elemConn[nn] <<
" ";
566 int offset = elemIndex*numNodes;
567 for(
int j=0; j<numNodes; j++) {
568 if ( conn[offset+j] != elemConn[j]) {
569 fei::console_out() <<
"SNL_FEI_Structure::initElem ERROR, elemID " << (int)elemID
570 <<
" registered more than once, with differing connectivity."
577 int offset = elemIndex*numNodes;
578 for(
int j = 0; j < numNodes; j++) {
579 conn[offset+j] = elemConn[j];
591 int offsetIntoSlaveField,
594 const int* masterFieldIDs,
595 const double* weights,
600 os <<
"FEI: initSlaveVariable" <<
FEI_ENDL;
601 os <<
"#slvNodeID" << FEI_ENDL << (int)slaveNodeID << FEI_ENDL
602 <<
"#slvFieldID"<< FEI_ENDL << slaveFieldID << FEI_ENDL
603 <<
"#offsetIntoSlvField" << FEI_ENDL << offsetIntoSlaveField << FEI_ENDL
604 <<
"#numMasterNodes" << FEI_ENDL << numMasterNodes << FEI_ENDL
605 <<
"#masterNodeIDs" << FEI_ENDL;
607 for(nn=0; nn<numMasterNodes; ++nn) {
608 os <<(int)masterNodeIDs[nn]<<
" ";
610 os << FEI_ENDL <<
"#masterFieldIDs" <<
FEI_ENDL;
611 for(nn=0; nn<numMasterNodes; ++nn) {
612 os <<masterFieldIDs[nn] <<
" ";
614 os << FEI_ENDL <<
"#field-sizes" <<
FEI_ENDL;
615 for(nn=0; nn<numMasterNodes; ++nn) {
619 os << FEI_ENDL <<
"#weights" <<
FEI_ENDL;
621 for(nn=0; nn<numMasterNodes; ++nn) {
623 for(
int j=0; j<size; ++j) {
624 os << weights[offset++] <<
" ";
627 os << FEI_ENDL <<
"#rhsValue" << FEI_ENDL << rhsValue <<
FEI_ENDL;
640 for(
int i=0; i<numMasterNodes; i++) {
646 for(
int j=0; j<fieldSize; j++) {
670 const int* numProcsPerNode,
671 const int *
const *sharingProcIDs)
675 os <<
"FEI: initSharedNodes"<<
FEI_ENDL;
676 os <<
"#n-nodes"<<FEI_ENDL<<numSharedNodes<<
FEI_ENDL;
677 os <<
"#num-procs-per-node"<<
FEI_ENDL;
679 for(nn=0; nn<numSharedNodes; ++nn) {
680 os << numProcsPerNode[nn] <<
" ";
682 os << FEI_ENDL <<
"#following lines: nodeID sharing-procs" <<
FEI_ENDL;
683 for(nn=0; nn<numSharedNodes; nn++) {
684 os << (int)sharedNodeIDs[nn]<<
" ";
685 for(
int np=0; np<numProcsPerNode[nn]; np++) os<<sharingProcIDs[nn][np]<<
" ";
688 os <<
"#end shared nodes"<<
FEI_ENDL;
695 sharingProcIDs, numProcsPerNode) );
708 for(
int i=0; i<numSharedNodes; ++i) {
710 if (
connTables_[nc]->elem_conn_ids == NULL)
continue;
712 if (len < 1)
continue;
716 for(
int j=0; j<len; ++j) {
717 if (conn_ids[j] == sharedNodeIDs[i]) {
740 for(nn=0; nn<numCRNodes; nn++) {
741 os << (int)CRNodes[nn]<<
" ";
743 os << FEI_ENDL<<
"#fields:"<<
FEI_ENDL;
744 for(nn=0; nn<numCRNodes; nn++) {
745 os << CRFields[nn]<<
" ";
761 std::vector<GlobalID>& CRNodeArray = multCR.
getMasters();
764 for(
int j = 0; j < numCRNodes; j++) {
765 CRNodeArray.push_back(CRNodes[j]);
766 CRFieldArray.push_back(CRFields[j]);
782 os <<
"initCRPen, numCRNodes: "<<numCRNodes<<
FEI_ENDL;
783 for(
int nn=0; nn<numCRNodes; nn++) {
784 os <<
" crNodeID: "<<(int)CRNodes[nn]<<
", field: "<<CRFields[nn]<<FEI_ENDL;
798 std::vector<GlobalID>& CRNodesArray = penCR.
getMasters();
802 for(
int i = 0; i < numCRNodes; i++) {
803 CRNodesArray.push_back(CRNodes[i]);
804 CRFieldArray.push_back(CRFields[i]);
820 if (err != 0)
return(
false);
836 if (index >= 0)
return(
true);
943 os <<
"FEI: initComplete" <<
FEI_ENDL;
971 os <<
"# numMultCRs: " << numLocalMultCRs_ <<
", numElemDOF: "
1046 catch (std::runtime_error& exc) {
1109 catch(std::runtime_error& exc) {
1122 os <<
"# after eqnCommMgr_->exchangeIndices, numRecvEqns: "
1126 for(i=0; i<numRecvEqns; i++) {
1127 int eqn = recvEqnNumbers[i];
1129 fei::console_out() <<
"SNL_FEI_Structure::initComplete: ERROR, recvEqn " << eqn
1136 for(
size_t j=0; j<recvEqns[i]->size(); j++) {
1143 os <<
"# leaving formMatrixStructure" <<
FEI_ENDL;
1156 os <<
"# initElemBlockStructure" <<
FEI_ENDL;
1157 os <<
"# numElemBlocks: " << numBlocks <<
FEI_ENDL;
1160 for (
int bIndex = 0; bIndex < numBlocks; bIndex++) {
1166 std::vector<int> scatterIndices(numEqns);
1171 std::map<GlobalID,int>& elemIDList = connTable.
elemIDs;
1178 os <<
"# block " << bIndex <<
", numElems: " << numBlockElems<<
FEI_ENDL;
1180 for(
int elemIndex = 0; elemIndex < numBlockElems; elemIndex++) {
1183 &scatterIndices[0]);
1214 std::vector<int>& rowLengths)
1230 std::vector<int>& ptRowLengths,
1231 int** blkColIndices,
1233 std::vector<int>& blkRowLengths,
1234 std::vector<int>& numPtRowsPerBlkRow)
1237 if (err != 0)
return(-1);
1242 int numRows = ptRowLengths.size();
1243 blkRowLengths.resize(numRows);
1244 numPtRowsPerBlkRow.assign(numRows, 1);
1246 blkRowLengths.resize(ptRowLengths.size());
1247 for(
size_t ii=0; ii<ptRowLengths.size(); ++ii) {
1248 blkRowLengths[ii] = ptRowLengths[ii];
1251 for(
int i=0; i<numRows; i++) {
1252 blkColIndices[i] = ptColIndices[i];
1260 int numPtEqns = ptEqns->size();
1262 std::map<int,int>::const_iterator
1263 pteq = ptEqns->begin();
1265 int lastBlkRow = -1;
1267 for(
int jj=0; jj<numPtEqns; ++jj, ++pteq) {
1268 int ptEqn = (*pteq).first;
1279 if (blkRow == lastBlkRow)
continue;
1288 int* theseColIndices = ptColIndices[localPtEqn];
1290 for(
int colj=0; colj<rowLength; colj++) {
1294 <<
"SNL_FEI_Structure::getMatrixStructure ERROR pt row "
1295 << ptEqn <<
", pt col "
1296 << ptColIndices[localPtEqn][colj]
1297 <<
" doesn't have a corresponding block" <<
FEI_ENDL;
1302 sysBlkIndices.
insert2(blkCol);
1305 lastBlkRow = blkRow;
1316 &(blkIndices_1D[offset]));
1317 offset += blkRowLengths[i];
1329 std::vector<int>& slaveEqns)
1335 for(
int i=0; i<numFields; ++i) {
1337 for(
int eqn=0; eqn<fieldSize; ++eqn) {
1338 int thisEqn = fieldEqns[i] + eqn;
1359 fei::console_out() <<
"ERROR, findNodeDescriptor unable to find node " << (int)nodeID
1392 std::map<GlobalID,ConstraintType*>::const_iterator
1396 while(cr_iter != cr_end) {
1401 std::vector<GlobalID>& CRNode_vec = multCR.
getMasters();
1402 GlobalID *CRNodePtr = &CRNode_vec[0];
1404 int* CRFieldPtr = &CRField_vec[0];
1407 int reducedCrEqn = 0;
1412 for(
int j=0; j<lenList; j++) {
1414 int fieldID = CRFieldPtr[j];
1417 if(nodePtr==NULL)
continue;
1476 std::map<GlobalID,ConstraintType*>::const_iterator
1480 while(cr_iter != cr_end) {
1484 std::vector<GlobalID>& CRNode_vec = penCR.
getMasters();
1485 GlobalID* CRNodesPtr = &CRNode_vec[0];
1488 int* CRFieldPtr = &CRField_vec[0];
1493 for(
int i = 0; i < lenList; i++) {
1495 int iField = CRFieldPtr[i];
1498 if(!iNodePtr)
continue;
1501 for(
int j = 0; j < lenList; j++) {
1503 int jField = CRFieldPtr[j];
1506 if(!jNodePtr)
continue;
1547 fei::console_out() <<
"FEI error, attempt to store indices for field ("<<fieldID
1548 <<
") with size "<<numEqns<<
FEI_ENDL;
1552 for(
int i=0; i<numEqns; i++) {
1567 int iEqn = -1, jEqn = -1;
1573 if (iNumParams < 1 || jNumParams < 1) {
1574 fei::console_out() <<
"FEI ERROR, attempt to store indices for field with non-positive size"
1575 <<
" field "<<iField<<
", size "<<iNumParams<<
", field "<<jField<<
", size "
1580 for(
int i=0; i<iNumParams; i++) {
1583 for(
int j=0; j<jNumParams; j++) {
1599 int iEqn = -1, jEqn = -1;
1605 if (iNumParams < 1 || jNumParams < 1) {
1606 fei::console_out() <<
"FEI ERROR, attempt to store indices for field with non-positive size"
1607 <<
" field "<<iField<<
", size "<<iNumParams<<
", field "<<jField<<
", size "
1612 for(
int i=0; i<iNumParams; i++) {
1614 int reducedRow = -1;
1616 if (isSlave)
continue;
1618 for(
int j=0; j<jNumParams; j++) {
1620 int reducedCol = -1;
1622 if (isSlave)
continue;
1646 if (numParams < 1) {
1647 fei::console_out() <<
"FEI error, attempt to store indices for field ("<<fieldID
1648 <<
") with size "<<numParams<<
FEI_ENDL;
1652 int reducedEqn = -1;
1654 if (isSlave)
return;
1656 for(
int j=0; j<numParams; j++) {
1657 int reducedCol = -1;
1659 if (isSlave)
continue;
1668 int fieldID,
int eqn)
1678 if (numParams < 1) {
1679 fei::console_out() <<
"FEI error, attempt to store indices for field ("<<fieldID
1680 <<
") with size "<<numParams<<
FEI_ENDL;
1684 int reducedEqn = -1;
1686 if (isSlave)
return;
1688 for(
int j=0; j<numParams; j++) {
1689 int reducedRow = -1;
1691 if (isSlave)
continue;
1713 int len = scatterIndices.size();
1714 bool anySlaves =
false;
1716 for(
int is=0; is<len; is++) {
1718 if (
rSlave_[is] == 1) anySlaves =
true;
1728 int* scatterPtr = &scatterIndices[0];
1731 for(
int j=0; j<len; j++) {
1735 for(
int i=0; i<len; i++) {
1736 int row = scatterPtr[i];
1743 for(
int jj=0; jj<len; jj++) {
1744 int col = scatterPtr[jj];
1748 for(
int ii=0; ii<len; ii++) {
1749 int rowi = scatterPtr[ii];
1752 if (
rSlave_[ii] == 1)
continue;
1764 for(
int kk=0; kk<len; kk++) {
1765 int colk = scatterPtr[kk];
1767 if (
rSlave_[kk] != 1)
continue;
1775 int reducedRow = -1;
1778 bool rowIsLocal =
true;
1785 for(
int j=0; j<len; j++) {
1786 if (
rSlave_[j] == 1)
continue;
1804 catch(std::runtime_error& exc) {
1827 int len = scatterIndices.size();
1828 bool anySlaves =
false;
1830 for(
int is=0; is<len; is++) {
1832 if (
rSlave_[is] == 1) anySlaves =
true;
1842 int* scatterPtr = &scatterIndices[0];
1845 for(
int j=0; j<len; j++) {
1849 for(
int i=0; i<len; i++) {
1850 int row = scatterPtr[i];
1857 for(
int jj=0; jj<len; jj++) {
1858 int col = scatterPtr[jj];
1862 for(
int ii=0; ii<len; ii++) {
1863 int rowi = scatterPtr[ii];
1866 if (
rSlave_[ii] == 1)
continue;
1878 for(
int kk=0; kk<len; kk++) {
1879 int colk = scatterPtr[kk];
1881 if (
rSlave_[kk] != 1)
continue;
1889 int reducedRow = -1;
1892 bool rowIsLocal =
true;
1899 for(
int j=0; j<len; j++) {
1900 if (
rSlave_[j] == 1)
continue;
1918 catch(std::runtime_error& exc) {
1935 int numIndices = indices.size();
1936 int* indPtr = &indices[0];
1940 int reducedEqn = -1;
1941 for(
size_t j=0; j<indices.size(); j++) {
1944 workPtr[j] = reducedEqn;
1947 for(
int i=0; i<numIndices; i++) {
1948 int row = indPtr[i];
1949 int rrow = workPtr[i];
1959 "storeElemScttrInd") );
1974 int i, numIndices = indices.size();
1975 int* indPtr = &indices[0];
1977 for(i=0; i<numIndices; i++) {
1978 int row = indPtr[i];
1989 for(
int j=0; j<numIndices; ++j) {
1991 dbgOut() <<
"# storeElemScttrInds_ns crtMatPoss("
1992 << row <<
"," << indPtr[j] <<
")"<<
FEI_ENDL;
2012 int i, numIndices = indices.size();
2013 int* indPtr = &indices[0];
2015 for(i=0; i<numIndices; i++) {
2016 int row = indPtr[i];
2027 for(
int j=0; j<numIndices; ++j) {
2029 dbgOut() <<
"# storeElemScttrInds_ns crtMatPoss("
2030 << row <<
"," << indPtr[j] <<
")"<<
FEI_ENDL;
2112 std::vector<fei::CSVec*>& eqnArray = eqnBuf.
eqns();
2113 for(
int i=0; i<numEqns; ++i) {
2116 eqnNumbers[i] = reducedEqn;
2118 int* indicesPtr = &(eqnArray[i]->indices()[0]);
2119 int numIndices = eqnArray[i]->size();
2120 for(
int j=0; j<numIndices; ++j) {
2122 indicesPtr[j] = reducedEqn;
2133 int dim1 = eqnTable.size();
2134 for(
int i=0; i<dim1; ++i) {
2135 int dim2 = eqnTable[i]->size();
2136 int* indicesPtr = &(*(eqnTable[i]))[0];
2137 for(
int j=0; j<dim2; ++j) {
2140 indicesPtr[j] = reducedEqn;
2155 int reducedEqn = -1;
2160 std::vector<int>& rowNumbers = srg.
rowNumbers;
2161 for(
size_t i=0; i<rowNumbers.size(); ++i) {
2163 if (isSlave) foundSlave = 1;
2164 else rowNumbers[i] = reducedEqn;
2168 for(
size_t i=0; i<colIndices.size(); ++i) {
2170 if (isSlave) foundSlave = 1;
2171 else colIndices[i] = reducedEqn;
2195 for(
size_t i=0; i<rowNumbers.size(); ++i) {
2196 int row = rowNumbers[i];
2197 int offset = rowOffsets[i];
2198 int rowlen = rowOffsets[i+1]-offset;
2199 const int* indices = &pckColInds[offset];
2201 for(
int j=0; j<rowlen; j++) {
2211 const char* callingFunction)
2229 dbgOut() <<
" " << callingFunction <<
" passed " <<row<<
","<<col
2237 dbgOut() <<
"# " << callingFunction <<
" crtMatPos("
2238 << row <<
"," << col <<
")"<<
FEI_ENDL;
2250 const char* callingFunction)
2268 dbgOut() <<
" " << callingFunction <<
" passed " <<row
2277 for(
int i=0; i<numCols; i++) {
2279 dbgOut() <<
"# " << callingFunction <<
" crtMatPoss("
2280 << row <<
"," << cols[i] <<
")"<<
FEI_ENDL;
2306 const int* fieldSizes = fieldIDs+numFields;
2307 int numNonNegativeFields = 0;
2308 int maxFieldSize = 0;
2309 for(
int f=0;
f<numFields;
f++) {
2310 if (fieldIDs[
f] >= 0) {
2311 numNonNegativeFields++;
2312 if (fieldSizes[
f] > maxFieldSize) maxFieldSize = fieldSizes[
f];
2316 if (numNonNegativeFields == 1 && maxFieldSize == 1) {
2322 int localVanishedNodeAdjustment = 0;
2327 int eqnNumber, blkEqnNumber;
2330 std::map<GlobalID,int>::iterator
2331 iter = nodeIDmap.begin(), iter_end = nodeIDmap.end();
2333 for(; iter!=iter_end; ++iter) {
2338 if (node==NULL)
continue;
2342 if(numFields == 0)
continue;
2348 int blkSize = numNodalDOF;
2350 for(
int j=0; j<numNodalDOF; ++j) {
2364 ++localVanishedNodeAdjustment;
2376 for(
int i = 0; i < numBlocks; i++) {
2382 if (numElemDOF > 0) {
2385 for(
int j=0; j<numElems; j++) {
2387 for(
int ede=0; ede<numElemDOF; ede++) {
2388 blkEqnMapper.
setEqn(eqnNumber+ede, blkEqnNumber+ede);
2392 eqnNumber += numElemDOF;
2393 blkEqnNumber += numElemDOF;
2402 std::map<GlobalID,ConstraintType*>::const_iterator
2406 std::vector<int> localMultEqns;
2407 localMultEqns.reserve(
multCRs_.size()*2);
2408 while(cr_iter != cr_end) {
2416 localMultEqns.push_back(eqnNumber);
2417 localMultEqns.push_back(blkEqnNumber);
2440 std::vector<int> recvLengths, globalMultEqns;
2445 if (p == localProc_) { offset += recvLengths[p];
continue; }
2447 for(
int j=0; j<recvLengths[p]/2; j++) {
2465 std::map<GlobalID,ConstraintType*>::const_iterator
2472 while(cr_iter != cr_end) {
2491 osstr <<
dbgPath_ <<
"/FEI" <<
name_ <<
"_nID_nNum_blkEq_ptEq."
2497 fei::console_out() <<
"SNL_FEI_Structure::writeEqn2NodeMap: ERROR, couldn't open file "
2502 std::map<GlobalID,ConstraintType*>::const_iterator
2506 while(cr_iter != cr_end) {
2511 e2nFile <<
"-999 -999 " << blkEqnNumber <<
" " << eqnNumber <<
FEI_ENDL;
2516 std::map<GlobalID,int>::iterator
2517 iter = nodeIDmap.begin(), iter_end = nodeIDmap.end();
2519 for(; iter!=iter_end; ++iter) {
2533 for(
int j=0; j<numFields; j++) {
2535 assert( numFieldParams > 0 );
2537 for(
int k=0; k<numFieldParams; k++) {
2539 <<
" " << blkEqnNumber <<
" " << eqnNumbers[j]+k<<
FEI_ENDL;
2551 int totalNumElemDOF = 0;
2553 for(
int i = 0; i < numBlocks; i++) {
2557 if (numElemDOF > 0) {
2560 totalNumElemDOF += numElems*numElemDOF;
2564 return(totalNumElemDOF);
2570 int totalNumMultCRs = 0;
2573 totalNumMultCRs = numMCRecords;
2575 return( totalNumMultCRs );
2581 int numLocalEqnBlks)
2595 std::vector<int> numProcNodes(
numProcs_);
2596 std::vector<int> numProcEqns(
numProcs_);
2597 std::vector<int> numProcEqnBlks(
numProcs_);
2604 glist[0] = numLocallyOwnedNodes;
2605 glist[1] = numLocalEqns;
2606 glist[2] = numLocalEqnBlks;
2607 if (MPI_Gather(&glist[0], 3, MPI_INT, &recvList[0], 3,
2614 numProcNodes[p] = recvList[p*3];
2615 numProcEqns[p] = recvList[p*3+1];
2616 numProcEqnBlks[p] = recvList[p*3+2];
2621 numProcNodes[0] = numLocallyOwnedNodes;
2622 numProcEqns[0] = numLocalEqns;
2623 numProcEqnBlks[0] = numLocalEqnBlks;
2641 numProcEqnBlks[i-1];
2645 numProcNodes[numProcs_-1];
2647 numProcEqns[numProcs_-1];
2649 numProcEqnBlks[numProcs_-1];
2656 std::vector<int> blist(3*(
numProcs_+1));
2667 if (MPI_Bcast(&blist[0], 3*(
numProcs_+1), MPI_INT,
2715 os <<
"# leaving calcGlobalEqnInfo" <<
FEI_ENDL;
2736 std::map<GlobalID,int>::iterator
2737 iter = nodeIDmap.begin(), iter_end = nodeIDmap.end();
2739 for(; iter!=iter_end; ++iter) {
2743 if (node==NULL)
continue;
2749 int numNodalDOF = 0;
2751 for(
int j=0; j<numFields; j++) {
2755 numNodalDOF += fieldSize;
2779 for(
int i = 0; i < numBlocks; i++) {
2786 if (numElemDOF > 0) {
2788 std::map<GlobalID,int>& elemIDs =
connTables_[i]->elemIDs;
2790 std::map<GlobalID,int>::const_iterator
2791 iter = elemIDs.begin(),
2792 iter_end = elemIDs.end();
2794 for(; iter != iter_end; ++iter) {
2795 elemDOFEqns[iter->second] = eqnNumber;
2797 eqnNumber += numElemDOF;
2810 int insertPoint = -1;
2835 fei::console_out() <<
"SNL_FEI_Structure::getBlockDescriptor: ERROR, blockID "
2836 << (int)blockID <<
" not found." <<
FEI_ENDL;
2869 fei::console_out() <<
"SNL_FEI_Structure::allocateConnectivityTable: ERROR, blockID "
2870 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
2875 blocks_[index]->getNumNodesPerElement();
2877 int numRows =
blocks_[index]->getNumElements();
2878 int numCols =
connTables_[index]->numNodesPerElem;
2880 if ((numRows <= 0) || (numCols <= 0)) {
2881 fei::console_out() <<
"SNL_FEI_Structure::allocateConnectivityTable: ERROR, either "
2882 <<
"numElems or numNodesPerElem not yet set for blockID "
2883 << (int)blockID <<
". Aborting." <<
FEI_ENDL;
2889 connTables_[index]->elem_conn_ids =
new std::vector<GlobalID>(numRows*numCols);
2900 fei::console_out() <<
"SNL_FEI_Structure::getBlockConnectivity: ERROR, blockID "
2901 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
2913 os <<
"# finalizeActiveNodes" <<
FEI_ENDL;
2919 for(
unsigned i=0; i<shNodeIDs.size(); i++) {
2936 for(
int bIndex=0; bIndex<numBlocks; bIndex++) {
2944 int numElems = conn.
elemIDs.size();
2949 conn.
elem_conn_ptrs =
new std::vector<NodeDescriptor*>(elemConnLen);
2955 int* fieldsPerNodePtr =
blocks_[bIndex]->fieldsPerNodePtr();
2956 int** fieldIDsTablePtr =
blocks_[bIndex]->fieldIDsTablePtr();
2971 int numDistinctFields =
blocks_[bIndex]->getNumDistinctFields();
2972 int fieldID = fieldIDsTablePtr[0][0];
2975 for(elem=0; elem<numElems; elem++) {
2977 GlobalID* elemNodes = &(elemConn[elem*nodesPerElem]);
2978 NodeDescriptor** elemNodePtrs = &(elemNodeDescPtrs[elem*nodesPerElem]);
2980 for(
int n=0;
n<nodesPerElem;
n++) {
2984 fei::console_out() <<
"ERROR in SNL_FEI_Structure::initializeActiveNodes, "
2985 <<
FEI_ENDL <<
"failed to find node "
2986 << (int)(elemNodes[n]) <<
FEI_ENDL;
2989 if (numDistinctFields == 1) {
2993 for(
int i=0; i<fieldsPerNodePtr[n]; i++) {
2994 node->
addField(fieldIDsTablePtr[n][i]);
3004 elemNodePtrs[n] = node;
3018 std::map<GlobalID,ConstraintType*>::const_iterator
3022 while(cr_iter != cr_end) {
3024 std::vector<GlobalID>& nodeID_vec = cr.
getMasters();
3025 GlobalID* nodeIDs = &nodeID_vec[0];
3029 for(
int k=0; k<numNodes; ++k) {
3058 FEI_COUT <<
"FEI Info: A consistency-check of shared-node data will be "
3059 <<
"performed, which involves all-to-all communication. This check is "
3060 <<
"done only if explicitly requested by parameter "
3061 <<
"'FEI_CHECK_SHARED_IDS'."<<
FEI_ENDL;
3069 os <<
"# numSharedNodes: " << numSharedNodes <<
FEI_ENDL;
3070 for(
int ns=0; ns<numSharedNodes; ns++) {
3074 os <<
"# shNodeID " << (int)nodeID <<
", owned by proc "<<proc<<FEI_ENDL;
3088 std::vector<int> nodesPerBlock(numBlocks);
3089 std::vector<int> eqnsPerBlock(numBlocks);
3092 for(j=0; j<numBlocks; j++) {
3093 nodesPerBlock[j] = 0;
3094 eqnsPerBlock[j] = 0;
3099 for(j=0; j<numNodes; j++) {
3102 if (node==NULL)
continue;
3109 for(std::vector<unsigned>::const_iterator b=blkIndices.begin(), bend=blkIndices.end();
3111 nodesPerBlock[*b]++;
3113 for(
int fld=0; fld<numFields; fld++) {
3114 if (
blocks_[*b]->containsField(fieldIDList[fld])) {
3117 eqnsPerBlock[*b] += fSize;
3123 for(j=0; j<numBlocks; j++) {
3124 blocks_[j]->setNumActiveNodes(nodesPerBlock[j]);
3130 for(j=0; j<numBlocks; j++) {
3131 eqnsPerBlock[j] +=
blocks_[j]->getNumElemDOFPerElement() *
3134 blocks_[j]->setTotalNumEqns(eqnsPerBlock[j]);
3155 for(
int i=0; i<numSharedNodes; i++) {
3171 for(
int j=0; j<numFields; j++) {
3173 assert(numEqns >= 0);
3176 for(eqn=0; eqn<numEqns; eqn++) {
3177 int reducedEqn = -1;
3180 if (isSlave)
continue;
3188 for(
int j=0; j<numFields; j++) {
3190 assert(numEqns >= 0);
3191 for(
int eqn=0; eqn<numEqns; eqn++) {
3192 int reducedEqn = -1;
3194 if (isSlave)
continue;
3207 int& localStartRow,
int& localEndRow){
3217 int idType,
int fieldID,
3218 int& numEqns,
int* eqnNumbers)
3229 int nodeFieldEqnNumber = -1;
3234 for(
int i=0; i<numEqns; i++) eqnNumbers[i] = nodeFieldEqnNumber + i;
3242 int idType,
int fieldID,
3243 int& numEqns,
int* eqnNumbers)
3249 if (fieldSize < 0) {
3254 for(
int i=0; i<numIDs; ++i) {
3259 for(
int ii=0; ii<fieldSize; ii++) {
3260 eqnNumbers[offset++] = -1;
3266 int nodeFieldEqnNumber = -1;
3272 for(
int ii=0; ii<fieldSize; ii++) {
3273 eqnNumbers[offset++] = -1;
3278 for(
int ii=0; ii<fieldSize; ii++) {
3279 eqnNumbers[offset++] = nodeFieldEqnNumber + ii;
3284 numEqns = fieldSize*numIDs;
3296 int insertPoint = -1;
3300 int localAdjustment = index < 0 ? insertPoint : index + 1;
3307 int& numLocalEqnBlks,
3308 int& localBlkOffset) {
3325 std::vector<int> eqns;
3326 std::vector<int> mEqns;
3327 std::vector<double> mCoefs;
3335 numEqns, &eqns[0]));
3341 const std::vector<double>* mWeights = svar->
getWeights();
3342 const std::vector<double>& mWeightsRef = *mWeights;
3345 for(
size_t j=0; j<mNodes->size(); j++) {
3348 eqns.resize(mfSize);
3350 int mFieldID = (*mFields)[j];
3354 double fei_eps = 1.e-49;
3356 for(
int k=0; k<mfSize; k++) {
3357 if (std::abs(mWeightsRef[mwOffset++]) > fei_eps) {
3358 mEqns.push_back(eqns[k]);
3359 mCoefs.push_back(mWeightsRef[mwOffset-1]);
3365 mEqns.size(),
false) );
3372 int globalMaxSlaves = 0;
3375 if (globalMaxSlaves > 0) {
3390 os <<
"# slave-equations:" <<
FEI_ENDL;
3392 os <<
"# leaving calculateSlaveEqns" <<
FEI_ENDL;
3395 int levelsOfCoupling;
3399 os <<
"# SNL_FEI_Structure: " << levelsOfCoupling
3400 <<
" level(s) of coupling removed: " <<
FEI_ENDL;
3424 int numLocalNodesVanished = 0;
3430 int reducedSlaveEqn;
3432 int numMasters = mstrEqns[i]->size();
3437 os <<
"# no local node for slave eqn " << slvEqns[i] <<
FEI_ENDL;
3446 numLocalNodesVanished++;
3463 for(
int j=0; j<numMasters; j++) {
3464 int masterEquation = mstrEqns[i]->indices()[j];
3467 int reducedMasterEqn;
3471 int numSharing = sharingProcs.size();
3472 for(
int sp=0; sp<numSharing; sp++) {
3473 if (sharingProcs[sp] ==
localProc_)
continue;
3476 os <<
"# slave node " << (int)slvNodeID <<
",eqn "<<slvEqns[i]
3477 <<
", master eqn " << masterEquation <<
" eqnCommMgr_->addLocal "
3478 << reducedMasterEqn <<
", proc " << sharingProcs[sp] << FEI_ENDL;
3482 &reducedMasterEqn, 1);
3487 os <<
"# slave node " << (int)slvNodeID <<
",eqn "<<slvEqns[i]
3488 <<
", master eqn " << masterEquation <<
" eqnCommMgr_->addRemote "
3489 << reducedMasterEqn <<
", proc " << owner << FEI_ENDL;
3492 &reducedMasterEqn, 1);
3498 std::vector<int> tmp(1), tmp2(
numProcs_);
3499 tmp[0] = numLocalNodesVanished;
3507 int tmpNumVanished = 0;
3508 for(
int proc=0; proc<
numProcs_; ++proc) {
3509 int temporary = tmpNumVanished;
3520 os <<
"# slave-equations:" <<
FEI_ENDL;
3522 os <<
"# leaving calculateSlaveEqns" <<
FEI_ENDL;
3531 std::vector<int>& eqnNumbers = eqnbuf.
eqnNumbers();
3532 std::vector<fei::CSVec*>& eqns = eqnbuf.
eqns();
3534 std::vector<double> tempCoefs;
3535 std::vector<int> tempIndices;
3537 levelsOfCoupling = 0;
3538 bool finished =
false;
3540 bool foundCoupling =
false;
3541 for(
size_t i=0; i<eqnNumbers.size(); i++) {
3544 if (rowIndex == (
int)i) {
3546 <<
" illegal master-slave constraint coupling. Eqn "
3547 << eqnNumbers[i] <<
" is both master and slave. " <<
FEI_ENDL;
3551 while(rowIndex >= 0) {
3552 foundCoupling =
true;
3555 eqnNumbers[i], coef) );
3557 std::vector<int>& indicesRef = eqns[i]->indices();
3558 std::vector<double>& coefsRef = eqns[i]->coefs();
3560 int len = indicesRef.size();
3561 tempCoefs.resize(len);
3562 tempIndices.resize(len);
3564 double* tempCoefsPtr = &tempCoefs[0];
3565 int* tempIndicesPtr = &tempIndices[0];
3566 double* coefsPtr = &coefsRef[0];
3567 int* indicesPtr = &indicesRef[0];
3569 for(
int j=0; j<len; ++j) {
3570 tempIndicesPtr[j] = indicesPtr[j];
3571 tempCoefsPtr[j] = coef*coefsPtr[j];
3575 tempIndicesPtr, len,
true) );
3580 if (foundCoupling) ++levelsOfCoupling;
3581 else finished =
true;
3583 if (levelsOfCoupling>1 && !finished) {
3585 <<
" too many (>1) levels of master-slave constraint coupling. "
3586 <<
"Hint: coupling is considered infinite if two slaves depend on "
3587 <<
"each other. This may or may not be the case here." <<
FEI_ENDL;
3602 if (MPI_Comm_size(comm, &numProcs) !=
MPI_SUCCESS)
return(-1);
3603 if (numProcs == 1)
return(0);
3605 if (MPI_Comm_rank(comm, &localProc) !=
MPI_SUCCESS)
return(-1);
3611 ProcEqns localProcEqns, remoteProcEqns;
3612 std::vector<int>& slvEqnNums = slaveEqns->
eqnNumbers();
3614 if (slaveEqns->
eqns().size() > 0) slvEqnsPtr = &(slaveEqns->
eqns()[0]);
3616 for(
size_t i=0; i<slvEqnNums.size(); i++) {
3618 if (p == localProc)
continue;
3620 localProcEqns.
addEqn(slvEqnNums[i], slvEqnsPtr[i]->size(), p);
3631 &remoteProcEqns, &remoteEqns,
3648 int insertPoint = -1;
3651 if (foundOffset >= 0)
return(
true);
3658 if (
numSlvs_ == 0) { reducedEqn = eqn;
return(
false); }
3660 if (eqn <
lowestSlv_) {reducedEqn = eqn;
return(
false); }
3666 bool isSlave =
false;
3668 if (foundOffset < 0) {
3669 reducedEqn = eqn - index;
3672 isSlave =
true; reducedEqn = eqn - (foundOffset+1);
3683 if (numSlvs == 0)
return(reducedEqn);
3687 if (reducedEqn < slvEqns[0])
return(reducedEqn);
3689 int eqn = reducedEqn;
3691 for(
int i=0; i<numSlvs; i++) {
3692 if (eqn < slvEqns[i])
return(eqn);
3701 std::vector<int>*& masterEqns)
3712 if (foundOffset >= 0) {
3724 std::vector<double>*& masterCoefs)
3735 if (foundOffset >= 0) {
3757 if (foundOffset >= 0) {
3759 rhsValue = (*rhsCoefsPtr)[0];
3767 int interleaveStrategy,
3768 int* scatterIndices)
3773 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID "
3774 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
3778 std::map<GlobalID,int>& elemIDs =
connTables_[index]->elemIDs;
3780 std::map<GlobalID,int>::const_iterator
3781 iter = elemIDs.find(elemID);
3783 if (iter == elemIDs.end()) {
3784 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID: "
3785 << (int)blockID <<
", elemID "
3786 << (
int)elemID <<
" not found. Aborting." <<
FEI_ENDL;
3790 int elemIndex = iter->second;
3793 interleaveStrategy, scatterIndices);
3798 int interleaveStrategy,
3799 int* scatterIndices,
3800 int* blkScatterIndices,
3806 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID "
3807 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
3811 std::map<GlobalID,int>& elemIDs =
connTables_[index]->elemIDs;
3813 std::map<GlobalID,int>::const_iterator
3814 iter = elemIDs.find(elemID);
3816 if (iter == elemIDs.end()) {
3817 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID: "
3818 << (int)blockID <<
", elemID "
3819 << (
int)elemID <<
" not found. Aborting." <<
FEI_ENDL;
3823 int elemIndex = iter->second;
3826 interleaveStrategy, scatterIndices,
3827 blkScatterIndices, blkSizes);
3833 int* scatterIndices)
3841 fei::console_out() <<
"SNL_FEI_Structure::getBlkScatterIndices_index: ERROR getting"
3842 <<
" node descriptors." <<
FEI_ENDL;
3852 int interleaveStrategy,
3853 int* scatterIndices)
3868 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_index: ERROR getting"
3869 <<
" node descriptors." <<
FEI_ENDL;
3876 scatterIndices, offset);
3880 switch (interleaveStrategy) {
3883 scatterIndices, offset);
3889 scatterIndices, offset);
3900 int numElemDOF =
blocks_[blockIndex]->getNumElemDOFPerElement();
3901 std::vector<int>& elemDOFEqns =
blocks_[blockIndex]->elemDOFEqnNumbers();
3903 for(
int i=0; i<numElemDOF; i++) {
3904 scatterIndices[offset++] = elemDOFEqns[elemIndex] + i;
3910 int interleaveStrategy,
3911 int* scatterIndices,
3912 int* blkScatterIndices,
3928 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_index: ERROR getting"
3929 <<
" node descriptors." <<
FEI_ENDL;
3933 int offset = 0, blkOffset = 0;
3936 scatterIndices, offset,
3937 blkScatterIndices, blkSizes, blkOffset);
3941 switch (interleaveStrategy) {
3944 scatterIndices, offset,
3945 blkScatterIndices, blkSizes, blkOffset);
3951 scatterIndices, offset);
3962 int numElemDOF =
blocks_[blockIndex]->getNumElemDOFPerElement();
3963 std::vector<int>& elemDOFEqns =
blocks_[blockIndex]->elemDOFEqnNumbers();
3965 for(
int i=0; i<numElemDOF; i++) {
3966 scatterIndices[offset++] = elemDOFEqns[elemIndex] + i;
3967 if (interleaveStrategy == 0) {
3968 blkSizes[blkOffset] = 1;
3969 blkScatterIndices[blkOffset++] = elemDOFEqns[elemIndex] + i;
3984 int numNodes =
connTables_[blockIndex]->numNodesPerElem;
3988 &((*
connTables_[blockIndex]->elem_conn_ptrs)[elemIndex*numNodes]);
3989 for(
int i=0; i<numNodes; ++i) nodes[i] = elemNodePtrs[i];
3993 &((*
connTables_[blockIndex]->elem_conn_ids)[elemIndex*numNodes]);
3994 for(
int i=0; i<numNodes; ++i) {
4006 int* scatterIndices,
4011 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4014 int eqn = eqnNumbers[0];
4015 scatterIndices[offset++] = eqn;
4016 if (fieldSize > 1) {
4017 for(
int i=1; i<fieldSize; i++) {
4018 scatterIndices[offset++] = eqn+i;
4029 int* scatterIndices,
4031 int* blkScatterIndices,
4037 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4040 int eqn = eqnNumbers[0];
4041 scatterIndices[offset++] = eqn;
4042 if (fieldSize > 1) {
4043 for(
int i=1; i<fieldSize; i++) {
4044 scatterIndices[offset++] = eqn+i;
4055 int** fieldIDs,
int* fieldsPerNode,
4056 int* scatterIndices,
int& offset)
4058 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4066 int* fieldID_ind = fieldIDs[nodeIndex];
4068 for(
int j=0; j<fieldsPerNode[nodeIndex]; j++) {
4070 assert(numEqns >= 0);
4077 int eqn = nodeEqnNums[nind];
4080 FEI_COUT <<
"SNL_FEI_Structure::getNodeMajorIndices: ERROR, node "
4082 <<
", field " << nodeFieldIDList[nind]
4083 <<
" has equation number " << eqn <<
FEI_ENDL;
4087 for(
int jj=0; jj<numEqns; jj++) {
4088 scatterIndices[offset++] = eqn+jj;
4094 <<
" not found for node "
4107 int* scatterIndices,
4110 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4119 int** fieldIDs,
int* fieldsPerNode,
4120 int* scatterIndices,
int& offset,
4121 int* blkScatterIndices,
4125 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4136 int* fieldID_ind = fieldIDs[nodeIndex];
4138 for(
int j=0; j<fieldsPerNode[nodeIndex]; j++) {
4140 assert(numEqns >= 0);
4147 int eqn = nodeEqnNums[nind];
4149 FEI_COUT <<
"SNL_FEI_Structure::getNodeMajorIndices: ERROR, node "
4151 <<
", field " << nodeFieldIDList[nind]
4152 <<
" has equation number " << eqn <<
FEI_ENDL;
4156 for(
int jj=0; jj<numEqns; jj++) {
4157 scatterIndices[offset++] = eqn+jj;
4163 <<
" not found for node "
4175 std::vector<int>* fieldIDs,
4176 std::vector<int>& fieldsPerNode,
4177 std::vector<int>& scatterIndices)
4180 scatterIndices.resize(0);
4182 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4190 int* fieldID_ind = &(fieldIDs[nodeIndex][0]);
4192 for(
int j=0; j<fieldsPerNode[nodeIndex]; j++) {
4194 assert(numEqns >= 0);
4201 int eqn = nodeEqnNums[nind];
4204 FEI_COUT <<
"SNL_FEI_Structure::getNodeMajorIndices: ERROR, node "
4206 <<
", field " << nodeFieldIDList[nind]
4207 <<
" has equation number " << eqn <<
FEI_ENDL;
4211 scatterIndices.resize(offset+numEqns);
4212 int* inds = &scatterIndices[0];
4214 for(
int jj=0; jj<numEqns; jj++) {
4215 inds[offset+jj] = eqn+jj;
4222 <<
" not found for node "
4234 int** fieldIDs,
int* fieldsPerNode,
4235 int* scatterIndices,
int& offset)
4243 std::vector<int> fields;
4244 for(
int ii=0; ii<numNodes; ii++) {
4245 for(
int j=0; j<fieldsPerNode[ii]; j++) {
4246 if (std::find(fields.begin(), fields.end(), fieldIDs[ii][j]) == fields.end()) {
4247 fields.push_back(fieldIDs[ii][j]);
4252 int* fieldsPtr = fields.size()>0 ? &fields[0] : NULL;
4257 for(
size_t i=0; i<fields.size(); i++) {
4258 int field = fieldsPtr[i];
4260 for(
int nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex) {
4262 fieldsPerNode[nodeIndex]);
4274 assert(numEqns >= 0);
4281 for(
int jj=0; jj<numEqns; ++jj) {
4282 scatterIndices[offset++] = nodeEqnNums[nind]+jj;
4296 std::vector<int>* fieldIDs,
4297 std::vector<int>& fieldsPerNode,
4298 std::vector<int>& scatterIndices)
4306 std::vector<int> fields;
4307 for(
int ii=0; ii<numNodes; ii++) {
4308 for(
int j=0; j<fieldsPerNode[ii]; j++) {
4309 std::vector<int>& fldIDs = fieldIDs[ii];
4310 if (std::find(fields.begin(), fields.end(), fldIDs[j]) == fields.end()) {
4311 fields.push_back(fldIDs[j]);
4320 scatterIndices.resize(0);
4322 for(
size_t i=0; i<fields.size(); i++) {
4323 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4330 assert(numEqns >= 0);
4337 for(
int jj=0; jj<numEqns; jj++) {
4338 scatterIndices.push_back(nodeEqnNums[nind]+jj);
4345 <<
" not found for node "
4346 << (int)nodes[nodeIndex]->getGlobalNodeID() <<
FEI_ENDL;
4360 std::map<GlobalID,snl_fei::Constraint<GlobalID>* >::iterator
4361 cr_iter = crDB.find(CRID);
4363 if (cr_iter == crDB.end()) {
void addMasterField(int masterField)
static int exchangeEqnBuffers(MPI_Comm comm, ProcEqns *sendProcEqns, EqnBuffer *sendEqns, ProcEqns *recvProcEqns, EqnBuffer *recvEqns, bool accumulate)
int setDbgOut(std::ostream &ostr, const char *path, const char *feiName)
std::vector< fei::CSVec * > & localEqns()
int sortedListInsert(const T &item, std::vector< T > &list)
std::vector< BlockDescriptor * > blocks_
int translateMatToReducedEqns(fei::CSRMat &mat)
fei::FieldDofMap< int > fieldDofMap_
void setBlkEqnNumber(int blkEqn)
snl_fei::PointBlockMap * blkEqnMapper_
int getNumElemDOFPerElement()
std::vector< int > & localEqnNumbers()
int createMatrixPositions(int row, int numCols, int *cols, const char *callingFunction)
std::vector< int > & getSharedNodeProcs(int index)
int getFieldSize(int fieldID)
const int * getFieldIDsPtr()
int setNumNodesAndEqnsPerBlock()
int Allgatherv(MPI_Comm comm, std::vector< T > &sendbuf, std::vector< int > &recvLengths, std::vector< T > &recvbuf)
std::vector< int > globalNumNodesVanished_
int countLocalNodeDescriptors(int localRank)
std::vector< int > & getMasterFieldIDs()
int getBlockDescriptor_index(int index, BlockDescriptor *&block)
std::map< GlobalID, int > & getNodeIDs()
int getNodeWithNumber(int nodeNumber, const NodeDescriptor *&node) const
std::map< GlobalID, snl_fei::Constraint< GlobalID > * > penCRs_
int addSharedNodes(const GlobalID *nodeIDs, int numNodes, const int *const *procs, const int *numProcs)
fei::FillableMat * slaveMatrix_
int getElemNodeDescriptors(int blockIndex, int elemIndex, NodeDescriptor **nodes)
void addWeight(double weight)
int getNumNodalDOF() const
int addEqn(int eqnNumber, const double *coefs, const int *indices, int len, bool accumulate, bool create_indices_union=false)
SNL_FEI_Structure(MPI_Comm comm)
void multiply_CSRMat_CSRMat(const CSRMat &A, const CSRMat &B, CSRMat &C, bool storeResultZeros)
int getMasterEqnRHS(int slaveEqn, double &rhsValue)
bool nodalEqnsAllSlaves(const NodeDescriptor *node, std::vector< int > &slaveEqns)
int initNodeID(GlobalID nodeID)
std::vector< GlobalID > blockIDs_
std::vector< int > * slvEqnNumbers_
const std::vector< GlobalID > * getMasterNodeIDs()
const int * getFieldIDList() const
int ptEqnToBlkEqn(int ptEqn)
std::vector< fei::CSVec * > & eqns()
ProcEqns * getSendProcEqns()
int addRemoteEqns(fei::CSRMat &mat, bool onlyIndices)
int getInterleaveStrategy() const
int finalizeActiveNodes()
std::vector< NodeDescriptor * > work_nodePtrs_
int initElemBlockStructure()
void getScatterIndices_index(int blockIndex, int elemIndex, int interleaveStrategy, int *scatterIndices)
snl_fei::PointBlockMap & getBlkEqnMapper()
void setNumEqnsPerElement(int numEqns)
int allocateFieldIDsTable()
int finalizeNodeCommMgr()
std::vector< int > localVanishedNodeNumbers_
int getMasterEqnCoefs(int slaveEqn, std::vector< double > *&masterCoefs)
int getEqnNumbers(GlobalID ID, int idType, int fieldID, int &numEqns, int *eqnNumbers)
int mirrorProcEqns(ProcEqns &inProcEqns, ProcEqns &outProcEqns)
std::vector< GlobalID > * elem_conn_ids
void addEqn(int eqnNumber, int proc)
std::vector< int > rowNumbers
std::vector< int > & eqnNumbers()
const int * getFieldEqnNumbers() const
fei::FillableMat * getSlaveDependencies()
int storeElementScatterBlkIndices_noSlaves(std::vector< int > &scatterIndices)
void setFieldEqnNumber(int fieldID, int eqn)
static int removeCouplings(EqnBuffer &eqnbuf, int &levelsOfCoupling)
int exchangePtToBlkInfo(snl_fei::PointBlockMap &blkEqnMapper)
void copySetToArray(const SET_TYPE &set_obj, int lenList, int *list)
bool getFieldEqnNumber(int fieldID, int &eqnNumber) const
fei::ctg_set< int > * sysMatIndices_
int createBlkSymmEqnStructure(std::vector< int > &scatterIndices)
int setElemDofFieldIDs(int numFields, const int *fieldIDs)
int storeElementScatterIndices(std::vector< int > &scatterIndices)
int initMultCRStructure()
void setEqnNumber(int eqn)
const std::vector< double > * getWeights()
void setConstraintID(int id)
void addBlockIndex(unsigned blk_idx)
std::vector< int > fieldSizes_
void getEqnInfo(int &numGlobalEqns, int &numLocalEqns, int &localStartRow, int &localEndRow)
int getSharedNodeIndex(GlobalID nodeID)
void createPosition(int row, int col)
std::vector< int > elemNumbers
ProcEqns * getRecvProcEqns()
int createSymmEqnStructure(std::vector< int > &scatterIndices)
int getMasterEqnNumbers(int slaveEqn, std::vector< int > *&masterEqns)
bool activeNodesInitialized_
std::vector< int > packedColumnIndices
std::vector< std::vector< double > * > * rhsCoefsPtr()
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDofFieldIDs, int interleaveStrategy)
std::vector< int > rowOffsets
void setBlkEqnNumber(int blkEqn)
NodeDescriptor & getSharedNodeAtIndex(int index)
void addLocalEqn(int eqnNumber, int srcProc)
NodeDatabase * nodeDatabase_
int initComplete(NodeDatabase &nodeDB, bool safetyCheck)
int ** fieldIDsTablePtr()
std::vector< GlobalID > & getLocalNodeIDs()
int binarySearch(const T &item, const T *list, int len)
int getNodeWithEqn(int eqnNumber, const NodeDescriptor *&node) const
int assembleReducedStructure()
int translateToReducedNodeNumber(int nodeNumber, int proc)
void setNumElemDOFPerElement(int ndof)
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
int getMatrixRowLengths(std::vector< int > &rowLengths)
int synchronize(int firstLocalNodeNumber, int firstLocalEqn, int localRank, MPI_Comm comm)
virtual ~SNL_FEI_Structure()
std::vector< int > & elemDOFEqnNumbers()
void setGlobalBlockID(GlobalID blockID)
#define FEI_ISTRINGSTREAM
std::ostream * dbgOStreamPtr_
int getMatrixStructure(int **colIndices, std::vector< int > &rowLengths)
std::vector< NodeDescriptor * > * elem_conn_ptrs
void add_field(LocalOrdinal fieldID, LocalOrdinal fieldSize, LocalOrdinal fieldType=fei::UNKNOWN)
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
int exchangeIndices(std::ostream *dbgOut=NULL)
EqnBuffer * getRecvEqns()
int addBlock(GlobalID blockID)
std::vector< std::vector< int > * > & procEqnNumbersPtr()
int calculateSlaveEqns(MPI_Comm comm)
const std::vector< int > * getMasterFields()
void getNodeAtIndex(int i, const NodeDescriptor *&node) const
std::map< GlobalID, snl_fei::Constraint< GlobalID > * > & getPenConstRecords()
int firstLocalNodeNumber_
std::vector< int > fieldIDs_
fei::ctg_set< int > * sysBlkMatIndices_
void getEqnBlkInfo(int &numGlobalEqnBlks, int &numLocalEqnBlks, int &localBlkOffset)
GlobalID getGlobalNodeID() const
int getNodeMajorIndices(NodeDescriptor **nodes, int numNodes, int **fieldIDs, int *fieldsPerNode, int *scatterIndices, int &offset)
void setFieldOffset(int foff)
int setBlkEqnSize(int blkEqn, int size)
void getScatterIndices_ID(GlobalID blockID, GlobalID elemID, int interleaveStrategy, int *scatterIndices)
std::map< GlobalID, int > elemIDs
void setSharedOwnershipRule(int ownershipRule)
void setNumNodalDOF(int dof)
int informLocal(const NodeDescriptor &node)
void addRemoteIndices(int eqnNumber, int destProc, int *indices, int num)
void insert2(const T &item)
int translateToReducedEqns(EqnCommMgr &eqnCommMgr)
std::vector< int > workSpace_
int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double &coef)
int initCRMult(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
bool isInLocalElement(int nodeNumber)
void storeNodalRowIndices(NodeDescriptor &node, int fieldID, int eqn)
void addSlaveVariable(SlaveVariable *svar)
int initCRPen(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
int setEqn(int ptEqn, int blkEqn)
void initializeEqnCommMgr()
const int * getNumFieldsPerNode(GlobalID blockID)
void addCR(int CRID, snl_fei::Constraint< GlobalID > *&cr, std::map< GlobalID, snl_fei::Constraint< GlobalID > * > &crDB)
int eqnToBlkEqn(int eqn) const
int countLocalNodalEqns(int localRank)
int getNumNodesPerElement() const
const char * getParam(const char *key, int numParams, const char *const *paramStrings)
void destroyBlockRoster()
int addEqns(EqnBuffer &inputEqns, bool accumulate)
void addMasterNodeID(GlobalID masterNode)
int getBlkEqnNumber() const
int localReducedBlkOffset_
void setInterleaveStrategy(int strat)
int storeElementScatterIndices_noSlaves(std::vector< int > &scatterIndices)
int getBlockDescriptor(GlobalID blockID, BlockDescriptor *&block)
std::map< GlobalID, snl_fei::Constraint< GlobalID > * > multCRs_
std::vector< int > globalBlkEqnOffsets_
SparseRowGraph & getGraph()
bool translateToReducedEqn(int eqn, int &reducedEqn)
int calcTotalNumElemDOF()
ConnectivityTable & getBlockConnectivity(GlobalID blockID)
std::ostream & console_out()
int initSlaveVariable(GlobalID slaveNodeID, int slaveFieldID, int offsetIntoSlaveField, int numMasterNodes, const GlobalID *masterNodeIDs, const int *masterFieldIDs, const double *weights, double rhsValue)
int GlobalMax(MPI_Comm comm, std::vector< T > &local, std::vector< T > &global)
const std::vector< unsigned > & getBlockIndexList() const
void storeNodalSendIndices(NodeDescriptor &iNode, int iField, NodeDescriptor &jNode, int jField)
std::vector< SlaveVariable * > * slaveVars_
std::vector< int > globalNodeOffsets_
int getNodeIndices_simple(NodeDescriptor **nodes, int numNodes, int fieldID, int *scatterIndices, int &offset)
int getOwnerProcForEqn(int eqn)
void setMaxBlkEqnSize(int sz)
int getBlkScatterIndices_index(int blockIndex, int elemIndex, int *scatterIndices)
void setIsPenalty(bool isPenaltyConstr)
void multiply_trans_CSRMat_CSRMat(const CSRMat &A, const CSRMat &B, CSRMat &C, bool storeResultZeros)
int getBlkEqnSize(int blkEqn)
int getNodeBlkIndices(NodeDescriptor **nodes, int numNodes, int *scatterIndices, int &offset)
int createMatrixPosition(int row, int col, const char *callingFunction)
int localProc(MPI_Comm comm)
void destroyConnectivityTables()
int initializeBlkEqnMapper()
int mirrorProcEqnLengths(ProcEqns &inProcEqns, ProcEqns &outProcEqns)
void setNumBlkEqnsPerElement(int numBlkEqns)
void storeLocalNodeIndices(NodeDescriptor &iNode, int iField, NodeDescriptor &jNode, int jField)
GlobalID getGlobalBlockID()
int getLumpingStrategy() const
NodeDescriptor & findNodeDescriptor(GlobalID nodeID)
void setNumRHSs(int numRHSs)
void storeNodalSendIndex(NodeDescriptor &node, int fieldID, int col)
std::map< int, int > * getPtEqns()
std::vector< int > rSlave_
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
void setNodeID(GlobalID nid)
NodeDescriptor * findNode(GlobalID nodeID)
std::vector< ConnectivityTable * > connTables_
int getBlkEqnNumber() const
void storeNodalColumnIndices(int eqn, NodeDescriptor &node, int fieldID)
std::vector< int > & getMasters()
std::map< int, int > * fieldDatabase_
void destroyValues(MAP_TYPE &map_obj)
int getNumNodeDescriptors() const
int translateFromReducedEqn(int reducedEqn)
int getNodeWithID(GlobalID nodeID, const NodeDescriptor *&node) const
void setOwnerProc(int proc)
EqnBuffer * getSendEqns()
int getNumMultConstRecords()
int allocateBlockConnectivity(GlobalID blockID)
int formMatrixStructure()
int getNumEqnsPerElement()
size_t getNumSharedNodes()
void setNumElements(int numElems)
NodeCommMgr * nodeCommMgr_
void addField(int fieldID)
int parameters(int numParams, const char *const *paramStrings)
snl_fei::Constraint< GlobalID > ConstraintType
#define FEI_OSTRINGSTREAM
void getElemBlockInfo(GlobalID blockID, int &interleaveStrategy, int &lumpingStrategy, int &numElemDOF, int &numElements, int &numNodesPerElem, int &numEqnsPerElem)
const char * getParamValue(const char *key, int numParams, const char *const *paramStrings, char separator=' ')
void calcGlobalEqnInfo(int numLocallyOwnedNodes, int numLocalEqns, int numLocalEqnBlks)
std::vector< int > globalEqnOffsets_
std::vector< GlobalID > & getSharedNodeIDs()
int searchList(const T &item, const T *list, int len)
int getNodeNumber() const
int initComplete(bool generateGraph=true)
static int gatherSlaveEqns(MPI_Comm comm, EqnCommMgr *eqnCommMgr, EqnBuffer *slaveEqns)
int getFieldMajorIndices(NodeDescriptor **nodes, int numNodes, int **fieldIDs, int *fieldsPerNode, int *scatterIndices, int &offset)
int setNumNodesPerElement(int numNodes)
int numProcs(MPI_Comm comm)
int getIndexOfBlock(GlobalID blockID) const
const int *const * getFieldIDsTable(GlobalID blockID)
int numLocalReducedEqnBlks_
int getEqnNumber(int nodeNumber, int fieldID)
int initNodeIDs(GlobalID *nodeIDs, int numNodes)
bool matIndicesDestroyed_
void setNumDistinctFields(int nFields)