Epetra: What's the point of BlockMap?
Created by: bartgol
@trilinos/Epetra
Motivation and Context
This is more of a big picture view, but its consequences have sometimes bit me when implementing functions that take Epetra_Map&
as input. As I see it, Epetra_Map
is just a 'special case' of Epetra_BlockMap
, when all blocks have size one. It is useful to enforce this constraint at compile time, rather than check inside every constructor if that's the case. On the other hand, this code does not compile:
void f(const Epetra_Map& m) {...}
void g(const Epetra_Vector&v) { f(v.Map()); }
since the Map()
method returns a reference to Epetra_BlockMap
, and you would have to cast Epetra_BlockMap
down to Epetra_Map
before calling f
. Yes, this is possible, since Epetra_Map
does not store any additional attribute compared to Epetra_BlockMap
, but it is...ugly!
However, it appears to me that all Epetra classes use only Epetra_Map&
. All the matrices only accept and return Epetra_Map
. Even the vector and multivector, which formally take a Epetra_BlockMap
as input at construction, allocate enough space for Map().NumMyPoints()
doubles (per vector), which means they would be wrong if the element size is larger than one.
Or perhaps I am completely misunderstanding what Epetra_BlockMap
is intended to do.
Could someone shed some light on this? Or, if my impression is right, why shouldn't we completely remove the Epetra_BlockMap
(perhaps with a typedef for backward compatibility)?