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"
24template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
25FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
26FEMultiVector (
const Teuchos::RCP<const map_type>& map,
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 ()) {
38 const bool debug = ::Tpetra::Details::Behavior::debug ();
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));
66template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
73 if (*activeMultiVector_ == FE::ACTIVE_OWNED) {
74 switchActiveMultiVector ();
78template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80FEMultiVector<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.");
96template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97void 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;
108template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
109void 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;
120template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121void 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;
131template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
132void 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;
142template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
150template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
152FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
153replaceMap (
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.");
161template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
163FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
164doOwnedPlusSharedToOwned (
const CombineMode CM)
166 if (! importer_.is_null () &&
167 *activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
168 inactiveMultiVector_->doExport (*
this, *importer_, CM);
172template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
175doOwnedToOwnedPlusShared (
const CombineMode CM)
177 if (! importer_.is_null () &&
178 *activeMultiVector_ == FE::ACTIVE_OWNED) {
179 inactiveMultiVector_->doImport (*
this, *importer_, CM);
183template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
185FEMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
186switchActiveMultiVector ()
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 >;
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Namespace Tpetra contains the class and methods constituting the Tpetra library.