10#ifndef TPETRA_FECRSMATRIX_DEF_HPP 
   11#define TPETRA_FECRSMATRIX_DEF_HPP 
   13#include "Tpetra_CrsMatrix.hpp" 
   17template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   20                const Teuchos::RCP<Teuchos::ParameterList>& 
params)
 
   27  const char tfecfFuncName[] = 
"FECrsMatrix(RCP<const FECrsGraph>[, RCP<ParameterList>]): ";
 
   32                                        "fill complete. You must call fillComplete on the graph before using " 
   33                                        "it to construct a FECrsMatrix.  Note that calling resumeFill on the " 
   34                                        "graph makes it not fill complete, even if you had previously called " 
   35                                        "fillComplete.  In that case, you must call fillComplete on the graph " 
   38                                        "Input graph must be in FE::ACTIVE_OWNED mode when this constructor is called.");
 
   42    if (
params->isParameter(
"start owned")) {
 
   47    activeCrsMatrix_ = Teuchos::rcp(
new FE::WhichActive(FE::ACTIVE_OWNED));
 
   49    activeCrsMatrix_ = Teuchos::rcp(
new FE::WhichActive(FE::ACTIVE_OWNED_PLUS_SHARED));
 
   53  if (!
graph->inactiveCrsGraph_.is_null()) {
 
   59  fillState_ = Teuchos::rcp(
new FE::FillState(FE::FillState::closed));
 
 
   62template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   64  if (!inactiveCrsMatrix_.is_null() && *activeCrsMatrix_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
 
   66    this->doExport(*
this, *feGraph_->ownedRowsImporter_, 
CM, 
true);
 
   67    inactiveCrsMatrix_->fillComplete();
 
 
   72template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   77template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   79  if (*activeCrsMatrix_ == FE::ACTIVE_OWNED_PLUS_SHARED)
 
   80    *activeCrsMatrix_ = FE::ACTIVE_OWNED;
 
   82    *activeCrsMatrix_ = FE::ACTIVE_OWNED_PLUS_SHARED;
 
   84  if (inactiveCrsMatrix_.is_null()) 
return;
 
   86  this->swap(*inactiveCrsMatrix_);
 
 
   90template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   92  if (*activeCrsMatrix_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
 
   94    switchActiveCrsMatrix();
 
   96    throw std::runtime_error(
"FECrsMatrix: Local CrsMatrix already active.  Cannot endFill()");
 
   99template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  100void FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::beginFill() {
 
  103  if (*activeCrsMatrix_ == FE::ACTIVE_OWNED) {
 
  105    switchActiveCrsMatrix();
 
  110template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  113  if (*fillState_ != FE::FillState::closed) {
 
  114    std::ostringstream 
errmsg;
 
  115    errmsg << 
"Cannot begin assembly, matrix is not in a closed state " 
  116           << 
"but is currently open for " 
  117           << (*fillState_ == FE::FillState::open ? 
"assembly" : 
"modification");
 
  120  *fillState_ = FE::FillState::open;
 
 
  124template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  127  if (*fillState_ != FE::FillState::open) {
 
  128    std::ostringstream 
errmsg;
 
  129    errmsg << 
"Cannot end assembly, matrix is not open for assembly " 
  130           << 
"but is currently " 
  131           << (*fillState_ == FE::FillState::closed ? 
"closed" : 
"open for modification");
 
  134  *fillState_ = FE::FillState::closed;
 
 
  138template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  141  if (*fillState_ != FE::FillState::closed) {
 
  142    std::ostringstream 
errmsg;
 
  143    errmsg << 
"Cannot begin modifying, matrix is not in a closed state " 
  144           << 
"but is currently open for " 
  145           << (*fillState_ == FE::FillState::open ? 
"assembly" : 
"modification");
 
  148  *fillState_ = FE::FillState::modify;
 
 
  152template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  155  if (*fillState_ != FE::FillState::modify) {
 
  156    std::ostringstream 
errmsg;
 
  157    errmsg << 
"Cannot end modifying, matrix is not open to modify but is currently " 
  158           << (*fillState_ == FE::FillState::open ? 
"open for assembly" : 
"closed");
 
  161  *fillState_ = FE::FillState::closed;
 
  162  this->fillComplete();
 
 
  165template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  174  const char tfecfFuncName[] = 
"FECrsMatrix::replaceGlobalValues: ";
 
  175  if (*fillState_ != FE::FillState::open) {
 
  176    std::ostringstream 
errmsg;
 
  177    errmsg << 
"Cannot replace global values, matrix is not open for assembly " 
  178           << 
"but is currently " 
  179           << (*fillState_ == FE::FillState::modify ? 
"open for modification" : 
"closed");
 
 
  185template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  194  const char tfecfFuncName[] = 
"FECrsMatrix::replaceLocalValues: ";
 
  195  if (*fillState_ != FE::FillState::open && *fillState_ != FE::FillState::modify) {
 
  196    std::ostringstream 
errmsg;
 
  197    errmsg << 
"Cannot replace local values, matrix is not open to fill/modify. " 
  198           << 
"The matrix is currently closed";
 
 
  204template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  214  const char tfecfFuncName[] = 
"FECrsMatrix::sumIntoGlobalValues: ";
 
  215  if (*fillState_ != FE::FillState::open) {
 
  216    std::ostringstream 
errmsg;
 
  217    errmsg << 
"Cannot sum in to global values, matrix is not open for assembly. " 
  218           << 
"The matrix is currently " 
  219           << (*fillState_ == FE::FillState::modify ? 
"open for modification" : 
"closed");
 
 
  226template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  236  const char tfecfFuncName[] = 
"FECrsMatrix::sumIntoLocalValues: ";
 
  237  if (*fillState_ != FE::FillState::open) {
 
  238    std::ostringstream 
errmsg;
 
  239    errmsg << 
"Cannot sum in to local values, matrix is not open for assembly. " 
  240           << 
"The matrix is currently " 
  241           << (*fillState_ == FE::FillState::modify ? 
"open for modification" : 
"closed");
 
 
  248template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
  255  const char tfecfFuncName[] = 
"FECrsMatrix::insertGlobalValues: ";
 
  256  if (*fillState_ != FE::FillState::open) {
 
  257    std::ostringstream 
errmsg;
 
  258    errmsg << 
"Cannot insert global values, matrix is not open for assembly. " 
  259           << 
"The matrix is currently " 
  260           << (*fillState_ == FE::FillState::modify ? 
"open for modification" : 
"closed");
 
 
  273#define TPETRA_FECRSMATRIX_INSTANT(SCALAR, LO, GO, NODE) \ 
  274  template class FECrsMatrix<SCALAR, LO, GO, NODE>; 
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
 
Struct that holds views of the contents of a CrsMatrix.
 
Sparse matrix that presents a row-oriented interface that lets users read or modify entries.
 
virtual void insertGlobalValuesImpl(crs_graph_type &graph, RowInfo &rowInfo, const GlobalOrdinal gblColInds[], const impl_scalar_type vals[], const size_t numInputEnt)
Common implementation detail of insertGlobalValues and insertGlobalValuesFiltered.
 
virtual LocalOrdinal sumIntoGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoGlobalValues.
 
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Tell the matrix that you are done changing its structure or values, and that you are ready to do comp...
 
virtual LocalOrdinal sumIntoLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoLocalValues.
 
virtual LocalOrdinal replaceLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceLocalValues.
 
virtual LocalOrdinal replaceGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceGlobalValues.
 
Sparse matrix that presents a row-oriented interface that lets users read or modify entries.
 
CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > crs_matrix_type
Parent CrsMatrix type using the same scalars.
 
void beginAssembly()
Activates the owned+shared mode for assembly.
 
FECrsMatrix(const Teuchos::RCP< const fe_crs_graph_type > &graph, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying one or two previously constructed graphs.
 
void insertGlobalValuesImpl(crs_graph_type &graph, RowInfo &rowInfo, const GlobalOrdinal gblColInds[], const impl_scalar_type vals[], const size_t numInputEnt)
Common implementation detail of insertGlobalValues and insertGlobalValuesFiltered.
 
LocalOrdinal replaceLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceLocalValues.
 
LocalOrdinal replaceGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Overloads of modification methods.
 
CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
 
void endAssembly()
Migrates data to the owned mode.
 
void doOwnedPlusSharedToOwned(const CombineMode CM=Tpetra::ADD)
Migrate data from the owned+shared to the owned matrix Since this is non-unique -> unique,...
 
void endModify()
Closes modification phase.
 
void beginModify()
Activates the owned mode for modifying local values.
 
LocalOrdinal sumIntoGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoGlobalValues.
 
LocalOrdinal sumIntoLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoLocalValues.
 
void switchActiveCrsMatrix()
Switches which CrsGraph is active (without migrating data)
 
void doOwnedToOwnedPlusShared(const CombineMode CM=Tpetra::ADD)
Migrate data from the owned to the owned+shared matrix Precondition: Must be FE_ACTIVE_OWNED mode.
 
Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
CombineMode
Rule for combining data in an Import or Export.
 
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.