[petsc-users] about MatTranspose

Likun Tan likunt at andrew.cmu.edu
Wed Aug 31 13:02:52 CDT 2011


The error is Segmentation Violation, i think this is because  when i
generate matrix B, i use the part of the 3D array that is not in the same
processor as B.

Each column of B only depends on the values in the corresponding z
direction of the 3D array. That is to say, the Kth column of B only
requires the data Array[i][j][K] for all i and j. Theoretically if i split
the matirx B in 2 processors by column and the 3D array in 2 processors in
z direction, the evaluation of B is compatible.

However, when i implemented the following code, it gives segmentation
violation error:

PetscInt petn=PETSC_DECIDE;
PetscSplitOwnership(PETSC_COMM_WORLD, &petn, &N);
MatCreateSeqDense(PETSC_COMM_SELF, M, petn, PETSC_NULL, &B);
DACreate3d(PETSC_COMM_WORLD, DA_NONPERIODIC, DA_STENCIL_STAR, M, P, N, 1,
1, petn, 1, 0, PETSC_NULL, PETSC_NULL, &da3D);
//set values to da3D with
DAGetCorners(da3D, &xs, &ys, &zs, &m, &n, &p)
DAVecGetArray()...
//Set values to B with
for(k=0, k<P, k++)
{
   for(j=0; j<N; j++)
   {
      for(i=0; i<M; i++)
      {
         a=node[i][j];   //i and j are local number of element and node
         MatSetValues(B, 1, &a, 1, &k, &Value, ADD_VALUES); //the Value
depends on the 3D array
      }
    }
}


On Wed, August 31, 2011 1:45 pm, Jed Brown wrote:
> On Wed, Aug 31, 2011 at 12:31, Likun Tan <likunt at andrew.cmu.edu> wrote:
>
>
>> Thank you very much.
>>
>>
>> I implemented the following, but it seems not working:
>>
>>
>
> "not working" isn't very helpful. What exactly did you try, what did you
> expect, and what happened (paste full error messages)?
>






More information about the petsc-users mailing list