[Trilinos-Users] Tpetra::Map copy constructor?

Chris Baker cgbaker at gmail.com
Mon Oct 12 19:30:04 MDT 2009


Hi Nico. In Epetra and in the previous design of Tpetra, a Map was a
value-type object, containing a reference counted pointer to the Map's data.
Therefore, a copy of a Map was effectively a copy of a pointer to the
underlying data. There were two problems with this approach. The first is
that it made it difficult to enforce const correctness of the Map class. The
second is that it wasn't clear without looking at the source what was a copy
of a Map.

Before the Trilinos 10.0 release, we decided to change Map and the other
Tpetra classes to be a little more straightforward, following the approach
of the Thyra package. Under this design, a copy of a Map is done by having
multiple pointers to the Map. This is effectively what happened before (and
in Epetra); now it is made explicit. Therefore, the preferred way of dealing
with Maps is to dynamically allocate them and store the resulting object in
a Teuchos::RCP (reference-counted pointer). Note, for this reason, most of
the classes in Tpetra utilizing a Map now accept an RCP to a Map instead of
a reference (see, e.g., the MultiVector constructors). There is no support
for making a deep-copy of a Map. This is currently okay, because there is
currently no use case for having multiple copies of two identical Maps, as
they are read-only objects and can (in some cases) be quite memory
intensive.

I hope this helps. For an example of dynamically allocating and
RCP-encapsulating a Tpetra::Map, please see the Tpetra Power method example
in packages/tpetra/example/PowerMethod/Tpetra_Power_Method.cpp (approx. line
90).

Best regards,
Chris

On Mon, Oct 12, 2009 at 15:47, Nico Schlömer <nico.schloemer at ua.ac.be>wrote:

> Hi,
>
> I just noticed that the copy constructor for Tpetra::Map's has gone on
> Trilinos 10.0 -- did that happen on purpose? What's the preferred way of
> copying maps if so?
>
> Cheers,
> Nico
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20091012/493462c9/attachment.html 


More information about the Trilinos-Users mailing list