From: Niklas Fehn Date: Fri, 6 Mar 2020 07:50:17 +0000 (+0100) Subject: new function set_zero_mean_value() X-Git-Tag: v9.2.0-rc1~417^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a0e615272e8f350f656056c322380baaf9fe15e;p=dealii.git new function set_zero_mean_value() --- diff --git a/doc/news/changes/minor/20200306NiklasFehn b/doc/news/changes/minor/20200306NiklasFehn new file mode 100644 index 0000000000..3a935604fd --- /dev/null +++ b/doc/news/changes/minor/20200306NiklasFehn @@ -0,0 +1,7 @@ +New: LinearAlgebra::set_zero_mean_value() +Add free function that allows to shift a vector by a constant value in a +way that its mean value becomes zero. This function only makes use of the +pure virtual functions add() and mean_value() of the abstract class +VectorSpaceVector. +
+(Niklas Fehn, 2020/03/06) diff --git a/include/deal.II/lac/vector_space_vector.h b/include/deal.II/lac/vector_space_vector.h index 10975c1d1c..1c13cc8640 100644 --- a/include/deal.II/lac/vector_space_vector.h +++ b/include/deal.II/lac/vector_space_vector.h @@ -273,6 +273,22 @@ namespace LinearAlgebra /*@}*/ } // namespace LinearAlgebra +// ---------------------------- Free functions -------------------------- + +namespace LinearAlgebra +{ + /** + * Shift all entries of the vector by a constant factor so that the mean + * value of the vector becomes zero. + */ + template + void + set_zero_mean_value(VectorSpaceVector &vector) + { + vector.add(-vector.mean_value()); + } +} // namespace LinearAlgebra + DEAL_II_NAMESPACE_CLOSE #endif