* for example done during the
* solution of linear systems.
*/
- void do_data_exchange (const TrilinosWrappers::BlockSparseMatrix &m,
- const BlockVector &v);
+ void import_nonlocal_data_for_fe (const TrilinosWrappers::BlockSparseMatrix &m,
+ const BlockVector &v);
/**
* Compresses all the components
// present in the input data.
for (unsigned int i=0; i<n_rows; ++i)
{
+ const int row = row_indices[i];
+
// If the calling matrix owns the row to
- // which we want to add values, we
+ // which we want to insert values, we
// can directly call the Epetra_CrsMatrix
// input function, which is much faster
- // than the Epetra_FECrsMatrix function.
- if (row_map.MyGID(i) == true)
+ // than the Epetra_FECrsMatrix
+ // function. We distinguish between two
+ // cases: the first one is when the matrix
+ // is not filled (i.e., it is possible to
+ // add new elements to the sparsity pattern),
+ // and the second one is when the pattern is
+ // already fixed. In the former case, we
+ // add the possibility to insert new values,
+ // and in the second we just replace
+ // data.
+ if (row_map.MyGID(row) == true)
{
if (matrix->Filled() == false)
{
ierr = matrix->Epetra_CrsMatrix::InsertGlobalValues(
- (int)row_indices[i], (int)n_cols,
+ row, (int)n_cols,
const_cast<TrilinosScalar*>(&values[i*n_cols]),
(int*)&col_indices[0]);
- // When adding up elements, we do
+ // When inserting elements, we do
// not want to create exceptions in
- // the case when adding elements.
+ // the case when inserting non-local
+ // data (since that's what we want
+ // to do right now).
if (ierr > 0)
ierr = 0;
}
else
ierr = matrix->Epetra_CrsMatrix::ReplaceGlobalValues(
- (int)row_indices[i], (int)n_cols,
+ row, (int)n_cols,
const_cast<TrilinosScalar*>(&values[i*n_cols]),
(int*)&col_indices[0]);
}
{
// When we're at off-processor data, we
// have to stick with the standard
- // SumIntoGlobalValues
+ // Insert/ReplaceGlobalValues
// function. Nevertheless, the way we
// call it is the fastest one (any other
// will lead to repeated allocation and
if (matrix->Filled() == false)
{
- ierr = matrix->InsertGlobalValues (1, (int*)&i,
+ ierr = matrix->InsertGlobalValues (1, &row,
(int)n_cols, (int*)&col_indices[0],
&value_ptr,
Epetra_FECrsMatrix::ROW_MAJOR);
ierr = 0;
}
else
- ierr = matrix->ReplaceGlobalValues (1, (int*)&i,
+ ierr = matrix->ReplaceGlobalValues (1, &row,
(int)n_cols, (int*)&col_indices[0],
&value_ptr,
Epetra_FECrsMatrix::ROW_MAJOR);
// present in the input data.
for (unsigned int i=0; i<n_rows; ++i)
{
+ const int row = row_indices[i];
// If the calling matrix owns the row to
// which we want to add values, we
// can directly call the Epetra_CrsMatrix
// input function, which is much faster
// than the Epetra_FECrsMatrix function.
- if (row_map.MyGID(i) == true)
+ if (row_map.MyGID(row_indices[i]) == true)
{
ierr = matrix->Epetra_CrsMatrix::SumIntoGlobalValues(
- (int)row_indices[i], (int)n_cols,
+ row, (int)n_cols,
const_cast<TrilinosScalar*>(&values[i*n_cols]),
(int*)&col_indices[0]);
}
const TrilinosScalar* value_ptr = &values[i*n_cols];
- ierr = matrix->SumIntoGlobalValues (1, (int*)&i,
+ ierr = matrix->SumIntoGlobalValues (1, &row,
(int)n_cols, (int*)&col_indices[0],
&value_ptr,
Epetra_FECrsMatrix::ROW_MAJOR);
* for example done during the
* solution of linear systems.
*/
- void do_data_exchange (const dealii::TrilinosWrappers::SparseMatrix &matrix,
- const Vector &vector);
+ void import_nonlocal_data_for_fe
+ (const dealii::TrilinosWrappers::SparseMatrix &matrix,
+ const Vector &vector);
private:
/**
+ inline
+ std::pair<unsigned int, unsigned int>
+ VectorBase::local_range () const
+ {
+ int begin, end;
+ begin = vector->Map().MinMyGID();
+ end = vector->Map().MaxMyGID()+1;
+ return std::make_pair (begin, end);
+ }
+
#endif // DOXYGEN
void
- BlockVector::do_data_exchange (const TrilinosWrappers::BlockSparseMatrix &m,
- const BlockVector &v)
+ BlockVector::import_nonlocal_data_for_fe
+ (const TrilinosWrappers::BlockSparseMatrix &m,
+ const BlockVector &v)
{
Assert (m.n_block_rows() == v.n_blocks(),
ExcDimensionMismatch(m.n_block_rows(),v.n_blocks()));
}
for (unsigned int i=0; i<this->n_blocks(); ++i)
- components[i].do_data_exchange(m.block(i,i), v.block(i));
+ components[i].import_nonlocal_data_for_fe(m.block(i,i), v.block(i));
collect_sizes();
}
}
+
void
SparseMatrix::clear ()
{
// generate the vector.
if (allow_different_maps == false)
{
- if (map.SameAs(v.vector->Map()) == false)
+ if (local_range() != v.local_range())
{
vector.reset();
map = Epetra_Map(v.vector->Map().NumGlobalElements(),
else if (fast == false)
{
int ierr;
+ Assert (vector->Map().SameAs(v.vector->Map()) == true,
+ ExcMessage ("The Epetra maps in the assignment operator ="
+ " do not match, even though the local_range "
+ " seems to be the same. Check vector setup!"));
ierr = vector->GlobalAssemble (last_action);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
Vector &
Vector::operator = (const Vector &v)
{
- if (vector->Map().SameAs(v.vector->Map()) == true)
+ if (local_range() == v.local_range())
{
+ Assert (vector->Map().SameAs(v.vector->Map()) == true,
+ ExcMessage ("The Epetra maps in the assignment operator ="
+ " do not match, even though the local_range "
+ " seems to be the same. Check vector setup!"));
vector->GlobalAssemble(last_action);
const int ierr = vector->Update(1.0, *v.vector, 0.0);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
void
- Vector::do_data_exchange (const TrilinosWrappers::SparseMatrix &m,
- const Vector &v)
+ Vector::import_nonlocal_data_for_fe (const TrilinosWrappers::SparseMatrix &m,
+ const Vector &v)
{
Assert (m.matrix->Filled() == true,
ExcMessage ("Matrix is not compressed. "
// generate the vector.
if (allow_different_maps == false)
{
- if (map.SameAs(v.vector->Map()) == false)
+ if (local_range() != v.local_range())
{
vector.reset();
map = Epetra_LocalMap (v.vector->GlobalLength(),
else
{
int ierr;
+ Assert (vector->Map().SameAs(v.vector->Map()) == true,
+ ExcMessage ("The Epetra maps in the assignment operator ="
+ " do not match, even though the local_range "
+ " seems to be the same. Check vector setup!"));
+
ierr = vector->GlobalAssemble(last_action);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
Vector &
Vector::operator = (const Vector &v)
{
- if (vector->Map().SameAs(v.vector->Map()) == false)
+ if (size() != v.size())
{
map = Epetra_LocalMap (v.vector->Map().NumGlobalElements(),
v.vector->Map().IndexBase(),
Assert (&*vector != 0,
ExcMessage("Vector has not been constructed properly."));
- if (fast == false || vector->Map().SameAs(v.vector->Map()) == false)
+ if (fast == false || local_range() != v.local_range())
vector = std::auto_ptr<Epetra_FEVector>(new Epetra_FEVector(*v.vector));
}
Assert (&*vector != 0,
ExcMessage("Vector is not constructed properly."));
- if (vector->Map().SameAs(v.vector->Map()) == false)
+ if (local_range() != v.local_range())
{
vector.reset();
last_action = Zero;
}
else
{
+ Assert (vector->Map().SameAs(v.vector->Map()) == true,
+ ExcMessage ("The Epetra maps in the assignment operator ="
+ " do not match, even though the local_range "
+ " seems to be the same. Check vector setup!"));
int ierr;
ierr = vector->GlobalAssemble(last_action);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
- std::pair<unsigned int, unsigned int>
- VectorBase::local_range () const
- {
- int begin, end;
- begin = vector->Map().MinMyGID();
- end = vector->Map().MaxMyGID()+1;
- return std::make_pair (begin, end);
- }
-
-
-
TrilinosScalar
VectorBase::el (const unsigned int index) const
{