[petsc-users] dmda and structures

Jed Brown jedbrown at mcs.anl.gov
Sun Dec 29 13:51:29 CST 2013


Gideon Simpson <gideon.simpson at icloud.com> writes:

> How would that work?  I took Jed's advice, and set it up so that I have access via:
>
> realization_array[ realization_dof * i + 1 +j] = jth point of ith realization
>
> and then I further used a pointer:
>
> PetscScalar *x;
>
> x = & realization_array[ realization_dof * i + 1];
>
> so that I have "clean" access to the elements of each realization through x[j].

DMDAVecGetArrayDOF sets up one extra level of pointer indirection.  You
can't have the reserved member "id" that way, but you can use a syntax
closer to what you suggested.

  PetscScalar **realization_array;

  DMDAVecGetArrayDOF(sim_data_da, sim_data_vec, &realization_array);

    realization_array[i][j] = 1.234;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131229/5da1096e/attachment.pgp>


More information about the petsc-users mailing list