17 #define fei_file "test_EqnBuffer.cpp"
44 std::vector<double> eqnCoefs(3);
45 std::vector<int> colIndices(3);
47 eqnCoefs[0] = 0.5; colIndices[0] = 2;
48 eqnCoefs[1] = 0.5; colIndices[1] = 4;
49 eqnCoefs[2] = 0.5; colIndices[2] = 6;
54 eqnCoefs.size(),
false) );
56 eqnCoefs[0] = 0.5; colIndices[0] = 1;
57 eqnCoefs[1] = 0.5; colIndices[1] = 3;
58 eqnCoefs[2] = 0.5; colIndices[2] = 5;
61 eqnCoefs.size(),
true) );
63 eqnCoefs[0] = 0.25; colIndices[0] = 2;
64 eqnCoefs[1] = 0.25; colIndices[1] = 3;
65 eqnCoefs[2] = 0.5; colIndices[2] = 6;
68 eqnCoefs.size(),
false) );
74 if (std::abs(coef - 0.5) > 1.e-49)
ERReturn(-1);
77 int err = eqns.
getCoef(7, 3, coef);
81 if (std::abs(coef - 0.5) > 1.e-49)
ERReturn(-1);
87 std::vector<int>& eqnNumbers = eqns.
eqnNumbers();
88 std::vector<fei::CSVec*>& rows = eqns.
eqns();
92 std::vector<int>& eqnNumbersCopy = eqnsCopy->
eqnNumbers();
94 if (eqnNumbersCopy != eqnNumbers) {
101 std::vector<double> tempCoefs;
102 std::vector<int> tempIndices;
104 int levelsOfCoupling = 0;
105 bool finished =
false;
107 bool foundCoupling =
false;
108 for(
size_t i=0; i<eqnNumbers.size(); i++) {
111 while(rowIndex >= 0) {
112 foundCoupling =
true;
117 std::vector<int>& indicesRef = rows[i]->indices();
118 std::vector<double>& coefsRef = rows[i]->coefs();
120 int len = indicesRef.size();
121 tempCoefs.resize(len);
122 tempIndices.resize(len);
124 double* tempCoefsPtr = &tempCoefs[0];
125 int* tempIndicesPtr = &tempIndices[0];
126 double* coefsPtr = &coefsRef[0];
127 int* indicesPtr = &indicesRef[0];
129 for(
int j=0; j<len; ++j) {
130 tempIndicesPtr[j] = indicesPtr[j];
131 tempCoefsPtr[j] = coef*coefsPtr[j];
134 CHK_ERR( eqns.
addEqn(eqnNumbers[rowIndex], tempCoefsPtr, tempIndicesPtr,
140 if (foundCoupling) ++levelsOfCoupling;
141 else finished =
true;
144 if (levelsOfCoupling != 1) {
test_EqnBuffer(MPI_Comm comm)
int addEqn(int eqnNumber, const double *coefs, const int *indices, int len, bool accumulate, bool create_indices_union=false)
std::vector< fei::CSVec * > & eqns()
std::vector< int > & eqnNumbers()
int addRHS(int eqnNumber, int rhsIndex, double value, bool accumulate=true)
int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double &coef)
int addEqns(EqnBuffer &inputEqns, bool accumulate)
int addIndices(int eqnNumber, const int *indices, int len)
int removeIndex(int eqnNumber, int colIndex)
int getCoef(int eqnNumber, int colIndex, double &coef)
virtual ~test_EqnBuffer()