solver(&s, typeid(*this).name())
{
matrix = linear_operator<VectorType>(m);
- precondition = linear_operator<VectorType>(p);
+ precondition = linear_operator<VectorType>(m, p);
}
const PreconditionerType &p)
{
solver = &s;
- if (matrix)
- delete matrix;
matrix = linear_operator<VectorType>(m);
- if (precondition)
- delete precondition;
- precondition = linear_operator<VectorType>(p);
+ precondition = linear_operator<VectorType>(m, p);
}
MGCoarseGridLACIteration<SolverType, VectorType>
::set_matrix(const MatrixType &m)
{
- if (matrix)
- delete matrix;
matrix = linear_operator<VectorType>(m);
}
Matrix<VectorType>::initialize (const MGLevelObject<MatrixType> &p)
{
matrices.resize(p.min_level(), p.max_level());
- for (unsigned int level=p.min_level(); level <= p.max_level(); ++level)
- matrices[level] = linear_operator<VectorType>(p[level]);
+ for (unsigned int level = p.min_level(); level <= p.max_level(); ++level)
+ {
+ // Workaround: The matrix objects supplied to this class do not
+ // expose information how to reinitialize a vector. Therefore,
+ // populate vmult and Tvmult by hand...
+ matrices[level] = LinearOperator<VectorType>();
+ matrices[level].vmult = [&p, level](
+ VectorType &v, const VectorType &u)
+ {
+ p[level].vmult(v, u);
+ };
+ matrices[level].Tvmult = [&p, level](
+ VectorType &v, const VectorType &u)
+ {
+ p[level].Tvmult(v, u);
+ };
+ }
}