Matrix-based diagonal preconditioner.
Apply preconditioner to z, i.e. z=D^-1.
Apply preconditioner: Multiply r by the inverse of the diagonal.
Implements oomph::Preconditioner.
121 if (*
r.distribution_pt() != *this->distribution_pt())
123 std::ostringstream error_message_stream;
125 <<
"The r vector must have the same distribution as the "
127 <<
"(this is the same as the matrix passed to setup())";
128 throw OomphLibError(error_message_stream.str(),
134 if (*z.distribution_pt() != *this->distribution_pt())
136 std::ostringstream error_message_stream;
138 <<
"The z vector distribution has been setup; it must have the "
139 <<
"same distribution as the r vector (and preconditioner).";
140 throw OomphLibError(error_message_stream.str(),
154 const double* r_values =
r.values_pt();
155 double* z_values = z.values_pt();
int i
Definition: BiCGSTAB_step_by_step.cpp:9
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
Definition: linear_algebra_distribution.h:457
unsigned nrow_local() const
access function for the num of local rows on this processor.
Definition: linear_algebra_distribution.h:469
Vector< double > Inv_diag
Vector of inverse diagonal entries.
Definition: general_purpose_preconditioners.h:73
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
References oomph::DoubleVector::build(), oomph::DoubleVector::built(), oomph::DistributableLinearAlgebraObject::distribution_pt(), i, Inv_diag, oomph::DistributableLinearAlgebraObject::nrow_local(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, UniformPSDSelfTest::r, and oomph::DoubleVector::values_pt().
| void oomph::MatrixBasedDiagPreconditioner::setup |
( |
| ) |
|
|
virtual |
Setup the preconditioner (store diagonal) from the fully assembled matrix.
Setup diagonal preconditioner: Store the inverse of the diagonal entries from the fully assembled matrix.
Implements oomph::Preconditioner.
50 if (dist_matrix_pt != 0)
53 unsigned nrow_local = dist_matrix_pt->nrow_local();
54 unsigned first_row = dist_matrix_pt->first_row();
67 "Zero diagonal in matrix --> Cannot use diagonal preconditioner.",
90 for (
unsigned i = 0;
i < n_row;
i++)
96 "Zero diagonal in matrix --> Cannot use diagonal preconditioner.",
108 LinearAlgebraDistribution dist(
comm_pt(), n_row,
false);
unsigned first_row() const
access function for the first row on this processor
Definition: linear_algebra_distribution.h:481
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
Definition: linear_algebra_distribution.h:507
DistributableLinearAlgebraObject()
Default constructor - create a distribution.
Definition: linear_algebra_distribution.h:438
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
Definition: preconditioner.h:150
virtual const OomphCommunicator * comm_pt() const
Get function for comm pointer.
Definition: preconditioner.h:171
References oomph::DistributableLinearAlgebraObject::build_distribution(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::DistributableLinearAlgebraObject::first_row(), i, Inv_diag, oomph::Preconditioner::matrix_pt(), oomph::DoubleMatrixBase::nrow(), oomph::DistributableLinearAlgebraObject::nrow_local(), OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.