24 #ifdef HAVE_FEI_AZTECOO
30 #include <FETI_DP_FiniteElementData.h>
34 #define fei_file "test_Matrix.cpp"
39 std::vector<double> data1D;
40 std::vector<const double*>data2D;
44 double** values =
new double*[numRows];
46 for(i=0; i<numRows; ++i) {
47 values[i] =
new double[numCols];
48 for(j=0; j<numCols; ++j) {
54 values, data1D, data2D);
56 for(i=0; i<numRows; ++i) {
57 for(j=0; j<numCols; ++j) {
58 if (std::abs(values[i][j] - (data2D[j])[i]) > 1.e-49) {
76 FEI_COUT <<
"testing fei::Matrix_Impl...";
81 int rowfield = 0, rowfieldsize = 1;
94 std::vector<int> ids(2);
95 ids[0] = 0; ids[1] = 1;
100 osstr <<
"test_Matrix_unit2, initConnectivity returned err="<<err;
101 throw std::runtime_error(osstr.str());
107 osstr <<
"test_Matrix_unit2, initComplete returned err="<<err;
108 throw std::runtime_error(osstr.str());
111 bool factory_created =
false;
115 factory_created =
true;
119 if (!factory_created) {
128 std::vector<double> coefs(numrowindices*numrowindices, 1.0);
129 std::vector<double*> coefs_2D(numrowindices);
130 for(
int i=0; i<numrowindices; ++i) {
131 coefs_2D[i] = &(coefs[i*numrowindices]);
134 err = feimat->
sumIn(0, 0, &coefs_2D[0]);
137 osstr <<
"test_Matrix_unit2, feimat->sumIn returned err="<<err;
138 throw std::runtime_error(osstr.str());
144 osstr <<
"test_Matrix_unit2, feimat->globalAssemble returned err="<<err;
145 throw std::runtime_error(osstr.str());
151 osstr <<
"test_Matrix_unit2, feimat->writeToFile returned err="<<err;
152 throw std::runtime_error(osstr.str());
159 osstr <<
"test_Matrix_unit2, copy_feiMatrix_to_FillableMat returned err="<<err;
160 throw std::runtime_error(osstr.str());
174 FEI_COUT <<
"testing fei::Matrix_Impl with FEI_BLOCK_DIAGONAL_ROW...";
179 int rowfield = 0, rowfieldsize = 2;
190 bool diagonal =
true;
193 std::vector<int> ids(2);
194 ids[0] = 0; ids[1] = 1;
199 osstr <<
"test_Matrix_unit4, initConnectivity returned err="<<err;
200 throw std::runtime_error(osstr.str());
206 osstr <<
"test_Matrix_unit4, initComplete returned err="<<err;
207 throw std::runtime_error(osstr.str());
223 paramset.
add(blktrue);
228 paramset.
add(blkfalse);
235 std::vector<double> coefs(numrowindices*rowfieldsize*rowfieldsize, 1.0);
236 std::vector<double*> coefs_2D(numrowindices*rowfieldsize);
238 for(
int i=0; i<numrowindices*rowfieldsize; ++i) {
239 coefs_2D[i] = &(coefs[offset]);
240 offset += rowfieldsize;
246 osstr <<
"test_Matrix_unit4, feimat->sumIn returned err="<<err;
247 throw std::runtime_error(osstr.str());
253 osstr <<
"test_Matrix_unit4, feiblkmat->sumIn returned err="<<err;
254 throw std::runtime_error(osstr.str());
260 osstr <<
"test_Matrix_unit4, feimat->globalAssemble returned err="<<err;
261 throw std::runtime_error(osstr.str());
267 osstr <<
"test_Matrix_unit4, feimat->globalAssemble returned err="<<err;
268 throw std::runtime_error(osstr.str());
300 #ifdef HAVE_FEI_AZTECOO
326 false,
false, (
const char*)0, factory);
330 throw std::runtime_error(
"test_Vector::vector_test1: ERROR, failed to create valid fei::VectorSpace.");
336 std::vector<int>& fieldIDs = test_data.
fieldIDs;
337 std::vector<int>& idTypes = test_data.
idTypes;
338 std::vector<int>& ids = test_data.
ids;
340 int numIDs = ids.size();
341 int fieldID = fieldIDs[0];
342 int idType = idTypes[0];
344 int patternID = mgraph->
definePattern(numIDs, idType, fieldID);
359 FEI_COUT <<
" matrix_test1: testing fei::Matrix with type '"
367 FEI_COUT <<
" testing get{Global/Local}NumRows,getRowLength...";
372 if (mglobalrows != vglobaleqns) {
373 throw std::runtime_error(
"mat reports different num rows than vector-space eqns");
376 std::vector<int> global_offsets;
381 throw std::runtime_error(
"num-local-rows mis-match between mat and vector-space");
384 int i, my_first_row = global_offsets[
localProc_];
385 std::vector<int> row_lengths(my_num_rows);
387 for(i=0; i<my_num_rows; ++i) {
388 int errcode = mat->
getRowLength(i+my_first_row, row_lengths[i]);
390 throw std::runtime_error(
"nonzero errcode from mat->getRowLength");
400 std::vector<int>& fieldIDs = testdata->
fieldIDs;
401 std::vector<int>& fieldSizes = testdata->
fieldSizes;
402 std::vector<int>& idTypes = testdata->
idTypes;
403 std::vector<int>& ids = testdata->
ids;
416 int numIDs = ids.size();
417 int fieldID = fieldIDs[0];
418 int idType = idTypes[0];
420 int patternID = matgraph->
definePattern(numIDs, idType, fieldID);
434 std::vector<int> indices(numIDs);
437 std::vector<double> data1(numIDs*numIDs);
438 std::vector<double*> data2d(numIDs);
441 for(i=0; i<numIDs; ++i) {
442 data2d[i] = &(data1[i*numIDs]);
445 for(i=0; i<numIDs*numIDs; ++i) {
449 CHK_ERR( matrix->
sumIn(numIDs, &indices[0], numIDs, &indices[0],
455 numIDs, &indices[0], &data2d[0], 3) );
459 if (*ssmat != *ssmatT) {
469 std::vector<int>& idTypes = testdata->
idTypes;
470 std::vector<int>& ids = testdata->
ids;
478 int numIDs = ids.size();
479 int idType = idTypes[0];
495 std::vector<int> indices(numIDs);
496 CHK_ERR( matgraph->getConnectivityIndices(0, 0, numIDs, &indices[0], numIDs) );
498 std::vector<double> data1(numIDs*numIDs);
499 std::vector<double*> data2d(numIDs);
502 for(i=0; i<numIDs; ++i) {
503 data2d[i] = &(data1[i*numIDs]);
506 for(i=0; i<numIDs*numIDs; ++i) {
511 numIDs, &indices[0], &data2d[0], 0) );
514 numIDs, &indices[0], &data2d[0], 3) );
516 if (*ssmat != *ssmatT) {
530 std::vector<int>& fieldIDs = testdata->
fieldIDs;
531 std::vector<int>& fieldSizes = testdata->
fieldSizes;
532 std::vector<int>& idTypes = testdata->
idTypes;
533 std::vector<int>& ids = testdata->
ids;
537 vspc->
defineFields(fieldIDs.size(), &fieldIDs[0], &fieldSizes[0]);
544 int numIDs = ids.size();
545 int fieldID = fieldIDs[0];
546 int idType = idTypes[0];
548 int patternID = matgraph->
definePattern(numIDs, idType, fieldID);
556 int offsetOfSlave = 1;
557 int offsetIntoSlaveField = 0;
558 std::vector<double> weights(2);
561 double rhsValue = 0.0;
562 std::vector<int> cr_idtypes(2, idTypes[0]);
563 std::vector<int> cr_fieldIDs(2, fieldIDs[0]);
570 offsetIntoSlaveField,
581 if (matrix == NULL) {
585 std::vector<int> indices(numIDs);
586 CHK_ERR( matgraph->getConnectivityIndices(0, 0, numIDs,
587 &indices[0], numIDs) );
589 std::vector<double> data1(numIDs*numIDs);
590 std::vector<double*> data2d(numIDs);
593 for(i=0; i<numIDs; ++i) {
594 data2d[i] = &(data1[i*numIDs]);
597 for(i=0; i<numIDs*numIDs; ++i) {
602 numIDs, &indices[0], &data2d[0], 0) );
626 std::vector<int>& idTypes = testdata->
idTypes;
627 std::vector<int>& ids = testdata->
ids;
631 std::string paramstr(
"debugOutput .");
632 char* param =
const_cast<char*
>(paramstr.c_str());
641 false,
false,
"U_FEMat", factory);
645 false,
false,
"U_FEMat", vectorSpacePtr,
663 std::vector<int> indicesArray(numIndices);
664 int* indicesPtr = &indicesArray[0];
666 int checkNumIndices = 0;
668 numIndices, indicesPtr,
671 std::vector<double> data(ids.size(), 1.0);
672 double* dptr = &data[0];
673 std::vector<double*> coefPtrs(ids.size(), dptr);
677 CHK_ERR( vec_fed->sumIn(blockID, 0, &data[0]) );
688 #endif //HAVE_FEI_FETI
virtual int parameters(int numParams, char **params)=0
virtual const char * typeName()=0
int writeMatrix(const char *fileName, fei::FillableMat &matrix)
std::vector< int > fieldSizes
int getGlobalNumIndices() const
int getNumIndices() const
virtual int loadComplete()=0
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
virtual void parameters(const fei::ParameterSet ¶mset)
virtual int initSlaveConstraint(int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs, int offsetOfSlave, int offsetIntoSlaveField, const double *weights, double rhsValue)=0
std::vector< int > fieldIDs
test_Matrix(MPI_Comm comm)
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
#define FEI_BLOCK_DIAGONAL_ROW
fei::SharedPtr< fei::Matrix > create_matrix(fei::SharedPtr< fei::Factory > factory)
std::vector< int > idTypes
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 int getConnectivityNumIndices(int blockID) const =0
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
virtual int initConnectivity(int blockID, int connectivityID, const int *connectedIdentifiers)=0
virtual int initComplete()=0
void test_Matrix_unit2(MPI_Comm comm, int numProcs, int localProc)
void add(const Param ¶m, bool maintain_unique_keys=true)
virtual int writeToFile(const char *filename, bool matrixMarketFormat=true)=0
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
int copy_feiMatrix_to_FillableMat(fei::Matrix &feimat, fei::FillableMat &fmat)
virtual int getRowLength(int row, int &length) const =0
void defineIDTypes(int numIDTypes, const int *idTypes)
virtual fei::SharedPtr< fei::MatrixGraph > getMatrixGraph() const =0
static void copyTransposeToWorkArrays(int numRows, int numCols, const double *const *values, std::vector< double > &work_1D, std::vector< const double * > &work_2D)
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const
virtual int getGlobalNumRows() const =0
int localProc(MPI_Comm comm)
void matrix_test1(fei::SharedPtr< fei::Matrix > mat)
virtual int globalAssemble()=0
virtual int definePattern(int numIDs, int idType)=0
virtual fei::SharedPtr< fei::Matrix > createMatrix(fei::SharedPtr< fei::MatrixGraph > matrixGraph)=0
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)=0
virtual fei::Pattern * getPattern(int patternID)=0
int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)
virtual int gatherFromOverlap(bool accumulate=true)=0
void test_Matrix_unit4(MPI_Comm comm, int numProcs, int localProc)
#define FEI_OSTRINGSTREAM
virtual int getLocalNumRows() const =0
int numProcs(MPI_Comm comm)
int getNumIndices_Owned() const
virtual int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)=0
static fei::SharedPtr< fei::VectorSpace > create_VectorSpace(MPI_Comm comm)