27 #ifndef EWOMS_OVERLAPPING_SCALAR_PRODUCT_HH 28 #define EWOMS_OVERLAPPING_SCALAR_PRODUCT_HH 30 #include <dune/common/version.hh> 31 #include <dune/common/parallel/mpihelper.hh> 32 #include <dune/istl/scalarproducts.hh> 40 template <
class OverlappingBlockVector,
class Overlap>
42 :
public Dune::ScalarProduct<OverlappingBlockVector>
45 typedef typename OverlappingBlockVector::field_type field_type;
46 typedef typename Dune::CollectiveCommunication<typename Dune::MPIHelper::MPICommunicator> CollectiveCommunication;
48 #if DUNE_VERSION_NEWER(DUNE_ISTL, 2, 5) 49 typedef typename Dune::ScalarProduct<OverlappingBlockVector>::real_type real_type;
51 typedef double real_type;
54 enum { category = Dune::SolverCategory::overlapping };
57 : overlap_(overlap), comm_( Dune::MPIHelper::getCollectiveCommunication() )
64 size_t numLocal = overlap_.numLocal();
65 for (
unsigned localIdx = 0; localIdx < numLocal; ++localIdx) {
66 if (overlap_.iAmMasterOf(static_cast<int>(localIdx)))
67 sum += x[localIdx] * y[localIdx];
71 return comm_.sum( sum );
75 {
return std::sqrt(dot(x, x)); }
78 const Overlap& overlap_;
79 const CollectiveCommunication comm_;
An overlap aware ISTL scalar product.
Definition: overlappingscalarproduct.hh:41
Definition: baseauxiliarymodule.hh:37
An overlap aware block vector.
Definition: overlappingblockvector.hh:49