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: ";
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 "
92 inactiveMultiVector_ =
93 Teuchos::rcp (
new base_type (*
this,
importer_->getSourceMap(), 0));
95 fillState_ = Teuchos::rcp(
new FillState(FillState::closed));
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
100 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
105 if (*activeMultiVector_ == FE_ACTIVE_OWNED) {
106 switchActiveMultiVector ();
110 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
112 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
115 const char tfecfFuncName[] =
"endFill: ";
117 if (*activeMultiVector_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
119 switchActiveMultiVector ();
122 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
123 (
true, std::runtime_error,
"Owned+Shared MultiVector already active; "
124 "cannot call endFill.");
128 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
129 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginAssembly() {
130 const char tfecfFuncName[] =
"FEMultiVector::beginAssembly: ";
131 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
132 *fillState_ != FillState::closed,
134 "Cannot beginAssembly, matrix is not in a closed state"
136 *fillState_ = FillState::open;
140 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
141 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endAssembly() {
142 const char tfecfFuncName[] =
"FEMultiVector::endAssembly: ";
143 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
144 *fillState_ != FillState::open,
146 "Cannot endAssembly, matrix is not open to fill."
148 *fillState_ = FillState::closed;
152 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
153 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginModify() {
154 const char tfecfFuncName[] =
"FEMultiVector::beginModify: ";
155 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
156 *fillState_ != FillState::closed,
158 "Cannot beginModify, matrix is not in a closed state"
160 *fillState_ = FillState::modify;
163 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
164 void FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endModify() {
165 const char tfecfFuncName[] =
"FEMultiVector::endModify: ";
166 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
167 *fillState_ != FillState::modify,
169 "Cannot endModify, matrix is not open to modify."
171 *fillState_ = FillState::closed;
174 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
176 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
182 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
184 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
185 replaceMap (
const Teuchos::RCP<const map_type>& )
187 const char tfecfFuncName[] =
"replaceMap: ";
189 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
190 (
true, std::runtime_error,
"This method is not implemented.");
193 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
195 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
198 if (! importer_.is_null () &&
199 *activeMultiVector_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
200 inactiveMultiVector_->doExport (*
this, *importer_, CM);
204 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
206 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
209 if (! importer_.is_null () &&
210 *activeMultiVector_ == FE_ACTIVE_OWNED) {
211 inactiveMultiVector_->doImport (*
this, *importer_, CM);
215 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
217 FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
218 switchActiveMultiVector ()
220 if (*activeMultiVector_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
221 *activeMultiVector_ = FE_ACTIVE_OWNED;
224 *activeMultiVector_ = FE_ACTIVE_OWNED_PLUS_SHARED;
227 if (importer_.is_null ()) {
232 this->swap (*inactiveMultiVector_);
243 #define TPETRA_FEMULTIVECTOR_INSTANT(SCALAR,LO,GO,NODE) \
244 template class FEMultiVector< SCALAR , LO , GO , NODE >;
246 #endif // TPETRA_FEMULTIVECTOR_DEF_HPP
static bool debug()
Whether Tpetra is in debug mode.
Teuchos::RCP< const import_type > importer_
The Import from the domain Map to the column Map.
CombineMode
Rule for combining data in an Import or Export.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.