#include <base/subscriptor.h>
#include <lac/exceptions.h>
-#include <base/std_cxx1x/shared_ptr.h>
#include <vector>
#include <cmath>
#include <memory>
+#include <base/std_cxx1x/shared_ptr.h>
+#include <boost/scoped_ptr.hpp>
+
#ifdef DEAL_II_USE_TRILINOS
# include <Epetra_FECrsGraph.h>
void
copy_from (const SparsityType &SP);
+ /**
+ * Copy operator. This operation is
+ * only allowed for empty objects, to
+ * avoid potentially very costly
+ * operations automatically synthesized
+ * by the compiler. Use copy_from()
+ * instead if you know that you really
+ * want to copy a sparsity pattern with
+ * non-trivial content.
+ */
+ void operator = (const SparsityPattern &sp);
+
/**
* Release all memory and
* return to a state just like
<< " exist in the Trilinos sparsity pattern.");
//@}
private:
+ /**
+ * A pointer to the communicator used
+ * for all operations in this object.
+ *
+ * Note that we create a new
+ * communicator (with a unique MPI ID)
+ * for each object if we are running in
+ * parallel.
+ */
+ boost::scoped_ptr<Epetra_Comm> communicator;
+
/**
* Epetra Trilinos
* mapping of the matrix rows
//
//---------------------------------------------------------------------------
+#include <base/utilities.h>
#include <lac/trilinos_sparsity_pattern.h>
-
#include <lac/sparsity_pattern.h>
#include <lac/compressed_sparsity_pattern.h>
#include <lac/compressed_set_sparsity_pattern.h>
SparsityPattern::SparsityPattern ()
:
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- row_map (0, 0, Epetra_MpiComm(MPI_COMM_SELF)),
+ communicator (Utilities::Trilinos::duplicate_communicator (MPI_COMM_SELF)),
#else
- row_map (0, 0, Epetra_SerialComm()),
+ communicator (new Epetra_SerialComm()),
#endif
- col_map (row_map),
+ row_map (0, 0, *communicator),
+ col_map (0, 0, *communicator),
compressed (true),
graph (std::auto_ptr<Epetra_FECrsGraph>
(new Epetra_FECrsGraph(View, row_map, col_map, 0)))
graph->FillComplete();
}
+
SparsityPattern::SparsityPattern (const Epetra_Map &InputMap,
const unsigned int n_entries_per_row)
:
- row_map (InputMap),
+ communicator (Utilities::Trilinos::duplicate_communicator (InputMap.Comm())),
+ row_map (Utilities::Trilinos::duplicate_map (InputMap, *communicator)),
col_map (row_map),
compressed (false),
// for more than one processor, need to
SparsityPattern::SparsityPattern (const Epetra_Map &InputMap,
const std::vector<unsigned int> &n_entries_per_row)
:
- row_map (InputMap),
+ communicator (Utilities::Trilinos::duplicate_communicator (InputMap.Comm())),
+ row_map (Utilities::Trilinos::duplicate_map (InputMap, *communicator)),
col_map (row_map),
compressed (false),
graph (row_map.Comm().NumProc() > 1 ?
const Epetra_Map &InputColMap,
const unsigned int n_entries_per_row)
:
- row_map (InputRowMap),
- col_map (InputColMap),
+ communicator (Utilities::Trilinos::duplicate_communicator (InputRowMap.Comm())),
+ row_map (Utilities::Trilinos::duplicate_map (InputRowMap, *communicator)),
+ col_map (Utilities::Trilinos::duplicate_map (InputColMap, *communicator)),
compressed (false),
graph (row_map.Comm().NumProc() > 1 ?
(std::auto_ptr<Epetra_FECrsGraph>
const Epetra_Map &InputColMap,
const std::vector<unsigned int> &n_entries_per_row)
:
- row_map (InputRowMap),
- col_map (InputColMap),
+ communicator (Utilities::Trilinos::duplicate_communicator (InputRowMap.Comm())),
+ row_map (Utilities::Trilinos::duplicate_map (InputRowMap, *communicator)),
+ col_map (Utilities::Trilinos::duplicate_map (InputColMap, *communicator)),
compressed (false),
graph (row_map.Comm().NumProc() > 1 ?
(std::auto_ptr<Epetra_FECrsGraph>
const unsigned int n_entries_per_row)
:
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- row_map (m, 0, Epetra_MpiComm(MPI_COMM_SELF)),
- col_map (n, 0, Epetra_MpiComm(MPI_COMM_SELF)),
+ communicator (Utilities::Trilinos::duplicate_communicator (MPI_COMM_SELF)),
#else
- row_map (m, 0, Epetra_SerialComm()),
- col_map (n, 0, Epetra_SerialComm()),
+ communicator (new Epetra_SerialComm()),
#endif
+ row_map (m, 0, *communicator),
+ col_map (n, 0, *communicator),
compressed (false),
graph (std::auto_ptr<Epetra_FECrsGraph>
(new Epetra_FECrsGraph(Copy, row_map, col_map,
int(n_entries_per_row), false)))
{}
+
SparsityPattern::SparsityPattern (const unsigned int m,
const unsigned int n,
const std::vector<unsigned int> &n_entries_per_row)
:
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- row_map (m, 0, Epetra_MpiComm(MPI_COMM_SELF)),
- col_map (n, 0, Epetra_MpiComm(MPI_COMM_SELF)),
+ communicator (Utilities::Trilinos::duplicate_communicator (MPI_COMM_SELF)),
#else
- row_map (m, 0, Epetra_SerialComm()),
- col_map (n, 0, Epetra_SerialComm()),
+ communicator (new Epetra_SerialComm()),
#endif
+ row_map (m, 0, *communicator),
+ col_map (n, 0, *communicator),
compressed (false),
graph (std::auto_ptr<Epetra_FECrsGraph>
(new Epetra_FECrsGraph(Copy, row_map, col_map,
- /* void
SparsityPattern::copy_from (const SparsityPattern &sp)
{
- graph.reset();
- row_map = sp.row_map;
- col_map = sp.col_map;
-
- graph = std::auto_ptr<Epetra_FECrsGraph> (new Epetra_FECrsGraph(*sp.graph));
+ Assert (false, ExcNotImplemented());
}
- */
+
template <typename SparsityType>
void