Hi Matt, Thanks for your reply.
The sparsity pattern is slightly different from one Newton iteration to another. We preallocate enough memory at the beginning, and want to use that memory for the following iterations. Does PETSc accutally free the preallocated (extra) memory? I so cannot use it during the second iteration. Fande, On Mon, Sep 25, 2017 at 9:43 AM, Matthew Knepley <knep...@gmail.com> wrote: > On Mon, Sep 25, 2017 at 11:39 AM, Kong, Fande <fande.k...@inl.gov> wrote: > >> Hi All, >> >> A matrix is created with the right preallocation, and then MatAssembly is >> called. The preallocation info will be removed. We insert any values then, >> and will encounter an malloc error. >> >> My question is that we was intending to design like this way? Attached >> simple example demonstrates what I am talking about. >> > > Yes, this is the intent. Why are you assembling? Could you use > MAT_ASSEMBLY_FLUSH? > > Matt > > >> >> Fande, >> > > > > -- > What most experimenters take for granted before they begin their > experiments is infinitely more interesting than any results to which their > experiments lead. > -- Norbert Wiener > > https://www.cse.buffalo.edu/~knepley/ > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.caam.rice.edu_-7Emk51_&d=DwMFaQ&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=DUUt3SRGI0_JgtNaS3udV68GRkgV4ts7XKfj2opmiCY&m=WrDpQnak7wiz1D4Pyx_jvRGpFKeNDwW2WOH8cIlxrP0&s=7NvRav6CET5Eqpsg7MAiCne1LJ1h2RYKf-OgP6trMkE&e=> >