]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
catch more divide by zero and infinite numbers
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Oct 2010 14:09:00 +0000 (14:09 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Oct 2010 14:09:00 +0000 (14:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@22349 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/flow_function.cc
deal.II/lac/include/lac/filtered_matrix.h
deal.II/lac/include/lac/sparse_matrix.templates.h

index 535b4b916c392bea4f8e63c1e79b8086fa824734..12cf8a82093c870280e316c74094b58a70729019 100644 (file)
@@ -185,7 +185,9 @@ namespace Functions
                                        const double Re)
                  :
                  radius(r), Reynolds(Re)
-  {}
+  {
+    Assert(Reynolds != 0., ExcMessage("Reynolds number cannot be zero"));
+  }
 
 
   template<int dim>
index 20de47e91c80921a226794458399ff6353c8b29c..2bc9a6697f491b52ac6b4128262e30a5ff5fce67 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -922,22 +922,27 @@ FilteredMatrix<VECTOR>::apply_constraints (
   const bool  /* matrix_is_symmetric */) const
 {
   GrowingVectorMemory<VECTOR> mem;
-  VECTOR* tmp_vector = mem.alloc();
+  typename VectorMemory<VECTOR>::Pointer tmp_vector(mem);
   tmp_vector->reinit(v);
   const_index_value_iterator       i = constraints.begin();
   const const_index_value_iterator e = constraints.end();
   for (; i!=e; ++i)
-    (*tmp_vector)(i->first) = -i->second;
+    {
+      Assert(numbers::is_finite(i->second), ExcNumberNotFinite());
+      (*tmp_vector)(i->first) = -i->second;
+    }
   
                                   // This vmult is without bc, to get
                                   // the rhs correction in a correct
                                   // way.
   matrix->vmult_add(v, *tmp_vector);
-  mem.free(tmp_vector);
                                   // finally set constrained
                                   // entries themselves
   for (i=constraints.begin(); i!=e; ++i)
-    v(i->first) = i->second;
+    {
+      Assert(numbers::is_finite(i->second), ExcNumberNotFinite());
+      v(i->first) = i->second;
+    }
 }
 
 
@@ -968,7 +973,10 @@ FilteredMatrix<VECTOR>::post_filter (const VECTOR &in,
   const_index_value_iterator       i = constraints.begin();
     const const_index_value_iterator e = constraints.end();
     for (; i!=e; ++i)
-      out(i->first) = in(i->first);
+      {
+       Assert(numbers::is_finite(in(i->first)), ExcNumberNotFinite());
+       out(i->first) = in(i->first);
+      }
 }
 
 
index 9d3f561727665fc7327b294761e824d72f8d17a1..f107bdc6c9aa50591f1d7e22a63c0c1913b7a05d 100644 (file)
@@ -1342,6 +1342,7 @@ SparseMatrix<number>::precondition_SSOR (Vector<somenumber>              &dst,
 
                                   // divide by diagonal element
          *dst_ptr -= s * om;
+         Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
          *dst_ptr /= val[*rowstart_ptr];
        };
 
@@ -1363,6 +1364,7 @@ SparseMatrix<number>::precondition_SSOR (Vector<somenumber>              &dst,
            s += val[j] * dst(cols->colnums[j]);
 
          *dst_ptr -= s * om;
+         Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
          *dst_ptr /= val[*rowstart_ptr];
        };
       return;
@@ -1395,6 +1397,7 @@ SparseMatrix<number>::precondition_SSOR (Vector<somenumber>              &dst,
 
                                       // divide by diagonal element
       *dst_ptr -= s * om;
+      Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
       *dst_ptr /= val[*rowstart_ptr];
     };
 
@@ -1418,6 +1421,7 @@ SparseMatrix<number>::precondition_SSOR (Vector<somenumber>              &dst,
       for (unsigned int j=first_right_of_diagonal_index; j<end_row; ++j)
        s += val[j] * dst(cols->colnums[j]);
       *dst_ptr -= s * om;
+      Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
       *dst_ptr /= val[*rowstart_ptr];
     };
 }
@@ -1481,7 +1485,8 @@ SparseMatrix<number>::SOR (Vector<somenumber>& dst,
          if (col < row)
            s -= val[j] * dst(col);
        }
-
+      
+      Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
       dst(row) = s * om / val[cols->rowstart[row]];
     }
 }
@@ -1508,6 +1513,7 @@ SparseMatrix<number>::TSOR (Vector<somenumber>& dst,
        if (cols->colnums[j] > row)
          s -= val[j] * dst(cols->colnums[j]);
 
+      Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
       dst(row) = s * om / val[cols->rowstart[row]];
 
       if (row == 0)
@@ -1551,6 +1557,7 @@ SparseMatrix<number>::PSOR (Vector<somenumber>& dst,
            }
        }
 
+      Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
       dst(row) = s * om / val[cols->rowstart[row]];
     }
 }
@@ -1587,6 +1594,7 @@ SparseMatrix<number>::TPSOR (Vector<somenumber>& dst,
            s -= val[j] * dst(col);
        }
 
+      Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
       dst(row) = s * om / val[cols->rowstart[row]];
     }
 }
@@ -1647,6 +1655,7 @@ SparseMatrix<number>::SOR_step (Vector<somenumber> &v,
        {
          s -= val[j] * v(cols->colnums[j]);
        }
+      Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
       v(row) += s * om / val[cols->rowstart[row]];
     }
 }
@@ -1675,6 +1684,7 @@ SparseMatrix<number>::TSOR_step (Vector<somenumber> &v,
        {
          s -= val[j] * v(cols->colnums[j]);
        }
+      Assert(val[cols->rowstart[row]]!= 0., ExcDivideByZero());
       v(row) += s * om / val[cols->rowstart[row]];
     }
 }
@@ -1726,6 +1736,7 @@ SparseMatrix<number>::SSOR (Vector<somenumber>& dst,
            }
        }
       dst(i) -= s * om;
+      Assert(val[cols->rowstart[i]]!= 0., ExcDivideByZero());
       dst(i) /= val[cols->rowstart[i]];
     }
 
@@ -1740,6 +1751,7 @@ SparseMatrix<number>::SSOR (Vector<somenumber>& dst,
              if (static_cast<unsigned int>(i)<j) s += val[j] * dst(p);
            }
        }
+      Assert(val[cols->rowstart[i]]!= 0., ExcDivideByZero());
       dst(i) -= s * om / val[cols->rowstart[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.