From: wolf Date: Wed, 17 Nov 1999 18:45:53 +0000 (+0000) Subject: Fix an assumption that might be violated in very rare cases: that 1e308 is not greate... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=272db207d6c3fb97dbdca3bad1f27bee5a6ca8a7;p=dealii-svn.git Fix an assumption that might be violated in very rare cases: that 1e308 is not greater than the diameter of the domain. git-svn-id: https://svn.dealii.org/trunk@1884 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/Todo b/deal.II/deal.II/Todo index cb8631eb28..b58badfbc0 100644 --- a/deal.II/deal.II/Todo +++ b/deal.II/deal.II/Todo @@ -159,7 +159,3 @@ Remove the hack in Make_forward_declarations when using gcc2.95. See Move the TriaNumberCache into the Triangulation class once the compiler supports this (gcc2.95 does not allow this at present) - - -In Tria::distort_random: replace the initial value 1e308 by the - diameter of the domain (sum of diameters of coarse level cells). diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 7816b93655..8346f2bc8d 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -1143,9 +1143,20 @@ void Triangulation<1>::distort_random (const double factor, const unsigned int dim = 1; - // find the smallest length of the lines - // adjacent to the vertex - vector minimal_length (vertices.size(), 1e308); + // find the smallest length of the + // lines adjacent to the + // vertex. take the initial value + // to be larger than anything that + // might be found: the diameter of + // the triangulation, here computed + // by adding up the diameters of + // the coarse grid cells. + double almost_infinite_length = 0; + for (cell_iterator cell=begin(0); cell!=end(0); ++cell) + almost_infinite_length += cell->diameter(); + + vector minimal_length (vertices.size(), + almost_infinite_length); // also note if a vertex is at // the boundary vector at_boundary (vertices.size(), false); @@ -1205,9 +1216,21 @@ void Triangulation::distort_random (const double factor, // if you change something here, don't // forget to do so there as well - // find the smallest length of the lines - // adjecent to the vertex - vector minimal_length (vertices.size(), 1e308); + // find the smallest length of the + // lines adjacent to the + // vertex. take the initial value + // to be larger than anything that + // might be found: the diameter of + // the triangulation, here estimated + // by adding up the diameters of + // the coarse grid cells. + double almost_infinite_length = 0; + for (cell_iterator cell=begin(0); cell!=end(0); ++cell) + almost_infinite_length += cell->diameter(); + + vector minimal_length (vertices.size(), + almost_infinite_length); + // also note if a vertex is at // the boundary vector at_boundary (vertices.size(), false);