// @HEADER // ***************************************************************************** // Xpetra: A linear algebra interface package // // Copyright 2012 NTESS and the Xpetra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef XPETRA_TPETRAVECTOR_DEF_HPP #define XPETRA_TPETRAVECTOR_DEF_HPP #include "Xpetra_TpetraVector_decl.hpp" namespace Xpetra { template TpetraVector:: TpetraVector(const Teuchos::RCP>& map, bool zeroOut) : TpetraMultiVector(map, 1, zeroOut) { } template TpetraVector:: TpetraVector(const Teuchos::RCP>& map, const Teuchos::ArrayView& A) : TpetraMultiVector(map, A, map->getLocalNumElements(), 1) { } template TpetraVector:: ~TpetraVector() { } template void TpetraVector:: replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) { XPETRA_MONITOR("TpetraVector::replaceGlobalValue"); getTpetra_Vector()->replaceGlobalValue(globalRow, value); } template void TpetraVector:: sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) { XPETRA_MONITOR("TpetraVector::sumIntoGlobalValue"); getTpetra_Vector()->sumIntoGlobalValue(globalRow, value); } template void TpetraVector:: replaceLocalValue(LocalOrdinal myRow, const Scalar& value) { XPETRA_MONITOR("TpetraVector::replaceLocalValue"); getTpetra_Vector()->replaceLocalValue(myRow, value); } template void TpetraVector:: sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) { XPETRA_MONITOR("TpetraVector::sumIntoLocalValue"); getTpetra_Vector()->sumIntoLocalValue(myRow, value); } template typename Teuchos::ScalarTraits::magnitudeType TpetraVector:: norm1() const { XPETRA_MONITOR("TpetraVector::norm1"); return getTpetra_Vector()->norm1(); } template typename Teuchos::ScalarTraits::magnitudeType TpetraVector:: norm2() const { XPETRA_MONITOR("TpetraVector::norm2"); return getTpetra_Vector()->norm2(); } template typename Teuchos::ScalarTraits::magnitudeType TpetraVector:: normInf() const { XPETRA_MONITOR("TpetraVector::normInf"); return getTpetra_Vector()->normInf(); } template Scalar TpetraVector:: meanValue() const { XPETRA_MONITOR("TpetraVector::meanValue"); return getTpetra_Vector()->meanValue(); } template std::string TpetraVector:: description() const { XPETRA_MONITOR("TpetraVector::description"); return getTpetra_Vector()->description(); } template void TpetraVector:: describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const { XPETRA_MONITOR("TpetraVector::describe"); getTpetra_Vector()->describe(out, verbLevel); } template Scalar TpetraVector:: dot(const Vector& a) const { XPETRA_MONITOR("TpetraVector::dot"); return getTpetra_Vector()->dot(*toTpetra(a)); } template TpetraVector:: TpetraVector(const Teuchos::RCP>& vec) : TpetraMultiVector(vec) { } template RCP> TpetraVector:: getTpetra_Vector() const { return this->TpetraMultiVector::getTpetra_MultiVector()->getVectorNonConst(0); } #ifdef HAVE_XPETRA_EPETRA #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) // specialization of TpetraVector for GO=int and NO=SerialNode template class TpetraVector : public virtual Vector, public TpetraMultiVector { typedef int LocalOrdinal; typedef int GlobalOrdinal; typedef EpetraNode Node; #undef XPETRA_TPETRAMULTIVECTOR_SHORT #undef XPETRA_TPETRAVECTOR_SHORT #include "Xpetra_UseShortNames.hpp" #define XPETRA_TPETRAMULTIVECTOR_SHORT #define XPETRA_TPETRAVECTOR_SHORT public: using TpetraMultiVector::dot; // overloading, not hiding using TpetraMultiVector::norm1; // overloading, not hiding using TpetraMultiVector::norm2; // overloading, not hiding using TpetraMultiVector::normInf; // overloading, not hiding using TpetraMultiVector::meanValue; // overloading, not hiding using TpetraMultiVector::replaceGlobalValue; // overloading, not hiding using TpetraMultiVector::sumIntoGlobalValue; // overloading, not hiding using TpetraMultiVector::replaceLocalValue; // overloading, not hiding using TpetraMultiVector::sumIntoLocalValue; // overloading, not hiding //! @name Constructor/Destructor Methods //@{ //! Sets all vector entries to zero. TpetraVector(const Teuchos::RCP& map, bool zeroOut = true) : TpetraMultiVector(map, 1, zeroOut) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraVector).name(), typeid(TpetraVector).name(), "int", typeid(EpetraNode).name()); } //! Set multi-vector values from an array using Teuchos memory management classes. (copy) TpetraVector(const Teuchos::RCP& map, const Teuchos::ArrayView& A) : TpetraMultiVector(map, A, map->getLocalNumElements(), 1) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraVector).name(), typeid(TpetraVector).name(), "int", typeid(EpetraNode).name()); } virtual ~TpetraVector() {} void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {} //! Adds specified value to existing value at the specified location. void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {} //! Replace current value at the specified location with specified values. void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {} //! Adds specified value to existing value at the specified location. void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {} //@} //! @name Mathematical methods //@{ //! Return 1-norm of this Vector. typename Teuchos::ScalarTraits::magnitudeType norm1() const { return Teuchos::ScalarTraits::magnitude(Teuchos::ScalarTraits::zero()); } //! Compute 2-norm of this Vector. typename Teuchos::ScalarTraits::magnitudeType norm2() const { return Teuchos::ScalarTraits::magnitude(Teuchos::ScalarTraits::zero()); } //! Compute Inf-norm of this Vector. typename Teuchos::ScalarTraits::magnitudeType normInf() const { return Teuchos::ScalarTraits::magnitude(Teuchos::ScalarTraits::zero()); } //! Compute mean (average) value of this Vector. Scalar meanValue() const { return Teuchos::ScalarTraits::zero(); } //@} //! @name Overridden from Teuchos::Describable //@{ //! Return a simple one-line description of this object. std::string description() const { return std::string(""); } //! Print the object with some verbosity level to an FancyOStream object. void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {} //@} //! Computes dot product of this Vector against input Vector x. Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits::zero(); } //! @name Xpetra specific //@{ //! TpetraMultiVector constructor to wrap a Tpetra::MultiVector object TpetraVector(const Teuchos::RCP>& vec) : TpetraMultiVector(vec) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraVector).name(), typeid(TpetraVector).name(), "int", typeid(EpetraNode).name()); } //! Get the underlying Tpetra multivector RCP> getTpetra_Vector() const { return Teuchos::null; } //@} }; // TpetraVector class (specialization on GO=int, NO=EpetraNode) #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))) // specialization of TpetraVector for GO=int and NO=SerialNode template class TpetraVector : public virtual Vector, public TpetraMultiVector { typedef int LocalOrdinal; typedef long long GlobalOrdinal; typedef EpetraNode Node; #undef XPETRA_TPETRAMULTIVECTOR_SHORT #undef XPETRA_TPETRAVECTOR_SHORT #include "Xpetra_UseShortNames.hpp" #define XPETRA_TPETRAMULTIVECTOR_SHORT #define XPETRA_TPETRAVECTOR_SHORT public: using TpetraMultiVector::dot; // overloading, not hiding using TpetraMultiVector::norm1; // overloading, not hiding using TpetraMultiVector::norm2; // overloading, not hiding using TpetraMultiVector::normInf; // overloading, not hiding using TpetraMultiVector::meanValue; // overloading, not hiding using TpetraMultiVector::replaceGlobalValue; // overloading, not hiding using TpetraMultiVector::sumIntoGlobalValue; // overloading, not hiding using TpetraMultiVector::replaceLocalValue; // overloading, not hiding using TpetraMultiVector::sumIntoLocalValue; // overloading, not hiding //! @name Constructor/Destructor Methods //@{ //! Sets all vector entries to zero. TpetraVector(const Teuchos::RCP& map, bool zeroOut = true) : TpetraMultiVector(map, 1, zeroOut) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraVector).name(), typeid(TpetraVector).name(), "long long", typeid(EpetraNode).name()); } //! Set multi-vector values from an array using Teuchos memory management classes. (copy) TpetraVector(const Teuchos::RCP& map, const Teuchos::ArrayView& A) : TpetraMultiVector(map, A, map->getLocalNumElements(), 1) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraVector).name(), typeid(TpetraVector).name(), "long long", typeid(EpetraNode).name()); } //! Destructor. virtual ~TpetraVector() {} //@} //! @name Post-construction modification routines //@{ //! Replace current value at the specified location with specified value. void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {} //! Adds specified value to existing value at the specified location. void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {} //! Replace current value at the specified location with specified values. void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {} //! Adds specified value to existing value at the specified location. void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {} //@} //! @name Mathematical methods //@{ //! Return 1-norm of this Vector. typename Teuchos::ScalarTraits::magnitudeType norm1() const { return Teuchos::ScalarTraits::magnitude(Teuchos::ScalarTraits::zero()); } //! Compute 2-norm of this Vector. typename Teuchos::ScalarTraits::magnitudeType norm2() const { return Teuchos::ScalarTraits::magnitude(Teuchos::ScalarTraits::zero()); } //! Compute Inf-norm of this Vector. typename Teuchos::ScalarTraits::magnitudeType normInf() const { return Teuchos::ScalarTraits::magnitude(Teuchos::ScalarTraits::zero()); } //! Compute mean (average) value of this Vector. Scalar meanValue() const { return Teuchos::ScalarTraits::zero(); } //@} //! @name Overridden from Teuchos::Describable //@{ //! Return a simple one-line description of this object. std::string description() const { return std::string(""); } //! Print the object with some verbosity level to an FancyOStream object. void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {} //@} //! Computes dot product of this Vector against input Vector x. Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits::zero(); } //! Compute Weighted 2-norm (RMS Norm) of this Vector. //! @name Xpetra specific //@{ //! TpetraMultiVector constructor to wrap a Tpetra::MultiVector object TpetraVector(const Teuchos::RCP>& vec) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraVector).name(), typeid(TpetraVector).name(), "long long", typeid(EpetraNode).name()); } //! Get the underlying Tpetra multivector RCP> getTpetra_Vector() const { return Teuchos::null; } //@} }; // TpetraVector class (specialization on GO=long long, NO=EpetraNode) #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))) #endif // HAVE_XPETRA_EPETRA } // namespace Xpetra #endif