47 #ifndef XPETRA_BLOCKEDVECTOR_HPP 48 #define XPETRA_BLOCKEDVECTOR_HPP 60 #ifndef DOXYGEN_SHOULD_SKIP_THIS 62 template<
class S,
class LO,
class GO,
class N>
class Vector;
63 template<
class S,
class LO,
class GO,
class N>
class MapExtractor;
64 template<
class S,
class LO,
class GO,
class N>
class VectorFactory;
67 template <
class Scalar = double,
72 :
public virtual Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >,
93 #undef XPETRA_BLOCKEDVECTOR_SHORT 295 virtual void scale(
const Scalar &alpha) {
415 throw Xpetra::Exceptions::RuntimeError(
"BlockedVector::getLocalLength: routine not implemented. It has no value as one must iterate on the partial vectors.");
421 return this->
getBlockedMap()->getFullMap()->getGlobalNumElements();
431 return std::string(
"BlockedVector");
437 for(
size_t r = 0; r < this->
getBlockedMap()->getNumMaps(); r++)
472 for(
size_t r = 0; r < this->
getBlockedMap()->getNumMaps(); ++r) {
478 virtual void randomize(
bool bUseXpetraImplementation =
false) {
479 for(
size_t r = 0; r < this->
getBlockedMap()->getNumMaps(); ++r) {
490 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 491 typedef typename Kokkos::Details::ArithTraits<Scalar>::val_type impl_scalar_type;
492 typedef Kokkos::DualView<impl_scalar_type**, Kokkos::LayoutStride,
493 typename node_type::execution_space,
494 Kokkos::MemoryUnmanaged> dual_view_type;
495 typedef typename dual_view_type::host_mirror_space host_execution_space;
496 typedef typename dual_view_type::t_dev::execution_space dev_execution_space;
503 template<
class TargetDeviceType>
504 typename Kokkos::Impl::if_c<
505 Kokkos::Impl::is_same<
506 typename dev_execution_space::memory_space,
507 typename TargetDeviceType::memory_space>::value,
508 typename dual_view_type::t_dev_um,
509 typename dual_view_type::t_host_um>::type
510 getLocalView ()
const {
511 if(Kokkos::Impl::is_same<
512 typename host_execution_space::memory_space,
513 typename TargetDeviceType::memory_space
515 return getHostLocalView();
517 return getDeviceLocalView();
521 virtual typename dual_view_type::t_host_um getHostLocalView ()
const {
522 typename dual_view_type::t_host_um test;
525 virtual typename dual_view_type::t_dev_um getDeviceLocalView()
const {
526 typename dual_view_type::t_dev_um test;
581 #define XPETRA_BLOCKEDVECTOR_SHORT 582 #endif // XPETRA_BLOCKEDVECTOR_HPP virtual void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export &exporter, CombineMode CM)
Import (using an Exporter).
virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
virtual void putScalar(const Scalar &value)
Set all values in the vector with the given value.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of vector.
LocalOrdinal local_ordinal_type
virtual size_t getLocalLength() const
Local number of rows on the calling process.
virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Teuchos::RCP< const Xpetra::BlockedMap< LocalOrdinal, GlobalOrdinal, Node > > getBlockedMap() const
Access function for the underlying Map this DistObject was constructed with.
virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
virtual void dot(const MultiVector &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
GlobalOrdinal global_ordinal_type
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this vector.
virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
virtual void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace value, using global (row) index.
virtual void abs(const MultiVector &A)
Put element-wise absolute values of input vector in target: A = abs(this).
virtual Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
void setMultiVector(size_t r, Teuchos::RCP< const Vector > v, bool bThyraMode)
set partial Vector associated with block row r
GlobalOrdinal global_ordinal_type
virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
virtual void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Add value to existing value, using local (row) index.
BlockedVector(Teuchos::RCP< const Xpetra::BlockedMap< LocalOrdinal, GlobalOrdinal, Node > > bmap, Teuchos::RCP< Vector > v)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void Xpetra_randomize()
Set multi-vector values to random numbers. XPetra implementation.
virtual void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export &exporter, CombineMode CM)
Export (using an Importer).
virtual void scale(Teuchos::ArrayView< const Scalar > alpha)
Scale the current values of a vector, this[j] = alpha[j]*this[j].
Exception throws to report errors in the internal logical of the program.
virtual void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace value, using local (row) index.
virtual void Xpetra_randomize()
Set vector values to random numbers. XPetra implementation.
virtual void reciprocal(const MultiVector &A)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
virtual void update(const Scalar &alpha, const MultiVector &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
virtual void scale(const Scalar &alpha)
Scale the current values of a multi-vector, this = alpha*this.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
Teuchos::RCP< MultiVector > getMultiVector(size_t r) const
return partial multivector associated with block row r
virtual void replaceMap(const RCP< const Map > &map)
virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
virtual void update(const Scalar &alpha, const MultiVector &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
virtual void elementWiseMultiply(Scalar scalarAB, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Vector &B, Scalar scalarThis)
Element-wise multiply of a Vector A with a Vector B.
virtual void assign(const MultiVector &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Add value to existing value, using global (row) index.
virtual void dot(const MultiVector &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
BlockedVector(Teuchos::RCP< const Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mapExtractor, Teuchos::RCP< Vector > v)
Teuchos::RCP< MultiVector > getMultiVector(size_t r, bool bThyraMode) const
return partial Vector associated with block row r
BlockedVector(Teuchos::RCP< const Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mapExtractor, Teuchos::RCP< const Vector > v)
virtual void setSeed(unsigned int seed)
Set seed for Random function.
Teuchos::RCP< MultiVector > Merge() const
merge BlockedVector blocks to a single Vector
virtual void randomize(bool bUseXpetraImplementation=false)
Teuchos::RCP< MultiVector > getMultiVector(size_t r) const
return partial Vector associated with block row r
virtual Scalar dot(const Vector &A) const
Computes dot product of this Vector against input Vector x.
Teuchos::RCP< const Map > getMap() const
Access function for the underlying Map this DistObject was constructed with.
virtual void abs(const MultiVector &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
virtual size_t getNumVectors() const
Number of columns in the Vector.
virtual void replaceMap(const RCP< const Map > &map)
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
LocalOrdinal local_ordinal_type
virtual void assign(const MultiVector &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
virtual void elementWiseMultiply(Scalar scalarAB, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector &B, Scalar scalarThis)
Element-wise multiply of a Vector A with a MultiVector B.
virtual Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
virtual Scalar meanValue() const
Compute mean (average) value of this Vector.
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this vector.
void setMultiVector(size_t r, Teuchos::RCP< const MultiVector > v, bool bThyraMode)
set partial multivector associated with block row r
BlockedVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector &rhs)
Assignment operator: Does a deep copy.
virtual void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import &importer, CombineMode CM)
Import.
virtual void scale(const Scalar &alpha)
Scale the current values of a vector, this = alpha*this.
size_t global_size_t
Global size_t object.
Teuchos::RCP< MultiVector > Merge() const
merge BlockedMultiVector blocks to a single MultiVector
static const EVerbosityLevel verbLevel_default
virtual Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
virtual global_size_t getGlobalLength() const
Global number of rows in the Vector.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm in vector.
BlockedVector(const Teuchos::RCP< const BlockedMap > &map, bool zeroOut=true)
Constructor.
virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
virtual void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import &importer, CombineMode CM)
Export.
virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual void update(const Scalar &alpha, const MultiVector &A, const Scalar &beta, const MultiVector &B, const Scalar &gamma)
Update vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
virtual void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
virtual void meanValue(const Teuchos::ArrayView< Scalar > &means) const
Compute mean (average) value of each vector in vector. The outcome of this routine is undefined for n...
virtual void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector &A, const MultiVector &B, const Scalar &beta)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
virtual void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const Vector &A, const Vector &B, const Scalar &beta)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
CombineMode
Xpetra::Combine Mode enumerable type.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Compute 1-norm of vector.
virtual ~BlockedVector()
Destructor.
#define XPETRA_MONITOR(funcName)
virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
BlockedVector(Teuchos::RCP< const Xpetra::BlockedMap< LocalOrdinal, GlobalOrdinal, Node > > bmap, Teuchos::RCP< const Vector > v)
virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
virtual Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
virtual std::string description() const
A simple one-line description of this object.
virtual void reciprocal(const MultiVector &A)
Put element-wise reciprocal values of input vector in target, this(i,j) = 1/A(i,j).