Bug Report in GridTools::get_active_neighbors()

80 views
Skip to first unread message

Andreas Kyritsakis

unread,
Nov 28, 2019, 4:03:17 AM11/28/19
to deal.II User Group
Hello,

This is to report what I think is a bug in GridTools::get_active_neighbors().

The following code should compile but it does not.

#include <deal.II/grid/tria.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_tools.h>
using namespace dealii;

template<int dim>
class Test{
public: 
    Test(Triangulation<dim> *tria) : triangulation(triangulation), dof_handler(*tria){}
    
    void run(){
        typename DoFHandler<dim>::active_cell_iterator cell;
  
        for (cell = dof_handler.begin_active(); cell != dof_handler.end(); ++cell){
            std::vector<typename DoFHandler<dim>::active_cell_iterator> neighbors;
            GridTools::get_active_neighbors(cell, neighbors); 
    }
    }
private:
    Triangulation<dim>* triangulation;
    DoFHandler<dim> dof_handler;
};

int main(){
    Triangulation<2> triangulation;
    GridGenerator::hyper_cube(triangulation, -1, 1);
    Test<2> test(&triangulation);
    test.run();
}

I think somehow the compiler cannot resolve the generic type MeshType::active_cell_iterator into the specific one DoFHandler<dim>::active_cell_iterator, although from what I understand in the documentation it should. Probably some template specification missing somewhere, but I can't find it.

In my code I fixed it easily by copying the function directly to my own files and specifying appropriately, but I think it would be nice to report the bug.

Cheers,
Andreas 

Simon Sticko

unread,
Nov 28, 2019, 4:46:15 AM11/28/19
to deal.II User Group
Hi,
I think it's just the documentation that can be slightly improved here.

The function get_active_child_cells has a similar signature but it has
this note in its documentation:

* @note Since in C++ the MeshType template argument can not be deduced from
* a function call, you will have to specify it after the function name, as
* for example in
* @code
*   GridTools::get_active_child_cells<DoFHandler<dim> > (cell)
* @endcode
*/
template <class MeshType>
std::vector<typename MeshType::active_cell_iterator>
get_active_child_cells(const typename MeshType::cell_iterator &cell);

The same note should maybe be added to get_active_neighbors for clarity.

Best,
Simon

Wolfgang Bangerth

unread,
Nov 29, 2019, 4:22:12 PM11/29/19
to dea...@googlegroups.com
On 11/28/19 2:46 AM, Simon Sticko wrote:
> Hi,
> I think it's just the documentation that can be slightly improved here.
>
> The function get_active_child_cells has a similar signature but it has
> this note in its documentation:
>
> * @note Since in C++ the MeshType template argument can not be deduced from
> * a function call, you will have to specify it after the function name, as
> * for example in
> * @code
> *   GridTools::get_active_child_cells<DoFHandler<dim> > (cell)
> * @endcode
> */
> template <class MeshType>
> std::vector<typename MeshType::active_cell_iterator>
> get_active_child_cells(const typename MeshType::cell_iterator &cell);

Yes, that's precisely correct!


> The same note should maybe be added to get_active_neighbors for clarity.

Would either of the two of you want to propose a patch that does this?

Best
Wolfgang

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Simon Sticko

unread,
Nov 29, 2019, 4:54:54 PM11/29/19
to deal.II User Group
Hi,
Fixed in #9108, already merged in. I should probably have written that here for completeness. Sorry.

Best,
Simon

Reply all
Reply to author
Forward
0 new messages