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(),
1264 pteq_end = ptEqns->end();
1266 int lastBlkRow = -1;
1268 for(
int jj=0; jj<numPtEqns; ++jj, ++pteq) {
1269 int ptEqn = (*pteq).first;
1280 if (blkRow == lastBlkRow)
continue;
1289 int* theseColIndices = ptColIndices[localPtEqn];
1291 for(
int colj=0; colj<rowLength; colj++) {
1295 <<
"SNL_FEI_Structure::getMatrixStructure ERROR pt row "
1296 << ptEqn <<
", pt col "
1297 << ptColIndices[localPtEqn][colj]
1298 <<
" doesn't have a corresponding block" <<
FEI_ENDL;
1303 sysBlkIndices.
insert2(blkCol);
1306 lastBlkRow = blkRow;
1317 &(blkIndices_1D[offset]));
1318 offset += blkRowLengths[i];
1330 std::vector<int>& slaveEqns)
1336 for(
int i=0; i<numFields; ++i) {
1338 for(
int eqn=0; eqn<fieldSize; ++eqn) {
1339 int thisEqn = fieldEqns[i] + eqn;
1360 fei::console_out() <<
"ERROR, findNodeDescriptor unable to find node " << (int)nodeID
1393 std::map<GlobalID,ConstraintType*>::const_iterator
1397 while(cr_iter != cr_end) {
1402 std::vector<GlobalID>& CRNode_vec = multCR.
getMasters();
1403 GlobalID *CRNodePtr = &CRNode_vec[0];
1405 int* CRFieldPtr = &CRField_vec[0];
1408 int reducedCrEqn = 0;
1413 for(
int j=0; j<lenList; j++) {
1415 int fieldID = CRFieldPtr[j];
1418 if(nodePtr==NULL)
continue;
1477 std::map<GlobalID,ConstraintType*>::const_iterator
1481 while(cr_iter != cr_end) {
1485 std::vector<GlobalID>& CRNode_vec = penCR.
getMasters();
1486 GlobalID* CRNodesPtr = &CRNode_vec[0];
1489 int* CRFieldPtr = &CRField_vec[0];
1494 for(
int i = 0; i < lenList; i++) {
1496 int iField = CRFieldPtr[i];
1499 if(!iNodePtr)
continue;
1502 for(
int j = 0; j < lenList; j++) {
1504 int jField = CRFieldPtr[j];
1507 if(!jNodePtr)
continue;
1548 fei::console_out() <<
"FEI error, attempt to store indices for field ("<<fieldID
1549 <<
") with size "<<numEqns<<
FEI_ENDL;
1553 for(
int i=0; i<numEqns; i++) {
1568 int iEqn = -1, jEqn = -1;
1574 if (iNumParams < 1 || jNumParams < 1) {
1575 fei::console_out() <<
"FEI ERROR, attempt to store indices for field with non-positive size"
1576 <<
" field "<<iField<<
", size "<<iNumParams<<
", field "<<jField<<
", size "
1581 for(
int i=0; i<iNumParams; i++) {
1584 for(
int j=0; j<jNumParams; j++) {
1600 int iEqn = -1, jEqn = -1;
1606 if (iNumParams < 1 || jNumParams < 1) {
1607 fei::console_out() <<
"FEI ERROR, attempt to store indices for field with non-positive size"
1608 <<
" field "<<iField<<
", size "<<iNumParams<<
", field "<<jField<<
", size "
1613 for(
int i=0; i<iNumParams; i++) {
1615 int reducedRow = -1;
1617 if (isSlave)
continue;
1619 for(
int j=0; j<jNumParams; j++) {
1621 int reducedCol = -1;
1623 if (isSlave)
continue;
1647 if (numParams < 1) {
1648 fei::console_out() <<
"FEI error, attempt to store indices for field ("<<fieldID
1649 <<
") with size "<<numParams<<
FEI_ENDL;
1653 int reducedEqn = -1;
1655 if (isSlave)
return;
1657 for(
int j=0; j<numParams; j++) {
1658 int reducedCol = -1;
1660 if (isSlave)
continue;
1669 int fieldID,
int eqn)
1679 if (numParams < 1) {
1680 fei::console_out() <<
"FEI error, attempt to store indices for field ("<<fieldID
1681 <<
") with size "<<numParams<<
FEI_ENDL;
1685 int reducedEqn = -1;
1687 if (isSlave)
return;
1689 for(
int j=0; j<numParams; j++) {
1690 int reducedRow = -1;
1692 if (isSlave)
continue;
1714 int len = scatterIndices.size();
1715 bool anySlaves =
false;
1717 for(
int is=0; is<len; is++) {
1719 if (
rSlave_[is] == 1) anySlaves =
true;
1729 int* scatterPtr = &scatterIndices[0];
1732 for(
int j=0; j<len; j++) {
1736 for(
int i=0; i<len; i++) {
1737 int row = scatterPtr[i];
1744 for(
int jj=0; jj<len; jj++) {
1745 int col = scatterPtr[jj];
1749 for(
int ii=0; ii<len; ii++) {
1750 int rowi = scatterPtr[ii];
1753 if (
rSlave_[ii] == 1)
continue;
1765 for(
int kk=0; kk<len; kk++) {
1766 int colk = scatterPtr[kk];
1768 if (
rSlave_[kk] != 1)
continue;
1776 int reducedRow = -1;
1779 bool rowIsLocal =
true;
1786 for(
int j=0; j<len; j++) {
1787 if (
rSlave_[j] == 1)
continue;
1805 catch(std::runtime_error& exc) {
1828 int len = scatterIndices.size();
1829 bool anySlaves =
false;
1831 for(
int is=0; is<len; is++) {
1833 if (
rSlave_[is] == 1) anySlaves =
true;
1843 int* scatterPtr = &scatterIndices[0];
1846 for(
int j=0; j<len; j++) {
1850 for(
int i=0; i<len; i++) {
1851 int row = scatterPtr[i];
1858 for(
int jj=0; jj<len; jj++) {
1859 int col = scatterPtr[jj];
1863 for(
int ii=0; ii<len; ii++) {
1864 int rowi = scatterPtr[ii];
1867 if (
rSlave_[ii] == 1)
continue;
1879 for(
int kk=0; kk<len; kk++) {
1880 int colk = scatterPtr[kk];
1882 if (
rSlave_[kk] != 1)
continue;
1890 int reducedRow = -1;
1893 bool rowIsLocal =
true;
1900 for(
int j=0; j<len; j++) {
1901 if (
rSlave_[j] == 1)
continue;
1919 catch(std::runtime_error& exc) {
1936 int numIndices = indices.size();
1937 int* indPtr = &indices[0];
1941 int reducedEqn = -1;
1942 for(
size_t j=0; j<indices.size(); j++) {
1945 workPtr[j] = reducedEqn;
1948 for(
int i=0; i<numIndices; i++) {
1949 int row = indPtr[i];
1950 int rrow = workPtr[i];
1960 "storeElemScttrInd") );
1975 int i, numIndices = indices.size();
1976 int* indPtr = &indices[0];
1978 for(i=0; i<numIndices; i++) {
1979 int row = indPtr[i];
1990 for(
int j=0; j<numIndices; ++j) {
1992 dbgOut() <<
"# storeElemScttrInds_ns crtMatPoss("
1993 << row <<
"," << indPtr[j] <<
")"<<
FEI_ENDL;
2013 int i, numIndices = indices.size();
2014 int* indPtr = &indices[0];
2016 for(i=0; i<numIndices; i++) {
2017 int row = indPtr[i];
2028 for(
int j=0; j<numIndices; ++j) {
2030 dbgOut() <<
"# storeElemScttrInds_ns crtMatPoss("
2031 << row <<
"," << indPtr[j] <<
")"<<
FEI_ENDL;
2113 std::vector<fei::CSVec*>& eqnArray = eqnBuf.
eqns();
2114 for(
int i=0; i<numEqns; ++i) {
2117 eqnNumbers[i] = reducedEqn;
2119 int* indicesPtr = &(eqnArray[i]->indices()[0]);
2120 int numIndices = eqnArray[i]->size();
2121 for(
int j=0; j<numIndices; ++j) {
2123 indicesPtr[j] = reducedEqn;
2134 int dim1 = eqnTable.size();
2135 for(
int i=0; i<dim1; ++i) {
2136 int dim2 = eqnTable[i]->size();
2137 int* indicesPtr = &(*(eqnTable[i]))[0];
2138 for(
int j=0; j<dim2; ++j) {
2141 indicesPtr[j] = reducedEqn;
2156 int reducedEqn = -1;
2161 std::vector<int>& rowNumbers = srg.
rowNumbers;
2162 for(
size_t i=0; i<rowNumbers.size(); ++i) {
2164 if (isSlave) foundSlave = 1;
2165 else rowNumbers[i] = reducedEqn;
2169 for(
size_t i=0; i<colIndices.size(); ++i) {
2171 if (isSlave) foundSlave = 1;
2172 else colIndices[i] = reducedEqn;
2196 for(
size_t i=0; i<rowNumbers.size(); ++i) {
2197 int row = rowNumbers[i];
2198 int offset = rowOffsets[i];
2199 int rowlen = rowOffsets[i+1]-offset;
2200 const int* indices = &pckColInds[offset];
2202 for(
int j=0; j<rowlen; j++) {
2212 const char* callingFunction)
2230 dbgOut() <<
" " << callingFunction <<
" passed " <<row<<
","<<col
2238 dbgOut() <<
"# " << callingFunction <<
" crtMatPos("
2239 << row <<
"," << col <<
")"<<
FEI_ENDL;
2251 const char* callingFunction)
2269 dbgOut() <<
" " << callingFunction <<
" passed " <<row
2278 for(
int i=0; i<numCols; i++) {
2280 dbgOut() <<
"# " << callingFunction <<
" crtMatPoss("
2281 << row <<
"," << cols[i] <<
")"<<
FEI_ENDL;
2307 const int* fieldSizes = fieldIDs+numFields;
2308 int numNonNegativeFields = 0;
2309 int maxFieldSize = 0;
2310 for(
int f=0;
f<numFields;
f++) {
2311 if (fieldIDs[
f] >= 0) {
2312 numNonNegativeFields++;
2313 if (fieldSizes[
f] > maxFieldSize) maxFieldSize = fieldSizes[
f];
2317 if (numNonNegativeFields == 1 && maxFieldSize == 1) {
2323 int localVanishedNodeAdjustment = 0;
2328 int eqnNumber, blkEqnNumber;
2331 std::map<GlobalID,int>::iterator
2332 iter = nodeIDmap.begin(), iter_end = nodeIDmap.end();
2334 for(; iter!=iter_end; ++iter) {
2339 if (node==NULL)
continue;
2343 if(numFields == 0)
continue;
2349 int blkSize = numNodalDOF;
2351 for(
int j=0; j<numNodalDOF; ++j) {
2365 ++localVanishedNodeAdjustment;
2377 for(
int i = 0; i < numBlocks; i++) {
2383 if (numElemDOF > 0) {
2386 for(
int j=0; j<numElems; j++) {
2388 for(
int ede=0; ede<numElemDOF; ede++) {
2389 blkEqnMapper.
setEqn(eqnNumber+ede, blkEqnNumber+ede);
2393 eqnNumber += numElemDOF;
2394 blkEqnNumber += numElemDOF;
2403 std::map<GlobalID,ConstraintType*>::const_iterator
2407 std::vector<int> localMultEqns;
2408 localMultEqns.reserve(
multCRs_.size()*2);
2409 while(cr_iter != cr_end) {
2417 localMultEqns.push_back(eqnNumber);
2418 localMultEqns.push_back(blkEqnNumber);
2441 std::vector<int> recvLengths, globalMultEqns;
2446 if (p == localProc_) { offset += recvLengths[p];
continue; }
2448 for(
int j=0; j<recvLengths[p]/2; j++) {
2466 std::map<GlobalID,ConstraintType*>::const_iterator
2473 while(cr_iter != cr_end) {
2492 osstr <<
dbgPath_ <<
"/FEI" <<
name_ <<
"_nID_nNum_blkEq_ptEq."
2498 fei::console_out() <<
"SNL_FEI_Structure::writeEqn2NodeMap: ERROR, couldn't open file "
2503 std::map<GlobalID,ConstraintType*>::const_iterator
2507 while(cr_iter != cr_end) {
2512 e2nFile <<
"-999 -999 " << blkEqnNumber <<
" " << eqnNumber <<
FEI_ENDL;
2517 std::map<GlobalID,int>::iterator
2518 iter = nodeIDmap.begin(), iter_end = nodeIDmap.end();
2520 for(; iter!=iter_end; ++iter) {
2534 for(
int j=0; j<numFields; j++) {
2536 assert( numFieldParams > 0 );
2538 for(
int k=0; k<numFieldParams; k++) {
2540 <<
" " << blkEqnNumber <<
" " << eqnNumbers[j]+k<<
FEI_ENDL;
2552 int totalNumElemDOF = 0;
2554 for(
int i = 0; i < numBlocks; i++) {
2558 if (numElemDOF > 0) {
2561 totalNumElemDOF += numElems*numElemDOF;
2565 return(totalNumElemDOF);
2571 int totalNumMultCRs = 0;
2574 totalNumMultCRs = numMCRecords;
2576 return( totalNumMultCRs );
2582 int numLocalEqnBlks)
2596 std::vector<int> numProcNodes(
numProcs_);
2597 std::vector<int> numProcEqns(
numProcs_);
2598 std::vector<int> numProcEqnBlks(
numProcs_);
2605 glist[0] = numLocallyOwnedNodes;
2606 glist[1] = numLocalEqns;
2607 glist[2] = numLocalEqnBlks;
2608 if (MPI_Gather(&glist[0], 3, MPI_INT, &recvList[0], 3,
2615 numProcNodes[p] = recvList[p*3];
2616 numProcEqns[p] = recvList[p*3+1];
2617 numProcEqnBlks[p] = recvList[p*3+2];
2622 numProcNodes[0] = numLocallyOwnedNodes;
2623 numProcEqns[0] = numLocalEqns;
2624 numProcEqnBlks[0] = numLocalEqnBlks;
2642 numProcEqnBlks[i-1];
2646 numProcNodes[numProcs_-1];
2648 numProcEqns[numProcs_-1];
2650 numProcEqnBlks[numProcs_-1];
2657 std::vector<int> blist(3*(
numProcs_+1));
2668 if (MPI_Bcast(&blist[0], 3*(
numProcs_+1), MPI_INT,
2716 os <<
"# leaving calcGlobalEqnInfo" <<
FEI_ENDL;
2737 std::map<GlobalID,int>::iterator
2738 iter = nodeIDmap.begin(), iter_end = nodeIDmap.end();
2740 for(; iter!=iter_end; ++iter) {
2744 if (node==NULL)
continue;
2750 int numNodalDOF = 0;
2752 for(
int j=0; j<numFields; j++) {
2756 numNodalDOF += fieldSize;
2780 for(
int i = 0; i < numBlocks; i++) {
2787 if (numElemDOF > 0) {
2789 std::map<GlobalID,int>& elemIDs =
connTables_[i]->elemIDs;
2791 std::map<GlobalID,int>::const_iterator
2792 iter = elemIDs.begin(),
2793 iter_end = elemIDs.end();
2795 for(; iter != iter_end; ++iter) {
2796 elemDOFEqns[iter->second] = eqnNumber;
2798 eqnNumber += numElemDOF;
2811 int insertPoint = -1;
2836 fei::console_out() <<
"SNL_FEI_Structure::getBlockDescriptor: ERROR, blockID "
2837 << (int)blockID <<
" not found." <<
FEI_ENDL;
2870 fei::console_out() <<
"SNL_FEI_Structure::allocateConnectivityTable: ERROR, blockID "
2871 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
2876 blocks_[index]->getNumNodesPerElement();
2878 int numRows =
blocks_[index]->getNumElements();
2879 int numCols =
connTables_[index]->numNodesPerElem;
2881 if ((numRows <= 0) || (numCols <= 0)) {
2882 fei::console_out() <<
"SNL_FEI_Structure::allocateConnectivityTable: ERROR, either "
2883 <<
"numElems or numNodesPerElem not yet set for blockID "
2884 << (int)blockID <<
". Aborting." <<
FEI_ENDL;
2890 connTables_[index]->elem_conn_ids =
new std::vector<GlobalID>(numRows*numCols);
2901 fei::console_out() <<
"SNL_FEI_Structure::getBlockConnectivity: ERROR, blockID "
2902 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
2914 os <<
"# finalizeActiveNodes" <<
FEI_ENDL;
2920 for(
unsigned i=0; i<shNodeIDs.size(); i++) {
2937 for(
int bIndex=0; bIndex<numBlocks; bIndex++) {
2945 int numElems = conn.
elemIDs.size();
2950 conn.
elem_conn_ptrs =
new std::vector<NodeDescriptor*>(elemConnLen);
2956 int* fieldsPerNodePtr =
blocks_[bIndex]->fieldsPerNodePtr();
2957 int** fieldIDsTablePtr =
blocks_[bIndex]->fieldIDsTablePtr();
2972 int numDistinctFields =
blocks_[bIndex]->getNumDistinctFields();
2973 int fieldID = fieldIDsTablePtr[0][0];
2976 for(elem=0; elem<numElems; elem++) {
2978 GlobalID* elemNodes = &(elemConn[elem*nodesPerElem]);
2979 NodeDescriptor** elemNodePtrs = &(elemNodeDescPtrs[elem*nodesPerElem]);
2981 for(
int n=0;
n<nodesPerElem;
n++) {
2985 fei::console_out() <<
"ERROR in SNL_FEI_Structure::initializeActiveNodes, "
2986 <<
FEI_ENDL <<
"failed to find node "
2987 << (int)(elemNodes[n]) <<
FEI_ENDL;
2990 if (numDistinctFields == 1) {
2994 for(
int i=0; i<fieldsPerNodePtr[n]; i++) {
2995 node->
addField(fieldIDsTablePtr[n][i]);
3005 elemNodePtrs[n] = node;
3019 std::map<GlobalID,ConstraintType*>::const_iterator
3023 while(cr_iter != cr_end) {
3025 std::vector<GlobalID>& nodeID_vec = cr.
getMasters();
3026 GlobalID* nodeIDs = &nodeID_vec[0];
3030 for(
int k=0; k<numNodes; ++k) {
3059 FEI_COUT <<
"FEI Info: A consistency-check of shared-node data will be "
3060 <<
"performed, which involves all-to-all communication. This check is "
3061 <<
"done only if explicitly requested by parameter "
3062 <<
"'FEI_CHECK_SHARED_IDS'."<<
FEI_ENDL;
3070 os <<
"# numSharedNodes: " << numSharedNodes <<
FEI_ENDL;
3071 for(
int ns=0; ns<numSharedNodes; ns++) {
3075 os <<
"# shNodeID " << (int)nodeID <<
", owned by proc "<<proc<<FEI_ENDL;
3089 std::vector<int> nodesPerBlock(numBlocks);
3090 std::vector<int> eqnsPerBlock(numBlocks);
3093 for(j=0; j<numBlocks; j++) {
3094 nodesPerBlock[j] = 0;
3095 eqnsPerBlock[j] = 0;
3100 for(j=0; j<numNodes; j++) {
3103 if (node==NULL)
continue;
3110 for(std::vector<unsigned>::const_iterator b=blkIndices.begin(), bend=blkIndices.end();
3112 nodesPerBlock[*b]++;
3114 for(
int fld=0; fld<numFields; fld++) {
3115 if (
blocks_[*b]->containsField(fieldIDList[fld])) {
3118 eqnsPerBlock[*b] += fSize;
3124 for(j=0; j<numBlocks; j++) {
3125 blocks_[j]->setNumActiveNodes(nodesPerBlock[j]);
3131 for(j=0; j<numBlocks; j++) {
3132 eqnsPerBlock[j] +=
blocks_[j]->getNumElemDOFPerElement() *
3135 blocks_[j]->setTotalNumEqns(eqnsPerBlock[j]);
3156 for(
int i=0; i<numSharedNodes; i++) {
3172 for(
int j=0; j<numFields; j++) {
3174 assert(numEqns >= 0);
3177 for(eqn=0; eqn<numEqns; eqn++) {
3178 int reducedEqn = -1;
3181 if (isSlave)
continue;
3189 for(
int j=0; j<numFields; j++) {
3191 assert(numEqns >= 0);
3192 for(
int eqn=0; eqn<numEqns; eqn++) {
3193 int reducedEqn = -1;
3195 if (isSlave)
continue;
3208 int& localStartRow,
int& localEndRow){
3218 int idType,
int fieldID,
3219 int& numEqns,
int* eqnNumbers)
3230 int nodeFieldEqnNumber = -1;
3235 for(
int i=0; i<numEqns; i++) eqnNumbers[i] = nodeFieldEqnNumber + i;
3243 int idType,
int fieldID,
3244 int& numEqns,
int* eqnNumbers)
3250 if (fieldSize < 0) {
3255 for(
int i=0; i<numIDs; ++i) {
3260 for(
int ii=0; ii<fieldSize; ii++) {
3261 eqnNumbers[offset++] = -1;
3267 int nodeFieldEqnNumber = -1;
3273 for(
int ii=0; ii<fieldSize; ii++) {
3274 eqnNumbers[offset++] = -1;
3279 for(
int ii=0; ii<fieldSize; ii++) {
3280 eqnNumbers[offset++] = nodeFieldEqnNumber + ii;
3285 numEqns = fieldSize*numIDs;
3297 int insertPoint = -1;
3301 int localAdjustment = index < 0 ? insertPoint : index + 1;
3308 int& numLocalEqnBlks,
3309 int& localBlkOffset) {
3326 std::vector<int> eqns;
3327 std::vector<int> mEqns;
3328 std::vector<double> mCoefs;
3336 numEqns, &eqns[0]));
3342 const std::vector<double>* mWeights = svar->
getWeights();
3343 const std::vector<double>& mWeightsRef = *mWeights;
3346 for(
size_t j=0; j<mNodes->size(); j++) {
3349 eqns.resize(mfSize);
3351 int mFieldID = (*mFields)[j];
3355 double fei_eps = 1.e-49;
3357 for(
int k=0; k<mfSize; k++) {
3358 if (std::abs(mWeightsRef[mwOffset++]) > fei_eps) {
3359 mEqns.push_back(eqns[k]);
3360 mCoefs.push_back(mWeightsRef[mwOffset-1]);
3366 mEqns.size(),
false) );
3373 int globalMaxSlaves = 0;
3376 if (globalMaxSlaves > 0) {
3391 os <<
"# slave-equations:" <<
FEI_ENDL;
3393 os <<
"# leaving calculateSlaveEqns" <<
FEI_ENDL;
3396 int levelsOfCoupling;
3400 os <<
"# SNL_FEI_Structure: " << levelsOfCoupling
3401 <<
" level(s) of coupling removed: " <<
FEI_ENDL;
3425 int numLocalNodesVanished = 0;
3431 int reducedSlaveEqn;
3433 int numMasters = mstrEqns[i]->size();
3438 os <<
"# no local node for slave eqn " << slvEqns[i] <<
FEI_ENDL;
3447 numLocalNodesVanished++;
3464 for(
int j=0; j<numMasters; j++) {
3465 int masterEquation = mstrEqns[i]->indices()[j];
3468 int reducedMasterEqn;
3472 int numSharing = sharingProcs.size();
3473 for(
int sp=0; sp<numSharing; sp++) {
3474 if (sharingProcs[sp] ==
localProc_)
continue;
3477 os <<
"# slave node " << (int)slvNodeID <<
",eqn "<<slvEqns[i]
3478 <<
", master eqn " << masterEquation <<
" eqnCommMgr_->addLocal "
3479 << reducedMasterEqn <<
", proc " << sharingProcs[sp] << FEI_ENDL;
3483 &reducedMasterEqn, 1);
3488 os <<
"# slave node " << (int)slvNodeID <<
",eqn "<<slvEqns[i]
3489 <<
", master eqn " << masterEquation <<
" eqnCommMgr_->addRemote "
3490 << reducedMasterEqn <<
", proc " << owner << FEI_ENDL;
3493 &reducedMasterEqn, 1);
3499 std::vector<int> tmp(1), tmp2(
numProcs_);
3500 tmp[0] = numLocalNodesVanished;
3508 int tmpNumVanished = 0;
3509 for(
int proc=0; proc<
numProcs_; ++proc) {
3510 int temporary = tmpNumVanished;
3521 os <<
"# slave-equations:" <<
FEI_ENDL;
3523 os <<
"# leaving calculateSlaveEqns" <<
FEI_ENDL;
3532 std::vector<int>& eqnNumbers = eqnbuf.
eqnNumbers();
3533 std::vector<fei::CSVec*>& eqns = eqnbuf.
eqns();
3535 std::vector<double> tempCoefs;
3536 std::vector<int> tempIndices;
3538 levelsOfCoupling = 0;
3539 bool finished =
false;
3541 bool foundCoupling =
false;
3542 for(
size_t i=0; i<eqnNumbers.size(); i++) {
3545 if (rowIndex == (
int)i) {
3547 <<
" illegal master-slave constraint coupling. Eqn "
3548 << eqnNumbers[i] <<
" is both master and slave. " <<
FEI_ENDL;
3552 while(rowIndex >= 0) {
3553 foundCoupling =
true;
3556 eqnNumbers[i], coef) );
3558 std::vector<int>& indicesRef = eqns[i]->indices();
3559 std::vector<double>& coefsRef = eqns[i]->coefs();
3561 int len = indicesRef.size();
3562 tempCoefs.resize(len);
3563 tempIndices.resize(len);
3565 double* tempCoefsPtr = &tempCoefs[0];
3566 int* tempIndicesPtr = &tempIndices[0];
3567 double* coefsPtr = &coefsRef[0];
3568 int* indicesPtr = &indicesRef[0];
3570 for(
int j=0; j<len; ++j) {
3571 tempIndicesPtr[j] = indicesPtr[j];
3572 tempCoefsPtr[j] = coef*coefsPtr[j];
3576 tempIndicesPtr, len,
true) );
3581 if (foundCoupling) ++levelsOfCoupling;
3582 else finished =
true;
3584 if (levelsOfCoupling>1 && !finished) {
3586 <<
" too many (>1) levels of master-slave constraint coupling. "
3587 <<
"Hint: coupling is considered infinite if two slaves depend on "
3588 <<
"each other. This may or may not be the case here." <<
FEI_ENDL;
3603 if (MPI_Comm_size(comm, &numProcs) !=
MPI_SUCCESS)
return(-1);
3604 if (numProcs == 1)
return(0);
3606 if (MPI_Comm_rank(comm, &localProc) !=
MPI_SUCCESS)
return(-1);
3612 ProcEqns localProcEqns, remoteProcEqns;
3613 std::vector<int>& slvEqnNums = slaveEqns->
eqnNumbers();
3615 if (slaveEqns->
eqns().size() > 0) slvEqnsPtr = &(slaveEqns->
eqns()[0]);
3617 for(
size_t i=0; i<slvEqnNums.size(); i++) {
3619 if (p == localProc)
continue;
3621 localProcEqns.
addEqn(slvEqnNums[i], slvEqnsPtr[i]->size(), p);
3632 &remoteProcEqns, &remoteEqns,
3649 int insertPoint = -1;
3652 if (foundOffset >= 0)
return(
true);
3659 if (
numSlvs_ == 0) { reducedEqn = eqn;
return(
false); }
3661 if (eqn <
lowestSlv_) {reducedEqn = eqn;
return(
false); }
3667 bool isSlave =
false;
3669 if (foundOffset < 0) {
3670 reducedEqn = eqn - index;
3673 isSlave =
true; reducedEqn = eqn - (foundOffset+1);
3684 if (numSlvs == 0)
return(reducedEqn);
3688 if (reducedEqn < slvEqns[0])
return(reducedEqn);
3690 int eqn = reducedEqn;
3692 for(
int i=0; i<numSlvs; i++) {
3693 if (eqn < slvEqns[i])
return(eqn);
3702 std::vector<int>*& masterEqns)
3713 if (foundOffset >= 0) {
3725 std::vector<double>*& masterCoefs)
3736 if (foundOffset >= 0) {
3758 if (foundOffset >= 0) {
3760 rhsValue = (*rhsCoefsPtr)[0];
3768 int interleaveStrategy,
3769 int* scatterIndices)
3774 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID "
3775 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
3779 std::map<GlobalID,int>& elemIDs =
connTables_[index]->elemIDs;
3781 std::map<GlobalID,int>::const_iterator
3782 iter = elemIDs.find(elemID);
3784 if (iter == elemIDs.end()) {
3785 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID: "
3786 << (int)blockID <<
", elemID "
3787 << (
int)elemID <<
" not found. Aborting." <<
FEI_ENDL;
3791 int elemIndex = iter->second;
3794 interleaveStrategy, scatterIndices);
3799 int interleaveStrategy,
3800 int* scatterIndices,
3801 int* blkScatterIndices,
3807 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID "
3808 << (int)blockID <<
" not found. Aborting." <<
FEI_ENDL;
3812 std::map<GlobalID,int>& elemIDs =
connTables_[index]->elemIDs;
3814 std::map<GlobalID,int>::const_iterator
3815 iter = elemIDs.find(elemID);
3817 if (iter == elemIDs.end()) {
3818 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_ID: ERROR, blockID: "
3819 << (int)blockID <<
", elemID "
3820 << (
int)elemID <<
" not found. Aborting." <<
FEI_ENDL;
3824 int elemIndex = iter->second;
3827 interleaveStrategy, scatterIndices,
3828 blkScatterIndices, blkSizes);
3834 int* scatterIndices)
3842 fei::console_out() <<
"SNL_FEI_Structure::getBlkScatterIndices_index: ERROR getting"
3843 <<
" node descriptors." <<
FEI_ENDL;
3853 int interleaveStrategy,
3854 int* scatterIndices)
3869 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_index: ERROR getting"
3870 <<
" node descriptors." <<
FEI_ENDL;
3877 scatterIndices, offset);
3881 switch (interleaveStrategy) {
3884 scatterIndices, offset);
3890 scatterIndices, offset);
3901 int numElemDOF =
blocks_[blockIndex]->getNumElemDOFPerElement();
3902 std::vector<int>& elemDOFEqns =
blocks_[blockIndex]->elemDOFEqnNumbers();
3904 for(
int i=0; i<numElemDOF; i++) {
3905 scatterIndices[offset++] = elemDOFEqns[elemIndex] + i;
3911 int interleaveStrategy,
3912 int* scatterIndices,
3913 int* blkScatterIndices,
3929 fei::console_out() <<
"SNL_FEI_Structure::getScatterIndices_index: ERROR getting"
3930 <<
" node descriptors." <<
FEI_ENDL;
3934 int offset = 0, blkOffset = 0;
3937 scatterIndices, offset,
3938 blkScatterIndices, blkSizes, blkOffset);
3942 switch (interleaveStrategy) {
3945 scatterIndices, offset,
3946 blkScatterIndices, blkSizes, blkOffset);
3952 scatterIndices, offset);
3963 int numElemDOF =
blocks_[blockIndex]->getNumElemDOFPerElement();
3964 std::vector<int>& elemDOFEqns =
blocks_[blockIndex]->elemDOFEqnNumbers();
3966 for(
int i=0; i<numElemDOF; i++) {
3967 scatterIndices[offset++] = elemDOFEqns[elemIndex] + i;
3968 if (interleaveStrategy == 0) {
3969 blkSizes[blkOffset] = 1;
3970 blkScatterIndices[blkOffset++] = elemDOFEqns[elemIndex] + i;
3985 int numNodes =
connTables_[blockIndex]->numNodesPerElem;
3989 &((*
connTables_[blockIndex]->elem_conn_ptrs)[elemIndex*numNodes]);
3990 for(
int i=0; i<numNodes; ++i) nodes[i] = elemNodePtrs[i];
3994 &((*
connTables_[blockIndex]->elem_conn_ids)[elemIndex*numNodes]);
3995 for(
int i=0; i<numNodes; ++i) {
4007 int* scatterIndices,
4012 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4015 int eqn = eqnNumbers[0];
4016 scatterIndices[offset++] = eqn;
4017 if (fieldSize > 1) {
4018 for(
int i=1; i<fieldSize; i++) {
4019 scatterIndices[offset++] = eqn+i;
4030 int* scatterIndices,
4032 int* blkScatterIndices,
4038 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4041 int eqn = eqnNumbers[0];
4042 scatterIndices[offset++] = eqn;
4043 if (fieldSize > 1) {
4044 for(
int i=1; i<fieldSize; i++) {
4045 scatterIndices[offset++] = eqn+i;
4056 int** fieldIDs,
int* fieldsPerNode,
4057 int* scatterIndices,
int& offset)
4059 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4067 int* fieldID_ind = fieldIDs[nodeIndex];
4069 for(
int j=0; j<fieldsPerNode[nodeIndex]; j++) {
4071 assert(numEqns >= 0);
4078 int eqn = nodeEqnNums[nind];
4081 FEI_COUT <<
"SNL_FEI_Structure::getNodeMajorIndices: ERROR, node "
4083 <<
", field " << nodeFieldIDList[nind]
4084 <<
" has equation number " << eqn <<
FEI_ENDL;
4088 for(
int jj=0; jj<numEqns; jj++) {
4089 scatterIndices[offset++] = eqn+jj;
4095 <<
" not found for node "
4108 int* scatterIndices,
4111 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4120 int** fieldIDs,
int* fieldsPerNode,
4121 int* scatterIndices,
int& offset,
4122 int* blkScatterIndices,
4126 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4137 int* fieldID_ind = fieldIDs[nodeIndex];
4139 for(
int j=0; j<fieldsPerNode[nodeIndex]; j++) {
4141 assert(numEqns >= 0);
4148 int eqn = nodeEqnNums[nind];
4150 FEI_COUT <<
"SNL_FEI_Structure::getNodeMajorIndices: ERROR, node "
4152 <<
", field " << nodeFieldIDList[nind]
4153 <<
" has equation number " << eqn <<
FEI_ENDL;
4157 for(
int jj=0; jj<numEqns; jj++) {
4158 scatterIndices[offset++] = eqn+jj;
4164 <<
" not found for node "
4176 std::vector<int>* fieldIDs,
4177 std::vector<int>& fieldsPerNode,
4178 std::vector<int>& scatterIndices)
4181 scatterIndices.resize(0);
4183 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4191 int* fieldID_ind = &(fieldIDs[nodeIndex][0]);
4193 for(
int j=0; j<fieldsPerNode[nodeIndex]; j++) {
4195 assert(numEqns >= 0);
4202 int eqn = nodeEqnNums[nind];
4205 FEI_COUT <<
"SNL_FEI_Structure::getNodeMajorIndices: ERROR, node "
4207 <<
", field " << nodeFieldIDList[nind]
4208 <<
" has equation number " << eqn <<
FEI_ENDL;
4212 scatterIndices.resize(offset+numEqns);
4213 int* inds = &scatterIndices[0];
4215 for(
int jj=0; jj<numEqns; jj++) {
4216 inds[offset+jj] = eqn+jj;
4223 <<
" not found for node "
4235 int** fieldIDs,
int* fieldsPerNode,
4236 int* scatterIndices,
int& offset)
4244 std::vector<int> fields;
4245 for(
int ii=0; ii<numNodes; ii++) {
4246 for(
int j=0; j<fieldsPerNode[ii]; j++) {
4247 if (std::find(fields.begin(), fields.end(), fieldIDs[ii][j]) == fields.end()) {
4248 fields.push_back(fieldIDs[ii][j]);
4253 int* fieldsPtr = fields.size()>0 ? &fields[0] : NULL;
4258 for(
size_t i=0; i<fields.size(); i++) {
4259 int field = fieldsPtr[i];
4261 for(
int nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex) {
4263 fieldsPerNode[nodeIndex]);
4275 assert(numEqns >= 0);
4282 for(
int jj=0; jj<numEqns; ++jj) {
4283 scatterIndices[offset++] = nodeEqnNums[nind]+jj;
4297 std::vector<int>* fieldIDs,
4298 std::vector<int>& fieldsPerNode,
4299 std::vector<int>& scatterIndices)
4307 std::vector<int> fields;
4308 for(
int ii=0; ii<numNodes; ii++) {
4309 for(
int j=0; j<fieldsPerNode[ii]; j++) {
4310 std::vector<int>& fldIDs = fieldIDs[ii];
4311 if (std::find(fields.begin(), fields.end(), fldIDs[j]) == fields.end()) {
4312 fields.push_back(fldIDs[j]);
4321 scatterIndices.resize(0);
4323 for(
size_t i=0; i<fields.size(); i++) {
4324 for(
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) {
4331 assert(numEqns >= 0);
4338 for(
int jj=0; jj<numEqns; jj++) {
4339 scatterIndices.push_back(nodeEqnNums[nind]+jj);
4346 <<
" not found for node "
4347 << (int)nodes[nodeIndex]->getGlobalNodeID() <<
FEI_ENDL;
4361 std::map<GlobalID,snl_fei::Constraint<GlobalID>* >::iterator
4362 cr_iter = crDB.find(CRID);
4364 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)