From: Wolfgang Bangerth Date: Thu, 2 Apr 1998 11:13:07 +0000 (+0000) Subject: Fix an error I oversaw beforehand. X-Git-Tag: v8.0.0~23139 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b20b495f1bc181466aaa25639de87e1970ad2d4a;p=dealii.git Fix an error I oversaw beforehand. git-svn-id: https://svn.dealii.org/trunk@115 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index ba2d1eaf33..3beb0fa479 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -91,6 +91,7 @@ void ConstraintMatrix::condense (const dSMatrixStruct &uncondensed, Assert (uncondensed.n_rows() == uncondensed.n_cols(), ExcMatrixNotSquare()); + // store for each line of the matrix // its new line number // after compression. If the shift is @@ -102,20 +103,40 @@ void ConstraintMatrix::condense (const dSMatrixStruct &uncondensed, vector::const_iterator next_constraint = lines.begin(); unsigned int shift = 0; unsigned int n_rows = (unsigned int)uncondensed.n_rows(); - for (unsigned int row=0; row!=n_rows; ++row) - if (row == (*next_constraint).line) - { - // this line is constrained - new_line.push_back (-1); - // note that #lines# is ordered - ++next_constraint; - ++shift; - } - else - new_line.push_back (row-shift); + + if (next_constraint == lines.end()) + // if no constraint is to be handled + for (unsigned int row=0; row!=n_rows; ++row) + new_line.push_back (row); + else + for (unsigned int row=0; row!=n_rows; ++row) + if (row == (*next_constraint).line) + { + // this line is constrained + new_line.push_back (-1); + // note that #lines# is ordered + ++shift; + ++next_constraint; + if (next_constraint == lines.end()) + // nothing more to do; finish rest + // of loop + { + for (unsigned int i=row+1; i::const_iterator next_constraint = lines.begin(); unsigned int shift = 0; unsigned int n_rows = (unsigned int)uncondensed_struct.n_rows(); - for (unsigned int row=0; row!=n_rows; ++row) - if (row == (*next_constraint).line) - { - // this line is constrained - new_line.push_back (-1); - // note that #lines# is ordered - ++next_constraint; - ++shift; - } - else - new_line.push_back (row-shift); + + if (next_constraint == lines.end()) + // if no constraint is to be handled + for (unsigned int row=0; row!=n_rows; ++row) + new_line.push_back (row); + else + for (unsigned int row=0; row!=n_rows; ++row) + if (row == (*next_constraint).line) + { + // this line is constrained + new_line.push_back (-1); + // note that #lines# is ordered + ++shift; + ++next_constraint; + if (next_constraint == lines.end()) + // nothing more to do; finish rest + // of loop + { + for (unsigned int i=row+1; i::const_iterator next_constraint = lines.begin(); unsigned int shift = 0; unsigned int n_rows = (unsigned int)uncondensed.n(); - for (unsigned int row=0; row!=n_rows; ++row) - if (row == (*next_constraint).line) - { - // this line is constrained - new_line.push_back (-1); - // note that #lines# is ordered - ++next_constraint; - ++shift; - } - else - new_line.push_back (row-shift); + + if (next_constraint == lines.end()) + // if no constraint is to be handled + for (unsigned int row=0; row!=n_rows; ++row) + new_line.push_back (row); + else + for (unsigned int row=0; row!=n_rows; ++row) + if (row == (*next_constraint).line) + { + // this line is constrained + new_line.push_back (-1); + // note that #lines# is ordered + ++shift; + ++next_constraint; + if (next_constraint == lines.end()) + // nothing more to do; finish rest + // of loop + { + for (unsigned int i=row+1; i::const_iterator next_constraint = lines.begin(); for (unsigned int row=0; row<(unsigned int)vec.n(); ++row) @@ -537,6 +602,9 @@ void ConstraintMatrix::condense (dVector &vec) const { vec(row) = 0.; ++next_constraint; + if (next_constraint == lines.end()) + // nothing more to do + break; }; }; @@ -548,7 +616,7 @@ void ConstraintMatrix::distribute (const dVector &condensed, Assert (sorted == true, ExcMatrixNotClosed()); Assert ((unsigned int)condensed.n()+n_constraints() == (unsigned int)uncondensed.n(), ExcWrongDimension()); - + // store for each line of the new vector // its old line number before // distribution. If the shift is @@ -560,20 +628,40 @@ void ConstraintMatrix::distribute (const dVector &condensed, vector::const_iterator next_constraint = lines.begin(); unsigned int shift = 0; unsigned int n_rows = (unsigned int)uncondensed.n(); - for (unsigned int row=0; row!=n_rows; ++row) - if (row == (*next_constraint).line) - { - // this line is constrained - old_line.push_back (-1); - // note that #lines# is ordered - ++next_constraint; - ++shift; - } - else - old_line.push_back (row-shift); + + if (next_constraint == lines.end()) + // if no constraint is to be handled + for (unsigned int row=0; row!=n_rows; ++row) + old_line.push_back (row); + else + for (unsigned int row=0; row!=n_rows; ++row) + if (row == (*next_constraint).line) + { + // this line is constrained + old_line.push_back (-1); + // note that #lines# is ordered + ++shift; + ++next_constraint; + if (next_constraint == lines.end()) + // nothing more to do; finish rest + // of loop + { + for (unsigned int i=row+1; i::max_couplings_between_dofs () const { // get these numbers by drawing pictures // and counting... // example: - // x-----x--x--o - // | | | | - // | x--x--x - // | | | | - // x--x--*--x--x - // | | | | - // x--x--x | - // | | | | - // o--x--x-----x + // | | | + // --x-----x--x--X-- + // | | | | + // | x--x--x + // | | | | + // --x--x--*--x--x-- + // | | | | + // x--x--x | + // | | | | + // --X--x--x-----x-- + // | | | // x = vertices connected with center vertex *; - // = total of 17 + // = total of 19 + // (the X vertices are connected with * if + // the vertices adjacent to X are hanging + // nodes) // count lines -> 28 (don't forget to count // mother and children separately!) switch (tria->max_adjacent_cells()) { case 4: - return (17*selected_fe->dofs_per_vertex + + return (19*selected_fe->dofs_per_vertex + 28*selected_fe->dofs_per_line + 8*selected_fe->dofs_per_quad); case 5: - return (19*selected_fe->dofs_per_vertex + + return (21*selected_fe->dofs_per_vertex + 31*selected_fe->dofs_per_line + 9*selected_fe->dofs_per_quad); case 6: - return (25*selected_fe->dofs_per_vertex + + return (28*selected_fe->dofs_per_vertex + 42*selected_fe->dofs_per_line + 12*selected_fe->dofs_per_quad); case 7: - return (27*selected_fe->dofs_per_vertex + + return (30*selected_fe->dofs_per_vertex + 45*selected_fe->dofs_per_line + 13*selected_fe->dofs_per_quad); case 8: - return (33*selected_fe->dofs_per_vertex + + return (37*selected_fe->dofs_per_vertex + 56*selected_fe->dofs_per_line + 16*selected_fe->dofs_per_quad); default: