[Dune-devel] Fwd: [Dune-Commit] [Commit] dune-grid - 800aa47: Introduce methods 'index' and 'subIndex' to eventually replace 'map' and 'map'
Tobias Malkmus
tomalk at mathematik.uni-freiburg.de
Tue Dec 2 09:46:35 CET 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Oli
For the UniversalMapper the patch created a conflict between the new
index method and the class internal member std::map< IdType, Index >
index.
Best Tobias
- -------- Forwarded Message --------
Subject: [Dune-Commit] [Commit] dune-grid - 800aa47: Introduce methods
'index' and 'subIndex' to eventually replace 'map' and 'map'
Date: Fri, 28 Nov 2014 20:44:38 +0100
From: Oliver Sander <sander at igpm.rwth-aachen.de>
Reply-To: dune-devel at dune-project.org
To: dune-commit at dune-project.org
New commit, appeared at Fri Nov 28 20:44:38 2014 +0100
as part of the following ref changes:
branch refs/heads/master updated from 50a9946 -> 800aa47
Browsable version:
http://cgit.dune-project.org/repositories/dune-grid/commit/?id=800aa47409c662bedb62b38e307525c6866cde5e
======================================================================
commit 800aa47409c662bedb62b38e307525c6866cde5e
Author: Oliver Sander <sander at igpm.rwth-aachen.de>
Date: Fri Nov 28 20:42:49 2014 +0100
Introduce methods 'index' and 'subIndex' to eventually replace
'map' and 'map'
At the 2014 dev meeting in Berlin it was decided that the method
'map' of
the Mapper classes should be renamed to 'index' and 'subIndex',
respectively,
to be more consistent with the IndexSet interface. This patch
does the
renaming. The old methods are still there, but they are now marked as
deprecated.
dune/grid/common/mapper.hh | 36
++++++++++++++++++++++++++++++----
dune/grid/common/mcmgmapper.hh | 33 +++++++++++++++++++++++++++++--
dune/grid/common/scsgmapper.hh | 31 +++++++++++++++++++++++++++--
dune/grid/common/universalmapper.hh | 39
+++++++++++++++++++++++++++++++++++--
4 files changed, 129 insertions(+), 10 deletions(-)
diff --git a/dune/grid/common/mapper.hh b/dune/grid/common/mapper.hh
index e4f70fb..ebec4f6 100644
- --- a/dune/grid/common/mapper.hh
+++ b/dune/grid/common/mapper.hh
@@ -64,11 +64,11 @@
This interface is implemented by the class template Dune::Mapper.
For a full documentation see the
description of this class.
- - The function Dune::Mapper::map delivers the index for an entity.
Note that that for
+ The function Dune::Mapper::index delivers the index for an entity.
Note that that for
performance reasons it is usually not checked whether the entity
is really in the
entity set.
- - The functions Dune::Mapper::map delivers the index for a (sub-)entity
+ The functions Dune::Mapper::index delivers the index for a
(sub-)entity
The function Dune::Mapper::size returns the size of the entity
set, i.e. \f$|E^\prime|\f$
@@ -116,13 +116,26 @@ namespace Dune
\return An index in the range 0 ... Max number of
entities in set - 1.
*/
template<class EntityType>
- - Index map (const EntityType& e) const
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'index' instead!") map (const EntityType& e) const
{
CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
return asImp().map(e);
}
+ /** @brief Map entity to array index.
+
+ \param e Reference to codim cc entity. The codim is
extracted from the entity.
+ \return An index in the range 0 ... Max number of
entities in set - 1.
+ */
+ template<class EntityType>
+ Index index (const EntityType& e) const
+ {
+ CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
+ return asImp().index(e);
+ }
+
+
/** @brief Map subentity i of codim cc of a codim 0 entity to
array index.
*
* \param e Reference to codim 0 entity.
@@ -130,7 +143,7 @@ namespace Dune
* \param codim codimension of subentity of e
* \return An index in the range 0 ... Max number of entities in
set - 1.
*/
- - Index map (const typename G::Traits::template Codim<0>::Entity& e,
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'index' instead!") map (const typename G::Traits::template
Codim<0>::Entity& e,
int i,
unsigned int codim) const
{
@@ -138,6 +151,21 @@ namespace Dune
return asImp().map(e,i,codim);
}
+ /** @brief Map subentity i of codim cc of a codim 0 entity to
array index.
+ *
+ * \param e Reference to codim 0 entity.
+ * \param i Number of codim cc subentity of e, where cc is the
template parameter of the function.
+ * \param codim codimension of subentity of e
+ * \return An index in the range 0 ... Max number of entities in
set - 1.
+ */
+ Index subIndex (const typename G::Traits::template
Codim<0>::Entity& e,
+ int i,
+ unsigned int codim) const
+ {
+ CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e,i,codim)));
+ return asImp().subIndex(e,i,codim);
+ }
+
/** @brief Return total number of entities in the entity set
managed by the mapper.
This number can be used to allocate a vector of data elements
associated with the
diff --git a/dune/grid/common/mcmgmapper.hh
b/dune/grid/common/mcmgmapper.hh
index f1de3c6..bd13336 100644
- --- a/dune/grid/common/mcmgmapper.hh
+++ b/dune/grid/common/mcmgmapper.hh
@@ -144,13 +144,42 @@ namespace Dune
* \return An index in the range 0 ... Max number of entities in
set - 1.
*/
template<class EntityType>
- - Index map (const EntityType& e) const
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'index' instead!") map (const EntityType& e) const
{
const GeometryType gt = e.type();
assert(layout.contains(gt));
return is.index(e) + offset[GlobalGeometryTypeIndex::index(gt)];
}
+ /*!
+ * \brief Map entity to array index.
+ *
+ * \tparam EntityType
+ * \param e Reference to codim \a EntityType entity.
+ * \return An index in the range 0 ... Max number of entities in
set - 1.
+ */
+ template<class EntityType>
+ Index index (const EntityType& e) const
+ {
+ const GeometryType gt = e.type();
+ assert(layout.contains(gt));
+ return is.index(e) + offset[GlobalGeometryTypeIndex::index(gt)];
+ }
+
+ /** @brief Map subentity of codim 0 entity to array index.
+
+ \param e Reference to codim 0 entity.
+ \param i Number of subentity of e
+ \param codim Codimension of the subentity
+ \return An index in the range 0 ... Max number of entities in
set - 1.
+ */
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'index' instead!") map (const typename GV::template
Codim<0>::Entity& e, int i, unsigned int codim) const
+ {
+ GeometryType
gt=ReferenceElements<double,GV::dimension>::general(e.type()).type(i,codim);
+ assert(layout.contains(gt));
+ return is.subIndex(e, i, codim) +
offset[GlobalGeometryTypeIndex::index(gt)];
+ }
+
/** @brief Map subentity of codim 0 entity to array index.
\param e Reference to codim 0 entity.
@@ -158,7 +187,7 @@ namespace Dune
\param codim Codimension of the subentity
\return An index in the range 0 ... Max number of entities in
set - 1.
*/
- - Index map (const typename GV::template Codim<0>::Entity& e, int
i, unsigned int codim) const
+ Index subIndex (const typename GV::template Codim<0>::Entity& e,
int i, unsigned int codim) const
{
GeometryType
gt=ReferenceElements<double,GV::dimension>::general(e.type()).type(i,codim);
assert(layout.contains(gt));
diff --git a/dune/grid/common/scsgmapper.hh
b/dune/grid/common/scsgmapper.hh
index baef39c..b0a70de 100644
- --- a/dune/grid/common/scsgmapper.hh
+++ b/dune/grid/common/scsgmapper.hh
@@ -61,12 +61,39 @@ namespace Dune
\return An index in the range 0 ... Max number of
entities in set - 1.
*/
template<class EntityType>
- - Index map (const EntityType& e) const
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'index' instead!") map (const EntityType& e) const
{
static_assert(EntityType::codimension == c, "Entity of wrong
codim passed to SingleCodimSingleGeomTypeMapper");
return is.index(e);
}
+ /** @brief Map entity to array index.
+
+ \param e Reference to codim cc entity, where cc is the
template parameter of the function.
+ \return An index in the range 0 ... Max number of
entities in set - 1.
+ */
+ template<class EntityType>
+ Index index (const EntityType& e) const
+ {
+ static_assert(EntityType::codimension == c, "Entity of wrong
codim passed to SingleCodimSingleGeomTypeMapper");
+ return is.index(e);
+ }
+
+ /** @brief Map subentity of codim 0 entity to array index.
+
+ \param e Reference to codim 0 entity.
+ \param i Number of the subentity of e, where cc is the
template parameter of the function.
+ \param codim Codimension of the subentity of e
+ \return An index in the range 0 ... Max number of entities in
set - 1.
+ */
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'subIndex' instead!") map (const typename GV::template
Codim<0>::Entity& e,
+ int i, unsigned int codim) const
+ {
+ if (codim != c)
+ DUNE_THROW(GridError, "Id of wrong codim requested from
SingleCodimSingleGeomTypeMapper");
+ return is.subIndex(e,i,codim);
+ }
+
/** @brief Map subentity of codim 0 entity to array index.
\param e Reference to codim 0 entity.
@@ -74,7 +101,7 @@ namespace Dune
\param codim Codimension of the subentity of e
\return An index in the range 0 ... Max number of entities in
set - 1.
*/
- - Index map (const typename GV::template Codim<0>::Entity& e,
+ Index subIndex (const typename GV::template Codim<0>::Entity& e,
int i, unsigned int codim) const
{
if (codim != c)
diff --git a/dune/grid/common/universalmapper.hh
b/dune/grid/common/universalmapper.hh
index 35cdbda..e0c82ba 100644
- --- a/dune/grid/common/universalmapper.hh
+++ b/dune/grid/common/universalmapper.hh
@@ -62,7 +62,7 @@ namespace Dune
\return An index in the range 0 ... Max number of
entities in set - 1.
*/
template<class EntityType>
- - Index map (const EntityType& e) const
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'index' instead!") map (const EntityType& e) const
{
IdType id = ids.id(e); // get id
typename std::map<IdType,Index>::iterator it = index.find(id);
// look up in map
@@ -71,6 +71,41 @@ namespace Dune
return n-1; // and
return it
}
+ /** @brief Map entity to array index.
+
+ If an entity is queried with map, the known index is returned
or a new index is created. A call to map can never fail.
+
+ \param e Reference to codim cc entity, where cc is the
template parameter of the function.
+ \return An index in the range 0 ... Max number of
entities in set - 1.
+ */
+ template<class EntityType>
+ Index index (const EntityType& e) const
+ {
+ IdType id = ids.id(e); // get id
+ typename std::map<IdType,Index>::iterator it = index.find(id);
// look up in map
+ if (it!=index.end()) return it->second; //
return index if found
+ index[id] = n++; // put
next index in map
+ return n-1; // and
return it
+ }
+
+
+ /** @brief Map subentity of codim 0 entity to array index.
+
+ If an entity is queried with map, the known index is returned
or a new index is created. A call to map can never fail.
+
+ \param e Reference to codim 0 entity.
+ \param i Number of codim cc subentity of e, where cc is the
template parameter of the function.
+ \param cc codim of the subentity
+ \return An index in the range 0 ... Max number of entities in
set - 1.
+ */
+ Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4.
Use method 'subIndex' instead!") map (const typename
G::Traits::template Codim<0>::Entity& e, int i, int cc) const
+ {
+ IdType id = ids.subId(e,i,cc); // get id
+ typename std::map<IdType,Index>::iterator it = index.find(id);
// look up in map
+ if (it!=index.end()) return it->second; //
return index if found
+ index[id] = n++; // put
next index in map
+ return n-1; // and
return it
+ }
/** @brief Map subentity of codim 0 entity to array index.
@@ -81,7 +116,7 @@ namespace Dune
\param cc codim of the subentity
\return An index in the range 0 ... Max number of entities in
set - 1.
*/
- - Index map (const typename G::Traits::template Codim<0>::Entity&
e, int i, int cc) const
+ Index subIndex (const typename G::Traits::template
Codim<0>::Entity& e, int i, int cc) const
{
IdType id = ids.subId(e,i,cc); // get id
typename std::map<IdType,Index>::iterator it = index.find(id);
// look up in map
_______________________________________________
Dune-Commit mailing list
Dune-Commit at dune-project.org
http://lists.dune-project.org/mailman/listinfo/dune-commit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBAgAGBQJUfXxrAAoJEBMY7DHvcWNglHIH/RLK/+RHurNHTSIScWCggpLT
l2IcH8LIfNjQbuYxnt6OlCcmWBDxcs0v5583nQGwZ13RPRSZAI2DvQ1uRc87znDB
lr0xwhNiz7cnt9pHKDELHW+lmNaw4v/STD61i1h7N8CsxyWB02gr/YaZmAw3TbtS
tqZHxXutiUCFZqqpjDBBVpbepSSswA3g/RsyOuYHA1Gph5EI0WUswPmazHBC+Moj
vppFFkjwm6Ig5FzWLaNmBZVF5OnkR0Vx0vM4fG1GIDQc2a1JjEZarNe+Cihu6YYV
qf2ZUfF6AXg1BVscRE/phdzGa2yYu2JhRLyTZcelRiJ+j0IExI8fUcmeegXllsY=
=dAV4
-----END PGP SIGNATURE-----
More information about the Dune-devel
mailing list