}
+/* ----------------- PreconditionParaSails -------------------- */
+
+ PreconditionParaSails::AdditionalData::
+ AdditionalData(const unsigned int symmetric,
+ const unsigned int n_levels,
+ const double threshold,
+ const double filter,
+ const bool output_details)
+ :
+ symmetric(symmetric),
+ n_levels(n_levels),
+ threshold(threshold),
+ filter(filter),
+ output_details(output_details)
+ {}
+
+
+ PreconditionParaSails::PreconditionParaSails ()
+ {}
+
+
+ PreconditionParaSails::PreconditionParaSails (const MatrixBase &matrix,
+ const AdditionalData &additional_data)
+ {
+ initialize(matrix, additional_data);
+ }
+
+
+ void
+ PreconditionParaSails::initialize (const MatrixBase &matrix_,
+ const AdditionalData &additional_data_)
+ {
+ 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 = PCHYPRESetType(pc, "parasails");
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ if (additional_data.output_details)
+ PetscOptionsSetValue("-pc_hypre_parasails_logging","1");
+
+ Assert ((additional_data.symmetric == 0 ||
+ additional_data.symmetric == 1 ||
+ additional_data.symmetric == 2),
+ ExcMessage("ParaSails parameter symmetric can only be equal to 0, 1, 2!"));
+
+ std::stringstream ssStream;
+
+ switch (additional_data.symmetric)
+ {
+ case 0:
+ {
+ ssStream << "nonsymmetric";
+ break;
+ }
+
+ case 1:
+ {
+ ssStream << "SPD";
+ break;
+ }
+
+ case 2:
+ {
+ ssStream << "nonsymmetric,SPD";
+ break;
+ }
+
+ default:
+ Assert (false,
+ ExcMessage("ParaSails parameter symmetric can only be equal to 0, 1, 2!"));
+ };
+
+ PetscOptionsSetValue("-pc_hypre_parasails_sym",ssStream.str().c_str());
+
+ PetscOptionsSetValue("-pc_hypre_parasails_nlevels",
+ Utilities::int_to_string(
+ additional_data.n_levels
+ ).c_str());
+
+ ssStream.str(""); // empty the stringstream
+ ssStream << additional_data.threshold;
+ PetscOptionsSetValue("-pc_hypre_parasails_thresh", ssStream.str().c_str());
+
+ ssStream.str(""); // empty the stringstream
+ ssStream << additional_data.filter;
+ PetscOptionsSetValue("-pc_hypre_parasails_filter", ssStream.str().c_str());
+
+ ierr = PCSetFromOptions (pc);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ ierr = PCSetUp (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
+ }
+
+
+/* ----------------- PreconditionNone ------------------------- */
+
+ PreconditionNone::PreconditionNone ()
+ {}
+
+
+ PreconditionNone::PreconditionNone (const MatrixBase &matrix,
+ const AdditionalData &additional_data)
+ {
+ initialize (matrix, additional_data);
+ }
+
+
+ void
+ PreconditionNone::initialize (const MatrixBase &matrix_,
+ const AdditionalData &additional_data_)
+ {
+ matrix = static_cast<Mat>(matrix_);
+ additional_data = additional_data_;
+
+ create_pc();
+
+ int ierr;
+ ierr = PCSetType (pc, const_cast<char *>(PCNONE));
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ ierr = PCSetFromOptions (pc);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ ierr = PCSetUp (pc);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
+
+
/* ----------------- PreconditionLU -------------------- */
PreconditionLU::AdditionalData::