Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-26 Thread Matthew Knepley
On Sat, Apr 26, 2025 at 1:46 PM Barry Smith wrote: > > The guards are supposed to be universal, not one-offs that are put into > specific locations. How come no errors with debug mode are detected in this > situation?] > Hmm, VecSet() has PetscCall(VecSetErrorIfLocked(x, 1)); which shoul

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-26 Thread Barry Smith
The guards are supposed to be universal, not one-offs that are put into specific locations. How come no errors with debug mode are detected in this situation? Barry > On Apr 26, 2025, at 1:09 PM, Matthew Knepley wrote: > > Junchao, should we put guards in VecSet() and LocalToGlobal() fo

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-26 Thread Matthew Knepley
Junchao, should we put guards in VecSet() and LocalToGlobal() for the array lock? Thanks, Matt On Sat, Apr 26, 2025 at 11:50 AM Junchao Zhang wrote: > Yes, that is correct. > > --Junchao Zhang > > > On Sat, Apr 26, 2025 at 10:35 AM Derek Teaney > wrote: > >> Ok -- got it -- thanks so j

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-26 Thread Junchao Zhang
Yes, that is correct. --Junchao Zhang On Sat, Apr 26, 2025 at 10:35 AM Derek Teaney wrote: > Ok -- got it -- thanks so just do the RestoreArray before the final step, > e.g. > > Loop over cases > VecSet(dn_local, 0.) > GetArray(dn_local, &dn) // RIGHT > Fill up dn > Re

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-26 Thread Junchao Zhang
On Sat, Apr 26, 2025 at 8:27 AM Derek Teaney via petsc-users < petsc-users@mcs.anl.gov> wrote: > Thanks Barry -- this solved the issue. > > "probably will be fine" was fine with 3.17 and maybe 3.19, but definitely > not fine with 3.20. > > For others the faulty logic is: > > GetArray(dn_local, &d

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-26 Thread Derek Teaney via petsc-users
Thanks Barry -- this solved the issue. "probably will be fine" was fine with 3.17 and maybe 3.19, but definitely not fine with 3.20. For others the faulty logic is: GetArray(dn_local, &dn) //WRONG Loop over cases VecSet(dn_local, 0.) Fill up dn LocalToGlobal RestoreArray Whe

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-25 Thread Barry Smith
Technically you should not be calling VecSet() with any outstanding arrays but it will probably be fine. Even though GetArray() does not copy the array values; both GetArray/RestoreArray and Set track the current "state" of the vector and that count might get confused if they are used i

Re: [petsc-users] VecSet and VecAssemblyBegin

2025-04-25 Thread Barry Smith
You absolutely should not need to do an assembly after a VecSet. Please post a full reproducer that demonstrates the problem. Barry > On Apr 25, 2025, at 1:23 PM, Derek Teaney via petsc-users > wrote: > > Hi, > > I was under the (mistaken) impression that one does not need to due a

[petsc-users] VecSet and VecAssemblyBegin

2025-04-25 Thread Derek Teaney via petsc-users
Hi, I was under the (mistaken) impression that one does not need to due a VecAssemblyBegin etc following a VecSet, e.g. VecSet(dn_local, 0.); VecAssemblyBegin(dn_local) ; VecAssemblyEnd(dn_local) ; Seems to give different results without the Assembly. Thanks for clarifying, D