last_action (Zero),
compressed (true),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(View, row_map, 0)))
+ (new Epetra_FECrsMatrix(View, row_map, col_map, 0)))
{
matrix->FillComplete();
}
last_action (Zero),
compressed (true),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, row_map,
+ (new Epetra_FECrsMatrix(Copy, row_map,
(int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
false)))
{}
#endif
last_action (Zero),
compressed (true),
+ // on one processor only, we know how the
+ // columns of the matrix will be
+ // distributed (everything on one
+ // processor), so we can hand in this
+ // information to the constructor. we
+ // can't do so in parallel, where the
+ // information from columns is only
+ // available when entries have been added
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, row_map,
- int(n_max_entries_per_row), false)))
+ (new Epetra_FECrsMatrix(Copy, row_map, col_map,
+ int(n_max_entries_per_row),
+ false)))
{}
last_action (Zero),
compressed (true),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, row_map,
- (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
- false)))
+ (new Epetra_FECrsMatrix(Copy, row_map, col_map,
+ (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
+ false)))
{}
SparseMatrix::~SparseMatrix ()
- {
- }
+ {}
// it were square. The call to
// GlobalAssemble later will set the
// correct values.
- Epetra_CrsGraph graph (Copy, row_map,
- &n_entries_per_row[input_row_map.MinMyGID()], true);
+ // for more than one processor, need to
+ // specify only row map first and let the
+ // matrix entries decide about the column
+ // map (which says which columns are
+ // present in the matrix, not to be
+ // confused with the col_map that tells
+ // how the domain dofs of the matrix will
+ // be distributed). for only one
+ // processor, we can directly assign the
+ // columns as well.
+ std::auto_ptr<Epetra_CrsGraph> graph;
+ if (row_map.Comm().NumProc() > 1)
+ graph = std::auto_ptr<Epetra_CrsGraph>
+ (new Epetra_CrsGraph (Copy, row_map,
+ &n_entries_per_row[input_row_map.MinMyGID()], true));
+ else
+ graph = std::auto_ptr<Epetra_CrsGraph>
+ (new Epetra_CrsGraph (Copy, row_map, col_map,
+ &n_entries_per_row[input_row_map.MinMyGID()], true));
// TODO: As of now, assume that the
// sparsity pattern sits at the all
// each processor set its rows. Since
// this is wasteful, a better solution
// should be found in the future.
- Assert (graph.NumGlobalRows() == (int)sparsity_pattern.n_rows(),
- ExcDimensionMismatch (graph.NumGlobalRows(),
+ Assert (graph->NumGlobalRows() == (int)sparsity_pattern.n_rows(),
+ ExcDimensionMismatch (graph->NumGlobalRows(),
sparsity_pattern.n_rows()));
// Trilinos has a bug for rectangular
for (int col=0; col < row_length; ++col)
row_indices[col] = sparsity_pattern.column_number (row, col);
- graph.InsertGlobalIndices (row, row_length, &row_indices[0]);
+ graph->InsertGlobalIndices (row, row_length, &row_indices[0]);
}
// Now, fill the graph (sort indices, make
// memory contiguous, etc).
- graph.FillComplete(col_map, row_map);
+ graph->FillComplete(col_map, row_map);
// And now finally generate the matrix.
matrix = std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, graph, false));
+ (new Epetra_FECrsMatrix(Copy, *graph, false));
last_action = Zero;
// it were square. The call to
// GlobalAssemble later will set the
// correct values.
- Epetra_CrsGraph graph (Copy, row_map,
- &n_entries_per_row[input_row_map.MinMyGID()], true);
-
+ std::auto_ptr<Epetra_CrsGraph> graph;
+ if (row_map.Comm().NumProc() > 1)
+ graph = std::auto_ptr<Epetra_CrsGraph>
+ (new Epetra_CrsGraph (Copy, row_map,
+ &n_entries_per_row[input_row_map.MinMyGID()], true));
+ else
+ graph = std::auto_ptr<Epetra_CrsGraph>
+ (new Epetra_CrsGraph (Copy, row_map, col_map,
+ &n_entries_per_row[input_row_map.MinMyGID()], true));
// TODO: As of now, assume that the
// sparsity pattern sits at the all
// each processor set its rows. Since
// this is wasteful, a better solution
// should be found in the future.
- Assert (graph.NumGlobalRows() == (int)sparsity_pattern.n_rows(),
- ExcDimensionMismatch (graph.NumGlobalRows(),
+ Assert (graph->NumGlobalRows() == (int)sparsity_pattern.n_rows(),
+ ExcDimensionMismatch (graph->NumGlobalRows(),
sparsity_pattern.n_rows()));
// Trilinos has a bug for rectangular
++col_num, ++col)
row_indices[col] = *col_num;
- graph.InsertGlobalIndices (row, row_length, &row_indices[0]);
+ graph->InsertGlobalIndices (row, row_length, &row_indices[0]);
}
// Now, fill the graph (sort indices, make
// memory contiguous, etc).
- graph.FillComplete(col_map, row_map);
+ graph->FillComplete(col_map, row_map);
// And now finally generate the matrix.
matrix = std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, graph, false));
+ (new Epetra_FECrsMatrix(Copy, *graph, false));
last_action = Zero;
col_map (row_map),
compressed (true),
graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(View, row_map, 0))),
+ (new Epetra_FECrsGraph(View, row_map, col_map, 0))),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
row_map (InputMap),
col_map (row_map),
compressed (false),
- graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- int(n_entries_per_row), false))),
+ // for more than one processor, need to
+ // specify only row map first and let the
+ // matrix entries decide about the column
+ // map (which says which columns are
+ // present in the matrix, not to be
+ // confused with the col_map that tells
+ // how the domain dofs of the matrix will
+ // be distributed). for only one
+ // processor, we can directly assign the
+ // columns as well.
+ graph (row_map.Comm().NumProc() > 1 ?
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ (int)n_entries_per_row,
+ false)))
+ :
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ (int)n_entries_per_row,
+ false)))
+ ),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
{}
-
+
SparsityPattern::SparsityPattern (const Epetra_Map &InputMap,
const std::vector<unsigned int> &n_entries_per_row)
:
row_map (InputMap),
col_map (row_map),
compressed (false),
- graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
- false))),
+ graph (row_map.Comm().NumProc() > 1 ?
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ (int*)const_cast<unsigned int*>
+ (&(n_entries_per_row[row_map.MinMyGID()])),
+ false)))
+ :
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ (int*)const_cast<unsigned int*>
+ (&(n_entries_per_row[row_map.MinMyGID()])),
+ false)))
+ ),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
row_map (InputRowMap),
col_map (InputColMap),
compressed (false),
- graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- int(n_entries_per_row), false))),
+ graph (row_map.Comm().NumProc() > 1 ?
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ (int)n_entries_per_row,
+ false)))
+ :
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ (int)n_entries_per_row,
+ false)))
+ ),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
row_map (InputRowMap),
col_map (InputColMap),
compressed (false),
- graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
- false))),
+ graph (row_map.Comm().NumProc() > 1 ?
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ (int*)const_cast<unsigned int*>
+ (&(n_entries_per_row[row_map.MinMyGID()])),
+ false)))
+ :
+ (std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ (int*)const_cast<unsigned int*>
+ (&(n_entries_per_row[row_map.MinMyGID()])),
+ false)))
+ ),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
#endif
compressed (false),
graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- int(n_entries_per_row), false))),
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ int(n_entries_per_row), false))),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
#endif
compressed (false),
graph (std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
- false))),
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
+ false))),
cached_row_indices (1),
n_cached_elements (0),
row_in_cache (0)
// Copy function is currently not working
// because the Trilinos Epetra_FECrsGraph
- // does not implement a reinit function
- // from another graph.
+ // does not implement a constructor from
+ // another graph.
/*
SparsityPattern::SparsityPattern (const SparsityPattern &InputSP)
:
row_map = input_row_map;
col_map = input_col_map;
- graph = std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map, n_entries_per_row, false));
+ // for more than one processor, need to
+ // specify only row map first and let the
+ // matrix entries decide about the column
+ // map (which says which columns are
+ // present in the matrix, not to be
+ // confused with the col_map that tells
+ // how the domain dofs of the matrix will
+ // be distributed). for only one
+ // processor, we can directly assign the
+ // columns as well.
+ if (row_map.Comm().NumProc() > 1)
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, n_entries_per_row, false));
+ else
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map, n_entries_per_row, false));
n_cached_elements = 0;
row_in_cache = 0;
row_map = input_row_map;
col_map = input_col_map;
- graph = std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- n_entries_per_row[input_row_map.MinMyGID()],
- false));
+ if (row_map.Comm().NumProc() > 1)
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ n_entries_per_row[input_row_map.MinMyGID()],
+ false));
+ else
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ n_entries_per_row[input_row_map.MinMyGID()],
+ false));
n_cached_elements = 0;
row_in_cache = 0;
for (unsigned int row=0; row<n_rows; ++row)
n_entries_per_row[row] = sp.row_length(row);
- graph = std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- n_entries_per_row[input_row_map.MinMyGID()],
- false));
+ if (row_map.Comm().NumProc() > 1)
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ n_entries_per_row[input_row_map.MinMyGID()],
+ false));
+ else
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ n_entries_per_row[input_row_map.MinMyGID()],
+ false));
Assert (graph->NumGlobalRows() == (int)sp.n_rows(),
ExcDimensionMismatch (graph->NumGlobalRows(),
for (unsigned int row=0; row<n_rows; ++row)
n_entries_per_row[row] = sp.row_length(row);
- graph = std::auto_ptr<Epetra_FECrsGraph>
- (new Epetra_FECrsGraph(Copy, row_map,
- n_entries_per_row[input_row_map.MinMyGID()],
- false));
+ if (row_map.Comm().NumProc() > 1)
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map,
+ n_entries_per_row[input_row_map.MinMyGID()],
+ false));
+ else
+ graph = std::auto_ptr<Epetra_FECrsGraph>
+ (new Epetra_FECrsGraph(Copy, row_map, col_map,
+ n_entries_per_row[input_row_map.MinMyGID()],
+ false));
Assert (graph->NumGlobalRows() == (int)sp.n_rows(),
ExcDimensionMismatch (graph->NumGlobalRows(),