10 #include <fei_macros.hpp>
12 #include <test_utils/test_LinearSystem.hpp>
13 #include <test_utils/test_VectorSpace.hpp>
14 #include <test_utils/test_MatrixGraph.hpp>
15 #include <snl_fei_Factory.hpp>
16 #include <fei_Vector.hpp>
17 #include <fei_Matrix.hpp>
18 #include <snl_fei_LinearSystem_General.hpp>
20 #include <test_utils/LibraryFactory.hpp>
22 #ifdef HAVE_FEI_AZTECOO
23 #include <fei_Aztec_LinSysCore.hpp>
27 #define fei_file "test_LinearSystem.cpp"
28 #include <fei_ErrMacros.hpp>
30 test_LinearSystem::test_LinearSystem(MPI_Comm comm)
35 test_LinearSystem::~test_LinearSystem()
39 int test_LinearSystem::runtests()
50 int test_LinearSystem::test1()
55 int test_LinearSystem::test2()
57 #ifdef HAVE_FEI_AZTECOO
59 std::vector<int>& fieldIDs = testdata->fieldIDs;
60 std::vector<int>& idTypes = testdata->idTypes;
61 std::vector<int>& ids = testdata->ids;
65 char* param =
new char[64];
66 sprintf(param,
"debugOutput .");
68 CHK_ERR( az_lsc->parameters(1, ¶m) );
74 test_VectorSpace::create_VectorSpace(comm_,
75 testdata.get(), localProc_, numProcs_,
76 false,
false,
"U_LS2", factory);
79 test_MatrixGraph::create_MatrixGraph(testdata.get(), localProc_, numProcs_,
80 false,
false,
"U_LS2", vectorSpacePtr,
83 std::vector<int> crIDTypes(2);
84 std::vector<int> crFieldIDs(2);
85 crIDTypes[0] = idTypes[0]; crIDTypes[1] = idTypes[0];
86 crFieldIDs[0] = fieldIDs[0]; crFieldIDs[1] = fieldIDs[0];
88 CHK_ERR( matrixGraphPtr->initLagrangeConstraint(0, idTypes[1],
94 CHK_ERR( matrixGraphPtr->initComplete() );
108 int numIndices = matrixGraphPtr->getConnectivityNumIndices(blockID);
110 std::vector<int> indicesArray(numIndices);
111 int* indicesPtr = &indicesArray[0];
113 int checkNumIndices = 0;
114 CHK_ERR( matrixGraphPtr->getConnectivityIndices(blockID, 0,
115 numIndices, indicesPtr,
118 std::vector<double> data(ids.size(), 1.0);
119 double* dptr = &data[0];
120 std::vector<double*> coefPtrs(ids.size());
121 std::vector<double> crdata(2);
125 for(
unsigned ii=0; ii<ids.size(); ++ii) coefPtrs[ii] = dptr;
127 CHK_ERR( mat_lsc->
sumIn(numIndices, indicesPtr, numIndices, indicesPtr,
130 CHK_ERR( vec_lsc->sumInFieldData(fieldIDs[0], idTypes[0],
138 CHK_ERR( az_lsc->matrixLoadComplete() );
142 std::vector<int> crindices;
144 if (crindices.size() != 2) {
148 CHK_ERR( az_lsc->writeSystem(
"U_LS2") );
156 int test_LinearSystem::test3()
158 #ifdef HAVE_FEI_AZTECOO
160 std::vector<int>& fieldIDs = testdata->fieldIDs;
161 std::vector<int>& idTypes = testdata->idTypes;
162 std::vector<int>& ids = testdata->ids;
166 char* param =
new char[64];
167 sprintf(param,
"debugOutput .");
169 CHK_ERR( az_lsc->parameters(1, ¶m) );
174 test_VectorSpace::create_VectorSpace(comm_,
175 testdata.get(), localProc_, numProcs_,
176 false,
false,
"U_LS3", factory);
179 test_MatrixGraph::create_MatrixGraph(testdata.get(), localProc_, numProcs_,
180 false,
false,
"U_LS3", vectorSpacePtr,
183 std::vector<int> crIDTypes(2);
184 std::vector<int> crFieldIDs(2);
185 crIDTypes[0] = idTypes[0]; crIDTypes[1] = idTypes[0];
186 crFieldIDs[0] = fieldIDs[0]; crFieldIDs[1] = fieldIDs[0];
188 CHK_ERR( matrixGraphPtr->initPenaltyConstraint(0, idTypes[1],
194 CHK_ERR( matrixGraphPtr->initComplete() );
211 int numIndices = matrixGraphPtr->getConnectivityNumIndices(blockID);
213 std::vector<int> indicesArray(numIndices);
214 int* indicesPtr = &indicesArray[0];
216 int checkNumIndices = 0;
217 CHK_ERR( matrixGraphPtr->getConnectivityIndices(blockID, 0,
218 numIndices, indicesPtr,
221 std::vector<double> data(ids.size(), 1.0);
222 double* dptr = &data[0];
223 std::vector<double*> coefPtrs(ids.size());
224 std::vector<double> crdata(2);
228 for(
unsigned ii=0; ii<ids.size(); ++ii) coefPtrs[ii] = dptr;
230 CHK_ERR( mat_lsc->
sumIn(numIndices, indicesPtr, numIndices, indicesPtr,
233 CHK_ERR( vec_lsc->sumInFieldData(fieldIDs[0], idTypes[0],
241 CHK_ERR( az_lsc->matrixLoadComplete() );
245 CHK_ERR( az_lsc->writeSystem(
"U_LS3") );
253 int test_LinearSystem::test4()
255 #ifdef HAVE_FEI_AZTECOO
257 std::vector<int>& fieldIDs = testdata->fieldIDs;
258 std::vector<int>& idTypes = testdata->idTypes;
259 std::vector<int>& ids = testdata->ids;
263 char* param =
new char[64];
264 sprintf(param,
"debugOutput .");
266 CHK_ERR( az_lsc->parameters(1, ¶m) );
272 test_VectorSpace::create_VectorSpace(comm_,
273 testdata.get(), localProc_, numProcs_,
274 false,
false,
"U_LS4", factory);
277 test_MatrixGraph::create_MatrixGraph(testdata.get(), localProc_, numProcs_,
278 false,
false,
"U_LS4", vectorSpacePtr,
281 std::vector<int> crIDTypes(2);
282 std::vector<int> crFieldIDs(2);
283 crIDTypes[0] = idTypes[0]; crIDTypes[1] = idTypes[0];
284 crFieldIDs[0] = fieldIDs[0]; crFieldIDs[1] = fieldIDs[0];
286 CHK_ERR( matrixGraphPtr->initLagrangeConstraint(0, idTypes[1],
292 CHK_ERR( matrixGraphPtr->initComplete() );
306 int numIndices = matrixGraphPtr->getConnectivityNumIndices(blockID);
308 std::vector<int> indicesArray(numIndices);
309 int* indicesPtr = &indicesArray[0];
311 int checkNumIndices = 0;
312 CHK_ERR( matrixGraphPtr->getConnectivityIndices(blockID, 0,
313 numIndices, indicesPtr,
316 std::vector<double> data(ids.size(), 1.0);
317 double* dptr = &data[0];
318 std::vector<double*> coefPtrs(ids.size());
319 std::vector<double> crdata(2);
323 for(
unsigned ii=0; ii<ids.size(); ++ii) coefPtrs[ii] = dptr;
325 CHK_ERR( mat_lsc->
sumIn(numIndices, indicesPtr, numIndices, indicesPtr,
328 CHK_ERR( vec_lsc->sumInFieldData(fieldIDs[0], idTypes[0],
329 ids.size(), &ids[0], &data[0]) );
335 CHK_ERR( az_lsc->matrixLoadComplete() );
339 CHK_ERR( az_lsc->writeSystem(
"U_LS4") );
347 int test_LinearSystem::test5()
virtual void setMatrix(fei::SharedPtr< fei::Matrix > &matrix)
virtual int loadLagrangeConstraint(int constraintID, const double *weights, double rhsValue)=0
virtual int parameters(int numParams, const char *const *paramStrings)=0
virtual void setSolutionVector(fei::SharedPtr< fei::Vector > &soln)
virtual int loadPenaltyConstraint(int constraintID, const double *weights, double penaltyValue, double rhsValue)=0
virtual void setRHS(fei::SharedPtr< fei::Vector > &rhs)
virtual int loadComplete(bool applyBCs=true, bool globalAssemble=true)=0
virtual int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)=0
virtual void getConstrainedEqns(std::vector< int > &crEqns) const =0
virtual int gatherFromOverlap(bool accumulate=true)=0