SparseMatrix::SparseMatrix ()
:
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
+ row_map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD)),
#else
- dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
+ row_map (0, 0, Epetra_SerialComm()),
#endif
- row_map (const_cast<Epetra_Map*>(dummy_map)),
col_map (row_map),
last_action (Insert),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, 0)))
+ (new Epetra_FECrsMatrix(Copy, row_map, 0)))
{}
SparseMatrix::SparseMatrix (const Epetra_Map &InputMap,
const unsigned int n_max_entries_per_row)
:
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
- dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
- row_map (const_cast<Epetra_Map*>(&InputMap)),
+ row_map (InputMap),
col_map (row_map),
last_action (Insert),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map,
+ (new Epetra_FECrsMatrix(Copy, row_map,
int(n_max_entries_per_row), false)))
{}
SparseMatrix::SparseMatrix (const Epetra_Map &InputMap,
const std::vector<unsigned int> &n_entries_per_row)
:
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
- dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
- row_map (const_cast<Epetra_Map*>(&InputMap)),
+ row_map (InputMap),
col_map (row_map),
last_action (Insert),
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])),
true)))
{}
const Epetra_Map &InputColMap,
const unsigned int n_max_entries_per_row)
:
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
- dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
- row_map (const_cast<Epetra_Map*>(&InputRowMap)),
- col_map (const_cast<Epetra_Map*>(&InputColMap)),
+ row_map (InputRowMap),
+ col_map (InputColMap),
last_action (Insert),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, *col_map,
+ (new Epetra_FECrsMatrix(Copy, row_map, col_map,
int(n_max_entries_per_row), false)))
{}
const Epetra_Map &InputColMap,
const std::vector<unsigned int> &n_entries_per_row)
:
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
- dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
- row_map (const_cast<Epetra_Map*>(&InputRowMap)),
- col_map (const_cast<Epetra_Map*>(&InputColMap)),
+ row_map (InputRowMap),
+ col_map (InputColMap),
last_action (Insert),
matrix (std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, *col_map,
+ (new Epetra_FECrsMatrix(Copy, row_map, col_map,
(int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
true)))
{}
SparseMatrix::~SparseMatrix ()
{
- delete dummy_map;
}
// sparsity pattern on that
// processor, and only broadcast the
// pattern afterwards.
- if (row_map->Comm().MyPID() == 0)
+ if (row_map.Comm().MyPID() == 0)
{
Assert (matrix->NumGlobalRows() == (int)sparsity_pattern.n_rows(),
ExcDimensionMismatch (matrix->NumGlobalRows(),
unsigned int n_rows = sparsity_pattern.n_rows();
- if (row_map->Comm().MyPID() == 0)
+ if (row_map.Comm().MyPID() == 0)
{
Assert (input_map.NumGlobalElements() == (int)sparsity_pattern.n_rows(),
ExcDimensionMismatch (input_map.NumGlobalElements(),
sparsity_pattern.n_cols()));
}
- row_map = const_cast<Epetra_Map*>(&input_map);
+ row_map = input_map;
col_map = row_map;
std::vector<int> n_entries_per_row(n_rows);
n_entries_per_row[(int)row] = sparsity_pattern.row_length(row);
matrix = std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, &n_entries_per_row[0],
+ (new Epetra_FECrsMatrix(Copy, row_map, &n_entries_per_row[0],
false));
reinit (sparsity_pattern);*/
sparsity_pattern.n_cols()));
}
- row_map = const_cast<Epetra_Map*>(&input_row_map);
- col_map = const_cast<Epetra_Map*>(&input_col_map);
+ row_map = input_row_map;
+ col_map = input_col_map;
std::vector<int> n_entries_per_row(n_rows);
n_entries_per_row[(int)row] = sparsity_pattern.row_length(row);
matrix = std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, *col_map,
+ (new Epetra_FECrsMatrix(Copy, row_map, col_map,
&n_entries_per_row[0], false));
reinit (sparsity_pattern);
ExcDimensionMismatch (input_col_map.NumGlobalElements(),
dealii_sparse_matrix.n()));
- row_map = const_cast<Epetra_Map*>(&input_row_map);
- col_map = const_cast<Epetra_Map*>(&input_col_map);
+ row_map = input_row_map;
+ col_map = input_col_map;
std::vector<int> n_entries_per_row(n_rows);
dealii_sparse_matrix.get_sparsity_pattern().row_length(row);
matrix = std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, *col_map,
+ (new Epetra_FECrsMatrix(Copy, row_map, col_map,
&n_entries_per_row[0], true));
std::vector<double> values;
// the pointer and generate an
// empty matrix.
matrix.reset();
-
- row_map = const_cast<Epetra_Map*>(dummy_map);
+
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+ row_map = Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD));
+#else
+ row_map = Epetra_Map (0, 0, Epetra_SerialComm());
+#endif
+
col_map = row_map;
matrix = std::auto_ptr<Epetra_FECrsMatrix>
- (new Epetra_FECrsMatrix(Copy, *row_map, 0));
+ (new Epetra_FECrsMatrix(Copy, row_map, 0));
}
{
// flush buffers
int ierr;
- //if (row_map->SameAs(*col_map))
+ //if (row_map.SameAs(col_map))
//ierr = matrix->GlobalAssemble ();
//else
- ierr = matrix->GlobalAssemble (*col_map, *row_map);
+ ierr = matrix->GlobalAssemble (col_map, row_map);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
if (last_action == Add)
{
int ierr;
- if (row_map->SameAs(*col_map))
+ if (row_map.SameAs(col_map))
ierr = matrix->GlobalAssemble (false);
else
- ierr = matrix->GlobalAssemble(*col_map, *row_map, false);
+ ierr = matrix->GlobalAssemble(col_map, row_map, false);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
last_action = Insert;
if (last_action == Insert)
{
int ierr;
- if (row_map->SameAs(*col_map))
+ if (row_map.SameAs(col_map))
ierr = matrix->GlobalAssemble (false);
else
- ierr = matrix->GlobalAssemble(*col_map, *row_map, false);
+ ierr = matrix->GlobalAssemble(col_map, row_map, false);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
{
Assert (&src != &dst, ExcSourceEqualsDestination());
- Assert (col_map->SameAs(src.vector->Map()),
+ Assert (col_map.SameAs(src.vector->Map()) == true,
ExcMessage ("Column map of matrix does not fit with vector map!"));
- Assert (row_map->SameAs(dst.vector->Map()),
+ Assert (row_map.SameAs(dst.vector->Map()) == true,
ExcMessage ("Row map of matrix does not fit with vector map!"));
- if (!matrix->Filled())
+ if (matrix->Filled() == false)
matrix->FillComplete();
const int ierr = matrix->Multiply (false, *(src.vector), *(dst.vector));
{
Assert (&src != &dst, ExcSourceEqualsDestination());
- Assert (row_map->SameAs(src.vector->Map()),
+ Assert (row_map.SameAs(src.vector->Map()) == true,
ExcMessage ("Row map of matrix does not fit with vector map!"));
- Assert (col_map->SameAs(dst.vector->Map()),
+ Assert (col_map.SameAs(dst.vector->Map()) == true,
ExcMessage ("Column map of matrix does not fit with vector map!"));
- if (!matrix->Filled())
+ if (matrix->Filled() == false)
matrix->FillComplete();
const int ierr = matrix->Multiply (true, *(src.vector), *(dst.vector));
// checks index bounds Also,
// can only get local values
- AssertThrow ((static_cast<signed int>(index) >= vector.map->MinMyGID()) &&
- (static_cast<signed int>(index) <= vector.map->MaxMyGID()),
- ExcAccessToNonLocalElement (index, vector.map->MinMyGID(),
- vector.map->MaxMyGID()));
+ AssertThrow ((static_cast<signed int>(index) >= vector.map.MinMyGID()) &&
+ (static_cast<signed int>(index) <= vector.map.MaxMyGID()),
+ ExcAccessToNonLocalElement (index, vector.map.MinMyGID(),
+ vector.map.MaxMyGID()));
return (*(vector.vector))[0][index];
}
Vector::Vector ()
:
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0,0,Epetra_MpiComm(MPI_COMM_WORLD))),
+ map (0,0,Epetra_MpiComm(MPI_COMM_WORLD)),
#else
- dummy_map (new Epetra_Map (0,0,Epetra_SerialComm())),
+ map (0,0,Epetra_SerialComm()),
#endif
- map (const_cast<Epetra_Map*>(dummy_map)),
last_action (Insert),
vector(std::auto_ptr<Epetra_FEVector>
- (new Epetra_FEVector(*map)))
+ (new Epetra_FEVector(map)))
{}
Vector::Vector (const Epetra_Map &InputMap)
:
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0,0,Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
- dummy_map (new Epetra_Map (0,0,Epetra_SerialComm())),
-#endif
- map (const_cast<Epetra_Map*>(&InputMap)),
+ map (InputMap),
last_action (Insert),
vector (std::auto_ptr<Epetra_FEVector>
- (new Epetra_FEVector(*map)))
+ (new Epetra_FEVector(map)))
{}
Vector::Vector (const Vector &v,
const bool fast)
:
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- dummy_map (new Epetra_Map (0,0,Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
- dummy_map (new Epetra_Map (0,0,Epetra_SerialComm())),
-#endif
map (v.map),
last_action (Insert),
vector(std::auto_ptr<Epetra_FEVector>
- (new Epetra_FEVector(*map,!fast)))
+ (new Epetra_FEVector(map,!fast)))
{}
Vector::~Vector ()
{
- vector.reset();
- delete dummy_map;
}
Vector::reinit (const Epetra_Map &input_map)
{
vector.reset();
- map = const_cast<Epetra_Map*> (&input_map);
+ map = input_map;
- vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*map));
+ vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(map));
last_action = Insert;
}
const bool fast)
{
vector.reset();
+ if (map.SameAs(v.map) == false)
+ map = v.map;
- map = v.map;
-
- vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*map,!fast));
+ vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(map,!fast));
last_action = Insert;
}
// reset the pointer and generate
// an empty vector.
vector.reset();
- map = dummy_map;
- vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*map));
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+ map = Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD));
+#else
+ map = Epetra_Map (0, 0, Epetra_SerialComm());
+#endif
+
+ vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(map));
last_action = Insert;
}