The error message looks totally ok to me. What kind of geometry is it, which hat 7 vertices in 3D? There errors seems to be there since 2012, when I wrote this test.
No, it is not the correct fix. The reason for the loop is that we do not know easily which combinations are possible. Thus I use the brute force approach and perform a full search for possible settings for that amount of vertices.
My suggestion is to adapt the code and distinguish between different types of exceptions. Some signal that this is an inadequate test case, some actually report an error.
It is well-known that for dim >= 5 the number of corners no longer uniquely describes the geometry type. Take 'pyramid( pyramid( cube( 3 ) ) )' and 'prism( simplex( 4 ) )': Both have 10 corners. Note that these are exactly the two types coughed up in your example for dim = 5.
So: We should not test the conversion from number of corners to geometry type for dim > 4. It does not make sense (at least to me).
There is also no way of avoiding the impossible setting - there simply is no regular 3d geometry type with 7 corners. However, we could return 'none' in this case.
As a final note, I would like to add that arbitrary numbers of corners (> dim) are possible for geometry type 'none'. So there is always a certain non-uniqueness problem. So, another solution could be to iterate over all geometry types with the same number of corners (similar to a std::multimap< unsinged int, GeometryType >).
I think also in this ambiguous case we should have test, which assures a consistent setup. The thing is, that in this case the gt.makeFromVertices can not work and thus it should throw an exception. Our test would make sure that we observe the correct exception.
@christi: Currently makeFromVertices() only ever either returns a valid geometry or raises a NotImplemented exception. It could be extended to additionally raise a new exception type for the ambiguous cases and another one for impossible cases (like a 2D object with fewer than 3 vertices). To that end, we'd need
Names for the two new exception types
A (non-exhaustive because it would be infinite -- maybe up to dimension 8 as in the test(*)) list of dimensionally ambiguous polytopes.
If we had that, instead of using gt.makeFromVertices only for dim <= 3, it could always be used and we could check if we get the right exception or NotImplemented.
So, again, this is really not my area of expertise, so please excuse me for asking potentially rather stupid questions.
Is a list of numbers of vertices with corresponding polyhedra, which allows one to distinguish the three cases of no mapping, a unique mapping or an ambiguous mapping to a geometry, something that is easily available in the right book so that it could be hardcoded or even something that one could generate with a few lines of code?
@pipping The implementation would be quite trivial (just recurse over all reference elements, ask for the number of vertices and build the inverse lookup table).
The real questions are:
what kind of interface do you want to have?
what is the desired complexity of the operation?
what is your use case?
Especially to the latter point I have not yet heard a good answer. So: What's your interest in this mapping? Is is just the failing test?
Personally, I still think this feature is a utility and can easily be implemented by any user who is sufficiently advanced to need this feature.
@martin.nolte: I see. It seems I'm thinking in the wrong direction. I'm indeed only trying to cut down the number of failing tests, I don't have a use case.
Only failing tests? Fixing failing tests is very important otherwise the whole testing is useless. I want to find regressions and not test around failing tests.
I am with Elias, either we implement the list as suggested by Christan or we drop this feature as implicated by Martin. I don't need the feature but couldn't care less keeping it. Has someone a strong opinion towards one side?
If not Elias can choose or whoever is willing to do the work.
I wouldn't mind dropping the feature. Constructing a polyhedron from its number of corners is an ill-posed problem, as everybody in this thread is well aware of. All possible 'solutions' proposed here all seem like putting lipstick on a pig to me.
We have been using basically the same (OK, it is simple and not too long...) code in several modules depending on dune-geometry in order to setup the correct geometry from a list of vertices. Once particular point I have never seen anything which is not 2D or 3D. I doubt anybody uses something like this in higher dimensions, where the trouble starts. I think factoring out such code is a good thing, but perhaps we better move it to some utility class and not make it part of the interface. In this case we could easily make clear that it only works for 1D/2D/3D by specializing accordingly.
@gruenich ragarding the failing test. The test does not fail (at least it didn't, the last time I looked into it). It produces warnings. Do this is a different situation.
@christi: You're right, the test doesn't actually fail. It generates such large amounts of output containing Error: Dune::Exception, however, see also snippet 17, that even though this comes from exceptions which are caught, a user who's not 100% familiar with the test will think that something's very wrong.
On top of that, because all exceptions are caught (including also NotImplemented which makeFromVertices could throw), there's nothing that the test actually, well, tests. There's no if(...) exit(-1) anywhere. The only way it could fail is if a segfault was generated somehow.
In summary, the test seems confusing and not very useful. I guess that is what originally made me file this bug.
But on to more constructive thinking: Can we agree on a place and a name for the utility header and class?
If nobody has a suggestions, put the header into dune/geometry/utility and do whatever you think is best. When you create a merge request, people might ask for different names.
When I opened this bug, I was confused by the fact that test-geometrytype generates far too many warnings yet exits successfully. Now that I know these warnings are harmless, and given how far removed the corresponding parts of dune are both from my area of expertise and my area of interest, it's safe to say I won't put any more work into this issue.
If anyone else is willing to improve the situation here, that's great. Otherwise, please close this as WONTFIX.