Matthew Knepley <[email protected]> writes:
>>  array = (PetscScalar**)malloc(sizeof(PetscScalar*) * dof);
>>  for (k = 0; k < dof; k++){
>>    array[k] = (PetscScalar*)malloc(sizeof(PetscScalar) * dof);
>>   }
>>
>> When I pass it to MatSetValuesBlocked() there is a problem. Either Petsc
>> complains because I am not passing it the right way or when it accepts it,
>> wrong data is passed because the solution is not correct. Maybe Petsc
>> expect dof*dof values and only dof are passed ?
>>
>
> You can only pass contiguous memory to MatSetValues().

And, while perhaps atypical, VecGetArray2D will give you contiguous
memory behind the scenes, so it would work in this case.  (Make a Vec of
the right size using COMM_SELF instead of malloc.)

With C99, you can use VLA pointers to get the "2D indexing" without
setting up explicit pointers.

Attachment: pgpmcHBugsP5D.pgp
Description: PGP signature

Reply via email to