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"
24 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
25 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
26 FEMultiVector (
const Teuchos::RCP<const map_type>& map,
27 const Teuchos::RCP<
const Import<local_ordinal_type, global_ordinal_type, node_type>>& importer,
30 base_type (importer.is_null () ? map : importer->getTargetMap (),
32 activeMultiVector_ (Teuchos::rcp (new FE::WhichActive (FE::ACTIVE_OWNED_PLUS_SHARED))),
35 const char tfecfFuncName[] =
"FEMultiVector constructor: ";
37 if (! importer_.is_null ()) {
42 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
43 (! importer_->getSourceMap ()->isSameAs (*map),
45 "If you provide a nonnull Import, then the input Map "
46 "must be the same as the input Import's source Map.");
50 const bool locallyFitted =
51 importer->getTargetMap ()->isLocallyFitted (* (importer->getSourceMap ()));
52 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
53 (! locallyFitted, std::runtime_error,
54 "If you provide a nonnull Import, then its target Map must be "
55 "locally fitted (see Map::isLocallyFitted documentation) to its "
60 inactiveMultiVector_ =
61 Teuchos::rcp (
new base_type (*
this, importer_->getSourceMap(), 0));
63 fillState_ = Teuchos::rcp(
new FE::FillState(FE::FillState::closed));
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
73 if (*activeMultiVector_ == FE::ACTIVE_OWNED) {
74 switchActiveMultiVector ();
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
83 const char tfecfFuncName[] =
"endFill: ";
85 if (*activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
87 switchActiveMultiVector ();
90 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
91 (
true, std::runtime_error,
"Owned+Shared MultiVector already active; "
92 "cannot call endFill.");
96 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginAssembly() {
98 const char tfecfFuncName[] =
"FEMultiVector::beginAssembly: ";
99 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
100 *fillState_ != FE::FillState::closed,
102 "Cannot beginAssembly, matrix is not in a closed state"
104 *fillState_ = FE::FillState::open;
108 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
109 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endAssembly() {
110 const char tfecfFuncName[] =
"FEMultiVector::endAssembly: ";
111 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
112 *fillState_ != FE::FillState::open,
114 "Cannot endAssembly, matrix is not open to fill."
116 *fillState_ = FE::FillState::closed;
120 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginModify() {
122 const char tfecfFuncName[] =
"FEMultiVector::beginModify: ";
123 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
124 *fillState_ != FE::FillState::closed,
126 "Cannot beginModify, matrix is not in a closed state"
128 *fillState_ = FE::FillState::modify;
131 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
132 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endModify() {
133 const char tfecfFuncName[] =
"FEMultiVector::endModify: ";
134 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
135 *fillState_ != FE::FillState::modify,
137 "Cannot endModify, matrix is not open to modify."
139 *fillState_ = FE::FillState::closed;
142 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
150 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
152 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
153 replaceMap (
const Teuchos::RCP<const map_type>& )
155 const char tfecfFuncName[] =
"replaceMap: ";
157 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
158 (
true, std::runtime_error,
"This method is not implemented.");
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_PLUS_SHARED) {
168 inactiveMultiVector_->doExport (*
this, *importer_, CM);
172 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
177 if (! importer_.is_null () &&
178 *activeMultiVector_ == FE::ACTIVE_OWNED) {
179 inactiveMultiVector_->doImport (*
this, *importer_, CM);
183 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
185 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
186 switchActiveMultiVector ()
188 if (*activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
189 *activeMultiVector_ = FE::ACTIVE_OWNED;
192 *activeMultiVector_ = FE::ACTIVE_OWNED_PLUS_SHARED;
195 if (importer_.is_null ()) {
200 this->swap (*inactiveMultiVector_);
211 #define TPETRA_FEMULTIVECTOR_INSTANT(SCALAR,LO,GO,NODE) \
212 template class FEMultiVector< SCALAR , LO , GO , NODE >;
214 #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.