Tpetra Matrix/Vector Services Version of the Day
Public Member Functions
Tpetra::MultiVectorFiller< MV > Class Template Reference

Adds nonlocal sum-into functionality to Tpetra::MultiVector. More...

#include <Tpetra_MultiVectorFiller.hpp>

List of all members.

Public Member Functions

 MultiVectorFiller (const Teuchos::RCP< const map_type > &map, const size_t numCols)
 Constructor.
void globalAssemble (MV &X_out, const bool forceReuseMap=false)
 Assemble all the data (local and nonlocal) into X_out.
void sumIntoGlobalValues (Teuchos::ArrayView< const global_ordinal_type > rows, size_t column, Teuchos::ArrayView< const scalar_type > values)
 Sum data into the multivector.
void sumIntoGlobalValues (Teuchos::ArrayView< const global_ordinal_type > rows, Teuchos::ArrayView< const scalar_type > values)
 Sum data into the multivector.

Detailed Description

template<class MV>
class Tpetra::MultiVectorFiller< MV >

Adds nonlocal sum-into functionality to Tpetra::MultiVector.

Author:
Mark Hoemmen

MultiVector does not allow modifications to rows not owned by the calling process. This makes the implementation of MultiVector simple, fast, and local, but it complicates operations like assembly of the right-hand side in the finite element method. CrsMatrix already supports insertion into nonowned rows, so that makes assembly not consistent for sparse matrices and vectors. MultiVectorFiller remedies this by specializing for the case of filling a (multi)vector. It provides a constructor and sumIntoGlobalValues() methods that look just like those of MultiVector, so you can swap it in at the assembly stage. Then, you can call globalAssemble() to turn the MultiVectorFiller into a standard MultiVector.

The globalAssemble() method will redistribute data if necessary. You can force it to use the Map provided to the constructor (or the Map provided to the last call to globalAssemble(), which is a common use case for doing nonlinear solves where the sparse matrix structure doesn't change).

Template Parameters:
MVSpecialization of Tpetra::MultiVector.

Definition at line 910 of file Tpetra_MultiVectorFiller.hpp.


Constructor & Destructor Documentation

template<class MV >
Tpetra::MultiVectorFiller< MV >::MultiVectorFiller ( const Teuchos::RCP< const map_type > &  map,
const size_t  numCols 
)

Constructor.

The constructor takes the same arguments as MV's constructor. We did this on purpose, so that you can construct MultiVectorFiller as you would a standard MV.

Parameters:
map[in] A Map with the same communicator and Kokkos Node as the output multivector of globalAssemble(). This need not be the same Map as that output multivector's Map.
numCols[in] Expected number of columns in the output multivector of globalAssemble().
Note:
If the number of columns given here is not the same as the number of columns in the output multivector, the two-argument version of sumIntoGlobalValues() won't do the right thing. Use the three-argument version of that method if you don't know how many columns there will be in advance.
Not providing the output multivector in the constructor gives globalAssemble() more flexibility. For example, its output multivector may have any distribution with the same global number of rows. Furthermore, decoupling insertion from the output multivector lets this object store preassembled data in whatever format it likes. It doesn't have to insert directly into the output multivector until assembly time. (This may improve performance by amortizing the cost of global->local index conversions, for example.)

Definition at line 1087 of file Tpetra_MultiVectorFiller.hpp.


Member Function Documentation

template<class MV >
void Tpetra::MultiVectorFiller< MV >::globalAssemble ( MV &  X_out,
const bool  forceReuseMap = false 
)

Assemble all the data (local and nonlocal) into X_out.

You can call this method multiple times with different multivector output arguments. If those arguments have the same Map, this method will attempt to reuse the Export object each time. It will only reuse if the new target Map is the same as (in the sense of isSameAs()) the previous target Map, unless you force reuse with the second argument (that saves a few global reductions for the check).

Parameters:
X_out[in/out] MultiVector with a nonoverlapping Map. That Map need not be the same as the one with which this object was created.
forceReuseMap[in] If true, assume that X_out has the same Map (in the sense of isSameAs()) as the target Map in the previous call to this method. If this method was not called before, then assume that X_out has the same Map as the argument to the constructor of this object.

Definition at line 1119 of file Tpetra_MultiVectorFiller.hpp.

template<class MV >
void Tpetra::MultiVectorFiller< MV >::sumIntoGlobalValues ( Teuchos::ArrayView< const global_ordinal_type >  rows,
size_t  column,
Teuchos::ArrayView< const scalar_type >  values 
) [inline]

Sum data into the multivector.

Parameters:
rows[in] Array of global rows for which to insert values. Must have the same length as values.
column[in] Index of the column in which to insert.
values[in] Array of values to insert. Must have the same length as rows. rows[i] is the row in which values[i] is to be inserted.

Definition at line 989 of file Tpetra_MultiVectorFiller.hpp.

template<class MV >
void Tpetra::MultiVectorFiller< MV >::sumIntoGlobalValues ( Teuchos::ArrayView< const global_ordinal_type >  rows,
Teuchos::ArrayView< const scalar_type >  values 
) [inline]

Sum data into the multivector.

In rows and values, the data for each column are stored contiguously. Thus, each array is really a matrix in rowwise order. (The multivector may use columnwise order internally.)

Be sure that the number of columns is set correctly before calling this.

Parameters:
rows[in] Array of global rows for which to insert values. Must have the same length as values.
values[in] Array of values to insert. Must have the same length as rows. rows[i] is the row in which values[i] is to be inserted.

Definition at line 1012 of file Tpetra_MultiVectorFiller.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines