Hi Seyed, Nope, like I said, there's no such thing as a cell number in deal.II (at least in the sense that a cell knows its own "id" number). The cell->id() function <https://dealii.org/developer/doxygen/deal.II/classCellAccessor.html#a109cd0c706db7ff75f8db6f0e3a1f213> returns a CellId <https://dealii.org/developer/doxygen/deal.II/classCellId.html> object but it does not provide an index/counter in the sense that you think it does. One possible reason for this is that (refined) deal.II triangulations are stored in levels, and the numbering would have to be rebuilt each time you change the mesh. This becomes tricky for distributed triangulations where the actual mesh stored on each processor is different. Also, does one want to count inactive cells or not? Sometimes yes, sometimes no.
So, if for example I want to store the material ID for each cell in a vector I would have to do it like this: Vector<double> <https://dealii.org/developer/doxygen/deal.II/classVector.html> material_id; material_id.reinit <https://dealii.org/developer/doxygen/deal.II/classVector.html#ac4a4dbef7dd65ef8ad35ae56b57d7c05> (triangulation.n_active_cells <https://dealii.org/developer/doxygen/deal.II/classTriangulation.html#aa21f25016ce1b9d70d2003a128985870> ()); unsigned int c = 0; typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell, ++c) { material_id(c) = static_cast<int>(cell->material_id()); } Notice that I create and increment the cell counter "c". Notice as well that there is no presupposition of the order that deal.II traverses its cells. So dependent on what you're wanting to achieve, you probably wish to implement a permutation of the above. Picking out the cell that you are wanting to query is probably best achieved using a geometric query or by premarking it (e.g. by setting its user_index). Best, Jean-Paul On Friday, February 24, 2017 at 3:45:16 PM UTC+1, Seyed Ali Mohseni wrote: > > Thanks for your suggestions. > > > Generally, in FEM you number elements like in the below picture: > > > <https://lh3.googleusercontent.com/-0n-HlF1EsRs/WLBEmN34aaI/AAAAAAAAAGU/GlK9R9OqDJ8FSTLKGXeaI85eU6pdV3MkwCLcB/s1600/System.png> > > > I understand of course, that the cells (elements) in deal.II are parallely > distributed, but it should be possible to identify the geometrical position > and ID of the elements and their corresponding nodes. > > > For instance the following works: > > > typename parallel::distributed::Triangulation<dim>::active_cell_iterator > cell = triangulation.begin_active(), endc = triangulation.end(); > for (; cell != endc; ++cell) > { > std::cout << "CELL NUMBER: " << cell->id() << std::endl; > } > > > > Of course here the locally owned term is missing, but is it correct to > access the cells like this? > > > I am a bit confused since it is a rather easy task which should not be > such a big "deal" in deal.II. > > > Best regards, > > S. A. Mohseni > > > > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.