[petsc-users] about MatTranspose

Likun Tan likunt at andrew.cmu.edu
Wed Aug 31 12:31:27 CDT 2011


Thank you very much.

I implemented the following, but it seems not working:
(I set np=2, basically i try to store the matrix B in 2 processors by
column and the 3D array in 2 processors in z direction, since the columns
are independent to one another)

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
      }
    }
}

Many thanks,
Likun


On Wed, August 31, 2011 11:14 am, Jed Brown wrote:
> On Wed, Aug 31, 2011 at 10:02, Likun Tan <likunt at andrew.cmu.edu> wrote:
>
>
>> MatCreateSeqDense(PETSC_COMM_SELF, M, M, PESTC_NULL, &A)
>>
>>
>
> yes
>
>
>> MatCreateMPIDense(PETSC_COMM_WORLD, PETSC_DECIDE, PETSC_DECIDE, M, N,
>> PETSC_NULL, &B)
>>
>>
>
> No, use MatCreateSeqDense() here too. Do you also need the result array
> on every process?
>
> PetscInt n = PETSC_DECIDE;
> PetscSplitOwnership(PETSC_COMM_WORLD,&n,&N);
> MatCreateSeqDense(PETSC_COMM_SELF,M,n,PETSC_NULL,&B);
>
>
> MatSetValues() //Set values to A and B
>
>> MatCholeskyFactor()// Factorization
>>
>>
>
> MatDuplicate(B,MAT_DO_NOT_COPY_VALUES,&X);
>
>
>
>> MatMatSolve()
>>
>>
>
>
>> The 3D array is generated before setting values to A and B. It comes
>> from some known function evaluation, an i need the array in every
>> process.
>>
>
> Okay, just do the same thing on every process, but only set the values
> into B for the part that will be done locally.
>
>






More information about the petsc-users mailing list