#include <basic/forward-declarations.h>
#include <map>
-
+#include <bvector.h>
/**
* Denote which norm/integral is to be computed. The following possibilities
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);
/**
#include <numeric>
#include <algorithm>
+#include <bvector.h>
#include <cmath>
};
};
+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>;