]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fix serious bug in interpolate: previously, distribute_local_to_global
authorrichter <richter@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Jan 2000 18:20:40 +0000 (18:20 +0000)
committerrichter <richter@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Jan 2000 18:20:40 +0000 (18:20 +0000)
was used, which added up its contributions over all cells. It would be
necessary to rescale the sums afterwards by the number of summands in
each dof, but this was not done. That led to a factor of four
amplification at regular nodes (2d) and 2 at hanging nodes, of course,
so we modified that.

git-svn-id: https://svn.dealii.org/trunk@2257 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/numerics/vectors.cc

index d5e75e68bb620e828b348e2b97552ae45313d69a..90caa4f8ee4cb0d7ffe73e820cbd1364504abcd6 100644 (file)
@@ -284,6 +284,9 @@ VectorTools::interpolate (const DoFHandler<dim>           &high_dof,
 {
   Vector<double> cell_high(high_dof.get_fe().dofs_per_cell);
   Vector<double> cell_low(low_dof.get_fe().dofs_per_cell);
+
+  vector <short unsigned int> touch_count (low_dof.n_dofs(), 0);
+  vector <int> local_dof_indices (low_dof.get_fe().dofs_per_cell);
   
   DoFHandler<dim>::active_cell_iterator h = high_dof.begin_active();
   DoFHandler<dim>::active_cell_iterator l = low_dof.begin_active();
@@ -293,8 +296,32 @@ VectorTools::interpolate (const DoFHandler<dim>           &high_dof,
   {
     h->get_dof_values(high, cell_high);
     transfer.vmult(cell_low, cell_high);
-    l->distribute_local_to_global(cell_low, low);
-  }
+
+    l->get_dof_indices (local_dof_indices);
+  
+                                  // distribute cell vector
+    for (unsigned int j=0; j<low_dof.get_fe().dofs_per_cell; ++j) 
+      {
+       low(local_dof_indices[j]) += cell_low(j);
+
+                                        // count, how often we have
+                                        // added to this dof
+       Assert (touch_count[local_dof_indices[j]] < 255,
+               ExcInternalError());    
+       ++touch_count[local_dof_indices[j]];
+      };
+  };
+
+                                  // compute the mean value of the
+                                  // sum which we have placed in each
+                                  // entry of the output vector
+  for (unsigned int i=0; i<low_dof.n_dofs(); ++i)
+    {
+      Assert (touch_count[i] != 0,
+             ExcInternalError());
+      
+      low(i) /= touch_count[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.