]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Do not assume a fully functional matrix interface for mg matrices
authorMatthias Maier <tamiko@43-1.org>
Fri, 14 Jul 2017 19:10:50 +0000 (14:10 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sun, 16 Jul 2017 16:54:17 +0000 (11:54 -0500)
include/deal.II/multigrid/mg_block_smoother.h
include/deal.II/multigrid/mg_coarse.h
include/deal.II/multigrid/mg_matrix.h
include/deal.II/multigrid/mg_smoother.h

index 15c780af9316eeeef6c8bc49d9b08cc0b48814d4..3d5ccd70327ffb5674b88dd8403535aa0ebf64f8 100644 (file)
@@ -194,33 +194,12 @@ MGSmootherBlock<MatrixType, RelaxationType, number>::initialize (const MGMatrixT
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      // Workaround: The matrix objects supplied to this class do not
-      // expose information how to reinitialize a vector. Therefore,
-      // populate vmult and Tvmult by hand...
-
-      matrices[i] = LinearOperator<BlockVector<number>>();
-      matrices[i].vmult = [&m, i](BlockVector<number> &v,
-                                  const BlockVector<number> &u)
-      {
-        m[i].vmult(v, u);
-      };
-      matrices[i].Tvmult = [&m, i](BlockVector<number> &v,
-                                   const BlockVector<number> &u)
-      {
-        m[i].Tvmult(v, u);
-      };
-
-      smoothers[i] = LinearOperator<BlockVector<number>>();
-      smoothers[i].vmult = [&s, i](BlockVector<number> &v,
-                                   const BlockVector<number> &u)
-      {
-        s[i].vmult(v, u);
-      };
-      smoothers[i].Tvmult = [&s, i](BlockVector<number> &v,
-                                    const BlockVector<number> &u)
-      {
-        s[i].Tvmult(v, u);
-      };
+      // Workaround: Unfortunately, not every "m[i]" object has a
+      // rich enough interface to populate reinit_(domain|range)_vector.
+      // Thus, apply an empty LinearOperator exemplar.
+      matrices[i] = linear_operator<BlockVector<number> >(
+                      LinearOperator<BlockVector<number> >(), m[i]);
+      smoothers[i] = linear_operator<BlockVector<number> >(matrices[i], s[i]);
     }
 }
 
index 04b28f05f20818b9ca5d8116d2ac3a371f8d10de..f086cecc74232bf5372cb80b9d3b17b427ff045a 100644 (file)
@@ -376,8 +376,11 @@ MGCoarseGridLACIteration<SolverType, VectorType>
   :
   solver(&s, typeid(*this).name())
 {
-  matrix = linear_operator<VectorType>(m);
-  precondition = linear_operator<VectorType>(m, p);
+  // Workaround: Unfortunately, not every "m" object has a rich enough
+  // interface to populate reinit_(domain|range)_vector. Thus, supply an
+  // empty LinearOperator exemplar.
+  matrix = linear_operator<VectorType>(LinearOperator<VectorType>(), m);
+  precondition = linear_operator<VectorType>(matrix, p);
 }
 
 
@@ -398,8 +401,11 @@ MGCoarseGridLACIteration<SolverType, VectorType>
               const PreconditionerType &p)
 {
   solver = &s;
-  matrix = linear_operator<VectorType>(m);
-  precondition = linear_operator<VectorType>(m, p);
+  // Workaround: Unfortunately, not every "m" object has a rich enough
+  // interface to populate reinit_(domain|range)_vector. Thus, supply an
+  // empty LinearOperator exemplar.
+  matrix = linear_operator<VectorType>(LinearOperator<VectorType>(), m);
+  precondition = linear_operator<VectorType>(matrix, p);
 }
 
 
@@ -433,7 +439,10 @@ void
 MGCoarseGridLACIteration<SolverType, VectorType>
 ::set_matrix(const MatrixType &m)
 {
-  matrix = linear_operator<VectorType>(m);
+  // Workaround: Unfortunately, not every "m" object has a rich enough
+  // interface to populate reinit_(domain|range)_vector. Thus, supply an
+  // empty LinearOperator exemplar.
+  matrix = linear_operator<VectorType>(LinearOperator<VectorType>(), m);
 }
 
 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
index 8333cf21e83e1b9d41526a752b0abd3a978aec55..3f354be28601b829fa3d51f68c2c891cedfa558c 100644 (file)
@@ -185,20 +185,11 @@ namespace mg
     matrices.resize(p.min_level(), p.max_level());
     for (unsigned int level = p.min_level(); level <= p.max_level(); ++level)
       {
-        // Workaround: The matrix objects supplied to this class do not
-        // expose information how to reinitialize a vector. Therefore,
-        // populate vmult and Tvmult by hand...
-        matrices[level] = LinearOperator<VectorType>();
-        matrices[level].vmult = [&p, level](
-                                  VectorType &v, const VectorType &u)
-        {
-          p[level].vmult(v, u);
-        };
-        matrices[level].Tvmult = [&p, level](
-                                   VectorType &v, const VectorType &u)
-        {
-          p[level].Tvmult(v, u);
-        };
+        // Workaround: Unfortunately, not every "p[level]" object has a
+        // rich enough interface to populate reinit_(domain|range)_vector.
+        // Thus, apply an empty LinearOperator exemplar.
+        matrices[level] =
+          linear_operator<VectorType>(LinearOperator<VectorType>(), p[level]);
       }
   }
 
index 29726dc8871e5f67926013f2fcf95c2bbf080646..3c577b66ad66547f797fddbf9a947e9e67020b5f 100644 (file)
@@ -805,7 +805,11 @@ MGSmootherRelaxation<MatrixType, RelaxationType, VectorType>::initialize
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      matrices[i] = linear_operator<VectorType>(m[i]);
+      // Workaround: Unfortunately, not every "m[i]" object has a rich
+      // enough interface to populate reinit_(domain|range)_vector. Thus,
+      // apply an empty LinearOperator exemplar.
+      matrices[i] =
+        linear_operator<VectorType>(LinearOperator<VectorType>(), m[i]);
       smoothers[i].initialize(m[i], data);
     }
 }
@@ -830,7 +834,11 @@ MGSmootherRelaxation<MatrixType, RelaxationType, VectorType>::initialize
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      matrices[i] = linear_operator<VectorType>(m[i]);
+      // Workaround: Unfortunately, not every "m[i]" object has a rich
+      // enough interface to populate reinit_(domain|range)_vector. Thus,
+      // apply an empty LinearOperator exemplar.
+      matrices[i] =
+        linear_operator<VectorType>(LinearOperator<VectorType>(), m[i]);
       smoothers[i].initialize(m[i], data[i]);
     }
 }
@@ -852,7 +860,11 @@ MGSmootherRelaxation<MatrixType, RelaxationType, VectorType>::initialize
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      matrices[i] = &(m[i].block(row, col));
+      // Workaround: Unfortunately, not every "m[i]" object has a rich
+      // enough interface to populate reinit_(domain|range)_vector. Thus,
+      // apply an empty LinearOperator exemplar.
+      matrices[i] = linear_operator<VectorType>(LinearOperator<VectorType>(),
+                                                m[i].block(row, col));
       smoothers[i].initialize(m[i].block(row, col), data);
     }
 }
@@ -879,7 +891,11 @@ MGSmootherRelaxation<MatrixType, RelaxationType, VectorType>::initialize
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      matrices[i] = &(m[i].block(row, col));
+      // Workaround: Unfortunately, not every "m[i]" object has a rich
+      // enough interface to populate reinit_(domain|range)_vector. Thus,
+      // apply an empty LinearOperator exemplar.
+      matrices[i] = linear_operator<VectorType>(LinearOperator<VectorType>(),
+                                                m[i].block(row, col));
       smoothers[i].initialize(m[i].block(row, col), data[i]);
     }
 }
@@ -1009,7 +1025,11 @@ MGSmootherPrecondition<MatrixType, PreconditionerType, VectorType>::initialize
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      matrices[i] = linear_operator<VectorType>(m[i]);
+      // Workaround: Unfortunately, not every "m[i]" object has a rich
+      // enough interface to populate reinit_(domain|range)_vector. Thus,
+      // apply an empty LinearOperator exemplar.
+      matrices[i] =
+        linear_operator<VectorType>(LinearOperator<VectorType>(), m[i]);
       smoothers[i].initialize(m[i], data);
     }
 }
@@ -1036,7 +1056,11 @@ MGSmootherPrecondition<MatrixType, PreconditionerType, VectorType>::initialize
 
   for (unsigned int i=min; i<=max; ++i)
     {
-      matrices[i] = linear_operator<VectorType>(m[i]);
+      // Workaround: Unfortunately, not every "m[i]" object has a rich
+      // enough interface to populate reinit_(domain|range)_vector. Thus,
+      // apply an empty LinearOperator exemplar.
+      matrices[i] =
+        linear_operator<VectorType>(LinearOperator<VectorType>(), m[i]);
       smoothers[i].initialize(m[i], data[i]);
     }
 }

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.