PETSc sparsity

2007-06-15 Thread Toby Young
Hello petsc-users and petsc-dev. I am using PETSc to solve finite element problems. In particular I am working with the dealii package which has C++ wrappers designed to interface with PETSc. I am working on developing some of these wrappers. The difficulty I face is that, after applying bounda

PETSc sparsity

2007-06-15 Thread Mark Adams
Toby, If I understand you correctly, a trick we use for this is to use MatGetRow to get the sparcity pattern of each row (where you are applying BCs) and then create a vector of zeros and use MatSetValues using the *row* sparcity from MatGetRow and SET the *column* values with this vector

PETSc sparsity

2007-06-15 Thread Toby Young
> If I understand you correctly, a trick we use for this is to use > MatGetRow to get the sparcity pattern of each row (where you are > applying BCs) Neat trick. MatGetRow will give me the row of the matrix, so would then need a little loop to examine the elements and proceed as you suggested; a

PETSc sparsity

2007-06-15 Thread Mark Adams
> > Neat trick. MatGetRow will give me the row of the matrix, so would > then > need a little loop to examine the elements and proceed as you > suggested; > am I right? > There is probably more than one way to do this but you do NOT need to look at the elements (you can give PETSc a NULL arg

PETSc sparsity

2007-06-15 Thread Barry Smith
Toby, For Seq matrices you can call MatGetRowIJ() and it will give you exactly what you want. For MPI matrices the matrices are stored in two parts on each process (the "diagonal" part and the "off-diagonal" part) you can, of course, call the MatGetRowIJ() on each part but this is not exact

PETSc sparsity

2007-06-15 Thread Toby Young
Barry, Thank you for an interesting response. > For algorithms that require dealing with the sparsity structure of > the matrix we generally just include the appropriate private include file > for the matrix format and access the data directly in the underlying format. Can you please elabora

PETSc sparsity

2007-06-15 Thread Barry Smith
src/mat/impls/aij/seq/aij.h src/mat/impls/aij/mpi/mpiaij.h On Fri, 15 Jun 2007, Toby Young wrote: > > > Barry, > > Thank you for an interesting response. > > > For algorithms that require dealing with the sparsity structure of > > the matrix we generally just include the appropriate

PETSc sparsity

2007-06-15 Thread Mark Adams
Just a note, my way is much simpler - its two lines of code in a loop over the boundary nodes, followed by an MatAsseblyBegin/End, and you don't have to deal with parallel issues explicitly - PETSc does. For my FE codes the cost of this (dumb) way is negligible, PETSc implements these meth

PETSc sparsity

2007-06-15 Thread Matthew Knepley
Also, I have talked to Wolfgang many times about this. I am a firm believer in eliminating the boundary values during assembly at the element level. PETSc provides an easy mechanism for this. By default, all negative indices in calls to VecSetValues and MatSetValues are ignored. Matt On 6/15/07