Re: [petsc-users] Mat preallocation for adaptive grid

2022-06-11 Thread Samuel Estes
Ok thanks so much for the help! It's nice that it coincides with the easiest option! On Sat, Jun 11, 2022 at 7:54 PM Matthew Knepley wrote: > On Sat, Jun 11, 2022 at 8:43 PM Samuel Estes > wrote: > >> I'm sorry, would you mind clarifying? I think my email was so long and >&g

Re: [petsc-users] Mat preallocation for adaptive grid

2022-06-11 Thread Samuel Estes
I'm sorry, would you mind clarifying? I think my email was so long and rambling that it's tough for me to understand which part was being answered. On Sat, Jun 11, 2022 at 7:38 PM Matthew Knepley wrote: > On Sat, Jun 11, 2022 at 8:32 PM Samuel Estes > wrote: > >> Hello, &g

[petsc-users] Mat preallocation for adaptive grid

2022-06-11 Thread Samuel Estes
Hello, My question concerns preallocation for Mats in adaptive FEM problems. When the grid refines, I destroy the old matrix and create a new one of the appropriate (larger size). When the grid “un-refines” I just use the same (extra large) matrix and pad the extra unused diagonal entries with

Re: [petsc-users] MatZeroEntries for retaining allocated space

2022-04-12 Thread Samuel Estes
Thank you both so much. That makes sense. It also explains the zero fill option in the MatPreallocatorPreallocate routine. I believe I understand what I need to now. > On Apr 12, 2022, at 4:11 PM, Junchao Zhang wrote: > >  > > >> On Tue, Apr 12, 2022 at 3:51 PM Samue

Re: [petsc-users] MatZeroEntries for retaining allocated space

2022-04-12 Thread Samuel Estes
because the routine does that for me? On Tue, Apr 12, 2022 at 3:46 PM Junchao Zhang wrote: > > > On Tue, Apr 12, 2022 at 12:23 PM Samuel Estes > wrote: > >> Maybe I should create a separate question for this but I did some testing >> and now I'm a bit confused on how

Re: [petsc-users] MatZeroEntries for retaining allocated space

2022-04-12 Thread Samuel Estes
which entries will be non-zero, PETSc also actually assigns a zero value under the hood so that I don't have to explicitly assign values myself. Is this correct? Sorry for the convoluted question. I hope it's clear. On Tue, Apr 12, 2022 at 11:54 AM Samuel Estes wrote: > Hi, > > I have

[petsc-users] MatZeroEntries for retaining allocated space

2022-04-12 Thread Samuel Estes
Hi, I have a problem where I want to allocate some nonzero structure to a sparse matrix which will be used repeatedly to solve some equations. The assembly routines will compress out allocated space which has not been assigned a value so I know that I need to assign zero values to any unused

Re: [petsc-users] Allocating the diagonal for MatMPIAIJSetPreallocation

2022-04-01 Thread Samuel Estes
Ok thanks! I think I understand now. On Fri, Apr 1, 2022 at 12:44 PM Matthew Knepley wrote: > On Fri, Apr 1, 2022 at 1:08 PM Samuel Estes > wrote: > >> Thank you for all the help. I think I'm mostly clear now. >> >> I think my only remaining question relates t

Re: [petsc-users] Allocating the diagonal for MatMPIAIJSetPreallocation

2022-04-01 Thread Samuel Estes
PM Samuel Estes > wrote: > >> Ah, so let me see if I understand this now. So basically you preallocate >> for this "dummy matrix" of type MatPreallocator. But rather than simply >> calling MatXXXAIJSetPreallocation() to allocate space, you actually tell >> this

Re: [petsc-users] Allocating the diagonal for MatMPIAIJSetPreallocation

2022-04-01 Thread Samuel Estes
pr 1, 2022 at 11:50 AM Matthew Knepley wrote: > On Fri, Apr 1, 2022 at 12:45 PM Samuel Estes > wrote: > >> Thanks! This seems like it might be what I need. I'm still a little >> unclear on how it works though? My problem is basically that for any given >> row, I know the

Re: [petsc-users] Allocating the diagonal for MatMPIAIJSetPreallocation

2022-04-01 Thread Samuel Estes
there could be a black box utility to figure this out? Am I misunderstanding how this is used? On Fri, Apr 1, 2022 at 11:34 AM Matthew Knepley wrote: > On Fri, Apr 1, 2022 at 12:27 PM Samuel Estes > wrote: > >> Hi, >> >> I have a problem in which I know (roughly) the

[petsc-users] Allocating the diagonal for MatMPIAIJSetPreallocation

2022-04-01 Thread Samuel Estes
Hi, I have a problem in which I know (roughly) the number of non-zero entries for each row of a matrix but I don't have a convenient way of determining whether they belong to the diagonal or off-diagonal part of the parallel matrix. Is there some way I can just allocate the total number of

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 clari

Re: [petsc-users] Matrix preallocation

2022-02-06 Thread Samuel Estes
ey 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() >

[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

[petsc-users] PETSc object creation/destruction with adaptive grid

2021-12-07 Thread Samuel Estes
Hi, I have a code implementing a finite element method with an adaptive grid. Rather than destroying the PETSc objects (the Jacobian matrix and RHS residual vector) every time the code refines the grid, we want to (over-)allocate some "padding" for these objects so that we only destroy/create new

[petsc-users] Question about setting block size for arbitrary Mat formats

2021-10-27 Thread Samuel Estes
Hi, I am solving a linear system in which the matrix has some block structure. We will ultimately use the BAIJ format but for now we are just using the default CSR and would like to play with different formats to compare performance for our problem. Currently, I call MatSetBlockSize so that I can

Re: [petsc-users] Solving two successive linear systems

2021-09-17 Thread Samuel Estes
Thanks for the help! On Fri, Sep 17, 2021 at 11:37 AM Barry Smith wrote: > > > > On Sep 17, 2021, at 12:21 PM, Samuel Estes > wrote: > > > > Hi, > > > > I have two related questions about the best way to use the KSP solver: > > > > First

[petsc-users] Solving two successive linear systems

2021-09-17 Thread Samuel Estes
Hi, I have two related questions about the best way to use the KSP solver: First, I have an adaptive FEM code which solves the same linear system at each iteration until the grid is refined at which point, obviously, the size of the linear system changes. Currently, I just call:

[petsc-users] Solving subsystem using larger matrix

2021-09-03 Thread Samuel Estes
Hi, I have a model in which we alternatively solve two submodels by the finite element method both on the same unstructured mesh. The first model (call it model 1) has three degrees of freedom per node while the second model (model 2) is scalar (one degree of freedom). We are trying several