[petsc-users] difference between DMDAVecGetArrayDOF and DMDAVecGetArray?

Gideon Simpson gideon.simpson at gmail.com
Sat Feb 28 13:35:34 CST 2015


I’m having some trouble understanding what the difference between these two routines are, though I am finding that there certainly is a difference.  I have the following monte carlo problem.  I am generating n_sample paths each of length n_points, and storing them in a 1D DA:

DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE, n_samples, n_points, 0, NULL, &da);
DMCreateGlobalVector(da,&paths_vec);

When I then go to access them,

PetscScalar **u_array;

I find that:

DMDAVecGetArrayDOF(da, paths_vec, &u_array);

works as exepected, in that u_array[i] is a pointer to the first index of the i-th sample path, but if I call:

DMDAVecGetArray(da, paths_vec, &u_array);

u_array[i] is something else, and my attempts to manipulate it result in segmentation faults, even though the code compiles and builds.

-gideon



More information about the petsc-users mailing list