Matrix reuse

Lisandro Dalcin dalcinl at
Thu Nov 22 12:22:24 CST 2007

On 11/22/07, Zhifeng Sheng <z.sheng at> wrote:
> In my application, I have small matrices that are created and destroied,
> those matrices are of the same nozero pattern.
> I wonder if there is a way to reuse that matrices instead of destroy
> them every time.

Just do not destroy them! Use the matrices, and then start again your
loop with MatSetValues(), calling MatAssemblyBegin() and
MatAssemblyEnd() after the loop.

Lisandro Dalcín
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

More information about the petsc-users mailing list