@@ -618,11 +618,16 @@ def _init_monolithic(self):
618618 rset , cset = self .sparsity .dsets
619619 rlgmap = rset .unblocked_lgmap
620620 clgmap = cset .unblocked_lgmap
621- mat .createAIJ (size = ((self .nrows , None ), (self .ncols , None )),
622- nnz = (self .sparsity .nnz , self .sparsity .onnz ),
623- bsize = 1 ,
624- comm = self .comm )
621+ if self .mat_type == "is" :
622+ create = mat .createIS
623+ elif self .mat_type .endswith ("aij" ):
624+ create = mat .createAIJ
625+ else :
626+ raise ValueError (f"Unsupported mat_type { mat_type } " )
627+ size = ((self .nrows , None ), (self .ncols , None ))
628+ create (size , bsize = 1 , comm = self .comm )
625629 mat .setLGMap (rmap = rlgmap , cmap = clgmap )
630+ mat .setPreallocationNNZ ((self .sparsity .nnz , self .sparsity .onnzi ))
626631 self .handle = mat
627632 self ._blocks = []
628633 rows , cols = self .sparsity .shape
@@ -685,7 +690,10 @@ def _init_block(self):
685690 col_lg = cset .lgmap
686691 rdim , cdim = self .dims [0 ][0 ]
687692
688- if rdim == cdim and rdim > 1 and self .sparsity ._block_sparse :
693+ if self .mat_type == "is" :
694+ block_sparse = False
695+ create = mat .createIS
696+ elif rdim == cdim and rdim > 1 and self .sparsity ._block_sparse :
689697 # Size is total number of rows and columns, but the
690698 # /sparsity/ is the block sparsity.
691699 block_sparse = True
@@ -697,10 +705,10 @@ def _init_block(self):
697705 create = mat .createAIJ
698706 create (size = ((self .nrows , None ),
699707 (self .ncols , None )),
700- nnz = (self .sparsity .nnz , self .sparsity .onnz ),
701708 bsize = (rdim , cdim ),
702709 comm = self .comm )
703710 mat .setLGMap (rmap = row_lg , cmap = col_lg )
711+ mat .setPreallocationNNZ ((self .sparsity .nnz , self .sparsity .onnz ))
704712 # Stash entries destined for other processors
705713 mat .setOption (mat .Option .IGNORE_OFF_PROC_ENTRIES , False )
706714 # Any add or insertion that would generate a new entry that has not
@@ -716,7 +724,8 @@ def _init_block(self):
716724 mat .setOption (mat .Option .KEEP_NONZERO_PATTERN , True )
717725 # We completely fill the allocated matrix when zeroing the
718726 # entries, so raise an error if we "missed" one.
719- mat .setOption (mat .Option .UNUSED_NONZERO_LOCATION_ERR , True )
727+ if self .mat_type != "is" :
728+ mat .setOption (mat .Option .UNUSED_NONZERO_LOCATION_ERR , True )
720729 # Put zeros in all the places we might eventually put a value.
721730 with profiling .timed_region ("MatZeroInitial" ):
722731 sparsity .fill_with_zeros (mat , self .sparsity .dims [0 ][0 ],
0 commit comments