]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a bug with non-square/square block matrices.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 22 May 2000 09:09:31 +0000 (09:09 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 22 May 2000 09:09:31 +0000 (09:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@2917 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/numerics/matrices.cc

index 0c1017352fab55fec5ce0e5e05459c8b83d3d123..be9eeb19a075958b1eedbaf7eef27abddd02b2a8 100644 (file)
@@ -922,10 +922,32 @@ MatrixTools<dim>::apply_boundary_values (const map<unsigned int,double> &boundar
                                                   // (row,dof_number)
                                                   // in this block
                                                   // (not in the
-                                                  // transpose one)
-                 const unsigned int *
+                                                  // transpose
+                                                  // one). note that
+                                                  // we have to take
+                                                  // care of special
+                                                  // cases with
+                                                  // square
+                                                  // sub-matrices
+                 const unsigned int *p = 0;
+                 if (this_sparsity.n_rows() == this_sparsity.n_cols())
+                   {
+                     if (this_sparsity.get_column_numbers()
+                         [this_sparsity.get_rowstart_indices()[row]]
+                         ==
+                         block_index.second)
+                       p = &this_sparsity.get_column_numbers()
+                           [this_sparsity.get_rowstart_indices()[row]];
+                     else
+                       p = lower_bound(&this_sparsity.get_column_numbers()
+                                       [this_sparsity.get_rowstart_indices()[row]+1],
+                                       &this_sparsity.get_column_numbers()
+                                       [this_sparsity.get_rowstart_indices()[row+1]],
+                                       block_index.second);
+                   }
+                 else
                    p = lower_bound(&this_sparsity.get_column_numbers()
-                                   [this_sparsity.get_rowstart_indices()[row]+1],
+                                   [this_sparsity.get_rowstart_indices()[row]],
                                    &this_sparsity.get_column_numbers()
                                    [this_sparsity.get_rowstart_indices()[row+1]],
                                    block_index.second);
@@ -938,7 +960,15 @@ MatrixTools<dim>::apply_boundary_values (const map<unsigned int,double> &boundar
                                                   // past-the-end pointer but points
                                                   // to dof_number anyway...)
                                                   //
-                                                  // there should be such an entry!
+                                                  // there should be
+                                                  // such an entry!
+                                                  // note, however,
+                                                  // that this
+                                                  // assertion will
+                                                  // fail sometimes
+                                                  // if the sparsity
+                                                  // pattern is not
+                                                  // symmetric!
                  Assert ((*p == block_index.second) &&
                          (p != &this_sparsity.get_column_numbers()
                           [this_sparsity.get_rowstart_indices()[row+1]]),

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.