20 #include <FETI_DP_FiniteElementData.h>
27 #define fei_file "snl_fei_tester.cpp"
46 localProc_(localProc),
65 catch (std::runtime_error& exc) {
74 std::vector<std::string> stdstrings;
122 std::string str = osstr.str();
129 std::vector<std::string> stdstrings;
154 std::vector<std::string> stdstrings;
199 std::vector<std::string> stdstrings;
204 int status, itersTaken = 0;
207 paramset, itersTaken, status) );
236 if (
MPI_SUCCESS != MPI_Allreduce(&err, &globalErr, 1, MPI_INT, MPI_SUM,
239 if (globalErr != 0)
return(-1);
305 std::vector<int> indices(numIndices);
314 if (numIndices != checkNum) {
332 std::vector<int> idTypes;
338 for(
int j=0; j<1; ++j) {
341 crSet.
crID_ = constraintID++;
355 for(
int j=0; j<1; ++j) {
358 crSet.
crID_ = constraintID++;
369 std::map<int,int> fieldDB;
374 std::vector<int> nodeIDs;
375 std::vector<int> fieldIDs;
376 std::vector<double> weights;
388 nodeIDs[ii+1] = crSet.
nodeIDs_[0][ii];
396 for(ii=0; ii<fieldSize; ++ii) weights.push_back(0.0);
400 fieldSize = fieldDB[crSet.
fieldIDs_[ii]];
401 for(
int jj=0; jj<fieldSize; ++jj) {
402 weights.push_back(crSet.
weights_[offset++]);
426 for(
int j=0; j<1; ++j) {
436 for(
int j=0; j<1; ++j) {
450 int i, j, numIDTypes = 1;
454 std::vector<int> nodalFieldIDs;
455 std::vector<int> flatFieldIDsArray;
465 if (numIDTypes == 1 && nodalFieldIDs.size() == 1) {
471 else if (numIDTypes == 1) {
477 &flatFieldIDsArray[0]);
482 std::vector<int> numFieldsPerID(idTypes.size());
483 std::vector<int> fieldIDs;
504 const char* solnFileName,
int numProcs,
511 int* nodeList =
new int[numLocalNodes];
515 numLocalNodes, nodeList, checkNum);
521 fileName<< solnFileName<<
".node."<<solveCounter<<
"."<<numProcs<<
"."<<
localProc;
522 std::string str = fileName.str();
525 if (!outfile || outfile.bad()) {
532 std::vector<double> solnData;
533 std::vector<int> fieldList;
537 for(
int i=0; i<numLocalNodes; i++) {
539 int ID = nodeList[i];
543 solnData.resize(numDOF);
546 outfile << ID <<
" " << numDOF <<
FEI_ENDL;
547 for(
int j=0; j<numFields; ++j) {
549 totalSize += fieldSize;
552 1, &ID, &solnData[0]) );
554 for(
int k=0; k<fieldSize; ++k) {
555 outfile << solnData[k] <<
" ";
561 FEI_COUT <<
"save-node-soln: wrote " << totalSize <<
" entries for " << numLocalNodes <<
" nodes to " << str <<
FEI_ENDL;
571 const char* solnFileName,
579 int* elemList =
new int[numLocalElems];
583 numLocalElems, elemList, checkNum);
589 fileName<< solnFileName<<
".elem."<<solveCounter<<
"."<<numProcs<<
"."<<
localProc;
590 std::string str = fileName.str();
593 if (!outfile || outfile.bad()) {
598 std::vector<double> solnData;
599 std::vector<int> fieldList;
601 for(
int i=0; i<numLocalElems; i++) {
603 int ID = elemList[i];
607 solnData.resize(numDOF);
610 outfile << ID <<
" " << numDOF <<
FEI_ENDL;
611 for(
int j=0; j<numFields; ++j) {
615 1, &ID, &solnData[0]) );
617 for(
int k=0; k<fieldSize; ++k) {
618 outfile << solnData[k] <<
" ";
632 const char* solnFileName,
640 int* globalNumCRs =
new int[
numProcs];
642 if (MPI_Allgather(&numLocalCRs, 1, MPI_INT, globalNumCRs, 1, MPI_INT,
648 int localCRStart = 0;
650 for(
int p=0; p<
localProc; p++) localCRStart += globalNumCRs[p];
653 delete [] globalNumCRs;
655 std::vector<int> crList(numLocalCRs);
659 idTypes_[constraintTypeOffset_], numLocalCRs,
660 numLocalCRs ? &crList[0] : 0, checkNum);
666 fileName<< solnFileName<<
".mult."<<solveCounter<<
"."<<numProcs<<
"."<<
localProc;
667 std::string str = fileName.str();
670 if (!outfile || outfile.bad()) {
675 std::vector<double> solnData;
676 std::vector<int> fieldList;
678 for(
int i=0; i<numLocalCRs; i++) {
684 outfile << localCRStart++ <<
" " << 1 <<
FEI_ENDL;
685 for(
int j=0; j<1; ++j) {
686 int globalIndex = -1;
691 for(
int k=0; k<1; ++k) {
692 outfile << solnData[k] <<
" ";
virtual void setIndicesMode(int mode)=0
virtual void setMatrix(fei::SharedPtr< fei::Matrix > &matrix)
virtual fei::SharedPtr< fei::Solver > createSolver(const char *name=0)=0
virtual void setParameters(const fei::ParameterSet ¶ms)=0
int sortedListInsert(const T &item, std::vector< T > &list)
int initSharedIDs(int numShared, int idType, const int *sharedIDs, const int *numSharingProcsPerID, const int *sharingProcs)
void char_ptrs_to_strings(int numStrings, const char *const *charstrings, std::vector< std::string > &stdstrings)
virtual const char * typeName()=0
double * prescribed_values_
virtual int loadEssentialBCs(int numIDs, const int *IDs, int idType, int fieldID, int offsetIntoField, const double *prescribedValues)
virtual int loadLagrangeConstraint(int constraintID, const double *weights, double rhsValue)=0
int constraintTypeOffset_
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
fei::SharedPtr< fei::Matrix > A_
void setParameter(const char *param)
virtual int parameters(int numParams, const char *const *paramStrings)=0
virtual void parameters(const fei::ParameterSet ¶mset)
virtual int copyOutFieldData(int fieldID, int idType, int numIDs, const int *IDs, double *data, int vectorIndex=0)=0
fei::SharedPtr< fei::Factory > factory_
virtual int initLagrangeConstraint(int constraintID, int constraintIDType, int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs)=0
fei::SharedPtr< fei::Vector > b_
fei::SharedPtr< fei::VectorSpace > vecSpace_
std::string solverLibraryName_
virtual int initSlaveConstraint(int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs, int offsetOfSlave, int offsetIntoSlaveField, const double *weights, double rhsValue)=0
virtual void setSolutionVector(fei::SharedPtr< fei::Vector > &soln)
virtual int loadPenaltyConstraint(int constraintID, const double *weights, double penaltyValue, double rhsValue)=0
void definePattern(ElemBlock &eb, int &patternID)
virtual fei::SharedPtr< fei::LinearSystem > createLinearSystem(fei::SharedPtr< fei::MatrixGraph > &matrixGraph)
int save_block_elem_soln(DataReader &data, fei::Vector *vec, const char *solnFileName, int numProcs, int localProc, int solveCounter)
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
virtual void setRHS(fei::SharedPtr< fei::Vector > &rhs)
virtual int scatterToOverlap()=0
virtual int loadComplete(bool applyBCs=true, bool globalAssemble=true)=0
virtual int putScalar(double scalar)=0
virtual int getConnectivityNumIndices(int blockID) const =0
void setParameters(const fei::ParameterSet ¶mset)
void defineFieldsAndIDTypes()
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
int getGlobalIndex(int idType, int ID, int fieldID, int fieldOffset, int whichComponentOfField, int &globalIndex)
virtual int initConnectivity(int blockID, int connectivityID, const int *connectedIdentifiers)=0
virtual int initComplete()=0
void add(const Param ¶m, bool maintain_unique_keys=true)
int checkSolution(int localProc, int numProcs, const char *solnFileName, const char *checkFileName, const char *extension, int solveCounter)
int getOwnedAndSharedIDs(int idtype, int lenList, int *IDs, int &numOwnedAndSharedIDs)
virtual int writeToFile(const char *filename, bool matrixMarketFormat=true)=0
int save_multiplier_soln(DataReader &data, fei::Vector *vec, const char *solnFileName, int numProcs, int localProc, int solveCounter)
virtual int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)=0
virtual int getConnectivityIndices(int blockID, int connectivityID, int indicesAllocLen, int *indices, int &numIndices)=0
CommNodeSet * sharedNodeSets_
virtual int sumIn(int numValues, const int *indices, const double *values, int vectorIndex=0)=0
void defineIDTypes(int numIDTypes, const int *idTypes)
virtual int createSlaveMatrices()=0
std::string checkFileName_
LinearSystemCore * linSysCore_
virtual fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)=0
fei::SharedPtr< fei::Vector > x_
int getFieldSize(int fieldID)
void getFields(std::vector< int > &fieldIDs)
std::ostream & console_out()
fei::SharedPtr< fei::MatrixGraph > matrixGraph_
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
std::vector< int > idTypes_
snl_fei_tester(fei::SharedPtr< DataReader > data_reader, MPI_Comm comm, int localProc, int numProcs)
fei::SharedPtr< fei::LinearSystem > linSys_
std::string solnFileName_
int getNumOwnedAndSharedIDs(int idType)
int localProc(MPI_Comm comm)
virtual int solve(fei::LinearSystem *linearSystem, fei::Matrix *preconditioningMatrix, const fei::ParameterSet ¶meterSet, int &iterationsTaken, int &status)
virtual int definePattern(int numIDs, int idType)=0
unsigned getFieldSize(int fieldID)
virtual int initPenaltyConstraint(int constraintID, int constraintIDType, int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs)=0
virtual fei::SharedPtr< fei::Matrix > createMatrix(fei::SharedPtr< fei::MatrixGraph > matrixGraph)=0
FiniteElementData * feData_
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)=0
int getNumDegreesOfFreedom(int idType, int ID)
virtual int putScalar(double scalar)=0
fei::SharedPtr< DataReader > data_
#define FEI_OSTRINGSTREAM
virtual int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const =0
virtual int parameters(const fei::ParameterSet ¶mset)=0
int save_block_node_soln(DataReader &data, fei::Vector *vec, const char *solnFileName, int numProcs, int localProc, int solveCounter)
int numProcs(MPI_Comm comm)
virtual int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)=0