9 #include <fei_macros.hpp>
11 #include <fei_utils.hpp>
13 #include <fei_FEI_Impl.hpp>
14 #include <fei_Record.hpp>
15 #include <fei_TemplateUtils.hpp>
16 #include <fei_ParameterSet.hpp>
17 #include <fei_base.hpp>
19 #include <fei_Pattern.hpp>
20 #include <fei_LibraryWrapper.hpp>
21 #include <fei_Data.hpp>
28 #define fei_file "fei_FEI_Impl.cpp"
30 #include <fei_ErrMacros.hpp>
47 soln_fei_matrix_(NULL),
48 soln_fei_vector_(NULL),
50 masterRank_(masterRank),
58 matScalarsSet_(false),
60 rhsScalarsSet_(false),
64 index_current_rhs_row_(0),
67 setSolveTypeCalled_(false),
68 initPhaseIsComplete_(false),
69 aggregateSystemFormed_(false),
70 newMatrixDataLoaded_(0),
78 nodeset_filled_(false),
79 block_dof_per_elem_(),
80 any_blocks_have_elem_dof_(false)
82 wrapper_[0] = wrapper;
85 createdFactory_ =
true;
87 basic_initializations();
98 createdFactory_(false),
106 soln_fei_matrix_(NULL),
107 soln_fei_vector_(NULL),
109 masterRank_(masterRank),
117 matScalarsSet_(false),
119 rhsScalarsSet_(false),
123 index_current_rhs_row_(0),
126 setSolveTypeCalled_(false),
127 initPhaseIsComplete_(false),
128 aggregateSystemFormed_(false),
129 newMatrixDataLoaded_(0),
134 solnReturnTime_(0.0),
137 nodeset_filled_(false),
138 block_dof_per_elem_(),
139 any_blocks_have_elem_dof_(false)
141 wrapper_[0].reset(0);
145 if (snlfactory != NULL) {
149 factory_[0] = factory->
clone();
151 basic_initializations();
156 for(
int k=0; k<numParams_; k++) {
157 delete [] paramStrings_[k];
159 delete [] paramStrings_;
161 if (soln_fei_matrix_ != NULL && wrapper_[0].
get() != NULL) {
163 if (lsc.
get() != NULL) {
165 delete soln_fei_matrix_;
166 soln_fei_matrix_ = NULL;
170 if (soln_fei_vector_ != NULL && wrapper_[0].
get() != NULL) {
172 if (lsc.
get() != NULL) {
174 delete soln_fei_vector_;
175 soln_fei_vector_ = NULL;
180 void fei::FEI_Impl::basic_initializations()
185 constraintID_ = localProc_*100000;
187 matrixIDs_.resize(1);
194 rowSpace_ = factory_[0]->createVectorSpace(comm_, (
const char*)NULL);
196 rowSpace_->defineIDTypes(1, &nodeIDType_);
197 rowSpace_->defineIDTypes(1, &elemIDType_);
198 rowSpace_->defineIDTypes(1, &constraintIDType_);
200 matGraph_ = factory_[0]->createMatrixGraph(rowSpace_, rowSpace_,(
const char*)NULL);
201 if (matGraph_.get() == NULL) {
207 const int* matrixIDs,
211 if (numMatrices < 1 || numRHSs < 1) {
212 fei::console_out() <<
"fei::FEI_Impl::setIDLists ERROR, numMatrices and numRHSs "
213 <<
"must both be greater than 0."<<FEI_ENDL;
217 matrixIDs_.resize(0);
218 A_.resize(numMatrices);
219 for(
int i=0; i<numMatrices; ++i) {
222 if ((
int)matrixIDs_.size() != numMatrices) {
223 fei::console_out() <<
"fei::FEI_Impl::setIDLists ERROR creating matrixIDs_ list."<<FEI_ENDL;
229 for(
int i=0; i<numRHSs; ++i) {
232 if ((
int)rhsIDs_.size() != numRHSs) {
233 fei::console_out() <<
"fei::FEI_Impl::setIDLists ERROR creating rhsIDs_ list."<<FEI_ENDL;
237 if (wrapper_[0].
get() != NULL) {
239 if (linSysCore.
get() != NULL) {
253 const char *
const* paramStrings)
256 snl_fei::mergeStringLists(paramStrings_, numParams_,
257 paramStrings, numParams);
259 if (wrapper_[0].
get() != NULL) {
260 if (wrapper_[0]->haveLinearSystemCore()) {
261 CHK_ERR( wrapper_[0]->getLinearSystemCore()->parameters(numParams, (
char**)paramStrings) );
263 if (wrapper_[0]->haveFiniteElementData()) {
264 CHK_ERR( wrapper_[0]->getFiniteElementData()->parameters(numParams, (
char**)paramStrings) );
268 std::vector<std::string> stdstrings;
272 factory_[0]->parameters(paramset);
279 solveType_ = solveType;
280 setSolveTypeCalled_ =
true;
286 const int *fieldSizes,
288 const int *fieldTypes)
290 rowSpace_->defineFields(numFields, fieldIDs, fieldSizes, fieldTypes);
297 int numNodesPerElement,
298 const int* numFieldsPerNode,
299 const int*
const* nodalFieldIDs,
300 int numElemDofFieldsPerElement,
301 const int* elemDOFFieldIDs,
302 int interleaveStrategy)
307 int numIDs = numNodesPerElement;
308 if (numElemDofFieldsPerElement > 0) ++numIDs;
309 std::vector<int> idTypes;
310 std::vector<int> numFieldsPerID;
311 std::vector<int> fieldIDs;
314 for(i=0; i<numNodesPerElement; ++i) {
315 idTypes.push_back(nodeIDType_);
316 numFieldsPerID.push_back(numFieldsPerNode[i]);
318 for(j=0; j<numFieldsPerNode[i]; ++j) {
319 fieldIDs.push_back(nodalFieldIDs[i][j]);
323 if (numElemDofFieldsPerElement>0) {
324 idTypes.push_back(elemIDType_);
325 numFieldsPerID.push_back(numElemDofFieldsPerElement);
326 for(i=0; i<numElemDofFieldsPerElement; ++i) {
327 fieldIDs.push_back(elemDOFFieldIDs[i]);
330 block_dof_per_elem_.insert(std::pair<int,int>(elemBlockID, numElemDofFieldsPerElement));
331 any_blocks_have_elem_dof_ =
true;
334 int pattID = matGraph_->definePattern(numIDs,
340 CHK_ERR( matGraph_->initConnectivityBlock(elemBlockID, numElements,
348 const GlobalID* elemConn)
350 bool elemdof =
false;
352 if (any_blocks_have_elem_dof_) {
353 std::map<int,int>::const_iterator
354 b_iter = block_dof_per_elem_.find(elemBlockID);
355 if (b_iter != block_dof_per_elem_.end()) {
356 int numIDs = matGraph_->getNumIDsPerConnectivityList(elemBlockID);
357 iwork_.resize(numIDs);
358 int* iworkPtr = &iwork_[0];
359 for(
int i=0; i<numIDs-1; ++i) {
360 iworkPtr[i] = elemConn[i];
362 iworkPtr[numIDs-1] = elemID;
364 CHK_ERR( matGraph_->initConnectivity(elemBlockID, elemID, iworkPtr) );
370 CHK_ERR( matGraph_->initConnectivity(elemBlockID, elemID, elemConn) );
373 nodeset_filled_ =
false;
380 int offsetIntoSlaveField,
382 const GlobalID* masterNodeIDs,
383 const int* masterFieldIDs,
384 const double* weights,
387 throw std::runtime_error(
"FEI_Impl::initSlaveVariable not implemented.");
393 throw std::runtime_error(
"FEI_Impl::deleteMultCRs not implemented.");
398 const GlobalID *sharedNodeIDs,
399 const int* numProcsPerNode,
400 const int *
const *sharingProcIDs)
402 CHK_ERR( rowSpace_->initSharedIDs(numSharedNodes,
412 const GlobalID* CRNodeIDs,
413 const int *CRFieldIDs,
416 iwork_.assign(numCRNodes,nodeIDType_);
418 CRID = constraintID_++;
420 CHK_ERR( matGraph_->initLagrangeConstraint(CRID,
431 const GlobalID* CRNodeIDs,
432 const int *CRFieldIDs,
435 iwork_.assign(numCRNodes, nodeIDType_);
437 CRID = constraintID_++;
439 CHK_ERR( matGraph_->initPenaltyConstraint(CRID,
451 CHK_ERR( matGraph_->initComplete() );
453 if (matrixIDs_.size() < 1 || factory_.size() < 1 ||
454 A_.size() < 1 || b_.size() < 1) {
458 A_[0] = factory_[0]->createMatrix(matGraph_);
460 std::vector<std::string> stdstrings;
465 CHK_ERR( A_[0]->parameters(params) );
467 b_[0] = factory_[0]->createVector(matGraph_);
469 if (matrixIDs_.size() > 1) {
470 bool multiple_factories =
false;
472 if (wrapper_[0].
get() != NULL) {
473 multiple_factories =
true;
476 if (linsyscore.
get() == NULL) {
477 fei::console_out() <<
"fei::FEI_Impl ERROR, multiple matrix/rhs assembly not supported "
478 <<
"non-null LibraryWrapper holds null LinearSystemCore."<<FEI_ENDL;
482 wrapper_.resize(matrixIDs_.size());
483 factory_.resize(matrixIDs_.size());
484 for(
unsigned i=1; i<matrixIDs_.size(); ++i) {
486 wrapper_[i].
reset(
new LibraryWrapper(lscclone));
492 for(
unsigned i=1; i<matrixIDs_.size(); ++i) {
493 factory = multiple_factories ? factory_[i] : factory_[0];
496 CHK_ERR( A_[i]->parameters(params) );
499 for(
unsigned i=1; i<rhsIDs_.size(); ++i) {
500 factory = multiple_factories ? factory_[i] : factory_[0];
505 if (wrapper_[0].
get() != NULL) {
507 = wrapper_[0]->getLinearSystemCore();
511 unsigned num = rhsIDs_.size();
512 if (matrixIDs_.size() < num) num = matrixIDs_.size();
513 for(
unsigned i=1; i<num; ++i) {
516 if (i==num-1 && rhsIDs_.size() > num) {
517 int numRHSs = rhsIDs_.size() - matrixIDs_.size() + 1;
525 if (rhsIDs_.size() < matrixIDs_.size()) {
527 for(
unsigned i=rhsIDs_.size(); i<matrixIDs_.size(); ++i) {
528 wrapper_[i]->getLinearSystemCore()->setNumRHSVectors(1, &dummyID);
533 for(
unsigned i=1; i<matrixIDs_.size(); ++i) {
534 factory = multiple_factories ? factory_[i] : factory_[0];
537 CHK_ERR( A_[i]->parameters(params) );
540 for(
unsigned i=1; i<rhsIDs_.size(); ++i) {
541 factory = multiple_factories ? factory_[i] : factory_[0];
547 x_ = factory_[0]->createVector(matGraph_,
true);
549 linSys_ = factory_[0]->createLinearSystem(matGraph_);
551 CHK_ERR( linSys_->parameters(numParams_, paramStrings_) );
553 linSys_->setMatrix(A_[0]);
554 linSys_->setRHS(b_[0]);
555 linSys_->setSolutionVector(x_);
562 std::vector<int>::const_iterator
563 iter = std::lower_bound(matrixIDs_.begin(), matrixIDs_.end(), matID);
564 if (iter == matrixIDs_.end() || *iter != matID) {
566 <<
") not found." <<FEI_ENDL;
570 index_current_ = iter-matrixIDs_.begin();
577 std::vector<int>::const_iterator
578 iter = std::lower_bound(rhsIDs_.begin(), rhsIDs_.end(), rhsID);
579 if (iter == rhsIDs_.end() || *iter != rhsID) {
580 fei::console_out() <<
"fei::FEI_Impl::setCurrentRHS: rhsID ("<<rhsID<<
") not found."
585 index_current_rhs_row_ = iter - rhsIDs_.begin();
592 int err = A_[index_current_]->putScalar(s);
593 err += x_->putScalar(s);
594 err += b_[index_current_rhs_row_]->putScalar(s);
601 return( A_[index_current_]->putScalar(s) );
606 return( b_[index_current_rhs_row_]->putScalar(s) );
611 return( x_->putScalar(s) );
615 const GlobalID *nodeIDs,
617 const int* offsetsIntoField,
618 const double* prescribedValues)
620 CHK_ERR( linSys_->loadEssentialBCs(numNodes, nodeIDs,
621 nodeIDType_, fieldID,
622 offsetsIntoField, prescribedValues) );
630 const GlobalID* elemIDs,
632 const double *
const *alpha,
633 const double *
const *beta,
634 const double *
const *gamma)
636 throw std::runtime_error(
"FEI_Impl::loadElemBCs not implemented.");
642 const GlobalID* elemConn,
643 const double*
const* elemStiffness,
644 const double* elemLoad,
647 CHK_ERR( A_[index_current_]->sumIn(elemBlockID, elemID, elemStiffness, elemFormat) );
649 int num = matGraph_->getConnectivityNumIndices(elemBlockID);
650 std::vector<int> indices(num);
651 CHK_ERR( matGraph_->getConnectivityIndices(elemBlockID, elemID, num,
653 CHK_ERR( b_[index_current_rhs_row_]->sumIn(num, &indices[0], elemLoad, 0) );
662 const GlobalID* elemConn,
663 const double*
const* elemStiffness,
666 CHK_ERR( A_[index_current_]->sumIn(elemBlockID, elemID, elemStiffness, elemFormat) );
675 const GlobalID* elemConn,
676 const double* elemLoad)
678 int num = matGraph_->getConnectivityNumIndices(elemBlockID);
679 std::vector<int> indices(num);
680 CHK_ERR( matGraph_->getConnectivityIndices(elemBlockID, elemID, num,
682 CHK_ERR( b_[index_current_rhs_row_]->sumIn(num, &indices[0], elemLoad, 0) );
691 const GlobalID* CRNodeIDs,
692 const int* CRFieldIDs,
693 const double* CRWeights,
698 CHK_ERR( linSys_->loadLagrangeConstraint(CRMultID, CRWeights, CRValue) );
705 const GlobalID* CRNodeIDs,
706 const int* CRFieldIDs,
707 const double* CRWeights,
713 CHK_ERR( linSys_->loadPenaltyConstraint(CRPenID, CRWeights, penValue, CRValue) );
722 const double* coefficients)
724 CHK_ERR( inputRHS(IDType, fieldID, numIDs, IDs, coefficients,
false) );
735 const double* coefficients)
737 CHK_ERR( inputRHS(IDType, fieldID, numIDs, IDs, coefficients,
true) );
744 int fei::FEI_Impl::inputRHS(
int IDType,
748 const double* coefficients,
751 int fieldSize = rowSpace_->getFieldSize(fieldID);
754 for(
int i=0; i<numIDs; ++i) {
756 CHK_ERR( rowSpace_->getGlobalIndex(IDType, IDs[i], globalIndex) );
758 for(
int j=0; j<fieldSize; ++j) {
759 int eqn = globalIndex+j;
761 CHK_ERR( b_[index_current_rhs_row_]->sumIn(1, &eqn, &(coefficients[offset++])) );
764 CHK_ERR( b_[index_current_rhs_row_]->copyIn(1, &eqn, &(coefficients[offset++])) );
774 const double* scalars)
776 matScalars_.resize(matrixIDs_.size());
778 for(
int i=0; i<numScalars; ++i) {
779 std::vector<int>::const_iterator
780 iter = std::lower_bound(matrixIDs_.begin(), matrixIDs_.end(), IDs[i]);
781 if (iter == matrixIDs_.end() || *iter != IDs[i]) {
785 unsigned index = iter - matrixIDs_.begin();
786 matScalars_[index] = scalars[i];
789 matScalarsSet_ =
true;
796 const double* scalars)
798 rhsScalars_.resize(rhsIDs_.size());
800 for(
int i=0; i<numScalars; ++i) {
801 std::vector<int>::const_iterator
802 iter = std::lower_bound(rhsIDs_.begin(), rhsIDs_.end(), IDs[i]);
803 if (iter == rhsIDs_.end() || *iter != IDs[i]) {
807 unsigned index = iter - rhsIDs_.begin();
808 rhsScalars_[index] = scalars[i];
811 rhsScalarsSet_ =
true;
823 if (linSys_.get() == NULL) {
824 fei::console_out() <<
"fei::FEI_Impl::loadComplete: loadComplete can not be called"
825 <<
" until after initComplete has been called."<<FEI_ENDL;
829 if (solveType_ == FEI_AGGREGATE_SUM) {
830 for(
unsigned i=0; i<A_.size(); ++i) {
831 CHK_ERR( A_[i]->gatherFromOverlap() );
834 for(
unsigned j=0; j<b_.size(); ++j) {
835 CHK_ERR( b_[j]->gatherFromOverlap() );
838 CHK_ERR( aggregateSystem() );
841 CHK_ERR( linSys_->loadComplete(applyBCs, globalAssemble) );
845 for(
unsigned i=0; i<b_.size(); ++i) {
846 FEI_OSTRINGSTREAM osstr;
847 osstr <<
"rhs_" << rhs_counter++;
848 CHK_ERR( linSys_->putAttribute(osstr.str().c_str(), b_[i].get()) );
857 int fei::FEI_Impl::aggregateSystem()
859 if (wrapper_[0].
get() == NULL) {
863 if (wrapper_[0].
get() != NULL) {
864 CHK_ERR( aggregateSystem_LinSysCore() );
870 int fei::FEI_Impl::aggregateSystem_LinSysCore()
873 if (lsc.
get() == NULL)
return(-1);
875 if (soln_fei_matrix_ == NULL) {
876 soln_fei_matrix_ =
new Data();
881 if (soln_fei_vector_ == NULL) {
882 soln_fei_vector_ =
new Data();
884 CHK_ERR( lsc->
setRHSID(rhsIDs_[0]) );
889 for(
unsigned i=0; i<matrixIDs_.size(); ++i) {
891 if (lsci.
get() == NULL)
return(-1);
894 CHK_ERR( lsci->
copyInMatrix(matScalars_[i], *soln_fei_matrix_) );
902 int last_mat = matrixIDs_.size() - 1;
903 for(
unsigned i=0; i<rhsIDs_.size(); ++i) {
905 wrapper_[i]->getLinearSystemCore() : wrapper_[last_mat]->getLinearSystemCore();
911 CHK_ERR( lsci->
setRHSID(rhsIDs_[i]) );
925 CHK_ERR( loadComplete() );
928 matGraph_->getRowSpace();
931 std::vector<double> residValues(numLocalEqns);
932 double* residValuesPtr = &residValues[0];
934 std::vector<int> globalEqnOffsets;
936 int firstLocalOffset = globalEqnOffsets[localProc_];
938 if (wrapper_[0].
get() == NULL) {
942 CHK_ERR( A_[index_current_]->multiply(x_.get(), r.
get()) );
945 CHK_ERR( r->
update(1.0, b_[index_current_rhs_row_].get(), -1.0) );
948 for(
int ii=0; ii<numLocalEqns; ++ii) {
949 int index = firstLocalOffset+ii;
950 CHK_ERR( r->
copyOut(1, &index, &(residValuesPtr[ii]) ) );
955 if (linSysCore.
get() != NULL) {
956 CHK_ERR( linSysCore->
formResidual(residValuesPtr, numLocalEqns) );
959 fei::console_out() <<
"FEI_Impl::residualNorm: warning: residualNorm not implemented"
960 <<
" for FiniteElementData."<<FEI_ENDL;
962 for(
int ii=0; ii<numFields; ++ii) {
964 for(
int jj=0; jj<fieldSize; ++jj) {
965 norms[offset++] = -99.9;
973 std::vector<int> nodeIDs(numLocalNodes);
974 int* nodeIDsPtr = &nodeIDs[0];
976 CHK_ERR( rowspace->
getOwnedIDs(nodeIDType_, numLocalNodes,
977 nodeIDsPtr, check) );
978 std::vector<int> indices(numLocalEqns);
979 int* indicesPtr = &indices[0];
981 std::vector<double> tmpNorms(numFields, 0.0);
983 for(
int i=0; i<numFields; ++i) {
987 nodeIDType_, fieldIDs[i],
991 for(
int j=0; j<fieldSize*numLocalNodes; ++j) {
992 if (indicesPtr[j] < 0) {
996 double val = std::abs(residValuesPtr[indicesPtr[j]-firstLocalOffset]);
999 if (val > tmp) tmp = val;
1008 fei::console_out() <<
"FEI_Impl::residualNorm: whichNorm="<<whichNorm<<
" not recognized"
1016 std::vector<double> normsArray(numFields);
1017 for(
int i=0; i<numFields; ++i) {
1018 normsArray[i] = norms[i];
1029 for(
int i=0; i<numFields; ++i) {
1030 norms[i] = normsArray[i];
1033 if (whichNorm == 2) {
1034 for(
int ii=0; ii<numFields; ++ii) {
1035 norms[ii] = std::sqrt(norms[ii]);
1044 CHK_ERR( loadComplete() );
1048 std::vector<std::string> stdstrings;
1053 int err = solver->
solve(linSys_.get(),
1055 params, iterations_, status);
1057 CHK_ERR( x_->scatterToOverlap() );
1064 itersTaken = iterations_;
1079 double& solnReturnTime)
1081 initTime = initTime_;
1082 loadTime = loadTime_;
1083 solveTime = solveTime_;
1084 solnReturnTime = solnReturnTime_;
1091 const GlobalID *nodeIDs,
1096 return ( getNodalSolution(numNodes, nodeIDs, offsets, results) );
1100 const GlobalID* nodeIDs,
1106 std::vector<int> fieldIDs;
1107 for(
int i=0; i<numNodes; ++i) {
1108 offsets[i] = offset;
1110 GlobalID nodeID = nodeIDs[i];
1112 int numFields = rowSpace_->getNumFields(nodeIDType_, nodeID);
1113 iwork_.resize( numFields*2 );
1114 int* fieldSizes = &iwork_[0];
1115 rowSpace_->getFields(nodeIDType_, nodeID, fieldIDs);
1118 for(j=0; j<numFields; ++j) {
1119 fieldSizes[j] = rowSpace_->getFieldSize(fieldIDs[j]);
1120 numDOF += fieldSizes[j];
1123 if (!rowSpace_->isLocal(nodeIDType_, nodeID)) {
1128 int results_offset = offset;
1129 for(j=0; j<numFields; ++j) {
1130 CHK_ERR( x_->copyOutFieldData(fieldIDs[j], nodeIDType_,
1132 &(results[results_offset])));
1134 results_offset += fieldSizes[j];
1140 offsets[numNodes] = offset;
1148 const GlobalID *nodeIDs,
1151 throw std::runtime_error(
"FEI_Impl::getBlockFieldNodeSolution not implemented.");
1157 const GlobalID *elemIDs,
1158 int& numElemDOFPerElement,
1161 std::map<int,int>::const_iterator b_iter = block_dof_per_elem_.find(elemBlockID);
1162 if (b_iter == block_dof_per_elem_.end())
return(-1);
1163 numElemDOFPerElement = (*b_iter).second;
1167 FEI_OSTRINGSTREAM osstr;
1168 osstr<<
"fei::FEI_Impl::getBlockElemSolution ERROR, elemBlockID "
1169 << elemBlockID <<
" not valid.";
1170 throw std::runtime_error(osstr.str());
1180 std::vector<int> fieldIDs;
1183 for(i=0; i<numIDs; ++i) {
1184 if (idTypes[i] == elemIDType_) {
1185 for(
int j=0; j<numFieldsPerID[i]; ++j) {
1186 fieldIDs.push_back(fIDs[foffset++]);
1190 foffset += numFieldsPerID[i];
1193 if (fieldIDs.size() < 1) {
1198 for(i=0; i<numElems; ++i) {
1200 for(
size_t j=0; j<fieldIDs.size(); ++j) {
1202 getFieldSize(fieldIDs[j], fieldSize);
1204 CHK_ERR( x_->copyOutFieldData(fieldIDs[j], elemIDType_, 1, &(elemIDs[i]),
1205 &(results[foffset])) );
1206 foffset += fieldSize;
1209 offset += numElemDOFPerElement;
1217 numMultCRs = rowSpace_->getNumOwnedAndSharedIDs(constraintIDType_);
1224 CHK_ERR( rowSpace_->getOwnedAndSharedIDs(constraintIDType_, numMultCRs,
1225 multIDs, checkNum) );
1231 double *multipliers)
1233 iwork_.resize(numCRs);
1235 for(
int i=0; i<numCRs; ++i) {
1236 CHK_ERR( rowSpace_->getGlobalIndex(constraintIDType_, CRIDs[i], iwork_[i]));
1239 CHK_ERR( x_->copyOut(numCRs, &iwork_[0], multipliers) );
1246 const GlobalID *nodeIDs,
1248 const double *estimates)
1250 throw std::runtime_error(
"FEI_Impl::putBlockNodeSolution not implemented.");
1257 const GlobalID *nodeIDs,
1258 const double *estimates)
1260 throw std::runtime_error(
"FEI_Impl::putBlockFieldNodeSolution not implemented.");
1266 const GlobalID *elemIDs,
1268 const double *estimates)
1270 throw std::runtime_error(
"FEI_Impl::putBlockElemSolution not implemented.");
1276 const double* multEstimates)
1278 throw std::runtime_error(
"FEI_Impl::putCRMultipliers not implemented.");
1286 if (!nodeset_filled_ || elemBlockID != nodeset_blockid_) {
1287 CHK_ERR( fillNodeset(elemBlockID) );
1294 int fei::FEI_Impl::fillNodeset(
int blockID)
const
1296 if (nodeset_filled_ && blockID == nodeset_blockid_) {
1302 FEI_OSTRINGSTREAM osstr;
1303 osstr<<
"fei::FEI_Impl::fillNodeset ERROR, blockID "
1304 << blockID <<
" not valid.";
1305 throw std::runtime_error(osstr.str());
1310 matGraph_->getRowSpace()->getRecordCollection(nodeType, nodeRecords);
1315 for(
unsigned i=0; i<nodes.size(); ++i) {
1316 nodeset_.insert(nodeRecords->getRecordWithLocalID(nodes[i])->getID());
1319 nodeset_filled_ =
true;
1320 nodeset_blockid_ = blockID;
1331 FEI_OSTRINGSTREAM osstr;
1332 osstr<<
"fei::FEI_Impl::getBlockElemIDList ERROR, elemBlockID "
1333 << elemBlockID <<
" not valid.";
1334 throw std::runtime_error(osstr.str());
1346 numSolnParams = rowSpace_->getNumDegreesOfFreedom( nodeIDType_, nodeID);
1352 numElemBlocks = matGraph_->getNumConnectivityBlocks();
1358 if (!nodeset_filled_ || blockID != nodeset_blockid_) {
1359 CHK_ERR( fillNodeset(blockID) );
1362 numNodes = nodeset_.size();
1368 throw std::runtime_error(
"fei::FEI_Impl::getNumBlockActEqns not implemented.");
1374 nodesPerElem = matGraph_->getNumIDsPerConnectivityList(blockID);
1380 numEqns = matGraph_->getConnectivityNumIndices(blockID);
1387 matGraph_->getConnectivityBlock(blockID);
1388 if (cblock != NULL) {
1399 std::map<int,int>::const_iterator b_iter = block_dof_per_elem_.find(blockID);
1400 if (b_iter == block_dof_per_elem_.end()) DOFPerElem = 0;
1401 else DOFPerElem = (*b_iter).second;
1408 numParams = numParams_;
1409 paramStrings = paramStrings_;
1415 numScalars = rowSpace_->getFieldSize(fieldID);
1425 numEqns = rowSpace_->getFieldSize(fieldID);
1426 CHK_ERR( rowSpace_->getGlobalIndices(1, &ID, idType, fieldID, eqnNumbers) );
1432 const GlobalID* nodeIDs,
1435 CHK_ERR( x_->copyOutFieldData(fieldID, nodeIDType_, numNodes,
1436 nodeIDs, results) );
1442 numNodes = rowSpace_->getNumOwnedAndSharedIDs(nodeIDType_);
1450 CHK_ERR( rowSpace_->getOwnedAndSharedIDs(nodeIDType_, lenNodeIDs, nodeIDs, numNodes) );
1456 const GlobalID* nodeIDs,
1457 const double* nodeData)
1461 bool data_passed =
false;
1462 if (wrapper_[0].
get() != NULL) {
1463 std::vector<int> numbers(numNodes);
1464 for(
int i=0; i<numNodes; ++i) {
1465 err = rowSpace_->getGlobalBlkIndex(nodeIDType_, nodeIDs[i], numbers[i]);
1468 << nodeIDs[i] <<
" not found."<<FEI_ENDL;
1475 fieldSize = rowSpace_->getFieldSize(fieldID);
1477 catch (std::runtime_error& exc) {
1478 fei::console_out() <<
"fei::FEI_Impl::putNodalFieldData ERROR: " <<exc.what()<<FEI_ENDL;
1483 if (linSysCore.
get() != NULL) {
1485 &numbers[0], numNodes, nodeData);
1492 if (fedata.
get() != NULL) {
1494 &numbers[0], nodeData);
1502 if (wrapper_[0].
get() == NULL) {
1506 numNodes, nodeIDs, nodeData) );
1507 if (fieldID == -3) {
1508 CHK_ERR( linSys_->putAttribute(
"coordinates", dataVector.
get()) );
1511 FEI_OSTRINGSTREAM osstr;
1512 osstr <<
"fieldID:" << fieldID;
1513 CHK_ERR( linSys_->putAttribute(osstr.str().c_str(), dataVector.
get()) );
1517 fei::console_out() <<
"fei::FEI_Impl::putNodalFieldData ERROR, non-null LibraryWrapper"
1518 <<
" contains neither LinearSystemCore or FiniteElementData. " <<FEI_ENDL;
1525 CHK_ERR( x_->copyInFieldData(fieldID, nodeIDType_,
1526 numNodes, nodeIDs, nodeData));
virtual int setRHSID(int rhsID)=0
int GlobalSum(MPI_Comm comm, std::vector< T > &local, std::vector< T > &global)
int setSolveType(int solveType)
int sortedListInsert(const T &item, std::vector< T > &list)
int getNumLocalNodes(int &numNodes)
int putNodalFieldData(int fieldID, int numNodes, const GlobalID *nodeIDs, const double *nodeData)
void char_ptrs_to_strings(int numStrings, const char *const *charstrings, std::vector< std::string > &stdstrings)
int sumIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)
int getNumCRMultipliers(int &numMultCRs)
const int * getIDTypes() const
const std::map< int, int > & getConnectivityIDs() const
int iterations(int &itersTaken) const
int version(const char *&versionString)
const int * getNumFieldsPerID() const
int setIDLists(int numMatrices, const int *matrixIDs, int numRHSs, const int *rhsIDs)
fei::SharedPtr< fei::LinearSystem > getLinearSystem()
virtual int copyOutRHSVector(double scalar, Data &data)=0
int getBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int &numElemDOFPerElement, double *results)
int getParameters(int &numParams, char **¶mStrings)
int getOwnedIDs(int idtype, int lenList, int *IDs, int &numLocalIDs)
int initCRPen(int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, int &CRID)
virtual int putNodalFieldData(int fieldID, int fieldSize, int *nodeNumbers, int numNodes, const double *data)=0
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
const int * getFieldIDs() const
virtual int sumInRHSVector(double scalar, const Data &data)=0
void copySetToArray(const SET_TYPE &set_obj, int lenList, int *list)
int getFieldSize(int fieldID, int &numScalars)
int getNumSolnParams(GlobalID nodeID, int &numSolnParams) const
int getBlockNodeIDList(GlobalID elemBlockID, int numNodes, GlobalID *nodeIDs)
fei::SharedPtr< LibraryWrapper > get_LibraryWrapper() const
int putBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, const double *estimates)
int setCurrentMatrix(int matrixID)
int getCRMultipliers(int numCRs, const int *CRIDs, double *multipliers)
int cumulative_cpu_times(double &initTime, double &loadTime, double &solveTime, double &solnReturnTime)
virtual int getMatrixPtr(Data &data)=0
int setCurrentRHS(int rhsID)
void copyKeysToArray(const MAP_TYPE &map_obj, unsigned lenList, int *list)
virtual int update(double a, const fei::Vector *x, double b)=0
int putBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, const int *offsets, const double *estimates)
std::vector< int > & getRowConnectivities()
int parameters(int numParams, const char *const *paramStrings)
int resetSystem(double s=0.0)
int getGlobalIndices(int numIDs, const int *IDs, int idType, int fieldID, int *globalIndices)
int loadComplete(bool applyBCs=true, bool globalAssemble=true)
virtual int copyOutMatrix(double scalar, Data &data)=0
virtual int putNodalFieldData(int fieldID, int fieldSize, int numNodes, const int *nodeNumbers, const double *coefs)=0
virtual LinearSystemCore * clone()=0
int getBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
int getEqnNumbers(GlobalID ID, int idType, int fieldID, int &numEqns, int *eqnNumbers)
int getNodalSolution(int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)
int putCRMultipliers(int numMultCRs, const int *CRIDs, const double *multEstimates)
int getCRMultIDList(int numMultCRs, int *multIDs)
int getNumNodesPerElement(GlobalID blockID, int &nodesPerElem) const
int getNumOwnedIDs(int idType)
int sumInElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, const double *elemLoad, int elemFormat)
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
int getNumBlockElemDOF(GlobalID blockID, int &DOFPerElem) const
int sumInElemMatrix(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, int elemFormat)
int putBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int dofPerElem, const double *estimates)
int resetInitialGuess(double s=0.0)
int resetRHSVector(double s=0.0)
virtual int copyInFieldData(int fieldID, int idType, int numIDs, const int *IDs, const double *data, int vectorIndex=0)=0
int setMatScalars(int numScalars, const int *IDs, const double *scalars)
virtual int getRHSVectorPtr(Data &data)=0
virtual fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)=0
virtual int copyInMatrix(double scalar, const Data &data)=0
virtual fei::SharedPtr< Factory > clone() const =0
int initSlaveVariable(GlobalID slaveNodeID, int slaveFieldID, int offsetIntoSlaveField, int numMasterNodes, const GlobalID *masterNodeIDs, const int *masterFieldIDs, const double *weights, double rhsValue)
int getNumElemBlocks(int &numElemBlocks) const
virtual int setNumRHSVectors(int numRHSs, const int *rhsIDs)=0
std::ostream & console_out()
int getNumBlockActNodes(GlobalID blockID, int &numNodes) const
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
int GlobalMax(MPI_Comm comm, std::vector< T > &local, std::vector< T > &global)
virtual int destroyVectorData(Data &data)=0
int residualNorm(int whichNorm, int numFields, int *fieldIDs, double *norms)
int putIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)
int localProc(MPI_Comm comm)
int resetMatrix(double s=0.0)
int loadCRPen(int CRPenID, int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, const double *CRWeights, double CRValue, double penValue)
int getNumBlockActEqns(GlobalID blockID, int &numEqns) const
virtual int solve(fei::LinearSystem *linearSystem, fei::Matrix *preconditioningMatrix, const fei::ParameterSet ¶meterSet, int &iterationsTaken, int &status)
int initCRMult(int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, int &CRID)
virtual int sumInMatrix(double scalar, const Data &data)=0
int loadCRMult(int CRMultID, int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, const double *CRWeights, double CRValue)
unsigned getFieldSize(int fieldID)
int getNumEqnsPerElement(GlobalID blockID, int &numEqns) const
int getNumBlockElements(GlobalID blockID, int &numElems) const
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
int getBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
int loadNodeBCs(int numNodes, const GlobalID *nodeIDs, int fieldID, const int *offsetsIntoField, const double *prescribedValues)
int setRHSScalars(int numScalars, const int *IDs, const double *scalars)
int getLocalNodeIDList(int &numNodes, GlobalID *nodeIDs, int lenNodeIDs)
int loadElemBCs(int numElems, const GlobalID *elemIDs, int fieldID, const double *const *alpha, const double *const *beta, const double *const *gamma)
virtual fei::SharedPtr< fei::Matrix > createMatrix(fei::SharedPtr< fei::MatrixGraph > matrixGraph)=0
virtual int formResidual(double *values, int len)=0
int getBlockElemIDList(GlobalID elemBlockID, int numElems, GlobalID *elemIDs)
int getNodalFieldSolution(int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)
virtual int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const =0
const fei::Pattern * getRowPattern() const
virtual int destroyMatrixData(Data &data)=0
virtual int copyInRHSVector(double scalar, const Data &data)=0
int numProcs(MPI_Comm comm)
int getNumIndices_Owned() const
FEI_Impl(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm, int masterRank=0)