Dear all,<div> I hope you're having a nice day. I have a further question on this issue in 3D.</div><div>1, Following the idea of Dr. Brown and Dr. Knepley, I finished a 2D test, which works very fine. Here, I did it in 3D by</div>
<div><div><div>"</div><div> TESTVAR ***a, ***b, ***c;</div><div> TESTVAR **aa, **bb, **cc; </div><div> TESTVAR *arraya, *arrayb, *arrayc;</div></div><div><br></div><div> arraya = (TESTVAR*) calloc(SIZE*SIZE*SIZE, sizeof(TESTVAR));</div>
<div> arrayb = (TESTVAR*) calloc(SIZE*SIZE*SIZE, sizeof(TESTVAR));</div><div> arrayc = (TESTVAR*) calloc(SIZE*SIZE*SIZE, sizeof(TESTVAR));</div><div><br></div><div> aa =(TESTVAR**) calloc(SIZE*SIZE, sizeof(TESTVAR*));</div>
<div> bb =(TESTVAR**) calloc(SIZE*SIZE, sizeof(TESTVAR*));</div><div> cc =(TESTVAR**) calloc(SIZE*SIZE, sizeof(TESTVAR*));</div><div> </div><div> for(i = 0; i < SIZE*SIZE; i++) {</div><div> aa[i] = &arraya[i*SIZE];</div>
<div> bb[i] = &arrayb[i*SIZE];</div><div> cc[i] = &arrayc[i*SIZE]; </div><div> }</div><div><br></div><div> a =(TESTVAR***) calloc(SIZE*SIZE, sizeof(TESTVAR**));</div><div> b =(TESTVAR***) calloc(SIZE*SIZE, sizeof(TESTVAR**));</div>
<div> c =(TESTVAR***) calloc(SIZE*SIZE, sizeof(TESTVAR**));</div><div> </div><div> for(i = 0; i < SIZE; i++) {</div><div> a[i] = &aa[i*SIZE];</div><div> b[i] = &bb[i*SIZE];</div><div> c[i] = &cc[i*SIZE];</div>
<div> }</div><div>"</div><div> It works. However, I wonder if there is any other good ideas for 3D problem other than this kinda of 'two-layer' approach.</div><div><br></div><div>2, I have a little question on PETSc about 3D processor ordering. Does PETSc have any function giving me the nodes/rank number of neighboring nodes/ranks? Are those 'Application Ordering' functions applicable for my case?</div>
<div><br></div><div>thanks,</div><div>Alan</div><br><div class="gmail_quote">On Fri, Apr 13, 2012 at 5:41 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><div class="gmail_quote">On Fri, Apr 13, 2012 at 17:38, Zhenglun (Alan) Wei <span dir="ltr"><<a href="mailto:zhenglun.wei@gmail.com" target="_blank">zhenglun.wei@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a final question on it. Is it taken a lot of memory for
doing this? As I understand, pointers won't occupy many memories and
it works like an alias. It will not, to my limit knowledge, take
much extra memory by doing this. </blockquote></div><br></div><div>A pointer takes about as much space as a floating point value, so that array of pointers costs about 1*N compared to the N*N matrix.</div>
</blockquote></div><br></div>