Hi, Matthew:
Thank you for your reply so fast! but I also have some questions:
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. So i want to use PetscMalloc to bulid 2d arrays to store
element stiffness matrixs' values. And I don't know how to do, could do tell me?
then use another 1d array to abstract the nonzero values from 2d arrays
above-mentioned. could do you please tell me some other methods much more
convenient and faster?
-----原始邮件-----
发件人: "Matthew Knepley" <[email protected]>
发送时间: 2014年3月11日 星期二
收件人: "吕超" <[email protected]>
抄送: petsc-users <[email protected]>
主题: Re: [petsc-users] petsc malloc multidimensional array
On Tue, Mar 11, 2014 at 8:37 AM, 吕超 <[email protected]> wrote:
Hi, recently,when I use PETSc to bulid 2d arrays such as PetscScalar
A[512][512],B[512][512],C,D,E,F,..., program always has error of Segmentation
Violation. So I want to use PetscMalloc to bulid 2d array, and I hope that I
can also use these 2d array A[i][j] by subscripts as before. Could do please
tell me how can I do? Thank you.
1) This is a C question, not a PETSc question
2) If you are using 2D arrays for fields, you should be using the DMDA, which
has a section in the manual
Thanks,
Matt
LV CHAO
2014/3/11
--
What most experimenters take for granted before they begin their experiments is
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener