[Dune-devel] Dune grid concepts
Ospina De Los Rios, Santiago
santiago.ospina at iwr.uni-heidelberg.de
Tue Jan 19 16:36:16 CET 2021
Hi dune-devs,
here I share my thoughts regarding the dune-grid concepts that I want to open for a discussion on Friday:
My proposal is to move the dune grid towards a grid concept. That is, any grid that looks syntactically like a grid, is assumed to fulfill the grid semantics, i.e. duck-typing. In other words, syntax implies semantics. I already showed that it is possible to create such a concept in a merge request[1] even for generic dimensions. I want to highlight that I don't want to discuss this specific implementation but the _idea_ of detaching from the duck-typing made in Dune::Grid and move towards dune-grid as a concept.
Pros:
* The concept definition is much smaller and "cleaner" than Dune::Grid.
* Real duck-typing. The current one depends on some instantiations of the Dune::Grid base class.
* Grid implementations may not be related to dune.
* Special type of grids concepts may be refined in downstream projects. Such refinements are very simple and would define the grid interface and capabilities (e.g. multi-domain grids, axial-parallel, thread-safe grids). Again, syntax conveys semantic.
* Creation of new grids is currently very tedious. The grid can only be checked to be a dune grid if the whole grid passes the duck typing from dune-grid. This is not necessary with concepts, as one can check against smaller building blocks of the grid (entities, index sets, intersections, etc.).
* For the most of dune, I hope, it is backwards compatible.
Cons:
* Harder to document! (Doxygen does not know the concept concept)
* Template functions cannot be constrained (e.g. communicate). This means that a concept will not be able to tell whether objects that fulfill a concept are instantiable. A solution for this might be to check only some instantiations and assume that the implementation is generic.
* There will be legacy "bugs" where functions are expecting child classes of Dune::Grid
Discussion about the current implementation:
* Two implementations for the same purpose: C++20 and dune concepts. Bad because is repeating code (?)
* const-correctnes of the grid interface is not implemented.
* Currently, clang has no C++20 concepts library...
[1]: https://gitlab.dune-project.org/core/dune-grid/-/merge_requests/377
[https://gitlab.dune-project.org/assets/gitlab_logo-7ae504fe4f68fdebb3c2034e36621930cd36ea87924c11ff65dbcb8ed50dca58.png]<https://gitlab.dune-project.org/core/dune-grid/-/merge_requests/377>
Feature/concepts (!377) · Merge Requests · Core Modules / dune-grid · GitLab<https://gitlab.dune-project.org/core/dune-grid/-/merge_requests/377>
gitlab.dune-project.org
@santiago.ospina has put together a set of concept checks for a `Dune::Grid` using @carsten.graeser's implementation of concepts. I would be glad t have this in master.
Best Regards,
Santiago Ospina
--------------------------------
Santiago Ospina De Los Rios
Interdisciplinary Center for Scientific Computing
Heidelberg University
Im Neuenheimer Feld 205
69120 Heidelberg
Germany
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20210119/3c532e64/attachment.htm>
More information about the Dune-devel
mailing list