<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Barry,</div><div><br class=""></div><div>So adding the call to MatSetBlockSize to the preallocator does fix the error, but that is not necessary if I simply replace the call to MatPreallocaterPreallocate with a call to MatMPIAIJSetPreallocation.</div><div><br class=""></div><div>And it’s confusing to me especially in light of this exchange a couple months ago about block sizes:</div><div><br class=""></div><div><a href="https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2022-May/046094.html" class="">https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2022-May/046094.html</a></div><div><br class=""></div><div>Honestly it’s not very clear why in one case I need to explicitly set the block size (when using the MatPreallocator) but not in the other case.</div><div><br class=""></div><div>Thanks,</div><div><br class=""></div><div>Randy</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2022, at 2:36 PM, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""> <div class=""> 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.</div><div class=""><br class=""></div><div class=""> 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.</div><div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2022, at 5:33 PM, Randall Mackie <<a href="mailto:rlmackie862@gmail.com" class="">rlmackie862@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Why do I have to set the block size to 3? I’m not trying to create a block matrix.<div class=""><br class=""><div class=""><div class="">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:</div><div class=""><br class=""></div><div class=""><a href="https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2022-May/046094.html" class="">https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2022-May/046094.html</a></div><div class=""><br class=""></div><div class="">This works fine without the MatPreallocator routines.</div><div class=""><br class=""></div><div class="">Randy</div><div class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2022, at 2:23 PM, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> I'm hoping that it is as simple as that you did not set the block size of your newly created matrix to 3?<div class=""><br class=""></div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2022, at 4:04 PM, Randall Mackie <<a href="mailto:rlmackie862@gmail.com" class="">rlmackie862@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Barry,<div class=""><br class=""></div><div class="">It seems like this should be trivial to get working but so far I’ve been unsuccessful.</div><div class="">Most likely I’m doing something wrong but I have no idea what that is.</div><div class=""><br class=""></div><div class="">I’ve attached a little test program that fails with the errors:</div><div class=""><br class=""></div><div class=""><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: Petsc has generated inconsistent data<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: Blocksize of layout 1 must match that of mapping 3 (or the latter must be 1)<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: See <a href="https://petsc.org/release/faq/" style="color: rgb(5, 99, 193);" class="">https://petsc.org/release/faq/</a> for trouble shooting.<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: Petsc Release Version 3.17.3, Jun 29, 2022<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: ./test on a linux-gfortran-complex-debug named rmackie-VirtualBox by rmackie Fri Jul 29 12:16:13 2022<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[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<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: #1 PetscLayoutSetISLocalToGlobalMapping() at /home/rmackie/PETSc/petsc-3.17.3/src/vec/is/utils/pmap.c:363<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[0]PETSC ERROR: #2 MatSetLocalToGlobalMapping() at /home/rmackie/PETSc/petsc-3.17.3/src/mat/interface/matrix.c:2012</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Any help to point me in the right direction is appreciated.</div><div class=""><br class=""></div><div class="">Randy M.</div><div class=""><br class=""></div><div class=""></div></div></div></div><span id="cid:EA81F18D-811D-46DA-9855-9011D4624359" class=""><files.zip></span><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><div class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jul 28, 2022, at 2:49 PM, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""> 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.<br class=""><br class=""> Barry<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Jul 28, 2022, at 5:41 PM, Randall Mackie <<a href="mailto:rlmackie862@gmail.com" class="">rlmackie862@gmail.com</a>> wrote:<br class=""><br class="">Dear PETSc users:<br class=""><br class="">Can one use a MatPreallocator and then call MatPreAlloctorPreallocate if using MatStencil routines (which seem to call MatSetValuesLocal).<br class=""><br class=""><br class="">Thanks, Randy<br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>