<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 12, 2014 at 6:38 AM, 吕超 <span dir="ltr"><<a href="mailto:luchao@mail.iggcas.ac.cn" target="_blank">luchao@mail.iggcas.ac.cn</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p> Many thanks for all your explanation, its really help me!</p>
<p> Now my program run smoothly, and the result is satisfactory! </p><p> For 3d results, I now make drawings by many slices in matlab. </p><p> And I find it not visualized, so could do you please tell me how can I draw these 3d space fileds finely?<br>
</p></blockquote><div><br></div><div>Consider using <a href="http://www.paraview.org/">http://www.paraview.org/</a></div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<p><br>> -----原始邮件-----<br>> 发件人: "Jed Brown" <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>><br>> 发送时间: 2014年3月12日 星期三<br>> 收件人: "Barry Smith" <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>>, "Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
> 抄送: "吕超" <<a href="mailto:luchao@mail.iggcas.ac.cn" target="_blank">luchao@mail.iggcas.ac.cn</a>>, petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
> 主题: Re: [petsc-users] petsc malloc multidimensional array<br>> <br>> Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> writes:<br>> <br>> > On Mar 11, 2014, at 9:22 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
> ><br>> >> On Tue, Mar 11, 2014 at 9:05 AM, 吕超 <<a href="mailto:luchao@mail.iggcas.ac.cn" target="_blank">luchao@mail.iggcas.ac.cn</a>> wrote:<br>> >> Hi, Matthew:<br>> >> <br>> >> Thank you for your reply so fast! but I also have some questions:<br>
> >> <br>> >> 2d arrays I used is just intermediate variable, not for fields, and the fields is used Vector. In Finite element method, when I use element stiffness matrix to assemble global stiffness matrix, I always first compute the 2d element stiffness matrixs whose size is 512*512(inner points in element),so big for static arrays.<br>
> ><br>> > If the 512 is a fixed number, not different for different elements you can in C 89 standard use <br>> ><br>> > mysubroutine(….)<br>> > double element[512][512];<br>> <br>
> This is fairly "big" -- 2 MiB of what is typically an 8 MiB stack size,<br>> so if you allocate several of these, you may get a stack overflow. You<br>> can increase the stack size on most systems, but that makes it more<br>
> complicated to run your program. I would allocate dynamically if you<br>> are worried about this.<br>> <br>> If you want to avoid PETSc array functions, you can allocate dynamically<br>> and access via a pointer:<br>
> <br>> double *mem = malloc(M*N*sizeof(double));<br>> double (*p)[N] = (double (*)[N])mem;<br>> // access p[i][j]<br>> free(mem);<br></p><br><br><br></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
</div></div>