#include "petscmat.h" PetscErrorCode MatSetValuesBlocked(Mat mat,PetscInt m,const PetscInt idxm[],PetscInt n,const PetscInt idxn[],const PetscScalar v[],InsertMode addv)Not Collective Many br
mat | - the matrix Many br | |
v | - a logically two-dimensional array of values Many br | |
m, idxm | - the number of block rows and their global block indices Many br | |
n, idxn | - the number of block columns and their global block indices Many br | |
addv | - either ADD_VALUES or INSERT_VALUES, where Many brADD_VALUES adds values to any existing entries, and Many brINSERT_VALUES replaces existing entries with new values Many br |
The m and n count the NUMBER of blocks in the row direction and column direction, Many brNOT the total number of rows/columns; for example, if the block size is 2 and Many bryou are passing in values for rows 2,3,4,5 then m would be 2 (not 4). Many brThe values in idxm would be 1 2; that is the first index for each block divided by Many brthe block size. Many br
Note that you must call MatSetBlockSize() when constructing this matrix (before Many brpreallocating it). Many br
By default the values, v, are row-oriented, so the layout of Many brv is the same as for MatSetValues(). See MatSetOption() for other options. Many br
Calls to MatSetValuesBlocked() with the INSERT_VALUES and ADD_VALUES Many broptions cannot be mixed without intervening calls to the assembly Many brroutines. Many br
MatSetValuesBlocked() uses 0-based row and column numbers in Fortran Many bras well as in C. Many br
Negative indices may be passed in idxm and idxn, these rows and columns are Many brsimply ignored. This allows easily inserting element stiffness matrices Many brwith homogeneous Dirchlet boundary conditions that you don't want represented Many brin the matrix. Many br
Each time an entry is set within a sparse matrix via MatSetValues(), Many brinternal searching must be done to determine where to place the the Many brdata in the matrix storage space. By instead inserting blocks of Many brentries via MatSetValuesBlocked(), the overhead of matrix assembly is Many brreduced. Many br
Suppose m=n=2 and block size(bs) = 2 The array is
1 2 | 3 4
5 6 | 7 8
- - - | - - -
9 10 | 11 12
13 14 | 15 16
v[] should be passed in like
v[] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
If you are not using row oriented storage of v (that is you called MatSetOption(mat,MAT_ROW_ORIENTED,PETSC_FALSE)) then
v[] = [1,5,9,13,2,6,10,14,3,7,11,15,4,8,12,16]
Many br
Level:intermediate
Location:src/mat/interface/matrix.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages