petsc-3.7.1 2016-05-15
Report Typos and Errors

MatSetValuesBlockedStencil

Inserts or adds a block of values into a matrix. Using structured grid indexing

Synopsis

#include "petscmat.h" 
PetscErrorCode MatSetValuesBlockedStencil(Mat mat,PetscInt m,const MatStencil idxm[],PetscInt n,const MatStencil idxn[],const PetscScalar v[],InsertMode addv)
Not Collective Many br

Input Parameters

mat - the matrix Many br
m - number of rows being entered Many br
idxm - grid coordinates for matrix rows being entered Many br
n - number of columns being entered Many br
idxn - grid coordinates for matrix columns being entered Many br
v - a logically two-dimensional array of values 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

Notes

By default the values, v, are row-oriented and unsorted. Many brSee MatSetOption() for other options. Many br

Calls to MatSetValuesBlockedStencil() with the INSERT_VALUES and ADD_VALUES Many broptions cannot be mixed without intervening calls to the assembly Many brroutines. Many br

The grid coordinates are across the entire grid, not just the local portion Many br

MatSetValuesBlockedStencil() uses 0-based row and column numbers in Fortran Many bras well as in C. Many br

For setting/accessing vector values via array coordinates you can use the DMDAVecGetArray() routine Many br

In order to use this routine you must either obtain the matrix with DMCreateMatrix() Many bror call MatSetBlockSize(), MatSetLocalToGlobalMapping() and MatSetStencil() first. Many br

The columns and rows in the stencil passed in MUST be contained within the Many brghost region of the given process as set with DMDACreateXXX() or MatSetStencil(). For example, Many brif you create a DMDA with an overlap of one grid level and on a particular process its first Many brlocal nonghost x logical coordinate is 6 (so its first ghost x logical coordinate is 5) the Many brfirst i index you can use in your column and row indices in MatSetStencil() is 5. Many br

In Fortran idxm and idxn should be declared as Many br

    MatStencil idxm(4,m),idxn(4,n)
and the values inserted using Many br
   idxm(MatStencil_i,1) = i
   idxm(MatStencil_j,1) = j
   idxm(MatStencil_k,1) = k
etc 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

Inspired by the structured grid interface to the HYPRE package Many br(http://www.llnl.gov/CASC/hypre) Many br

Many br

See Also

MatSetOption(), MatAssemblyBegin(), MatAssemblyEnd(), MatSetValuesBlocked(), MatSetValuesLocal()
MatSetValues(), MatSetValuesStencil(), MatSetStencil(), DMCreateMatrix(), DMDAVecGetArray(), MatStencil, Many brMatSetBlockSize(), MatSetLocalToGlobalMapping() Many br

Level:beginner
Location:
src/mat/interface/matrix.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/snes/examples/tutorials/ex48.c.html