42 #ifndef TPETRA_FEMULTIVECTOR_DEF_HPP
43 #define TPETRA_FEMULTIVECTOR_DEF_HPP
48 #include "Tpetra_Map.hpp"
49 #include "Tpetra_MultiVector.hpp"
50 #include "Tpetra_Import.hpp"
56 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
57 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
58 FEMultiVector (
const Teuchos::RCP<const map_type>& map,
59 const Teuchos::RCP<
const Import<local_ordinal_type, global_ordinal_type, node_type>>& importer,
62 base_type (importer.is_null () ? map : importer->getTargetMap (),
64 activeMultiVector_ (Teuchos::rcp (new FEWhichActive (FE_ACTIVE_OWNED_PLUS_SHARED))),
67 const char tfecfFuncName[] =
"FEMultiVector constructor: ";
69 if (! importer_.is_null ()) {
74 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
75 (! importer_->getSourceMap ()->isSameAs (*map),
77 "If you provide a nonnull Import, then the input Map "
78 "must be the same as the input Import's source Map.");
82 const bool locallyFitted =
83 importer->getTargetMap ()->isLocallyFitted (* (importer->getSourceMap ()));
84 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
85 (! locallyFitted, std::runtime_error,
86 "If you provide a nonnull Import, then its target Map must be "
87 "locally fitted (see Map::isLocallyFitted documentation) to its "
91 using range_type = Kokkos::pair<size_t, size_t>;
92 auto dv = Kokkos::subview (this->view_,
93 range_type (0, map->getNodeNumElements ()),
96 inactiveMultiVector_ =
97 Teuchos::rcp (
new base_type (importer_->getSourceMap (), dv));
101 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
108 if (*activeMultiVector_ == FE_ACTIVE_OWNED) {
109 switchActiveMultiVector ();
113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
115 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
118 const char tfecfFuncName[] =
"endFill: ";
120 if (*activeMultiVector_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
122 switchActiveMultiVector ();
125 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
126 (
true, std::runtime_error,
"Owned+Shared MultiVector already active; "
127 "cannot call endFill.");
131 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
133 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
139 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
141 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
142 replaceMap (
const Teuchos::RCP<const map_type>& )
144 const char tfecfFuncName[] =
"replaceMap: ";
146 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
147 (
true, std::runtime_error,
"This method is not implemented.");
150 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
152 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
155 if (! importer_.is_null () &&
156 *activeMultiVector_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
157 inactiveMultiVector_->doExport (*
this, *importer_, CM);
161 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
163 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
166 if (! importer_.is_null () &&
167 *activeMultiVector_ == FE_ACTIVE_OWNED) {
168 inactiveMultiVector_->doImport (*
this, *importer_, CM);
172 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
175 switchActiveMultiVector ()
177 if (*activeMultiVector_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
178 *activeMultiVector_ = FE_ACTIVE_OWNED;
181 *activeMultiVector_ = FE_ACTIVE_OWNED_PLUS_SHARED;
184 if (importer_.is_null ()) {
189 this->swap (*inactiveMultiVector_);
200 #define TPETRA_FEMULTIVECTOR_INSTANT(SCALAR,LO,GO,NODE) \
201 template class FEMultiVector< SCALAR , LO , GO , NODE >;
203 #endif // TPETRA_FEMULTIVECTOR_DEF_HPP
static bool debug()
Whether Tpetra is in debug mode.
CombineMode
Rule for combining data in an Import or Export.
Sum new values into existing values.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.