Re: [petsc-users] How to efficiently represent a diagonal matrix?

2018-02-14 Thread Smith, Barry F.

  Fande,

I think you should just use AIJ, all the algorithms MatMult, MatFactor, 
MatSolve when the matrix is diagonal are order n work with a relatively small 
constant, and the overhead of using AIJ instead of a custom format is probably 
at most a factor of three  and since work is order n and it is a small constant 
any gain would be lost in the much bigger constants for the rest of the 
computation. 

   Barry

I know Rich doesn't have unlimited money and suspect spending it on almost 
anything else (like improving the load balancing in libMesh) will pay off far 
far more.


> On Feb 14, 2018, at 8:29 PM, Jed Brown  wrote:
> 
> Fande Kong  writes:
> 
>> On Wed, Feb 14, 2018 at 4:35 PM, Smith, Barry F.  wrote:
>> 
>>> 
>>>  What are you doing with the matrix?
>>> 
>> 
>> We are doing an explicit method. PDEs are discretized using a finite
>> element method, so there is a mass matrix. The mass matrix will be lumped,
>> and it becomes diagonal. We want to compute the inverse of the lumped
>> matrix, and also do a few of matrix-vector multiplications using  the
>> lumped matrix or  its inverse.
>> 
>> The specific implementation won't make this more efficient?
> 
> You can use pretty much any representation and you won't notice the time
> because you still have to apply the RHS operator and that is vastly more
> expensive.



Re: [petsc-users] How to efficiently represent a diagonal matrix?

2018-02-14 Thread Jed Brown
Fande Kong  writes:

> On Wed, Feb 14, 2018 at 4:35 PM, Smith, Barry F.  wrote:
>
>>
>>   What are you doing with the matrix?
>>
>
> We are doing an explicit method. PDEs are discretized using a finite
> element method, so there is a mass matrix. The mass matrix will be lumped,
> and it becomes diagonal. We want to compute the inverse of the lumped
> matrix, and also do a few of matrix-vector multiplications using  the
> lumped matrix or  its inverse.
>
> The specific implementation won't make this more efficient?

You can use pretty much any representation and you won't notice the time
because you still have to apply the RHS operator and that is vastly more
expensive.


Re: [petsc-users] How to efficiently represent a diagonal matrix?

2018-02-14 Thread Matthew Knepley
On Wed, Feb 14, 2018 at 7:11 PM, Fande Kong  wrote:

> On Wed, Feb 14, 2018 at 4:35 PM, Smith, Barry F. 
> wrote:
>
>>
>>   What are you doing with the matrix?
>>
>
> We are doing an explicit method. PDEs are discretized using a finite
> element method, so there is a mass matrix. The mass matrix will be lumped,
> and it becomes diagonal. We want to compute the inverse of the lumped
> matrix, and also do a few of matrix-vector multiplications using  the
> lumped matrix or  its inverse.
>
> The specific implementation won't make this more efficient?
>

I am doing this for Pylith. I think you should just do Vec operations, and
pull the inverse mass matrix to the rhs.

   Matt


> Fande,
>
>
>>
>>   We don't have a diagonal matrix but it would be easy to add such a
>> beast if it was performance critical, which it probably isn't.
>>
>>   Barry
>>
>>
>>
>>
>> > On Feb 14, 2018, at 3:57 PM, Fande Kong  wrote:
>> >
>> > Hi All,
>> >
>> > If  a matrix is always diagonal, what a good way to represent the
>> matrix?  Still MPIAIJ, MPIBAIJ? Can we have a specific implementation for
>> this?
>> >
>> >
>> > Fande,
>>
>>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ 


Re: [petsc-users] How to efficiently represent a diagonal matrix?

2018-02-14 Thread Fande Kong
On Wed, Feb 14, 2018 at 4:35 PM, Smith, Barry F.  wrote:

>
>   What are you doing with the matrix?
>

We are doing an explicit method. PDEs are discretized using a finite
element method, so there is a mass matrix. The mass matrix will be lumped,
and it becomes diagonal. We want to compute the inverse of the lumped
matrix, and also do a few of matrix-vector multiplications using  the
lumped matrix or  its inverse.

The specific implementation won't make this more efficient?


Fande,


>
>   We don't have a diagonal matrix but it would be easy to add such a beast
> if it was performance critical, which it probably isn't.
>
>   Barry
>
>
>
>
> > On Feb 14, 2018, at 3:57 PM, Fande Kong  wrote:
> >
> > Hi All,
> >
> > If  a matrix is always diagonal, what a good way to represent the
> matrix?  Still MPIAIJ, MPIBAIJ? Can we have a specific implementation for
> this?
> >
> >
> > Fande,
>
>


Re: [petsc-users] How to efficiently represent a diagonal matrix?

2018-02-14 Thread Smith, Barry F.

  What are you doing with the matrix?

  We don't have a diagonal matrix but it would be easy to add such a beast if 
it was performance critical, which it probably isn't.

  Barry




> On Feb 14, 2018, at 3:57 PM, Fande Kong  wrote:
> 
> Hi All,
> 
> If  a matrix is always diagonal, what a good way to represent the matrix?  
> Still MPIAIJ, MPIBAIJ? Can we have a specific implementation for this?
> 
> 
> Fande,



[petsc-users] How to efficiently represent a diagonal matrix?

2018-02-14 Thread Fande Kong
Hi All,

If  a matrix is always diagonal, what a good way to represent the matrix?
Still MPIAIJ, MPIBAIJ? Can we have a specific implementation for this?


Fande,