#848 add index method to GeometryType
Metadata
Property | Value |
---|---|
Reported by | Andreas Dedner (A.S.Dedner@warwick.ac.uk) |
Reported at | Dec 1, 2010 21:12 |
Type | Discussion |
Version | Git (pre2.4) [autotools] |
Operating System | Unspecified / All |
Last edited by | Christian Engwer (christi@conan.iwr.uni-heidelberg.de) |
Last edited at | Mar 20, 2012 18:08 |
Closed by | Christian Engwer (christi@conan.iwr.uni-heidelberg.de) |
Closed at | Mar 20, 2012 18:08 |
Closed in version | 2.2 |
Resolution | Implemented |
Comment | Judging from the comments this feature is implemented to everybodies liking. |
Description
Here two suggestions for GeometryType - the first one is the central one:
A) To avoid some of the problems caused by the fact that each Topology is represented by two topologIds (due to the lowest bit) I suggest to add the following to the GeometryType:
size_t index() const { return (topologyId_ >> 1); }
size_t size() const { return (1 << (dim_-1)); }
static size_t size(int dim) { return (1 << (dim_-1)); }
This makes it easier to use the topologyId for vector storage because one otherwise has to do the shift oneself or use twice as much storage and then runs into difficulties because each type uses two different sentries in the vector.
Furthermore it simplifies the rest of the GeometryType implementation, e.g.
bool operator==(...) { return other.dim_==dim_ && other.index()==index(); }
B) there are at least 7 ways to construct a 1d line:
- GeometryType(1) (id=0)
- GeometryType(1u) (id=0)
- GeometryType(0,1) (id=0)
- GeometryType(1,1) (id=1)
- GeometryType(Simplex) (id=0)
- GeometryType(Cube) (id=1)
- makeLine (id=0) Do we need the first two? (3) and (4) seem just as good... They are used in onedgrid but apparently nowhere else in dune-grid at least.
and for consistency makeLine(int id=0) seems to make sense...