1#ifndef OPM_SCALAR_PRODUCTS_HEADER_INCLUDED
2#define OPM_SCALAR_PRODUCTS_HEADER_INCLUDED
14template<
class Vector,
class Comm>
25 : _communication(com), _category(cat)
27 count_ = getLocalCount();
28 int verify = verifyLocalCount();
29 if (count_ != verify) OPM_THROW(std::runtime_error,
"Inconsistent local node count!!\n");
46 double dot (
const Vector& vx,
const Vector& vy)
const override
50 double const *x = &vx[0][0];
51 double const *y = &vy[0][0];
54 int NN = block_size*count_;
56 auto cc = _communication->communicator();
63 double norm (
const Vector& vx)
const override
65 return sqrt(
dot(vx,vx));
69 virtual SolverCategory::Category
category()
const override
77 static constexpr auto block_size = Vector::block_type::dimension;
79 std::shared_ptr<const Comm> _communication;
80 SolverCategory::Category _category;
85 int getLocalCount()
const
89 auto indexSet = _communication->indexSet();
90 for (
auto idx = indexSet.begin(); idx!=indexSet.end(); ++idx) {
91 if (idx->local().attribute()==1) count++;
98 int verifyLocalCount()
const
100 auto indexSet = _communication->indexSet();
104 for (
auto idx = indexSet.begin(); idx!=indexSet.end(); ++idx) {
106 if (idx->local().attribute()==1) {
108 auto loc = idx->local().local();
124template<
class Vector>
133 double dot(
const Vector& vx,
const Vector& vy)
const override
136 double const *x = &vx[0][0];
137 double const *y = &vy[0][0];
140 int NN = block_size*vx.N();
148 double norm(
const Vector& vx)
const override {
149 return std::sqrt(this->
dot(vx, vx));
155 static constexpr auto block_size = Vector::block_type::dimension;
Dune::OwnerOverlapCopyCommunication< int, int > Comm
Definition: FlexibleSolver_impl.hpp:394
Definition: ScalarProducts.hpp:16
double norm(const Vector &vx) const override
Vector L2-norm.
Definition: ScalarProducts.hpp:63
GhostLastScalarProduct(const Comm &com, SolverCategory::Category cat)
constructor
Definition: ScalarProducts.hpp:38
GhostLastScalarProduct(std::shared_ptr< const Comm > com, SolverCategory::Category cat)
constructor
Definition: ScalarProducts.hpp:24
virtual SolverCategory::Category category() const override
Category of the scalar product (see SolverCategory::Category)
Definition: ScalarProducts.hpp:69
double dot(const Vector &vx, const Vector &vy) const override
Dot product of two vectors.
Definition: ScalarProducts.hpp:46
Definition: ScalarProducts.hpp:126
double norm(const Vector &vx) const override
Vector L2-norm.
Definition: ScalarProducts.hpp:148
double dot(const Vector &vx, const Vector &vy) const override
Dot product of two vectors.
Definition: ScalarProducts.hpp:133
double vec_dot(double const *x, double const *y, int NN)
Definition: fvbaseprimaryvariables.hh:161