Assignement of scalar values in DenseVector
The following doesn't work for me:
#include <dune/common/fvector>
#include <dune/istl/bvector>
using Vector = Dune::FieldVector<Dune::BlockVector<double>,2>;
Vector v;
v = 0.; // ERROR: assignement is not possible
Error message
- Compiler:
clang-11
- Branch:
releases/2.8
[100%] Building CXX object dune/istl/test/CMakeFiles/bvectortest.dir/bvectortest.cc.o
dune-istl/dune/istl/test/bvectortest.cc:183:6: error: no viable overloaded '='
fv = 0.;
~~ ^ ~~
dune-common/dune/common/fvector.hh:144:18: note: candidate function not viable: no known conversion from 'double' to 'const Dune::FieldVector<Dune::BlockVector<double, std::allocator<double>>, 2>' for 1st argument
FieldVector& operator= (const FieldVector&) = default;
^
dune-common/dune/common/fvector.hh:147:18: note: candidate template ignored: could not match 'FieldVector<type-parameter-0-0, 2>' against 'double'
FieldVector& operator= (const FieldVector<T, SIZE>& x)
^
dune-common/dune/common/fvector.hh:154:18: note: candidate template ignored: could not match 'FieldVector<type-parameter-0-0, SIZE>' against 'double'
FieldVector& operator=(const FieldVector<T, N>&) = delete;
^
dune-common/dune/common/densevector.hh:267:26: note: candidate function not viable: no known conversion from 'double' to 'const Dune::DenseVector<Dune::FieldVector<Dune::BlockVector<double, std::allocator<double>>, 2>>::value_type' (aka 'const Dune::BlockVector<double, std::allocator<double>>') for 1st argument
inline derived_type& operator= (const value_type& k)
^
dune-common/dune/common/densevector.hh:277:18: note: candidate function not viable: no known conversion from 'double' to 'const Dune::DenseVector<Dune::FieldVector<Dune::BlockVector<double, std::allocator<double>>, 2>>' for 1st argument
DenseVector& operator=(const DenseVector&) = default;
^
dune-common/dune/common/densevector.hh:285:19: note: candidate template ignored: could not match 'DenseVector<type-parameter-0-0>' against 'double'
derived_type& operator= (const DenseVector<W>& other)
^
1 error generated.
I traced the error back to the DenseVector
assignment operator for scalars. It's set for value_type
instead of field_type
. If I change its argument to field_type
, everything seems to work as expected (including fvectortest
). But perhaps I am doing something wrong, or this is not possible because of some incompatibility?