[petsc-users] Set matrix column to vector

Lawrence Mitchell lawrence.mitchell at imperial.ac.uk
Tue Sep 2 03:55:44 CDT 2014

On 02/09/14 09:41, Florian Lindner wrote:
> Am 01.09.2014 16:11, schrieb Matthew Knepley:
>> I recommend running using the debugger so you can get a stack trace, and
>> perhaps see
>> exactly what the problem is. You can also run under valgrind as the error
>> says.
> This of course I tried, but had no real success. It crashes in
> ISLocalToGlobalMappingApply, on the first line: PetscInt i,bs =
> mapping->bs,Nmax = bs*mapping->n;
> It crashes only when using MatSetValuesLocal, not when using MatSetValues.
> I've created an example that compiles just fine:
> http://pastebin.com/iEkLK9DZ

You never create a local to global mapping and set it on the matrix, so
that mapping is NULL inside ISLocalToGlobalMappingApply.

You need to do something like:

ISLocalToGlobalMappingCreate(..., &rmapping);
ISLocalToGlobalMappingCreate(..., &cmapping);

MatSetLocalToGlobalMapping(mat, rmapping, cmapping);

Then you can use MatSetValuesLocal.



More information about the petsc-users mailing list