]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix some things which did not compile right away in 1D.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 6 Nov 1998 16:17:19 +0000 (16:17 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 6 Nov 1998 16:17:19 +0000 (16:17 +0000)
git-svn-id: https://svn.dealii.org/trunk@650 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria_boundary.h
deal.II/deal.II/source/dofs/dof_handler.cc
deal.II/deal.II/source/grid/tria.cc

index f67f7b4515666f015fddf59ba38e0a4d075c47dd..ebdb8e3e7af17be2b78b588d9cafe54f88e04c7a 100644 (file)
  * Workaround for a bug in egcs snapshot 1998/08/03.
  */
 template <int dim> struct BoundaryHelper;
+
+template <> struct BoundaryHelper<1> {
+                                    // actually, this does not make much
+                                    // sense, but declaring a zero-sized
+                                    // array is forbidden nowadays
+    typedef const Point<1> *PointArray[1];
+};
+
 template <> struct BoundaryHelper<2> {
     typedef const Point<2> *PointArray[GeometryInfo<2>::vertices_per_face];
 };
-    
+
 
 
 /**
@@ -74,7 +82,7 @@ class Boundary {
  *   arithmetic mean of the points.
  *
  *   This class does not really describe a boundary in the usual sense. By
- *   placing new points in teh middle of old ones, it rather assumes that the
+ *   placing new points in the middle of old ones, it rather assumes that the
  *   boundary of the domain is given by the polygon/polyhedron defined by the
  *   boundary of the initial coarse triangulation.
  */
index b6216e5241ee3134c53f36c2f5b50a4f378e06ac..fb090012be9d7329ddbb323db8d010c06c8ac1ba 100644 (file)
@@ -1192,7 +1192,7 @@ void DoFHandler<dim>::renumber_dofs (const RenumberingMethod method,
 
 template <>
 void DoFHandler<1>::do_renumbering (const vector<int> &new_numbers) {
-  Assert (new_number.size() == n_dofs(level), ExcRenumberingIncomplete());
+  Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
                                   // note that we can not use cell iterators
                                   // in this function since then we would
index 2ac8a1a2739e60aceaac126c18fa2a1dc8b44249..8ae4f6a27efa97d61191e9cfa1776f07dd168227 100644 (file)
@@ -666,10 +666,84 @@ void Triangulation<2>::create_hyper_ball (const Point<2> &p, const double radius
 
 
 
+#if deal_II_dimension == 1
+
+template <>
+void Triangulation<1>::distort_random (const double factor,
+                                      const bool   keep_boundary) {
+                                  // this function is mostly equivalent to
+                                  // that for the general dimensional case
+                                  // the only difference being the correction
+                                  // for split faces which is not necessary
+                                  // in 1D
+                                  //
+                                  // if you change something here, don't
+                                  // forget to do so there as well
+
+  const unsigned int dim = 1;
+  
+                                  // find the smallest length of the lines
+                                  // adjacent to the vertex
+  vector<double>             minimal_length (vertices.size(), 1e308);
+                                  // also note if a vertex is at
+                                  // the boundary
+  vector<bool>               at_boundary (vertices.size(), false);
+  
+  for (active_line_iterator line=begin_active_line();
+       line != end_line(); ++line)
+    {
+      if (keep_boundary && line->at_boundary())
+       {
+         at_boundary[line->vertex_index(0)] = true;
+         at_boundary[line->vertex_index(1)] = true;
+       };
+      
+      minimal_length[line->vertex_index(0)]
+       = min(line->diameter(), minimal_length[line->vertex_index(0)]);
+      minimal_length[line->vertex_index(1)]
+       = min(line->diameter(), minimal_length[line->vertex_index(1)]);
+    };
+
+
+  const unsigned int n_vertices = vertices.size();
+  Point<dim> shift_vector;
+  
+  for (unsigned int vertex=0; vertex<n_vertices; ++vertex) 
+    {
+                                      // ignore this vertex if we whall keep
+                                      // the boundary and this vertex *is* at
+                                      // the boundary
+      if (keep_boundary && at_boundary[vertex])
+       continue;
+      
+                                      // first compute a random shift vector
+      for (unsigned int d=0; d<dim; ++d)
+       shift_vector(d) = rand()*1.0/RAND_MAX;
+
+      shift_vector *= factor * minimal_length[vertex] /
+                     sqrt(shift_vector.square());
+
+                                      // finally move the vertex
+      vertices[vertex] += shift_vector;
+    };
+};
+
+#endif
+
+
 
 template <int dim>
 void Triangulation<dim>::distort_random (const double factor,
                                         const bool   keep_boundary) {
+                                  // this function is mostly equivalent to
+                                  // that for the general dimensional case
+                                  // the only difference being the correction
+                                  // for split faces which is not necessary
+                                  // in 1D
+                                  //
+                                  // 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<double>             minimal_length (vertices.size(), 1e308);
@@ -717,10 +791,8 @@ void Triangulation<dim>::distort_random (const double factor,
 
   
                                   // finally correct hanging nodes
-                                  // again. not necessary for 1D
-  if (dim==1)
-    return;
-  
+                                  // again. The following is not
+                                  // necessary for 1D
   active_cell_iterator cell = begin_active(),
                       endc = end();
   for (; cell!=endc; ++cell) 

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.