34 #define fei_file "FEI_Implementation.cpp"
41 : wrapper_(libWrapper),
44 haveLinSysCore_(false),
46 problemStructure_(NULL),
49 internalFEIsAllocated_(false),
55 matScalarsSet_(false),
57 rhsScalarsSet_(false),
58 index_soln_filter_(0),
59 index_current_filter_(0),
60 index_current_rhs_row_(0),
62 setSolveTypeCalled_(false),
63 initPhaseIsComplete_(false),
64 aggregateSystemFormed_(false),
65 newMatrixDataLoaded_(0),
66 soln_fei_matrix_(NULL),
67 soln_fei_vector_(NULL),
76 dbgFileOpened_(false),
135 (*dbgOStreamPtr_) <<
"FEI: destructor" <<
FEI_ENDL;
180 for(
size_t i=0; i<
rhsIDs_.size(); i++) {
200 (*dbgOStreamPtr_) <<
"FEI: setCurrentMatrix" <<
FEI_ENDL <<
"#matrix-id"
211 (*dbgOStreamPtr_) <<
"#--- ID: " << matID
217 fei::console_out() <<
"FEI_Implementation::setCurrentMatrix: ERROR, invalid matrix ID "
222 debugOut(
"#FEI_Implementation leaving setCurrentMatrix");
239 (*dbgOStreamPtr_) <<
"FEI: setCurrentRHS" <<
FEI_ENDL <<
"#rhs-id"
256 fei::console_out() <<
"FEI_Implementation::setCurrentRHS: ERROR, invalid RHS ID"
261 debugOut(
"#FEI_Implementation leaving setCurrentRHS");
270 (*dbgOStreamPtr_)<<
"FEI: setSolveType"<<
FEI_ENDL;
271 (*dbgOStreamPtr_)<<solveType<<
FEI_ENDL;
278 messageAbort(
"setSolveType: solve-type is FEI_SINGLE_SYSTEM, but setIDLists() has been called with numMatrices > 1.");
300 int numRHSs,
const int* rhsIDs)
308 for(i=0; i<numMatrices; ++i) os << matrixIDs[i] <<
" ";
309 os << FEI_ENDL <<
"#num-rhs's" <<
FEI_ENDL;
310 for(i=0; i<numRHSs; ++i) os << rhsIDs[i] <<
" ";
321 int myNumMatrices = numMatrices;
322 if (myNumMatrices == 0) myNumMatrices = 1;
330 if (numMatrices == 0) {
334 for(
int i=0; i<numMatrices; i++)
matrixIDs_[i] = matrixIDs[i];
337 int quotient = numRHSs/myNumMatrices;
338 int rem = numRHSs%numMatrices;
350 for(
int i=0; i<myNumMatrices; i++) {
357 rhsIDs_[i][j] = rhsIDs[offset+j];
360 offset += numRHSIDs_[i];
368 const int *fieldSizes,
370 const int *fieldTypes)
380 int numNodesPerElement,
381 const int* numFieldsPerNode,
382 const int*
const* nodalFieldIDs,
383 int numElemDofFieldsPerElement,
384 const int* elemDOFFieldIDs,
385 int interleaveStrategy)
392 numElemDofFieldsPerElement,
394 interleaveStrategy) );
412 int offsetIntoSlaveField,
415 const int* masterFieldIDs,
416 const double* weights,
420 offsetIntoSlaveField,
421 numMasterNodes, masterNodeIDs,
422 masterFieldIDs, weights, rhsValue));
445 const int* numProcsPerNode,
446 const int *
const *sharingProcIDs)
569 const int* offsetsIntoField,
570 const double* prescribedValues)
580 offsetsIntoField, prescribedValues));
589 const double *
const *alpha,
590 const double *
const *beta,
591 const double *
const *gamma)
610 const double*
const* elemStiffness,
611 const double* elemLoad,
619 elemConn, elemStiffness,
620 elemLoad, elemFormat));
631 const double*
const* elemStiffness,
639 elemStiffness, elemFormat))
651 const double* elemLoad)
657 elemID, elemConn, elemLoad))
669 const double* CRWeights,
679 CRFields, CRWeights, CRValue));
689 const double* CRWeights,
711 const double* rhsEntries)
717 numIDs, IDs, rhsEntries) );
728 const double* coefficients)
734 numIDs, IDs, coefficients) );
745 const double* rhsEntries)
751 numIDs, IDs, rhsEntries) );
759 const int* IDs,
const double* scalars)
761 for(
int i=0; i<numScalars; i++){
762 std::vector<int>::iterator iter =
769 fei::console_out() <<
"FEI_Implementation::setMatScalars: ERROR, invalid ID supplied"
783 const int* IDs,
const double* scalars)
785 for(
int i=0; i<numScalars; i++){
798 fei::console_out() <<
"FEI_Implementation::setRHSScalars: ERROR, invalid RHS ID supplied"
816 if (numParams == 0 || paramStrings == NULL) {
823 paramStrings, numParams);
835 (*dbgOStreamPtr_)<<
"FEI: parameters"<<
FEI_ENDL;
836 (*dbgOStreamPtr_)<<
"#FEI_Implementation, num-params "<<FEI_ENDL
838 (*dbgOStreamPtr_)<<
"# "<<numParams<<
" parameter lines follow:"<<
FEI_ENDL;
839 for(
int i=0; i<numParams; i++){
840 (*dbgOStreamPtr_)<<paramStrings[i]<<
FEI_ENDL;
859 debugOut(
"#FEI_Implementation leaving parameters method");
879 osstr << path <<
"/";
891 const char* version_str = NULL;
894 (*dbgFStreamPtr_) << version_str <<
FEI_ENDL;
914 (void)globalAssemble;
923 int* fieldIDs,
double* norms)
927 double residTime = 0.0;
930 fieldIDs, norms, residTime);
968 double& solnReturnTime)
1026 const double *estimates)
1030 offsets, estimates))
1039 const double *estimates)
1043 nodeIDs, estimates);
1051 int& numElemDOFPerElement,
1056 numElemDOFPerElement,
1066 const double *estimates)
1070 dofPerElem, estimates))
1087 std::map<GlobalID,snl_fei::Constraint<GlobalID>*>::const_iterator
1091 while(cr_iter != cr_end) {
1092 multIDs[i++] = (*cr_iter).first;
1102 double* multipliers)
1105 CRIDs, multipliers))
1112 const double *multEstimates)
1138 getBlockConnectivity(elemBlockID);
1140 std::map<GlobalID,int>& elemIDList = connTable.
elemIDs;
1141 int len = elemIDList.size();
1142 if (len > numElems) len = numElems;
1163 for(
int i=0; i<numActiveNodes; i++) {
1166 if (node==NULL)
continue;
1169 if (offset == numNodes)
break;
1177 int& nodesPerElem)
const
1271 int& DOFPerElem)
const
1298 int fieldID,
int& numEqns,
1306 numEqns, eqnNumbers) );
1316 nodeIDs, results) );
1331 std::map<GlobalID,int>& nodes =
1333 numNodes = nodes.size();
1335 if (lenNodeIDs < len) len = lenNodeIDs;
1346 const double* nodeData)
1349 nodeIDs, nodeData) );
1383 if (anyDataLoaded) {
1399 FEI_COUT <<
"FEI_Implementation: WARNING: solveType_==2, aggregating system, but setMatScalars and/or setRHSScalars not yet called." <<
FEI_ENDL;
1408 debugOut(
"# leaving buildLinearSystem");
1475 debugOut(
"# leaving aggregateSystem");
1503 for(
int j=0; j<numRHSIDs_[i]; j++){
1510 if (numInternalFEIs_ > 0) {
1530 lsc->setNumRHSVectors(1, &dummyID);
1551 fei::console_out() <<
"FEI_Implementation: ERROR, don't have LinearSystemCore"
1552 <<
" or FiniteElementData implementation..." <<
FEI_ENDL;
1559 osstr<<
"internalFei "<< i;
1560 std::string osstr_str = osstr.str();
1561 const char* param = osstr_str.c_str();
1565 (*dbgOStreamPtr_)<<
"#-- fei["<<i<<
"]->setNumRHSVectors "
1595 (*dbgOStreamPtr_)<<msg<<
", -> fei["<<whichFEI<<
"]"<<
FEI_ENDL;
1610 <<
FEI_ENDL <<
"ERROR, internal data structures not allocated."
1611 <<
FEI_ENDL <<
"'setIDLists' and/or 'setSolveType' must be called"
1612 <<
FEI_ENDL <<
"first to identify solveType and number of matrices"
1621 <<
FEI_ENDL <<
"FEI_Implementation: ERROR, numMatrices has not been specified."
1622 <<
FEI_ENDL <<
"FEI_Implementation: 'parameters' must be called up front with"
1623 <<
FEI_ENDL <<
"FEI_Implementation: the string 'numMatrices n' to specify that"
1624 <<
FEI_ENDL <<
"FEI_Implementation: n matrices will be assembled." <<
FEI_ENDL;
1632 <<
FEI_ENDL <<
"FEI_Implementation: ERROR, inconsistent 'solveType' and"
1633 <<
FEI_ENDL <<
"FEI_Implementation: 'numMatrices' parameters specified."
1634 <<
FEI_ENDL <<
"FEI_Implementation: Aborting."
void messageAbort(const char *msg)
int getBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
virtual int residualNorm(int whichNorm, int numFields, int *fieldIDs, double *norms, double &residTime)=0
int resetSystem(double s=0.0)
virtual int parameters(int numParams, char **params)=0
int setDbgOut(std::ostream &ostr, const char *path, const char *feiName)
int putBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, const double *estimates)
int getParameters(int &numParams, char **¶mStrings)
int getNumElemDOFPerElement()
int getFieldSize(int fieldID)
int setRHSScalars(int numScalars, const int *IDs, const double *scalars)
virtual ~FEI_Implementation()
std::map< GlobalID, int > & getNodeIDs()
void debugOut(const char *msg)
#define FEI_AGGREGATE_SUM
int getNodalFieldSolution(int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
bool hasBlockIndex(unsigned blk_idx) const
int getNumNodalDOF() const
int putBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, const int *offsets, const double *estimates)
int allocateInternalFEIs()
int sumInElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, const double *elemLoad, int elemFormat)
int loadElemBCs(int numElems, const GlobalID *elemIDs, int fieldID, const double *const *alpha, const double *const *beta, const double *const *gamma)
FEI_Implementation(fei::SharedPtr< LibraryWrapper > libWrapper, MPI_Comm comm, int masterRank=0)
int loadNodeBCs(int numNodes, const GlobalID *nodeIDs, int fieldID, const int *offsetsIntoField, const double *prescribedValues)
std::ostream * dbgOStreamPtr_
int getNodalSolution(int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
int initSlaveVariable(GlobalID slaveNodeID, int slaveFieldID, int offsetIntoSlaveField, int numMasterNodes, const GlobalID *masterNodeIDs, const int *masterFieldIDs, const double *weights, double rhsValue)
int iterations(int &itersTaken) const
void setTypeName(const char *name)
int setIDLists(int numMatrices, const int *matrixIDs, int numRHSs, const int *rhsIDs)
int getBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
bool aggregateSystemFormed_
std::vector< int > numRHSIDs_
int getEqnNumbers(GlobalID ID, int idType, int fieldID, int &numEqns, int *eqnNumbers)
NodeDatabase & getNodeDatabase()
int getNumElemBlocks(int &numElemBlocks) const
int index_current_rhs_row_
int sumInElemMatrix(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, int elemFormat)
int initCRPen(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
int version(const char *&versionString)
int initCRMult(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
virtual int parameters(int numParams, const char *const *paramStrings)
int getEqnNumbers(GlobalID ID, int idType, int fieldID, int &numEqns, int *eqnNumbers)
virtual int putBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, const double *estimates)=0
int resetInitialGuess(double s=0.0)
int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)
int mergeStringLists(char **&strings, int &numStrings, const char *const *stringsToMerge, int numStringsToMerge)
void copyKeysToArray(const MAP_TYPE &map_obj, unsigned lenList, int *list)
int sumIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *rhsEntries)
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDofFieldIDs, int interleaveStrategy)
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)
#define FEI_SINGLE_SYSTEM
int setSolveType(int solveType)
virtual int exchangeRemoteEquations()
int getNumBlockActEqns(GlobalID blockID, int &numEqns) const
int loadComplete(bool applyBCs=true, bool globalAssemble=true)
int getBlockNodeIDList(GlobalID elemBlockID, int numNodes, GlobalID *nodeIDs)
int getBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int &numElemDOFPerElement, double *results)
virtual int setNumRHSVectors(int numRHSs, int *rhsIDs)=0
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
fei::SharedPtr< LinearSystemCore > getLinearSystemCore()
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
int getCRMultIDList(int numMultCRs, int *multIDs)
virtual LinearSystemCore * clone()=0
std::vector< double * > rhsScalars_
void needParametersAbort(const char *name)
int setCurrentRHS(int rhsID)
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
void getNodeAtIndex(int i, const NodeDescriptor *&node) const
std::vector< fei::SharedPtr< LinearSystemCore > > lscArray_
std::vector< int > matrixIDs_
#define FEI_AGGREGATE_PRODUCT
GlobalID getGlobalNodeID() const
bool initPhaseIsComplete_
int getNumEqnsPerElement(GlobalID blockID, int &numEqns) const
std::map< GlobalID, int > elemIDs
SNL_FEI_Structure * problemStructure_
void setSharedOwnershipRule(int ownershipRule)
int getBlockElemIDList(GlobalID elemBlockID, int numElems, GlobalID *elemIDs)
int cumulative_cpu_times(double &initTime, double &loadTime, double &solveTime, double &solnReturnTime)
int putBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int dofPerElem, const double *estimates)
int putNodalFieldData(int fieldID, int numNodes, const GlobalID *nodeIDs, const double *nodeData)
int initCRMult(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
int parameters(int numParams, const char *const *paramStrings)
int initCRPen(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
int sumIntoMatrixDiagonal(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)
int index_current_filter_
fei::SharedPtr< FiniteElementData > getFiniteElementData()
int getNumNodesPerElement() const
void setLogStream(std::ostream *logstrm)
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
std::vector< double > matScalars_
int getBlockDescriptor(GlobalID blockID, BlockDescriptor *&block)
void setDebugOutput(const char *path, const char *name)
virtual int setNumRHSVectors(int numRHSs, const int *rhsIDs)=0
void * getDataPtr() const
bool haveLinearSystemCore()
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)
void setDataPtr(void *ptr)
virtual int destroyVectorData(Data &data)=0
fei::SharedPtr< LibraryWrapper > wrapper_
virtual int loadComplete()=0
int getNumCRMultipliers(int &numMultCRs)
int getNumNodesPerElement(GlobalID blockID, int &nodesPerElem) const
const char * getTypeName() const
fei::SharedPtr< LinearSystemCore > linSysCore_
int putIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *rhsEntries)
int localProc(MPI_Comm comm)
int loadCRPen(int CRID, int numCRNodes, const GlobalID *CRNodes, const int *CRFields, const double *CRWeights, double CRValue, double penValue)
int getCRMultipliers(int numCRs, const int *CRIDs, double *multipliers)
virtual int parameters(int numParams, const char *const *params)=0
int getNumBlockElements(GlobalID blockID, int &numElems) const
bool internalFEIsAllocated_
int resetMatrix(double s=0.0)
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
int getNumSolnParams(GlobalID nodeID, int &numSolnParams) const
int getNumLocalNodes(int &numNodes)
virtual int solve(int &status, double &sTime)=0
int loadCRMult(int CRID, int numCRNodes, const GlobalID *CRNodes, const int *CRFields, const double *CRWeights, double CRValue)
void badParametersAbort(const char *name)
int getLocalNodeIDList(int &numNodes, GlobalID *nodeIDs, int lenNodeIDs)
int putCRMultipliers(int numMultCRs, const int *CRIDs, const double *multEstimates)
int setMatScalars(int numScalars, const int *IDs, const double *scalars)
std::map< GlobalID, snl_fei::Constraint< GlobalID > * > & getMultConstRecords()
bool haveFiniteElementData()
std::ofstream * dbgFStreamPtr_
int getNodeWithID(GlobalID nodeID, const NodeDescriptor *&node) const
int getNumMultConstRecords()
int getIntParamValue(const char *key, int numParams, const char *const *params, int ¶mValue)
int getNumEqnsPerElement()
int parameters(int numParams, const char *const *paramStrings)
virtual int deleteMultCRs()=0
int resetRHSVector(double s=0.0)
#define FEI_OSTRINGSTREAM
const char * getParamValue(const char *key, int numParams, const char *const *paramStrings, char separator=' ')
virtual int iterations() const =0
int getFieldSize(int fieldID, int &numScalars)
int residualNorm(int whichNorm, int numFields, int *fieldIDs, double *norms)
int getNumBlockElemDOF(GlobalID blockID, int &DOFPerElem) const
int searchList(const T &item, const T *list, int len)
int initComplete(bool generateGraph=true)
std::vector< int * > rhsIDs_
virtual int destroyMatrixData(Data &data)=0
int getNumBlockActNodes(GlobalID blockID, int &numNodes) const
int numProcs(MPI_Comm comm)
NodeCommMgr & getNodeCommMgr()
int getIndexOfBlock(GlobalID blockID) const
void notAllocatedAbort(const char *name)
int setCurrentMatrix(int matID)