class MatrixBase;
class VectorBase;
class SolverBase;
-
-
+
+
/**
* Base class for preconditioner classes using the PETSc functionality. The
* classes in this hierarchy don't do a whole lot, except for providing a
* shall be constructed.
*/
PreconditionerBase (const MatrixBase &matrix);
-
+
/**
* Destructor.
*/
* a preconditioner.
*/
const Mat matrix;
-
+
/**
* Conversion operator to get a
* representation of the matrix that
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{};
*/
PreconditionJacobi (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
+
/**
* A class that implements the interface to use the PETSc Block Jacobi
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{};
*/
PreconditionBlockJacobi (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
+
/**
* A class that implements the interface to use the PETSc SOR
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* to one.
*/
AdditionalData (const double omega = 1);
-
+
/**
* Relaxation parameter.
*/
*/
PreconditionSOR (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
+
/**
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* to one.
*/
AdditionalData (const double omega = 1);
-
+
/**
* Relaxation parameter.
*/
*/
PreconditionSSOR (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
+
/**
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* to one.
*/
AdditionalData (const double omega = 1);
-
+
/**
* Relaxation parameter.
*/
*/
PreconditionEisenstat (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
+
/**
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* to zero.
*/
AdditionalData (const unsigned int levels = 0);
-
+
/**
* Fill-in parameter.
*/
*/
PreconditionICC (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
+
/**
* A class that implements the interface to use the PETSc ILU
* preconditioner.
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* to zero.
*/
AdditionalData (const unsigned int levels = 0);
-
+
/**
* Fill-in parameter.
*/
*/
PreconditionILU (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* Confer PetSC manual for more
* details.
*/
- double zero_pivot;
+ double zero_pivot;
/**
* This quantity is added to the
*/
PreconditionLU (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
* Standardized data struct to
* pipe additional flags to the
* preconditioner.
- */
+ */
struct AdditionalData
{
/**
* created.
*/
double max_row_sum;
-
+
/**
* Number of levels of aggressive
* coarsening. Increasing this
* time and memory requirements but
* may decrease effectiveness.*/
unsigned int aggressive_coarsening_num_levels;
-
+
/**
* Setting this flag to true
* produces debug output from
* is constructed.
*/
bool output_details;
-
-
-
-
};
-
+
/**
* Constructor. Take the matrix which
* is used to form the preconditioner,
*/
PreconditionBoomerAMG (const MatrixBase &matrix,
const AdditionalData &additional_data = AdditionalData());
-
+
protected:
/**
* Store a copy of the flags for this
* preconditioner that is appropriate
* for the present class.
*/
- virtual void set_preconditioner_type (PC &pc) const;
+ virtual void set_preconditioner_type (PC &pc) const;
};
-
-
}
# include <base/utilities.h>
# include <lac/petsc_matrix_base.h>
# include <lac/petsc_vector_base.h>
+# include <petscconf.h>
# include <cmath>
DEAL_II_NAMESPACE_OPEN
{}
-
+
PreconditionerBase::~PreconditionerBase ()
{}
-
+
PreconditionerBase::operator Mat () const
{
additional_data (additional_data)
{}
-
+
void
PreconditionJacobi::set_preconditioner_type (PC &pc) const
{
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionJacobi -------------------- */
additional_data (additional_data)
{}
-
+
void
PreconditionBlockJacobi::set_preconditioner_type (PC &pc) const
{
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionSOR -------------------- */
omega (omega)
{}
-
-
+
+
PreconditionSOR::PreconditionSOR (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionSOR::set_preconditioner_type (PC &pc) const
{
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionSSOR -------------------- */
omega (omega)
{}
-
-
+
+
PreconditionSSOR::PreconditionSSOR (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionSSOR::set_preconditioner_type (PC &pc) const
{
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionEisenstat -------------------- */
omega (omega)
{}
-
-
+
+
PreconditionEisenstat::PreconditionEisenstat (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionEisenstat::set_preconditioner_type (PC &pc) const
{
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionICC -------------------- */
levels (levels)
{}
-
-
+
+
PreconditionICC::PreconditionICC (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionICC::set_preconditioner_type (PC &pc) const
{
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionILU -------------------- */
levels (levels)
{}
-
-
+
+
PreconditionILU::PreconditionILU (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionILU::set_preconditioner_type (PC &pc) const
{
// then set flags
#if DEAL_II_PETSC_VERSION_LT(2,3,1)
- PCILUSetLevels (pc, additional_data.levels);
+ PCILUSetLevels (pc, additional_data.levels);
#else
PCFactorSetLevels (pc, additional_data.levels);
#endif
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
/* ----------------- PreconditionBoomerAMG -------------------- */
output_details(output_details)
{}
-
+
PreconditionBoomerAMG::PreconditionBoomerAMG (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionBoomerAMG::set_preconditioner_type (PC &pc) const
{
+#ifdef PETSC_HAVE_HYPRE
// set the right type for the
// preconditioner
int ierr;
ierr = PCSetType (pc, const_cast<char *>(PCHYPRE));
AssertThrow (ierr == 0, ExcPETScError(ierr));
-
+
ierr = PCHYPRESetType(pc, "boomeramg");
AssertThrow (ierr == 0, ExcPETScError(ierr));
if (additional_data.output_details)
PetscOptionsSetValue("-pc_hypre_boomeramg_print_statistics","1");
-
+
PetscOptionsSetValue("-pc_hypre_boomeramg_agg_nl",
Utilities::int_to_string(
additional_data.aggressive_coarsening_num_levels
std::stringstream ssStream;
ssStream << additional_data.max_row_sum;
PetscOptionsSetValue("-pc_hypre_boomeramg_max_row_sum", ssStream.str().c_str());
-
+
ssStream.str(""); // empty the stringstream
- ssStream << additional_data.strong_threshold;
+ ssStream << additional_data.strong_threshold;
PetscOptionsSetValue("-pc_hypre_boomeramg_strong_threshold", ssStream.str().c_str());
if (additional_data.symmetric_operator)
PetscOptionsSetValue("-pc_hypre_boomeramg_relax_type_down", "SOR/Jacobi");
PetscOptionsSetValue("-pc_hypre_boomeramg_relax_type_coarse", "Gaussian-elimination");
}
-
+
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
+#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
}
damping (damping)
{}
-
-
+
+
PreconditionLU::PreconditionLU (const MatrixBase &matrix,
const AdditionalData &additional_data)
:
additional_data (additional_data)
{}
-
+
void
PreconditionLU::set_preconditioner_type (PC &pc) const
{
#else
ierr = PCFactorSetZeroPivot (pc, additional_data.zero_pivot);
#endif
-
+
AssertThrow (ierr == 0, ExcPETScError(ierr));
#if DEAL_II_PETSC_VERSION_LT(2,3,0)
ierr = PCSetFromOptions (pc);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
-
+
}