`VecReplaceArray` with `VecDuplicateVecs` no longer works
I found that the following example worked until cec8e1ee48d2b6b0308890436f9bfafab17cd824
, but no longer does. Am I correct that the following usage got explicitly disallowed in b29a867181b58e4c4cb67065bfb2e850e8287d2a
?
ex999
:
#include <petscvec.h>
int main(int argc, char **argv)
{
PetscInt n = 4, m = 3, i;
Vec x;
Vec *z;
PetscScalar *array0, *array1, *array2;
PetscFunctionBeginUser;
PetscCall(PetscInitialize(&argc, &argv, (char *)0, (char *)0));
PetscCall(VecCreate(PETSC_COMM_SELF, &x));
PetscCall(VecSetSizes(x, n, PETSC_DECIDE));
PetscCall(VecSetType(x, "seq"));
PetscCall(VecSetFromOptions(x));
PetscCall(VecSet(x, 1.));
PetscCall(VecDuplicateVecs(x, m, &z));
PetscCall(PetscCalloc1(n, &array2));
PetscCall(PetscCalloc1(n, &array1));
PetscCall(PetscCalloc1(n, &array0));
for (i = 0; i < n; ++i) {
array2[i] = 5. * i;
array1[i] = 3. * i;
array0[i] = 2. * i;
}
PetscCall(VecReplaceArray(z[2], array2)); /* works */
VecView(z[2], NULL);
PetscCall(VecReplaceArray(z[1], array1)); /* works */
VecView(z[1], NULL);
PetscCall(VecReplaceArray(z[0], array0)); /* fails after b29a867181b58e4c4cb67065bfb2e850e8287d2a */
VecView(z[0], NULL);
PetscCall(VecDestroy(&x));
PetscCall(VecDestroyVecs(m, &z));
PetscCall(PetscFinalize());
return 0;
}
With cec8e1ee48d2b6b0308890436f9bfafab17cd824
, we get:
Vec Object: 1 MPI process
type: seq
0.
5.
10.
15.
Vec Object: 1 MPI process
type: seq
0.
3.
6.
9.
Vec Object: 1 MPI process
type: seq
0.
2.
4.
6.
With b29a867181b58e4c4cb67065bfb2e850e8287d2a
, we get:
Vec Object: 1 MPI process
type: seq
0.
5.
10.
15.
Vec Object: 1 MPI process
type: seq
0.
3.
6.
9.
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: No support for this operation for this object type
[0]PETSC ERROR: No method replacearray for Vec of type seq
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.20.1-220-g5be98cac4ae GIT Date: 2023-11-17 08:07:05 +0000
[0]PETSC ERROR: ./ex999 on a default named ma-ksagiyam-2 by ksagiyam Mon Jan 29 15:15:32 2024
[0]PETSC ERROR: Configure options PETSC_DIR=/home/ksagiyam/current/firedrake/src/petsc PETSC_ARCH=default --download-netcdf --download-metis --with-debugging=0 --with-zlib --download-hdf5 --with-shared-libraries=1 --download-pastix --download-hypre --with-c2html=0 --with-fortran-bindings=0 --download-pnetcdf --download-superlu_dist --download-mumps --download-scalapack --download-cmake --download-mpich --download-chaco --download-hwloc --download-bison --download-suitesparse --download-ptscotch
[0]PETSC ERROR: #1 VecReplaceArray() at /home/ksagiyam/current/firedrake/src/petsc/src/vec/vec/interface/rvector.c:2546
[0]PETSC ERROR: #2 main() at ex999.c:30
[0]PETSC ERROR: No PETSc Option Table entries
[0]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint@mcs.anl.gov----------