Skip to content
Snippets Groups Projects
Commit 85705ebb authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Merge branch 'feature/two-norm' into 'master'

Make TwoNorm more generic

See merge request !55
parents 25167c5c 440e3b49
No related branches found
No related tags found
1 merge request!55Make TwoNorm more generic
Pipeline #38904 passed
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <cstring> // For size_t #include <cstring> // For size_t
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/hybridutilities.hh>
#include "norm.hh" #include "norm.hh"
...@@ -43,15 +44,15 @@ class TwoNorm : public Norm<V> ...@@ -43,15 +44,15 @@ class TwoNorm : public Norm<V>
virtual field_type diff(const VectorType& f1, const VectorType& f2) const override virtual field_type diff(const VectorType& f1, const VectorType& f2) const override
{ {
assert(f1.size() == f2.size()); assert(f1.size() == f2.size());
double r = 0.0; field_type r = 0.0;
for (size_t i=0; i<f1.size(); ++i) Dune::Hybrid::forEach(Dune::Hybrid::integralRange(Dune::Hybrid::size(f1)), [&](auto&& i)
{ {
typename VectorType::block_type block = f1[i]; auto block = f1[i];
block -= f2[i]; block -= f2[i];
r += Dune::Impl::asVector(block).two_norm2(); r += Dune::Impl::asVector(block).two_norm2();
} });
return std::sqrt(r); return std::sqrt(r);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment