42 #ifndef TPETRA_FECRSMATRIX_DEF_HPP
43 #define TPETRA_FECRSMATRIX_DEF_HPP
45 #include "Tpetra_CrsMatrix.hpp"
49 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
50 FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
51 FECrsMatrix(
const Teuchos::RCP<const fe_crs_graph_type>& graph,
52 const Teuchos::RCP<Teuchos::ParameterList>& params) :
55 crs_matrix_type( graph->inactiveCrsGraph_.is_null() ? Teuchos::rcp_const_cast<crs_graph_type>(Teuchos::rcp_dynamic_cast<const crs_graph_type>(graph)) : graph->inactiveCrsGraph_,params),
59 const char tfecfFuncName[] =
"FECrsMatrix(RCP<const FECrsGraph>[, RCP<ParameterList>]): ";
60 typedef typename local_matrix_type::values_type values_type;
62 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
63 (graph.is_null (), std::runtime_error,
"Input graph is null.");
64 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
65 (!graph->isFillComplete (), std::runtime_error,
"Input graph is not "
66 "fill complete. You must call fillComplete on the graph before using "
67 "it to construct a FECrsMatrix. Note that calling resumeFill on the "
68 "graph makes it not fill complete, even if you had previously called "
69 "fillComplete. In that case, you must call fillComplete on the graph "
71 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
72 ( *graph->activeCrsGraph_!= fe_crs_graph_type::FE_ACTIVE_OWNED,std::runtime_error,
73 "Input graph must be in FE_ACTIVE_OWNED mode when this constructor is called.");
75 activeCrsMatrix_ = Teuchos::rcp(
new FEWhichActive(FE_ACTIVE_OWNED_PLUS_SHARED));
78 if(!graph->inactiveCrsGraph_.is_null() ) {
81 values_type myvals = this->getLocalMatrix().values;
83 size_t numOwnedVals = graph->getLocalGraph().entries.extent(0);
84 inactiveCrsMatrix_ = Teuchos::rcp(
new crs_matrix_type(graph,Kokkos::subview(myvals,Kokkos::pair<size_t,size_t>(0,numOwnedVals))));
90 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
91 void FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::doOwnedPlusSharedToOwned(
const CombineMode CM) {
92 if(!inactiveCrsMatrix_.is_null() && *activeCrsMatrix_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
94 this->doExport(*
this,*feGraph_->importer_,CM,
true);
95 inactiveCrsMatrix_->fillComplete();
97 crs_matrix_type::fillComplete();
101 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 void FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::doOwnedToOwnedPlusShared(
const CombineMode ) {
106 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
107 void FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::switchActiveCrsMatrix() {
108 if(*activeCrsMatrix_ == FE_ACTIVE_OWNED_PLUS_SHARED)
109 *activeCrsMatrix_ = FE_ACTIVE_OWNED;
111 *activeCrsMatrix_ = FE_ACTIVE_OWNED_PLUS_SHARED;
113 if(inactiveCrsMatrix_.is_null())
return;
115 this->swap(*inactiveCrsMatrix_);
120 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 void FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::endFill() {
122 if(*activeCrsMatrix_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
124 switchActiveCrsMatrix();
127 throw std::runtime_error(
"FECrsMatrix: Local CrsMatrix already active. Cannot endFill()");
130 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
131 void FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginFill() {
134 if(*activeCrsMatrix_ == FE_ACTIVE_OWNED) {
136 switchActiveCrsMatrix();
152 #define TPETRA_FECRSMATRIX_INSTANT(SCALAR,LO,GO,NODE) \
153 template class FECrsMatrix<SCALAR, LO, GO, NODE>;
157 #endif // TPETRA_FECRSMATRIX_DEF
CombineMode
Rule for combining data in an Import or Export.
Sum new values into existing values.