*/
PreconditionJacobi ();
- /**
- * A constructor intended to be used with SLEPc objects.
- */
- PreconditionJacobi (const MPI_Comm communicator,
- const AdditionalData &additional_data = AdditionalData());
-
/**
* Constructor. Take the matrix which is used to form the preconditioner,
PreconditionJacobi (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
+ /**
+ * Same as above but without setting a matrix to form the preconditioner.
+ * Intended to be used with SLEPc objects.
+ */
+ PreconditionJacobi (const MPI_Comm communicator,
+ const AdditionalData &additional_data = AdditionalData());
+
+
/**
* Initializes the preconditioner object and calculate all data that is
* necessary for applying it in a solver. This function is automatically
PreconditionBlockJacobi (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
+ /**
+ * Same as above but without setting a matrix to form the preconditioner.
+ * Intended to be used with SLEPc objects.
+ */
+ PreconditionBlockJacobi (const MPI_Comm communicator,
+ const AdditionalData &additional_data = AdditionalData());
+
+
/**
* Initializes the preconditioner object and calculate all data that is
* necessary for applying it in a solver. This function is automatically
* Store a copy of the flags for this particular preconditioner.
*/
AdditionalData additional_data;
+
+ /**
+ * Initializes the preconditioner object without knowing a particular matrix.
+ * This function sets up appropriate parameters to the underlying PETSc object
+ * after it has been created.
+ */
+ void initialize();
+
};
PreconditionBoomerAMG (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
+ /**
+ * Same as above but without setting a matrix to form the preconditioner.
+ * Intended to be used with SLEPc objects.
+ */
+ PreconditionBoomerAMG (const MPI_Comm communicator,
+ const AdditionalData &additional_data = AdditionalData());
+
+
/**
* Initializes the preconditioner object and calculate all data that is
* necessary for applying it in a solver. This function is automatically
* Store a copy of the flags for this particular preconditioner.
*/
AdditionalData additional_data;
+
+ /**
+ * Initializes the preconditioner object without knowing a particular matrix.
+ * This function sets up appropriate parameters to the underlying PETSc object
+ * after it has been created.
+ */
+ void initialize();
+
};
/* ----------------- PreconditionBlockJacobi -------------------- */
+ PreconditionBlockJacobi::PreconditionBlockJacobi (const MPI_Comm comm,
+ const AdditionalData &additional_data_)
+ {
+ additional_data = additional_data_;
+
+ int ierr = PCCreate(comm, &pc);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ initialize();
+ }
+
PreconditionBlockJacobi::PreconditionBlockJacobi ()
{}
}
void
- PreconditionBlockJacobi::initialize (const MatrixBase &matrix_,
- const AdditionalData &additional_data_)
+ PreconditionBlockJacobi::initialize()
{
- matrix = static_cast<Mat>(matrix_);
- additional_data = additional_data_;
-
- create_pc();
-
int ierr;
ierr = PCSetType (pc, const_cast<char *>(PCBJACOBI));
AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
- ierr = PCSetUp (pc);
+
+ void
+ PreconditionBlockJacobi::initialize (const MatrixBase &matrix_,
+ const AdditionalData &additional_data_)
+ {
+ matrix = static_cast<Mat>(matrix_);
+ additional_data = additional_data_;
+
+ create_pc();
+ initialize();
+
+ int ierr = PCSetUp (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
PreconditionBoomerAMG::PreconditionBoomerAMG ()
{}
+ PreconditionBoomerAMG::PreconditionBoomerAMG (const MPI_Comm comm,
+ const AdditionalData &additional_data_)
+ {
+ additional_data = additional_data_;
+
+ int ierr = PCCreate(comm, &pc);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+#ifdef PETSC_HAVE_HYPRE
+ initialize();
+#else // PETSC_HAVE_HYPRE
+ (void)pc;
+ Assert (false,
+ ExcMessage ("Your PETSc installation does not include a copy of "
+ "the hypre package necessary for this preconditioner."));
+#endif
+ }
+
PreconditionBoomerAMG::PreconditionBoomerAMG (const MatrixBase &matrix,
const AdditionalData &additional_data)
initialize(matrix, additional_data);
}
-
void
- PreconditionBoomerAMG::initialize (const MatrixBase &matrix_,
- const AdditionalData &additional_data_)
+ PreconditionBoomerAMG::initialize ()
{
- matrix = static_cast<Mat>(matrix_);
- additional_data = additional_data_;
-
-#ifdef PETSC_HAVE_HYPRE
- create_pc();
-
int ierr;
ierr = PCSetType (pc, const_cast<char *>(PCHYPRE));
AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
- ierr = PCSetUp (pc);
+ void
+ PreconditionBoomerAMG::initialize (const MatrixBase &matrix_,
+ const AdditionalData &additional_data_)
+ {
+ matrix = static_cast<Mat>(matrix_);
+ additional_data = additional_data_;
+
+#ifdef PETSC_HAVE_HYPRE
+ create_pc();
+ initialize ();
+
+ int ierr = PCSetUp (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
#else // PETSC_HAVE_HYPRE