]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
subtract_mean_values
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 13 Jul 1999 10:37:08 +0000 (10:37 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 13 Jul 1999 10:37:08 +0000 (10:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@1571 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 2e4a8f1e375154b56d309c214b40c649c2bd5b10..3b9fd5bce2dbaba429d7b917f1722f63aa993fc8 100644 (file)
@@ -11,7 +11,7 @@
 #include <basic/forward-declarations.h>
 #include <map>
 
-
+#include <bvector.h>
 
 /**
  *  Denote which norm/integral is to be computed. The following possibilities
@@ -468,7 +468,26 @@ class VectorTools //<dim>
                                      Vector<float>            &difference,
                                      const Quadrature<dim>    &q,
                                      const NormType           &norm,
-                                     const Function<dim>      *weight=0);
+                                     const Function<dim> *weight=0);
+
+                                    /**
+                                     * Mean-value filter for Stokes.
+                                     * The pressure in Stokes'
+                                     * equations is determined up to a
+                                     * constant only. This function
+                                     * allows to subtract the mean
+                                     * value of the pressure. It is
+                                     * usually called in a
+                                     * preconditioner and generates
+                                     * updates with mean value zero.
+                                     *
+                                     * Apart from the vector #v# to
+                                     * operate on, this function takes
+                                     * a bit vector. This has a true
+                                     * entry for every pressure component.
+                                     */
+    static void subtract_mean_value(Vector<double>& v, const
+                                   bit_vector& p_select);
     
 
                                     /**
index 8b5874a6c6642b86540117cc9d180e4e62c64bfa..a196449e76abbd05412b5e40a16ff1ce9449dc4d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <numeric>
 #include <algorithm>
+#include <bvector.h>
 #include <cmath>
 
 
@@ -1102,7 +1103,21 @@ VectorTools<dim>::integrate_difference (const DoFHandler<dim>    &dof,
     };
 };
 
+template<int dim>
+void
+VectorTools<dim>::subtract_mean_value(Vector<double>& v, const
+                                     bit_vector& p_select)
+{
+  unsigned int n = v.size();
+  Assert(n == p_select.size(), ExcDimensionMismatch(n, p_select.size()));
 
+  double s = 0;
+  for (unsigned int i=0;i<n;++i)
+    if (p_select[i]) s += v(i);
+
+  for (unsigned int i=0;i<n;++i)
+    if (p_select[i]) v(i) -= s;  
+}
 
 // explicit instantiations
 template VectorTools<deal_II_dimension>;

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.