[Dune] bug in topologytypes.hh ?

Jö Fahlke jorrit at jorrit.de
Wed Nov 26 15:21:25 CET 2014


Am Tue, 25. Nov 2014, 15:59:05 +0100 schrieb Matteo Semplice:
> Dear Duners,
>  I am implementing Jö's suggestion to specialize classes based on
> grid capabilities, but run into some troubles that look like a bug
> in dune-geometry... Basically the first code
> 
> typedef Dune :: GridSelector :: GridType G;
> bool cube = Dune::GenericGeometry::IsCube<
>                 Dune::GenericGeometry::Topology<
> Dune::Capabilities::hasSingleGeometryType<G>::topologyId,G::dimension
>                 >
>             >::value ;

Looking at the source code[1], it appears to me that the only public member of
"Topology<...>" is "type", which is constructed with the help of either
"Prism<...>" or "Pyramid<...>".  So AFAICT "Topology<...>" itself is not a
proper topology type, but just a way to contruct a topology type, which is
then accessible via its member type "type".  Only "Point", "Prism<...>" and
"Pyramid<...>" are proper topology types.  Thus you should be able to fix the
above code by adding a "::type":

  typedef Dune :: GridSelector :: GridType G;
  bool cube = Dune::GenericGeometry::IsCube<
    Dune::GenericGeometry::Topology<
      Dune::Capabilities::hasSingleGeometryType<G>::topologyId,
      G::dimension
    >::type
  >::value ;

Regards,
Jö.

[1] http://cgit.dune-project.org/repositories/dune-geometry/tree/dune/geometry/genericgeometry/topologytypes.hh?h=releases/2.3#n273

> does not compile. For example if G is OneDGrid, the gcc error message reads
> 
> In file included from /home/matteo/software/dune/dune-geometry/dune/geometry/genericgeometry/cornermapping.hh:6:0,
>                  from /home/matteo/software/dune/dune-geometry/dune/geometry/genericgeometry/geometrytraits.hh:8,
>                  from /home/matteo/software/dune/dune-geometry/dune/geometry/affinegeometry.hh:15,
>                  from /home/matteo/software/dune/dune-geometry/dune/geometry/referenceelements.hh:17,
>                  from
> /home/matteo/software/dune/dune-grid/dune/grid/common/geometry.hh:15,
>                  from
> /home/matteo/software/dune/dune-grid/dune/grid/common/grid.hh:1385,
>                  from
> /home/matteo/software/dune/dune-grid/dune/grid/onedgrid.hh:13,
>                  from ../config.h:787,
>                  from prova.cc:2:
> /home/matteo/software/dune/dune-geometry/dune/geometry/genericgeometry/topologytypes.hh:
> In instantiation of ‘const bool
> Dune::GenericGeometry::IsCube<Dune::GenericGeometry::Topology<1u,
> 1u> >::value’:
> prova.cc:12:7:   instantiated from here
> /home/matteo/software/dune/dune-geometry/dune/geometry/genericgeometry/topologytypes.hh:273:45:
> error: ‘const unsigned int Dune::GenericGeometry::Topology<1u,
> 1u>::dimension’ is private
> /home/matteo/software/dune/dune-geometry/dune/geometry/genericgeometry/topologytypes.hh:99:86:
> error: within this context
> /home/matteo/software/dune/dune-geometry/dune/geometry/genericgeometry/topologytypes.hh:99:86:
> error: ‘id’ is not a member of ‘Dune::GenericGeometry::Topology<1u,
> 1u>’
> prova.cc: In function ‘int main()’:
> 
> On the other hand, the other code suggested to me by Jö, i.e.
> 
> bool cube = (Dune::Capabilities::hasSingleGeometryType<G>::topologyId ==
>             Dune :: GenericGeometry :: CubeTopology< 2 > :: type :: id );
> 
> does work and is enough for my work.
> 
> Nevertheless, I thought I'd let you know... This is happening with
> release 2.3 from git.
> 
> Best,
>    Matteo
> 
> -------- Forwarded Message --------
> Subject: 	Re: [Dune] specializing template classes for Dune::Grid
> Date: 	Mon, 1 Sep 2014 23:14:22 +0200
> From: 	Jö Fahlke <jorrit at jorrit.de>
> To: 	Matteo Semplice <matteo.semplice at unito.it>, dune
> <dune at dune-project.org>
> 
> 
> 
> Am Mon,  1. Sep 2014, 23:01:03 +0200 schrieb Jö Fahlke:
> >The other specialization can be done like this:
> >
> >  template<class G>
> >  struct SomeClass<G, typename std::enable_if<
> >     G::dimension == 2 &&
> >     Dune::Capabilities::hasSingleGeometryType<G>::topologyId == topologyIdForQuad
> >  >::type>
> >  { /* specialization for dim==1 */ };
> 
> Oh, I forgot: The test for the topologyId is probably better written like this:
> 
>   template<class G>
>   struct SomeClass<G, typename std::enable_if<
>      G::dimension == 2 &&
>      Dune::GenericGeometry::IsCube<
>        Dune::GenericGeometry::Topology<
>          Dune::Capabilities::hasSingleGeometryType<G>::topologyId,
>          G::dimension
>          >
>        >::value
>      >::type>
>   { /* specialization for dim==1 */ };
> 
> See
> http://www.dune-project.org/doc/doxygen/html/topologytypes_8hh_source.html.
> 
> 
> Regards,
> Jö.
> 
> -- 
> Jorrit (Jö) Fahlke, Institute for Computational und Applied Mathematics,
> University of Münster, Orleans-Ring 10, D-48149 Münster
> Tel: +49 251 83 35146 Fax: +49 251 83 32729
> 
> If God had intended Man to Smoke, He would have set him on Fire.
> -- fortune
> 
> 
> 

> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune


-- 
Jorrit (Jö) Fahlke, Institute for Computational und Applied Mathematics,
University of Münster, Orleans-Ring 10, D-48149 Münster
Tel: +49 251 83 35146 Fax: +49 251 83 32729

Software is like sex; it's better when it's free.
-- Linus Torvalds
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20141126/4ea6384f/attachment.sig>


More information about the Dune mailing list