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>
27 const Teuchos::RCP<
const Import<LocalOrdinal, GlobalOrdinal, Node>>& importer,
30 : base_type(importer.is_null() ? map : importer->getTargetMap(),
32 , activeMultiVector_(Teuchos::rcp(new FE::WhichActive(FE::ACTIVE_OWNED_PLUS_SHARED)))
33 , importer_(importer) {
34 const char tfecfFuncName[] =
"FEMultiVector constructor: ";
36 if (!importer_.is_null()) {
41 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!importer_->getSourceMap()->isSameAs(*map),
43 "If you provide a nonnull Import, then the input Map "
44 "must be the same as the input Import's source Map.");
48 const bool locallyFitted =
49 importer->getTargetMap()->isLocallyFitted(*(importer->getSourceMap()));
50 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!locallyFitted, std::runtime_error,
51 "If you provide a nonnull Import, then its target Map must be "
52 "locally fitted (see Map::isLocallyFitted documentation) to its "
57 inactiveMultiVector_ =
58 Teuchos::rcp(
new base_type(*
this, importer_->getSourceMap(), 0));
60 fillState_ = Teuchos::rcp(
new FE::FillState(FE::FillState::closed));
63template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 if (*activeMultiVector_ == FE::ACTIVE_OWNED) {
69 switchActiveMultiVector();
73template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
76 const char tfecfFuncName[] =
"endFill: ";
78 if (*activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
80 switchActiveMultiVector();
82 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
true, std::runtime_error,
83 "Owned+Shared MultiVector already active; "
84 "cannot call endFill.");
88template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 const char tfecfFuncName[] =
"FEMultiVector::beginAssembly: ";
91 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
92 *fillState_ != FE::FillState::closed,
94 "Cannot beginAssembly, matrix is not in a closed state");
95 *fillState_ = FE::FillState::open;
99template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 const char tfecfFuncName[] =
"FEMultiVector::endAssembly: ";
102 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
103 *fillState_ != FE::FillState::open,
105 "Cannot endAssembly, matrix is not open to fill.");
106 *fillState_ = FE::FillState::closed;
110template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
112 const char tfecfFuncName[] =
"FEMultiVector::beginModify: ";
113 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
114 *fillState_ != FE::FillState::closed,
116 "Cannot beginModify, matrix is not in a closed state");
117 *fillState_ = FE::FillState::modify;
120template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
122 const char tfecfFuncName[] =
"FEMultiVector::endModify: ";
123 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
124 *fillState_ != FE::FillState::modify,
126 "Cannot endModify, matrix is not open to modify.");
127 *fillState_ = FE::FillState::closed;
130template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
138 replaceMap(
const Teuchos::RCP<const map_type>& ) {
139 const char tfecfFuncName[] =
"replaceMap: ";
141 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
true, std::runtime_error,
"This method is not implemented.");
144template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
147 if (!importer_.is_null() &&
148 *activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
149 inactiveMultiVector_->doExport(*
this, *importer_, CM);
153template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
156 if (!importer_.is_null() &&
157 *activeMultiVector_ == FE::ACTIVE_OWNED) {
158 inactiveMultiVector_->doImport(*
this, *importer_, CM);
162template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
165 if (*activeMultiVector_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
166 *activeMultiVector_ = FE::ACTIVE_OWNED;
168 *activeMultiVector_ = FE::ACTIVE_OWNED_PLUS_SHARED;
171 if (importer_.is_null()) {
176 this->swap(*inactiveMultiVector_);
187#define TPETRA_FEMULTIVECTOR_INSTANT(SCALAR, LO, GO, NODE) \
188 template class FEMultiVector<SCALAR, LO, GO, NODE>;
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Declaration of the Tpetra::FEMultiVector class.
A distributed MultiVector for finite element assembly.
static bool debug()
Whether Tpetra is in debug mode.
Namespace Tpetra contains the class and methods constituting the Tpetra library.