FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_MatrixGraph.cpp
Go to the documentation of this file.
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 
10 #include <fei_macros.hpp>
11 
13 
15 
16 #include <snl_fei_Factory.hpp>
17 #include <fei_Pattern.hpp>
19 #include <fei_SparseRowGraph.hpp>
20 #include <fei_LibraryWrapper.hpp>
21 
22 #undef fei_file
23 #define fei_file "test_MatrixGraph.cpp"
24 #include <fei_ErrMacros.hpp>
25 
27  : tester(comm)
28 {
29 }
30 
32 {
33 }
34 
36  const std::string& path)
37 {
38  testData* testdata = new testData(localProc, numProcs);
39  std::vector<int>& ids = testdata->ids;
40 
42  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(comm, wrapper));
43 
44  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
46  testdata, localProc, numProcs,
47  false, //defineBothFields
48  false, //initSolnBothFields
49  "U_MatGrph", factory);
50 
51  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
52  test_MatrixGraph::create_MatrixGraph(testdata, localProc, numProcs,
53  false, false, "U_MatGrph",
54  vectorSpacePtr, factory, path);
55 
56  CHK_ERR( matrixGraphPtr->initComplete() );
57 
58  fei::SharedPtr<fei::MatrixGraph> matrixGraph2Ptr =
59  test_MatrixGraph::create_MatrixGraph(testdata, localProc, numProcs,
60  false, false, "U_MatGrph2",
61  vectorSpacePtr, factory, path);
62 
63  CHK_ERR( matrixGraph2Ptr->initComplete() );
64 
65  bool equivalent = false;
66  CHK_ERR( matrixGraphPtr->compareStructure(*matrixGraph2Ptr, equivalent) );
67 
68  if (!equivalent) {
69  ERReturn(-1);
70  }
71 
72  fei::SharedPtr<fei::MatrixGraph> matrixGraph3Ptr =
73  test_MatrixGraph::create_MatrixGraph(testdata, localProc, numProcs,
74  false, false, "U_MatGrph3",
75  vectorSpacePtr, factory, path);
76 
77  if (localProc == 0) {
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]);
86 
87  CHK_ERR( matrixGraph3Ptr->initSlaveConstraint(2,
88  &cr_idTypes[0],
89  &ids[2],
90  &cr_fieldIDs[0],
91  offsetOfSlave,
92  offsetIntoSlaveField,
93  &weights[0],
94  rhsValue) );
95  }
96 
97  CHK_ERR( matrixGraph3Ptr->initComplete() );
98 
99  CHK_ERR( matrixGraphPtr->compareStructure(*matrixGraph3Ptr, equivalent) );
100 
101  if (equivalent) {
102  ERReturn(-1);
103  }
104 
105  delete testdata;
106 
107  return(0);
108 }
109 
111 {
114 
115  int rowfield = 0, rowfieldsize = 1;
116  int colfield = 1, colfieldsize = 3;
117  rowspace->defineFields(1, &rowfield, &rowfieldsize);
118  colspace->defineFields(1, &colfield, &colfieldsize);
119 
120  fei::MatrixGraph_Impl2 mgraph(rowspace, colspace);
121 
122  int pID = mgraph.definePattern(4, 0, colfield);
123  fei::Pattern* pattern = mgraph.getPattern(pID);
124 
125  if (pattern->getNumIndices() != 4*colfieldsize) {
126  FEI_COUT << "getNumIndices: " << pattern->getNumIndices()<<", colfieldsize: " << colfieldsize<<FEI_ENDL;
127  FEI_OSTRINGSTREAM osstr;
128  osstr << "test_MatrixGraph_test7, line "<<__LINE__<<FEI_ENDL;
129  throw std::runtime_error(osstr.str());
130  }
131 }
132 
134 {
135  FEI_COUT << "testing matrix-graph with 'diagonal' connectivity block...";
136 
137  try {
138 
141 
142  int rowfield = 0, rowfieldsize = 1;
143  rowspace->defineFields(1, &rowfield, &rowfieldsize);
144  int idType = 0;
145  rowspace->defineIDTypes(1, &idType);
146 
147  fei::MatrixGraph_Impl2 mgraph(rowspace, colspace);
148 
149  int numIDs = 4;
150  int patternID = mgraph.definePattern(numIDs, idType, rowfield);
151  fei::Pattern* pattern = mgraph.getPattern(patternID);
152 
153  if (pattern->getNumIndices() != 4*rowfieldsize) {
154  FEI_OSTRINGSTREAM osstr;
155  osstr << "test_MatrixGraph_test8, line "<<__LINE__<<FEI_ENDL;
156  throw std::runtime_error(osstr.str());
157  }
158 
159  int blockID = 0;
160  int numConnLists = 1;
161  bool diagonal = true;
162  mgraph.initConnectivityBlock(blockID, numConnLists, patternID, diagonal);
163 
164  std::vector<int> ids(numIDs);
165  for(int i=0; i<numIDs; ++i) {
166  ids[i] = i;
167  }
168 
169  mgraph.initConnectivity(blockID, 0, &ids[0]);
170 
171  mgraph.initComplete();
172 
174  mgraph.createGraph(false);
175 
176  if ((int)localSRGraph->packedColumnIndices.size() != numIDs) {
177  FEI_OSTRINGSTREAM osstr;
178  osstr << "test_MatrixGraph_test8, line "<<__LINE__<<FEI_ENDL;
179  throw std::runtime_error(osstr.str());
180  }
181 
182  }
183  catch(std::runtime_error& exc) {
184  FEI_OSTRINGSTREAM osstr;
185  osstr << "test_MatrixGraph_test8, caught exception: " << exc.what();
186  throw std::runtime_error(osstr.str());
187  }
188 
189  FEI_COUT << "ok" << FEI_ENDL;
190 }
191 
193 {
194  if (numProcs_ < 2) {
195  CHK_ERR( serialtest1() );
196  }
197 
198  CHK_ERR( test1() );
199  CHK_ERR( test2() );
200  CHK_ERR( test3() );
201  CHK_ERR( test4() );
202  CHK_ERR( test5() );
203 
205 
208 
209  return(0);
210 }
211 
213 {
214  int numIDs = 2;
215  std::vector<int> idTypes(numIDs, 1);
216  std::vector<snl_fei::RecordCollection*> recColls(numIDs, (snl_fei::RecordCollection*)NULL);
217  std::vector<int> numFieldsPerID(numIDs, 1);
218  std::vector<int> fieldIDs(numIDs, 0);
219  std::vector<int> fieldSizes(numIDs, 1);
220 
221  fei::Pattern pattern(numIDs, &idTypes[0], &recColls[0],
222  &numFieldsPerID[0], &fieldIDs[0], &fieldSizes[0]);
223 
224  fei::Pattern::PatternType pType = pattern.getPatternType();
225 
226  if (pType != fei::Pattern::SIMPLE) {
227  ERReturn(-1);
228  }
229 
230  return(0);
231 }
232 
234 {
235  testData* testdata = new testData(localProc_, numProcs_);
236  std::vector<int>& ids = testdata->ids;
237 
239  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(comm_, wrapper));
240 
241  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
243  testdata, localProc_, numProcs_,
244  false, //defineBothFields
245  false, //initSolnBothFields
246  "U_MatGrph", factory);
247 
248  int dofPerID = 1;
249 
250  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
252  false, false, "U_MatGrph", vectorSpacePtr, factory, path_);
253 
254  fei::VectorSpace& vectorSpace = *vectorSpacePtr;
255 
256  CHK_ERR( matrixGraphPtr->initComplete() );
257 
258  std::vector<int> globalIndexOffsets;
259 
260  vectorSpace.getGlobalIndexOffsets(globalIndexOffsets);
261 
262  int numRowLengths = globalIndexOffsets[localProc_+1] -
263  globalIndexOffsets[localProc_];
264 
265  int numLocalRows;
266 
268  matrixGraphPtr->createGraph(false);
269 
270  std::vector<int>& rowOffsets = localgraph->rowOffsets;
271  numLocalRows = rowOffsets.size()-1;
272 
273  if (numLocalRows != numRowLengths) ERReturn(-1);
274 
275  int correctNumLocalRows = localProc_==0 ? ids.size() : ids.size()-2;
276  correctNumLocalRows *= dofPerID;
277 
278  if (numLocalRows != correctNumLocalRows) {
279  ERReturn(-1);
280  }
281 
282  int numNonzeros = localgraph->packedColumnIndices.size();
283 
284  int correctNumNonzeros = numLocalRows*ids.size()*dofPerID;
285  if (localProc_ < numProcs_-1) correctNumNonzeros += 4*dofPerID;
286 
287  if (numNonzeros != correctNumNonzeros) {
288  ERReturn(-1);
289  }
290 
291  std::vector<int>& nonzeros = localgraph->packedColumnIndices;
292 
293  int offset = 0;
294  for(int i=0; i<numLocalRows; ++i) {
295  int globalRow = globalIndexOffsets[localProc_]+i;
296  int globalEndRow = globalIndexOffsets[numProcs_]-1;
297 
298  int correctRowLength = 4*dofPerID;
299  if (globalRow > 2*dofPerID-1 && globalRow < globalEndRow-(2*dofPerID-1)) {
300  correctRowLength += 2*dofPerID;
301  }
302 
303  if (rowOffsets[i+1]-rowOffsets[i] != correctRowLength) {
304  fei::console_out() << "localProc " << localProc_ << ", i: " << i
305  << ", correctRowLength: " << correctRowLength << ", "
306  << "rowOffsets[i+1]-rowOffsets[i]: " << rowOffsets[i+1]-rowOffsets[i] << FEI_ENDL;
307  ERReturn(-1);
308  }
309 
310  for(int j=0; j<rowOffsets[i+1]-rowOffsets[i]; ++j) {
311  if (nonzeros[offset++] != ids[0]+j) {
312  ERReturn(-1);
313  }
314  }
315  }
316 
317  delete testdata;
318 
319  return(0);
320 }
321 
323 {
324  return(0);
325 }
326 
328  fei::MatrixGraph* matrixGraph)
329 {
330  int rowPatternID = matrixGraph->definePattern(1, 0,
331  testdata->fieldIDs[0]);
332  int colPatternID = matrixGraph->definePattern(1, 0,
333  testdata->fieldIDs[1]);
334 
335  CHK_ERR( matrixGraph->initConnectivityBlock(2, 1, rowPatternID, colPatternID) );
336 
337  CHK_ERR( matrixGraph->initConnectivity(2, 0,
338  &(testdata->ids[0]),
339  &(testdata->ids[0])) );
340  return(0);
341 }
342 
344 {
345  testData* testdata = new testData(localProc_, numProcs_);
346  std::vector<int>& ids = testdata->ids;
347 
349  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(comm_, wrapper));
350 
351  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
353  testdata, localProc_, numProcs_,
354  true, //defineBothFields
355  true, //initSolnBothFields
356  "U_MatGrph3", factory);
357 
358  int dofPerID = 4;
359 
360  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
362  true, true, //non-symmetric
363  "U_MatGrph3", vectorSpacePtr,
364  factory, path_);
365 
366  fei::VectorSpace& vectorSpace = *vectorSpacePtr;
367 
368  CHK_ERR( init_nonsymmetric_block(testdata, matrixGraphPtr.get()) );
369 
370  CHK_ERR( matrixGraphPtr->initComplete() );
371 
372  std::vector<int> globalIndexOffsets;
373 
374  vectorSpace.getGlobalIndexOffsets(globalIndexOffsets);
375 
376  int numRowLengths = globalIndexOffsets[localProc_+1] -
377  globalIndexOffsets[localProc_];
378 
379  int numLocalRows;
380 
382  matrixGraphPtr->createGraph(false);
383 
384  int numGrphLocalRows = localgraph->rowNumbers.size();
385 
386  std::vector<int>& rowOffsets = localgraph->rowOffsets;
387  numLocalRows = rowOffsets.size()-1;
388 
389  int correctNumLocalRows = localProc_==0 ? ids.size() : ids.size()-2;
390  correctNumLocalRows *= dofPerID;
391 
392  if (numLocalRows != correctNumLocalRows) {
393  ERReturn(-1);
394  }
395 
396  if (numLocalRows != numRowLengths) ERReturn(-1);
397  if (numLocalRows != numGrphLocalRows) ERReturn(-1);
398 
399  int numNonzeros = localgraph->packedColumnIndices.size();
400 
401  int correctNumNonzeros = numLocalRows*ids.size()*dofPerID;
402  if (localProc_ < numProcs_-1) correctNumNonzeros += 4*dofPerID*dofPerID;
403 
404  if (numNonzeros != correctNumNonzeros) {
405  ERReturn(-1);
406  }
407 
408  std::vector<int>& nonzeros = localgraph->packedColumnIndices;
409 
410  std::vector<int> rowindices;
411  int offset = 0;
412  for(int i=0; i<numLocalRows; ++i) {
413  int globalRow = globalIndexOffsets[localProc_]+i;
414  int globalEndRow = globalIndexOffsets[numProcs_]-1;
415 
416  int correctRowLength = 4*dofPerID;
417  if (globalRow > 2*dofPerID-1 && globalRow < globalEndRow-(2*dofPerID-1)) {
418  correctRowLength += 2*dofPerID;
419  }
420 
421  if (rowOffsets[i+1]-rowOffsets[i] != correctRowLength) {
422  fei::console_out() << "localProc " << localProc_ << ", i: " << i
423  << ", correctRowLength: " << correctRowLength << ", "
424  << "rowOffsets[i+1]-rowOffsets[i]: " << rowOffsets[i+1]-rowOffsets[i] << FEI_ENDL;
425  ERReturn(-1);
426  }
427 
428  for(int j=0; j<rowOffsets[i+1]-rowOffsets[i]; ++j) {
429  if (nonzeros[offset++] != ids[0]*dofPerID+j) {
430  ERReturn(-1);
431  }
432  }
433  }
434 
435  delete testdata;
436 
437  return(0);
438 }
439 
441 {
442  testData* testdata = new testData(localProc_, numProcs_);
443  std::vector<int>& ids = testdata->ids;
444 
446  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(comm_, wrapper));
447 
448  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
450  testdata, localProc_, numProcs_,
451  false, //defineBothFields
452  false, //initSolnBothFields
453  "U_MatGrph4", factory);
454 
455  int dofPerID = 1;
456 
457  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
459  false, true, //non-symmetric
460  "U_MatGrph4", vectorSpacePtr, factory, path_);
461 
462  fei::VectorSpace& vectorSpace = *vectorSpacePtr;
463 
464  CHK_ERR( matrixGraphPtr->initComplete() );
465 
466  std::vector<int> globalIndexOffsets;
467 
468  vectorSpace.getGlobalIndexOffsets(globalIndexOffsets);
469 
470  int numRowLengths = globalIndexOffsets[localProc_+1] -
471  globalIndexOffsets[localProc_];
472 
473  int numLocalRows;
474 
476  matrixGraphPtr->createGraph(false);
477 
478  std::vector<int>& rowOffsets = localgraph->rowOffsets;
479  numLocalRows = rowOffsets.size()-1;
480 
481  int correctNumLocalRows = localProc_==0 ? ids.size() : ids.size()-2;
482  correctNumLocalRows *= dofPerID;
483 
484  if (numLocalRows != correctNumLocalRows) {
485  ERReturn(-1);
486  }
487 
488  if (numLocalRows != numRowLengths) ERReturn(-1);
489 
490  int numNonzeros = localgraph->packedColumnIndices.size();
491 
492  int correctNumNonzeros = numLocalRows*ids.size()*dofPerID;
493  if (localProc_ < numProcs_-1) correctNumNonzeros += 4*dofPerID*dofPerID;
494 
495  if (numNonzeros != correctNumNonzeros) {
496  ERReturn(-1);
497  }
498 
499  std::vector<int>& nonzeros = localgraph->packedColumnIndices;
500 
501  int offset = 0;
502  for(int i=0; i<numLocalRows; ++i) {
503  int globalRow = globalIndexOffsets[localProc_]+i;
504  int globalEndRow = globalIndexOffsets[numProcs_]-1;
505 
506  int correctRowLength = 4*dofPerID;
507  if (globalRow > 2*dofPerID-1 && globalRow < globalEndRow-(2*dofPerID-1)) {
508  correctRowLength += 2*dofPerID;
509  }
510 
511  if (rowOffsets[i+1]-rowOffsets[i] != correctRowLength) {
512  fei::console_out() << "localProc " << localProc_ << ", i: " << i
513  << ", correctRowLength: " << correctRowLength << ", "
514  << "rowOffsets[i+1]-rowOffsets[i]: " << rowOffsets[i+1]-rowOffsets[i] << FEI_ENDL;
515  ERReturn(-1);
516  }
517 
518  for(int j=0; j<rowOffsets[i+1]-rowOffsets[i]; ++j) {
519  if (nonzeros[offset++] != ids[0]*dofPerID+j) {
520  ERReturn(-1);
521  }
522  }
523  }
524 
525  delete testdata;
526 
527  return(0);
528 }
529 
531 {
532  testData* testdata = new testData(localProc_, numProcs_);
533  std::vector<int>& fieldIDs = testdata->fieldIDs;
534  std::vector<int>& idTypes = testdata->idTypes;
535  std::vector<int>& ids = testdata->ids;
536 
538  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(comm_, wrapper));
539 
540  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
542  testdata, localProc_, numProcs_,
543  true, //defineBothFields
544  true, //initSolnBothFields
545  "U_MatGrph5",
546  factory,true);
547 
548  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
550  true, false, "U_MatGrph5", vectorSpacePtr,
551  factory, path_, true);
552 
553  if (localProc_ == 0) {
554  int offsetOfSlave = 0;
555  int offsetIntoSlaveField = 0;
556  std::vector<double> weights(6, 0.0);
557  weights[3] = 1.0;
558  double rhsValue = 0.0;
559  std::vector<int> cr_idTypes(2, idTypes[0]);
560  std::vector<int> cr_fieldIDs(2, fieldIDs[1]);
561 
562  CHK_ERR( matrixGraphPtr->initSlaveConstraint(2,
563  &cr_idTypes[0],
564  &ids[2],
565  &cr_fieldIDs[0],
566  offsetOfSlave,
567  offsetIntoSlaveField,
568  &weights[0],
569  rhsValue) );
570 
571  weights[3] = 0.0;
572  weights[4] = 1.0;
573  offsetIntoSlaveField = 1;
574  CHK_ERR( matrixGraphPtr->initSlaveConstraint(2,
575  &cr_idTypes[0],
576  &ids[2],
577  &cr_fieldIDs[0],
578  offsetOfSlave,
579  offsetIntoSlaveField,
580  &weights[0],
581  rhsValue) );
582  }
583 
584  CHK_ERR( matrixGraphPtr->initComplete() );
585 
586  fei::SharedPtr<fei::VectorSpace> reducedSolnSpacePtr =
587  matrixGraphPtr->getRowSpace();
588 
589  std::vector<int> globalIndexOffsets;
590 
591  reducedSolnSpacePtr->getGlobalIndexOffsets(globalIndexOffsets);
592 
593  int numRows_unreduced = globalIndexOffsets[localProc_+1] -
594  globalIndexOffsets[localProc_];
595 
597  matrixGraphPtr->createGraph(false);
598 
599  std::vector<int>& rowOffsets = localgraph->rowOffsets;
600  int numReducedRows = rowOffsets.size()-1;
601 
602  if (localProc_ == 0) {
603  if (numReducedRows != numRows_unreduced-2) ERReturn(-1);
604  }
605  else {
606  if (numReducedRows != numRows_unreduced) ERReturn(-1);
607  }
608 
609  delete testdata;
610 
611  return(0);
612 }
613 
615  int localProc, int numProcs,
616  bool bothFields, bool nonSymmetric,
617  const char* name,
618  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr,
620  const std::string& path,
621  bool turnOnDebugOutput)
622 {
623  //
624  //This function creates a MatrixGraph object, and initializes it as follows:
625  //
626  //setRowSpace(vectorSpacePtr)
627  //
628  //definePattern patternID=0, numIDs=4, idType=testdata->idTypes[0]
629  // fieldID=testdata->fieldIDs[0] if !bothFields, else
630  // fieldIDs=testdata->fieldIDs
631  //
632  //initConnectivityBlock blockID=0, numConnectivityLists=1
633  //
634  //initConnectivity blockID, 0, testdata->ids
635  //
636  //If nonSymmetric==true, then also do the following:
637  // definePattern patternID=1, numIDs=1, idType=testdata->idTypes[0]
638  // fieldID=testdata->fieldIDs[0] if !bothFields, else
639  // fieldIDs=testdata->fieldIDs
640  // definePattern patternID=2, numIDs=4, idType=testdata->idTypes[0]
641  // fieldID=testdata->fieldIDs[0] if !bothFields, else
642  // fieldIDs=testdata->fieldIDs
643  //
644  //initConnectivityBlock blockID=1, patterns 1 and 2
645  //
646  //initConnectivity blockID, 0, testdata->ids
647  //
649  if (factory.get() == NULL) {
651  vectorSpacePtr, name));
652  mgptr = tmp;
653  }
654  else {
655  mgptr = factory->createMatrixGraph(vectorSpacePtr, vectorSpacePtr, name);
656  }
657 
658  fei::ParameterSet paramset;
659  fei::Param param1("name", name);
660  paramset.add(param1);
661  if (turnOnDebugOutput) {
662  if (path.empty()) {
663  fei::Param param2("debugOutput", ".");
664  paramset.add(param2);
665  }
666  else {
667  fei::Param param2("debugOutput", path.c_str());
668  paramset.add(param2);
669  }
670  }
671 
672  fei::MatrixGraph* matrixGraphPtr = mgptr.get();
673 
674  matrixGraphPtr->setParameters(paramset);
675 
676  matrixGraphPtr->setRowSpace(vectorSpacePtr);
677 
678  int patternID = 0;
679  int numIDs = 4;
680  int idType = testdata->idTypes[0];
681  int fieldID = testdata->fieldIDs[0];
682 
683  if (bothFields) {
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];
689  }
690 
691  patternID = matrixGraphPtr->definePattern(numIDs, idType,
692  &numFieldsPerID[0],
693  &fieldIDsArray[0]);
694  }
695  else {
696  patternID = matrixGraphPtr->definePattern(numIDs, idType, fieldID);
697  }
698 
699  int blockID = 0;
700  int numConnectivityLists = 1;
701 
702  matrixGraphPtr->initConnectivityBlock(blockID,
703  numConnectivityLists,
704  patternID);
705 
706  matrixGraphPtr->initConnectivity(blockID, 0, &(testdata->ids[0]));
707 
708  if (!nonSymmetric) {
709  return(mgptr);
710  }
711 
712  int patternID1 = 1, patternID2 = 2;
713  int numRowIDs = 1, numColIDs = 4;
714 
715  if (bothFields) {
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];
721  }
722 
723  patternID1 = matrixGraphPtr->definePattern(numRowIDs, idType,
724  &numFieldsPerID[0],
725  &fieldIDsArray[0]);
726  patternID2 = matrixGraphPtr->definePattern(numColIDs, idType,
727  &numFieldsPerID[0],
728  &fieldIDsArray[0]);
729  }
730  else {
731  patternID1 = matrixGraphPtr->definePattern(numRowIDs,
732  idType, fieldID);
733  patternID2 = matrixGraphPtr->definePattern(numColIDs,
734  idType, fieldID);
735  }
736 
737  blockID = 1;
738 
739  matrixGraphPtr->initConnectivityBlock(blockID,
740  numConnectivityLists,
741  patternID1, patternID2);
742 
743  matrixGraphPtr->initConnectivity(blockID, 0,
744  &(testdata->ids[0]),
745  &(testdata->ids[0]));
746 
747  return(mgptr);
748 }
virtual void setParameters(const fei::ParameterSet &params)=0
int definePattern(int numIDs, int idType)
virtual ~test_MatrixGraph()
#define FEI_COUT
int getNumIndices() const
Definition: fei_Pattern.hpp:92
MPI_Comm comm_
Definition: tester.hpp:37
fei::SharedPtr< fei::SparseRowGraph > createGraph(bool blockEntryGraph, bool localRowGraph_includeSharedRows=false)
fei::Pattern * getPattern(int patternID)
std::vector< int > ids
Definition: testData.hpp:72
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
Definition: testData.hpp:69
std::vector< int > rowNumbers
int localProc_
Definition: tester.hpp:38
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
Definition: testData.hpp:71
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
#define MPI_Comm
Definition: fei_mpi.h:56
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 &param, bool maintain_unique_keys=true)
void defineIDTypes(int numIDTypes, const int *idTypes)
#define ERReturn(a)
T * get() const
PatternType getPatternType() const
Definition: fei_Pattern.hpp:61
int numProcs_
Definition: tester.hpp:38
std::string path_
Definition: tester.hpp:39
int initConnectivity(int blockID, int connectivityID, const int *connectedIdentifiers)
#define FEI_ENDL
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)
#define CHK_ERR(a)
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
Definition: fei_sstream.hpp:32
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)