Re: [petsc-users] Matrix preallocation - d_nz and o_nz

2022-04-07 Thread Matthew Knepley
On Thu, Apr 7, 2022 at 6:12 AM Gabriela Nečasová wrote: > Dear PETSc team, > > I would like to ask you a question about the matrix preallocation. > I am using the routine MatMPIAIJSetPreallocation(). > > Example: The matrix A has the size 18 x 18 with 168 nonzeros: > A = > 106.21 -91.667

Re: [petsc-users] Matrix preallocation

2022-02-06 Thread Samuel Estes
Great. I think I've got it now. Thanks so much! On Sun, Feb 6, 2022 at 1:48 PM Matthew Knepley wrote: > On Sun, Feb 6, 2022 at 2:39 PM Samuel Estes > wrote: > >> First of all, thank you so much for the detailed answers! >> That clears up most of my confusion. Just to clarify let me make sure I

Re: [petsc-users] Matrix preallocation

2022-02-06 Thread Matthew Knepley
On Sun, Feb 6, 2022 at 2:39 PM Samuel Estes wrote: > First of all, thank you so much for the detailed answers! > That clears up most of my confusion. Just to clarify let me make sure I > understand everything: > 1. So it seems that your advice is just to call the > MatXAIJSetPreallocation()

Re: [petsc-users] Matrix preallocation

2022-02-06 Thread Samuel Estes
First of all, thank you so much for the detailed answers! That clears up most of my confusion. Just to clarify let me make sure I understand everything: 1. So it seems that your advice is just to call the MatXAIJSetPreallocation() routine (rather than make separate calls to other preallocation

Re: [petsc-users] Matrix preallocation

2022-02-05 Thread Mark Adams
On Sat, Feb 5, 2022 at 10:36 AM Matthew Knepley wrote: > On Fri, Feb 4, 2022 at 11:47 PM Samuel Estes > wrote: > >> Hi, >> >> I have a very basic question about matrix preallocation. I am trying to >> use the MatCreate(), MatSetFromOptions(), MatSetPreallocation() >> paradigm. I thought

Re: [petsc-users] Matrix preallocation

2022-02-05 Thread Matthew Knepley
On Fri, Feb 4, 2022 at 11:47 PM Samuel Estes wrote: > Hi, > > I have a very basic question about matrix preallocation. I am trying to > use the MatCreate(), MatSetFromOptions(), MatSetPreallocation() > paradigm. I thought that I should use the MatXAIJSetPreallocation() routine > since the

Re: [petsc-users] Matrix preallocation

2022-02-05 Thread Mark Adams
Woops, I misspoke. MatXAIJSetPreallocation does not take the integer estimate. You have to give it the nnz arrays. You can use NULL for the upper triangular part. The two args. Mark On Sat, Feb 5, 2022 at 6:20 AM Mark Adams wrote: > > > On Fri, Feb 4, 2022 at 11:47 PM Samuel Estes > wrote: >

Re: [petsc-users] Matrix preallocation

2022-02-05 Thread Mark Adams
On Fri, Feb 4, 2022 at 11:47 PM Samuel Estes wrote: > Hi, > > I have a very basic question about matrix preallocation. I am trying to > use the MatCreate(), MatSetFromOptions(), MatSetPreallocation() > paradigm. I thought that I should use the MatXAIJSetPreallocation() routine > since the

[petsc-users] Matrix preallocation

2022-02-04 Thread Samuel Estes
Hi, I have a very basic question about matrix preallocation. I am trying to use the MatCreate(), MatSetFromOptions(), MatSetPreallocation() paradigm. I thought that I should use the MatXAIJSetPreallocation() routine since the code may be run with a SeqAIJ or MPIAIJ matrix but I do not

Re: [petsc-users] matrix preallocation for unstructured finite element

2018-01-19 Thread Matthew Knepley
On Fri, Jan 19, 2018 at 12:04 AM, saturday luis wrote: > I am not exactly sure what you mean. > > Given an IEN array, how do you get dnz and onz? Do you have any algorithm > or pseudocode for that? Any reference will be appreciated! > You use a hash table the size of

Re: [petsc-users] matrix preallocation for unstructured finite element

2018-01-18 Thread saturday luis
I am not exactly sure what you mean. Given an IEN array, how do you get dnz and onz? Do you have any algorithm or pseudocode for that? Any reference will be appreciated! Thanks, Luis 2018-01-18 20:59 GMT-08:00 Sanjay Govindjee : > If you are doing FEA, then you should have

Re: [petsc-users] matrix preallocation for unstructured finite element

2018-01-18 Thread Sanjay Govindjee
If you are doing FEA, then you should have the element connectivity data available from the input.  From this it is an easy task to compute the the assembly pattern and hence the precise allocation data, dnz and onz.  There should be no need to perform a 'trial' assembly. -sanjay On 1/18/18

[petsc-users] matrix preallocation for unstructured finite element

2018-01-18 Thread saturday luis
Hi PETSc team: Is there a way to make precise matrix preallocation for an unstructured grid (I am not using the DMPlex object). Or do you have any example code for estimating the dnz & onz data? On top of my head, I can do a two-phase calculation. I can first give a rough estimate and do one

Re: [petsc-users] matrix preallocation

2016-10-21 Thread Barry Smith
We don't currently have a MatReset (corresponding to PCRest() etc) but it is the right thing for you in this situation I think. A shallow MatReset() would destroy all the matrix data structures but not the Layout information (likely you want this one) while a deep reset would even get

Re: [petsc-users] matrix preallocation

2016-10-21 Thread Jed Brown
"Kong, Fande" writes: > Hi, > > For mechanics problems, the contact surface changes during each nonlinear > iteration. Therefore, the sparsity of matrix also changes during each > nonlinear iteration. We know the preallocaiton is important for performance. > > My question

[petsc-users] matrix preallocation

2016-10-21 Thread Kong, Fande
Hi, For mechanics problems, the contact surface changes during each nonlinear iteration. Therefore, the sparsity of matrix also changes during each nonlinear iteration. We know the preallocaiton is important for performance. My question is: it is possible to re-allocate memory during each