23 #define fei_file "test_MatrixGraph.cpp"
36 const std::string& path)
39 std::vector<int>& ids = testdata->
ids;
46 testdata, localProc, numProcs,
49 "U_MatGrph", factory);
53 false,
false,
"U_MatGrph",
54 vectorSpacePtr, factory, path);
60 false,
false,
"U_MatGrph2",
61 vectorSpacePtr, factory, path);
63 CHK_ERR( matrixGraph2Ptr->initComplete() );
65 bool equivalent =
false;
74 false,
false,
"U_MatGrph3",
75 vectorSpacePtr, factory, path);
78 std::vector<int>& fieldIDs = testdata->
fieldIDs;
79 std::vector<int>& idTypes = testdata->
idTypes;
80 int offsetOfSlave = 0;
81 int offsetIntoSlaveField = 0;
82 std::vector<double> weights(2, 1.0);
83 double rhsValue = 0.0;
84 std::vector<int> cr_idTypes(2, idTypes[0]);
85 std::vector<int> cr_fieldIDs(2, fieldIDs[0]);
115 int rowfield = 0, rowfieldsize = 1;
116 int colfield = 1, colfieldsize = 3;
128 osstr <<
"test_MatrixGraph_test7, line "<<__LINE__<<
FEI_ENDL;
129 throw std::runtime_error(osstr.str());
135 FEI_COUT <<
"testing matrix-graph with 'diagonal' connectivity block...";
142 int rowfield = 0, rowfieldsize = 1;
150 int patternID = mgraph.
definePattern(numIDs, idType, rowfield);
155 osstr <<
"test_MatrixGraph_test8, line "<<__LINE__<<
FEI_ENDL;
156 throw std::runtime_error(osstr.str());
160 int numConnLists = 1;
161 bool diagonal =
true;
164 std::vector<int> ids(numIDs);
165 for(
int i=0; i<numIDs; ++i) {
178 osstr <<
"test_MatrixGraph_test8, line "<<__LINE__<<
FEI_ENDL;
179 throw std::runtime_error(osstr.str());
183 catch(std::runtime_error& exc) {
185 osstr <<
"test_MatrixGraph_test8, caught exception: " << exc.what();
186 throw std::runtime_error(osstr.str());
215 std::vector<int> idTypes(numIDs, 1);
217 std::vector<int> numFieldsPerID(numIDs, 1);
218 std::vector<int> fieldIDs(numIDs, 0);
219 std::vector<int> fieldSizes(numIDs, 1);
222 &numFieldsPerID[0], &fieldIDs[0], &fieldSizes[0]);
236 std::vector<int>& ids = testdata->
ids;
246 "U_MatGrph", factory);
252 false,
false,
"U_MatGrph", vectorSpacePtr, factory,
path_);
258 std::vector<int> globalIndexOffsets;
262 int numRowLengths = globalIndexOffsets[
localProc_+1] -
270 std::vector<int>& rowOffsets = localgraph->
rowOffsets;
271 numLocalRows = rowOffsets.size()-1;
273 if (numLocalRows != numRowLengths)
ERReturn(-1);
275 int correctNumLocalRows =
localProc_==0 ? ids.size() : ids.size()-2;
276 correctNumLocalRows *= dofPerID;
278 if (numLocalRows != correctNumLocalRows) {
284 int correctNumNonzeros = numLocalRows*ids.size()*dofPerID;
287 if (numNonzeros != correctNumNonzeros) {
294 for(
int i=0; i<numLocalRows; ++i) {
295 int globalRow = globalIndexOffsets[
localProc_]+i;
296 int globalEndRow = globalIndexOffsets[
numProcs_]-1;
298 int correctRowLength = 4*dofPerID;
299 if (globalRow > 2*dofPerID-1 && globalRow < globalEndRow-(2*dofPerID-1)) {
300 correctRowLength += 2*dofPerID;
303 if (rowOffsets[i+1]-rowOffsets[i] != correctRowLength) {
305 <<
", correctRowLength: " << correctRowLength <<
", "
306 <<
"rowOffsets[i+1]-rowOffsets[i]: " << rowOffsets[i+1]-rowOffsets[i] <<
FEI_ENDL;
310 for(
int j=0; j<rowOffsets[i+1]-rowOffsets[i]; ++j) {
311 if (nonzeros[offset++] != ids[0]+j) {
339 &(testdata->
ids[0])) );
346 std::vector<int>& ids = testdata->
ids;
356 "U_MatGrph3", factory);
363 "U_MatGrph3", vectorSpacePtr,
372 std::vector<int> globalIndexOffsets;
376 int numRowLengths = globalIndexOffsets[
localProc_+1] -
384 int numGrphLocalRows = localgraph->
rowNumbers.size();
386 std::vector<int>& rowOffsets = localgraph->
rowOffsets;
387 numLocalRows = rowOffsets.size()-1;
389 int correctNumLocalRows =
localProc_==0 ? ids.size() : ids.size()-2;
390 correctNumLocalRows *= dofPerID;
392 if (numLocalRows != correctNumLocalRows) {
396 if (numLocalRows != numRowLengths)
ERReturn(-1);
397 if (numLocalRows != numGrphLocalRows)
ERReturn(-1);
401 int correctNumNonzeros = numLocalRows*ids.size()*dofPerID;
404 if (numNonzeros != correctNumNonzeros) {
410 std::vector<int> rowindices;
412 for(
int i=0; i<numLocalRows; ++i) {
413 int globalRow = globalIndexOffsets[
localProc_]+i;
414 int globalEndRow = globalIndexOffsets[
numProcs_]-1;
416 int correctRowLength = 4*dofPerID;
417 if (globalRow > 2*dofPerID-1 && globalRow < globalEndRow-(2*dofPerID-1)) {
418 correctRowLength += 2*dofPerID;
421 if (rowOffsets[i+1]-rowOffsets[i] != correctRowLength) {
423 <<
", correctRowLength: " << correctRowLength <<
", "
424 <<
"rowOffsets[i+1]-rowOffsets[i]: " << rowOffsets[i+1]-rowOffsets[i] <<
FEI_ENDL;
428 for(
int j=0; j<rowOffsets[i+1]-rowOffsets[i]; ++j) {
429 if (nonzeros[offset++] != ids[0]*dofPerID+j) {
443 std::vector<int>& ids = testdata->
ids;
453 "U_MatGrph4", factory);
460 "U_MatGrph4", vectorSpacePtr, factory,
path_);
466 std::vector<int> globalIndexOffsets;
470 int numRowLengths = globalIndexOffsets[
localProc_+1] -
478 std::vector<int>& rowOffsets = localgraph->
rowOffsets;
479 numLocalRows = rowOffsets.size()-1;
481 int correctNumLocalRows =
localProc_==0 ? ids.size() : ids.size()-2;
482 correctNumLocalRows *= dofPerID;
484 if (numLocalRows != correctNumLocalRows) {
488 if (numLocalRows != numRowLengths)
ERReturn(-1);
492 int correctNumNonzeros = numLocalRows*ids.size()*dofPerID;
495 if (numNonzeros != correctNumNonzeros) {
502 for(
int i=0; i<numLocalRows; ++i) {
503 int globalRow = globalIndexOffsets[
localProc_]+i;
504 int globalEndRow = globalIndexOffsets[
numProcs_]-1;
506 int correctRowLength = 4*dofPerID;
507 if (globalRow > 2*dofPerID-1 && globalRow < globalEndRow-(2*dofPerID-1)) {
508 correctRowLength += 2*dofPerID;
511 if (rowOffsets[i+1]-rowOffsets[i] != correctRowLength) {
513 <<
", correctRowLength: " << correctRowLength <<
", "
514 <<
"rowOffsets[i+1]-rowOffsets[i]: " << rowOffsets[i+1]-rowOffsets[i] <<
FEI_ENDL;
518 for(
int j=0; j<rowOffsets[i+1]-rowOffsets[i]; ++j) {
519 if (nonzeros[offset++] != ids[0]*dofPerID+j) {
533 std::vector<int>& fieldIDs = testdata->
fieldIDs;
534 std::vector<int>& idTypes = testdata->
idTypes;
535 std::vector<int>& ids = testdata->
ids;
550 true,
false,
"U_MatGrph5", vectorSpacePtr,
551 factory,
path_,
true);
554 int offsetOfSlave = 0;
555 int offsetIntoSlaveField = 0;
556 std::vector<double> weights(6, 0.0);
558 double rhsValue = 0.0;
559 std::vector<int> cr_idTypes(2, idTypes[0]);
560 std::vector<int> cr_fieldIDs(2, fieldIDs[1]);
567 offsetIntoSlaveField,
573 offsetIntoSlaveField = 1;
579 offsetIntoSlaveField,
589 std::vector<int> globalIndexOffsets;
593 int numRows_unreduced = globalIndexOffsets[
localProc_+1] -
599 std::vector<int>& rowOffsets = localgraph->
rowOffsets;
600 int numReducedRows = rowOffsets.size()-1;
603 if (numReducedRows != numRows_unreduced-2)
ERReturn(-1);
606 if (numReducedRows != numRows_unreduced)
ERReturn(-1);
616 bool bothFields,
bool nonSymmetric,
620 const std::string& path,
621 bool turnOnDebugOutput)
649 if (factory.
get() == NULL) {
651 vectorSpacePtr, name));
660 paramset.
add(param1);
661 if (turnOnDebugOutput) {
664 paramset.
add(param2);
667 fei::Param param2(
"debugOutput", path.c_str());
668 paramset.
add(param2);
680 int idType = testdata->
idTypes[0];
681 int fieldID = testdata->
fieldIDs[0];
684 std::vector<int> numFieldsPerID(numIDs, 2);
685 std::vector<int> fieldIDsArray(numIDs*2);
686 for(
int i=0; i<numIDs; ++i) {
687 fieldIDsArray[i*2] = testdata->
fieldIDs[0];
688 fieldIDsArray[i*2+1] = testdata->
fieldIDs[1];
696 patternID = matrixGraphPtr->
definePattern(numIDs, idType, fieldID);
700 int numConnectivityLists = 1;
703 numConnectivityLists,
712 int patternID1 = 1, patternID2 = 2;
713 int numRowIDs = 1, numColIDs = 4;
716 std::vector<int> numFieldsPerID(numIDs, 2);
717 std::vector<int> fieldIDsArray(numIDs*2);
718 for(
int i=0; i<numIDs; ++i) {
719 fieldIDsArray[i*2] = testdata->
fieldIDs[0];
720 fieldIDsArray[i*2+1] = testdata->
fieldIDs[1];
723 patternID1 = matrixGraphPtr->
definePattern(numRowIDs, idType,
726 patternID2 = matrixGraphPtr->
definePattern(numColIDs, idType,
740 numConnectivityLists,
741 patternID1, patternID2);
745 &(testdata->
ids[0]));
virtual void setParameters(const fei::ParameterSet ¶ms)=0
int definePattern(int numIDs, int idType)
virtual ~test_MatrixGraph()
int getNumIndices() const
fei::SharedPtr< fei::SparseRowGraph > createGraph(bool blockEntryGraph, bool localRowGraph_includeSharedRows=false)
fei::Pattern * getPattern(int patternID)
void test_MatrixGraph_test7(MPI_Comm comm, int numProcs, int localProc)
virtual int initSlaveConstraint(int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs, int offsetOfSlave, int offsetIntoSlaveField, const double *weights, double rhsValue)=0
int test_MatrixGraph_test6(MPI_Comm comm, int numProcs, int localProc, const std::string &path)
std::vector< int > fieldIDs
std::vector< int > rowNumbers
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)
std::vector< int > idTypes
virtual void setRowSpace(fei::SharedPtr< fei::VectorSpace > rowSpace)=0
static fei::SharedPtr< fei::MatrixGraph > create_MatrixGraph(testData *testdata, int localProc, int numProcs, bool bothFields, bool nonSymmetric, const char *name, fei::SharedPtr< fei::VectorSpace > vectorSpacePtr, fei::SharedPtr< fei::Factory > factory, const std::string &path, bool turnOnDebugOutput=false)
virtual fei::SharedPtr< fei::SparseRowGraph > createGraph(bool blockEntryGraph, bool localRowGraph_includeSharedRows=false)=0
std::vector< int > packedColumnIndices
std::vector< int > rowOffsets
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
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)
void defineIDTypes(int numIDTypes, const int *idTypes)
PatternType getPatternType() const
int initConnectivity(int blockID, int connectivityID, const int *connectedIdentifiers)
std::ostream & console_out()
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const
int localProc(MPI_Comm comm)
virtual int compareStructure(const fei::MatrixGraph &matrixGraph, bool &equivalent) const =0
virtual int definePattern(int numIDs, int idType)=0
test_MatrixGraph(MPI_Comm comm)
int init_nonsymmetric_block(testData *testdata, fei::MatrixGraph *matrixGraph)
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)=0
void test_MatrixGraph_test8(MPI_Comm comm, int numProcs, int localProc)
#define FEI_OSTRINGSTREAM
int numProcs(MPI_Comm comm)
virtual int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)=0
static fei::SharedPtr< fei::VectorSpace > create_VectorSpace(MPI_Comm comm)