Because you create the DMDA with a dof of 3, this triggers any matrices it 
creates and the localtoglobalmapping object it creates to have a block size of 
three. The error you are seeing is that a localtoglobal with a block size of 3 
cannot be attached to a matrix with a block size of 1.

  The "block size" of 3 for the localtoglobalmapping does not have a lot of 
meaning but it is used to optimize the storage and application of global to 
local mappings.

  Barry


> On Jul 29, 2022, at 5:33 PM, Randall Mackie <rlmackie...@gmail.com> wrote:
> 
> Why do I have to set the block size to 3? I’m not trying to create a block 
> matrix.
> 
> In fact just a couple months ago I was told I don’t have block matrices and I 
> had to remove calls to set the block size:
> 
> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2022-May/046094.html 
> <https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2022-May/046094.html>
> 
> This works fine without the MatPreallocator routines.
> 
> Randy
> 
>> On Jul 29, 2022, at 2:23 PM, Barry Smith <bsm...@petsc.dev 
>> <mailto:bsm...@petsc.dev>> wrote:
>> 
>> 
>>   I'm hoping that it is as simple as that you did not set the block size of 
>> your newly created matrix to 3?
>> 
>> 
>> 
>>> On Jul 29, 2022, at 4:04 PM, Randall Mackie <rlmackie...@gmail.com 
>>> <mailto:rlmackie...@gmail.com>> wrote:
>>> 
>>> Hi Barry,
>>> 
>>> It seems like this should be trivial to get working but so far I’ve been 
>>> unsuccessful.
>>> Most likely I’m doing something wrong but I have no idea what that is.
>>> 
>>> I’ve attached a little test program that fails with the errors:
>>> 
>>> [0]PETSC ERROR: --------------------- Error Message 
>>> --------------------------------------------------------------
>>> [0]PETSC ERROR: Petsc has generated inconsistent data
>>> [0]PETSC ERROR: Blocksize of layout 1 must match that of mapping 3 (or the 
>>> latter must be 1)
>>> [0]PETSC ERROR: See https://petsc.org/release/faq/ 
>>> <https://petsc.org/release/faq/> for trouble shooting.
>>> [0]PETSC ERROR: Petsc Release Version 3.17.3, Jun 29, 2022
>>> [0]PETSC ERROR: ./test on a linux-gfortran-complex-debug named 
>>> rmackie-VirtualBox by rmackie Fri Jul 29 12:16:13 2022
>>> [0]PETSC ERROR: Configure options --with-clean=1 --with-scalar-type=complex 
>>> --with-debugging=1 --with-fortran=1 
>>> --download-mpich=../external/mpich-4.0.1.tar.gz
>>> [0]PETSC ERROR: #1 PetscLayoutSetISLocalToGlobalMapping() at 
>>> /home/rmackie/PETSc/petsc-3.17.3/src/vec/is/utils/pmap.c:363
>>> [0]PETSC ERROR: #2 MatSetLocalToGlobalMapping() at 
>>> /home/rmackie/PETSc/petsc-3.17.3/src/mat/interface/matrix.c:2012
>>> 
>>> 
>>> Any help to point me in the right direction is appreciated.
>>> 
>>> Randy M.
>>> 
>>> <files.zip>
>>> 
>>>> On Jul 28, 2022, at 2:49 PM, Barry Smith <bsm...@petsc.dev 
>>>> <mailto:bsm...@petsc.dev>> wrote:
>>>> 
>>>> 
>>>>   I am not sure what you are asking exactly but I think so, so long have 
>>>> you have called MatSetLocalToGlobalMapping() and the "stencil" idea makes 
>>>> sense for your discretization.
>>>> 
>>>>  Barry
>>>> 
>>>> 
>>>>> On Jul 28, 2022, at 5:41 PM, Randall Mackie <rlmackie...@gmail.com 
>>>>> <mailto:rlmackie...@gmail.com>> wrote:
>>>>> 
>>>>> Dear PETSc users:
>>>>> 
>>>>> Can one use a MatPreallocator and then call MatPreAlloctorPreallocate if 
>>>>> using MatStencil routines (which seem to call MatSetValuesLocal).
>>>>> 
>>>>> 
>>>>> Thanks, Randy
>>>> 
>>> 
>> 
> 

Reply via email to