10 #ifndef TPETRA_FEMULTIVECTOR_DEF_HPP
11 #define TPETRA_FEMULTIVECTOR_DEF_HPP
16 #include "Tpetra_Map.hpp"
17 #include "Tpetra_MultiVector.hpp"
18 #include "Tpetra_Import.hpp"
23 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
24 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
25 FEMultiVector(
const Teuchos::RCP<const map_type>& map,
26 const Teuchos::RCP<
const Import<local_ordinal_type, global_ordinal_type, node_type>>& importer,
29 : base_type(importer.is_null() ? map : importer->getTargetMap(),
31 , activeMultiVector_(Teuchos::rcp(new FE::WhichActive(FE::ACTIVE_OWNED_PLUS_SHARED)))
32 , importer_(importer) {
33 const char tfecfFuncName[] =
"FEMultiVector constructor: ";
35 if (!importer_.is_null()) {
40 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!importer_->getSourceMap()->isSameAs(*map),
42 "If you provide a nonnull Import, then the input Map "
43 "must be the same as the input Import's source Map.");
47 const bool locallyFitted =
48 importer->getTargetMap()->isLocallyFitted(*(importer->getSourceMap()));
49 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!locallyFitted, std::runtime_error,
50 "If you provide a nonnull Import, then its target Map must be "
51 "locally fitted (see Map::isLocallyFitted documentation) to its "
56 inactiveMultiVector_ =
57 Teuchos::rcp(
new base_type(*
this, importer_->getSourceMap(), 0));
59 fillState_ = Teuchos::rcp(
new FE::FillState(FE::FillState::closed));
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
67 if (*activeMultiVector_ == FE::ACTIVE_OWNED) {
68 switchActiveMultiVector();
72 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
75 const char tfecfFuncName[] =
"endFill: ";
77 if (*activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
79 switchActiveMultiVector();
81 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
true, std::runtime_error,
82 "Owned+Shared MultiVector already active; "
83 "cannot call endFill.");
87 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginAssembly() {
89 const char tfecfFuncName[] =
"FEMultiVector::beginAssembly: ";
90 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
91 *fillState_ != FE::FillState::closed,
93 "Cannot beginAssembly, matrix is not in a closed state");
94 *fillState_ = FE::FillState::open;
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
99 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endAssembly() {
100 const char tfecfFuncName[] =
"FEMultiVector::endAssembly: ";
101 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
102 *fillState_ != FE::FillState::open,
104 "Cannot endAssembly, matrix is not open to fill.");
105 *fillState_ = FE::FillState::closed;
109 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
110 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginModify() {
111 const char tfecfFuncName[] =
"FEMultiVector::beginModify: ";
112 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
113 *fillState_ != FE::FillState::closed,
115 "Cannot beginModify, matrix is not in a closed state");
116 *fillState_ = FE::FillState::modify;
119 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endModify() {
121 const char tfecfFuncName[] =
"FEMultiVector::endModify: ";
122 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
123 *fillState_ != FE::FillState::modify,
125 "Cannot endModify, matrix is not open to modify.");
126 *fillState_ = FE::FillState::closed;
129 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
135 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
137 replaceMap(
const Teuchos::RCP<const map_type>& ) {
138 const char tfecfFuncName[] =
"replaceMap: ";
140 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
true, std::runtime_error,
"This method is not implemented.");
143 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
146 if (!importer_.is_null() &&
147 *activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
148 inactiveMultiVector_->doExport(*
this, *importer_, CM);
152 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
153 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
155 if (!importer_.is_null() &&
156 *activeMultiVector_ == FE::ACTIVE_OWNED) {
157 inactiveMultiVector_->doImport(*
this, *importer_, CM);
161 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
162 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
163 switchActiveMultiVector() {
164 if (*activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
165 *activeMultiVector_ = FE::ACTIVE_OWNED;
167 *activeMultiVector_ = FE::ACTIVE_OWNED_PLUS_SHARED;
170 if (importer_.is_null()) {
175 this->swap(*inactiveMultiVector_);
186 #define TPETRA_FEMULTIVECTOR_INSTANT(SCALAR, LO, GO, NODE) \
187 template class FEMultiVector<SCALAR, LO, GO, NODE>;
189 #endif // TPETRA_FEMULTIVECTOR_DEF_HPP
static bool debug()
Whether Tpetra is in debug mode.
CombineMode
Rule for combining data in an Import or Export.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.