On Mon, Apr 16, 2012 at 5:11 PM, Juha Jäykkä <span dir="ltr"><<a href="mailto:juhaj@iki.fi">juhaj@iki.fi</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi list!<br>
<br>
I am trying to create a 3D DA such that I can use DMDAVecGetArray() and access<br>
it using array indexing. I know how to get several dof in the DA and how using<br>
a struct to access the members works, when the dof is determined at compile-<br>
time (so accesses like array[1][2][3].member1[2] are computed correctly.<br>
<br>
However, I would like to determine dof at run-time. Creating a struct with<br>
pointers (even of the type member[]) of course gives me a struct whose size<br>
depends on the *pointer* size, not my dof. So I was wondering if I could work<br>
around this somehow, but do not seem to be able to.<br></blockquote><div><br></div><div><a href="http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/DM/DMDAVecGetArrayDOF.html">http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/DM/DMDAVecGetArrayDOF.html</a></div>
<div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
My DA is created by<br>
<br>
DMDACreate3d(PETSC_COMM_WORLD,<br>
DMDA_BOUNDARY_GHOSTED, DMDA_BOUNDARY_GHOSTED,<br>
DMDA_BOUNDARY_GHOSTED, DMDA_STENCIL_BOX,<br>
2, 2, 2,<br>
PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,<br>
ndof, NGHOSTS,<br>
PETSC_NULL, PETSC_NULL, PETSC_NULL,<br>
&da);<br>
<br>
so my Vec does have the correct dof, but I cannot seem to fool C to address<br>
this as array[z][y][x][n] or something of the like, where the last index is<br>
the index to ndof. (Usually I would index that as array[z][y][x].member[n],<br>
but now I do not know how to make that happen since I cannot define a struct<br>
whose storage size is not known to the compiler.)<br>
<br>
Any ideas? Or am I trying to accomplish something which is not possible? (If<br>
so, why would that be? The vector is of the correct size.)<br>
<br>
Cheers,<br>
-Juha<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
-----------------------------------------------<br>
| Juha Jäykkä, <a href="mailto:juhaj@iki.fi">juhaj@iki.fi</a> |<br>
-----------------------------------------------<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>