47 #ifndef XPETRA_BLOCKEDVECTOR_DEF_HPP
48 #define XPETRA_BLOCKEDVECTOR_DEF_HPP
52 #include "Xpetra_BlockedMultiVector.hpp"
61 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 : Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut)
68 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 BlockedVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
76 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 : Xpetra::
BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mapExtractor, v)
84 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
100 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
109 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
118 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
145 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
153 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
161 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
169 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
177 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
178 Teuchos::RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
185 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
186 Teuchos::RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
193 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
194 Teuchos::ArrayRCP<const Scalar>
201 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
202 Teuchos::ArrayRCP<Scalar>
209 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
218 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
223 Teuchos::Array<Scalar> dots = Teuchos::Array<Scalar>(1);
228 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
237 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
246 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
255 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
258 scale(Teuchos::ArrayView<const Scalar> alpha)
264 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
275 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
288 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
289 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
293 using Array = Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>;
294 Array norm = Array(1);
299 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
300 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
304 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> norm =
305 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>(1);
311 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
312 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
316 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>
317 norm = Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>(1);
323 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
326 norm1(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms)
const
332 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
335 norm2(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms)
const
341 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
344 normInf(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms)
const
350 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
359 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
368 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
382 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
396 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
408 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
418 "BlockedVector::elementWiseMultipy: B must have same blocked map than this.");
419 TEUCHOS_TEST_FOR_EXCEPTION(A.
getMap()->getNodeNumElements() != B.
getMap()->getNodeNumElements(),
421 "BlockedVector::elementWiseMultipy: A has "
422 << A.
getMap()->getNodeNumElements() <<
" elements, B has " << B.
getMap()->getNodeNumElements()
424 TEUCHOS_TEST_FOR_EXCEPTION(A.
getMap()->getGlobalNumElements() != B.
getMap()->getGlobalNumElements(),
426 "BlockedVector::elementWiseMultipy: A has " << A.
getMap()->getGlobalNumElements()
427 <<
" elements, B has "
428 << B.
getMap()->getGlobalNumElements() <<
".");
430 RCP<const BlockedMap> bmap = this->getBlockedMap();
431 RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> rcpA = Teuchos::rcpFromRef(A);
432 RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> bmvec = Teuchos::rcpFromRef(B);
433 RCP<const BlockedVector> bbmvec = Teuchos::rcp_dynamic_cast<
const BlockedVector>(bmvec);
434 TEUCHOS_TEST_FOR_EXCEPTION(bbmvec.is_null() ==
true,
436 "BlockedVector::elementWiseMultipy: B must be a BlockedVector.");
452 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
461 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
467 "BlockedVector::getLocalLength: routine not implemented. It has no value as one must iterate on the partial vectors.");
468 TEUCHOS_UNREACHABLE_RETURN(0);
472 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
477 return this->getBlockedMap()->getFullMap()->getGlobalNumElements();
481 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
487 "BlockedVector::isSameSize: routine not implemented. It has no value as one must iterate on the partial vectors.");
488 TEUCHOS_UNREACHABLE_RETURN(0);
492 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
497 return std::string(
"BlockedVector");
501 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
504 describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel)
const
506 out << description() << std::endl;
507 for(
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); r++)
509 getMultiVector(r)->describe(out, verbLevel);
514 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
523 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
534 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
545 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
556 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
567 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
572 for(
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); ++r)
574 getMultiVector(r)->setSeed(seed);
579 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
584 for(
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); ++r)
586 getMultiVector(r)->randomize(bUseXpetraImplementation);
591 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
601 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
604 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
605 template<
class TargetDeviceType>
606 typename Kokkos::Impl::if_c<std::is_same<
typename dev_execution_space::memory_space,
607 typename TargetDeviceType::memory_space>::value,
608 typename dual_view_type::t_dev_um,
609 typename dual_view_type::t_host_um>::type
613 if(std::is_same<typename host_execution_space::memory_space, typename TargetDeviceType::memory_space>::value)
615 return getHostLocalView();
619 return getDeviceLocalView();
631 #endif // HAVE_XPETRA_KOKKOS_REFACTOR
634 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
635 Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
640 return this->getBlockedMap();
644 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
645 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
653 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
654 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
662 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
674 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
675 Teuchos::RCP< Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
683 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
702 #endif // XPETRA_BLOCKEDVECTOR_DEF_HPP
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 void reciprocal(const MultiVector &)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
virtual Scalar meanValue() const
Compute mean (average) value of this Vector.
virtual void setSeed(unsigned int seed)
Set seed for Random function.
virtual void multiply(Teuchos::ETransp, Teuchos::ETransp, const Scalar &, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Scalar &)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
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 Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
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 void sumIntoGlobalValue(GlobalOrdinal, size_t, const Scalar &)
Add value to existing value, using global (row) index.
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 void elementWiseMultiply(Scalar, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, Scalar)
Element-wise multiply of a Vector A with a MultiVector B.
virtual void scale(const Scalar &alpha)
Scale the current values of a vector, this = alpha*this.
virtual void replaceMap(const RCP< const Map > &map)
virtual size_t getNumVectors() const
Number of columns in the Vector.
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 void replaceGlobalValue(GlobalOrdinal, size_t, const Scalar &)
Replace value, using global (row) index.
virtual std::string description() const
A simple one-line description of this object.
Exception throws to report errors in the internal logical of the program.
virtual void Xpetra_randomize()
Set multi-vector values to random numbers. XPetra implementation.
virtual void abs(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input vector in target: A = abs(this).
virtual void sumIntoLocalValue(LocalOrdinal, size_t, const Scalar &)
Add value to existing value, using local (row) index.
virtual void dot(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
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 replaceLocalValue(LocalOrdinal, size_t, const Scalar &)
Replace value, using local (row) index.
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 > Merge() const
merge BlockedMultiVector blocks to a single MultiVector
virtual void reciprocal(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input vector in target, this(i,j) = 1/A(i,j).
virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual bool isSameSize(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &) const
Local number of rows on the calling process.
virtual void assign(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
virtual void replaceMap(const RCP< const Map > &map)
Teuchos::RCP< const Map > getMap() const
Access function for the underlying Map this DistObject was constructed with.
virtual size_t getLocalLength() const
Local number of rows on the calling process.
virtual void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
virtual void scale(const Scalar &alpha)
Scale the current values of a multi-vector, this = alpha*this.
virtual ~BlockedVector()
Destructor.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of vector.
void setMultiVector(size_t r, Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > v, bool bThyraMode)
set partial Vector associated with block row r
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
void setMultiVector(size_t r, Teuchos::RCP< const MultiVector > v, bool bThyraMode)
set partial multivector associated with block row r
virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
size_t global_size_t
Global size_t object.
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 abs(const MultiVector &)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
BlockedVector(const Teuchos::RCP< const BlockedMap > &map, bool zeroOut=true)
Constructor.
virtual void dot(const MultiVector &, const Teuchos::ArrayView< Scalar > &) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
Teuchos::RCP< MultiVector > getMultiVector(size_t r) const
return partial multivector associated with block row r
virtual void assign(const MultiVector &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Merge() const
merge BlockedVector blocks to a single Vector
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this vector.
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Compute 1-norm of vector.
virtual void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this vector.
virtual global_size_t getGlobalLength() const
Global number of rows in the Vector.
virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
BlockedVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Assignment operator: Does a deep copy.
CombineMode
Xpetra::Combine Mode enumerable type.
#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::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm in vector.
virtual void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Import &, CombineMode)
Import.
virtual void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Import &, CombineMode)
Export.
virtual void putScalar(const Scalar &value)
Set all values in the vector with the given value.
virtual void Xpetra_randomize()
Set vector values to random numbers. XPetra implementation.
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMultiVector(size_t r) const
return partial Vector associated with block row r
virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.