namespace PETScWrappers
{
- PreconditionBase::PreconditionBase()
- : pc(nullptr)
+ PreconditionBase::PreconditionBase(const MPI_Comm &comm)
+ : mpi_communicator(comm)
+ , pc(nullptr)
, matrix(nullptr)
{}
+
+
PreconditionBase::~PreconditionBase()
{
try
{}
}
+
void
PreconditionBase::clear()
{
+ mpi_communicator = MPI_COMM_NULL;
+
matrix = nullptr;
if (pc != nullptr)
}
+
void
PreconditionBase::Tvmult(VectorBase &dst, const VectorBase &src) const
{
}
+
+ MPI_Comm
+ PreconditionBase::get_mpi_communicator() const
+ {
+ return mpi_communicator;
+ }
+
+
+
void
PreconditionBase::create_pc()
{
// preconditioner once
AssertThrow(pc == nullptr, StandardExceptions::ExcInvalidState());
- MPI_Comm comm;
- // this ugly cast is necessary because the
- // type Mat and PETScObject are
- // unrelated.
- PetscErrorCode ierr =
- PetscObjectGetComm(reinterpret_cast<PetscObject>(matrix), &comm);
- AssertThrow(ierr == 0, ExcPETScError(ierr));
+ MPI_Comm comm = get_mpi_communicator();
- ierr = PCCreate(comm, &pc);
+ PetscErrorCode ierr = PCCreate(comm, &pc);
AssertThrow(ierr == 0, ExcPETScError(ierr));
# if DEAL_II_PETSC_VERSION_LT(3, 5, 0)
/* ----------------- PreconditionJacobi -------------------- */
PreconditionJacobi::PreconditionJacobi(const MPI_Comm & comm,
const AdditionalData &additional_data_)
+ : PreconditionBase(comm)
{
additional_data = additional_data_;
PreconditionJacobi::PreconditionJacobi(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
+
+
void
PreconditionJacobi::initialize()
{
AssertThrow(ierr == 0, ExcPETScError(ierr));
}
+
+
void
PreconditionJacobi::initialize(const MatrixBase & matrix_,
const AdditionalData &additional_data_)
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
/* ----------------- PreconditionBlockJacobi -------------------- */
+
+
PreconditionBlockJacobi::PreconditionBlockJacobi(
const MPI_Comm & comm,
const AdditionalData &additional_data_)
+ : PreconditionBase(comm)
{
additional_data = additional_data_;
PreconditionBlockJacobi::PreconditionBlockJacobi(
const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
+
+
void
PreconditionBlockJacobi::initialize()
{
}
+
void
PreconditionBlockJacobi::initialize(const MatrixBase & matrix_,
const AdditionalData &additional_data_)
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionSOR::PreconditionSOR(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionSSOR::PreconditionSSOR(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionICC::PreconditionICC(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionILU::PreconditionILU(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionBoomerAMG::PreconditionBoomerAMG(
const MPI_Comm & comm,
const AdditionalData &additional_data_)
+ : PreconditionBase(comm)
{
additional_data = additional_data_;
}
+
PreconditionBoomerAMG::PreconditionBoomerAMG(
const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
+
+
void
PreconditionBoomerAMG::initialize()
{
# endif
}
+
+
void
PreconditionBoomerAMG::initialize(const MatrixBase & matrix_,
const AdditionalData &additional_data_)
# ifdef DEAL_II_PETSC_WITH_HYPRE
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionParaSails::PreconditionParaSails(
const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionNone::PreconditionNone(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
PreconditionLU::PreconditionLU(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;
, coords(coords)
{}
+
+
template <int dim>
PreconditionBDDC<dim>::PreconditionBDDC(
const MPI_Comm comm,
const AdditionalData &additional_data_)
+ : PreconditionBase(comm)
{
additional_data = additional_data_;
initialize();
}
+
+
template <int dim>
PreconditionBDDC<dim>::PreconditionBDDC(const MatrixBase & matrix,
const AdditionalData &additional_data)
+ : PreconditionBase(matrix.get_mpi_communicator())
{
initialize(matrix, additional_data);
}
+
template <int dim>
void
PreconditionBDDC<dim>::initialize()
# endif
}
+
+
template <int dim>
void
PreconditionBDDC<dim>::initialize(const MatrixBase & matrix_,
{
clear();
+ mpi_communicator = matrix_.get_mpi_communicator();
+
matrix = static_cast<Mat>(matrix_);
additional_data = additional_data_;