On Mon, Sep 25, 2017 at 10:05 AM, Stefano Zampini <[email protected] > wrote:
> If you know the union of the different sparsity patterns, after you > preallocate you can set all zeros to use all the entries. This way PETSc > will not complain about new nonzeros in successive assemblies. > > Thanks, Stefano, Yes, we are actually using this way right now. We are explicitly setting zeros to the matrix to stop petsc shrinking the memory. But we want to know why we free the extra memory? Yes, we shrink the memory by moving all data together to have an efficiency computation. But it is still possible to not throw away our preallocated memory space if we want to use latter. Fande, > Il 25 Set 2017 7:01 PM, "Kong, Fande" <[email protected]> ha scritto: > >> 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 <[email protected]> >> wrote: >> >>> On Mon, Sep 25, 2017 at 11:39 AM, Kong, Fande <[email protected]> >>> 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=> >>> >> >>
