// ---------------------------------------------------------------------
//
-// Copyright (C) 1998 - 2015 by the deal.II authors
+// Copyright (C) 1998 - 2016 by the deal.II authors
//
// This file is part of the deal.II library.
//
DEAL_II_NAMESPACE_OPEN
+template <int, int> class Triangulation;
/**
* A class to represent a unique ID for a cell in a Triangulation. This class
*/
std::string to_string() const;
+ /**
+ * Return a cell_iterator to the cell represented by this CellId.
+ */
+ template<int dim, int spacedim>
+ typename Triangulation<dim,spacedim>::cell_iterator
+ to_cell(const Triangulation<dim,spacedim> &tria) const;
+
/**
* compare two CellIds
*/
)
SET(_inst
+ cell_id.inst.in
grid_generator.inst.in
grid_in.inst.in
grid_out.inst.in
// ---------------------------------------------------------------------
//
-// Copyright (C) 2015 by the deal.II authors
+// Copyright (C) 2015,2016 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <deal.II/grid/cell_id.h>
+#include <deal.II/grid/tria.h>
+
#include <sstream>
DEAL_II_NAMESPACE_OPEN
return ss.str();
}
+template<int dim, int spacedim>
+typename Triangulation<dim,spacedim>::cell_iterator
+CellId::to_cell(const Triangulation<dim,spacedim> &tria) const
+{
+ typename Triangulation<dim,spacedim>::cell_iterator cell (&tria,0,coarse_cell_id);
+
+ for (unsigned int i = 0; i < id.size(); ++i)
+ cell = cell->child(static_cast<unsigned int> (id[i]));
+
+ return cell;
+}
+
+// explicit instantiations
+#include "cell_id.inst"
+
DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+{
+#if deal_II_dimension <= deal_II_space_dimension
+ template typename Triangulation<deal_II_dimension,deal_II_space_dimension>::cell_iterator CellId::to_cell(const Triangulation<deal_II_dimension,deal_II_space_dimension> &tria) const;
+#endif
+}
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check CellId
+
+#include "../tests.h"
+
+#include <deal.II/base/geometry_info.h>
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_refinement.h>
+
+#include <fstream>
+#include <sstream>
+
+template <class TRIA>
+void check (TRIA &tr)
+{
+ typename TRIA::cell_iterator cell = tr.begin(),
+ endc = tr.end();
+
+
+ for (; cell!=endc; ++cell)
+ {
+ deallog << cell->level() << " " << cell->index() << std::endl;
+
+ // Store the CellId and create a cell iterator pointing to the same cell
+
+ const CellId cid = cell->id();
+
+ typename TRIA::cell_iterator cell2 = cid.to_cell(tr);
+
+ deallog << cell2->level() << " " << cell2->index() << std::endl;
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+int main (int argc, char *argv[])
+{
+ // Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads());
+
+ initlog();
+ deal_II_exceptions::disable_abort_on_exception();
+
+ Triangulation<2> tria;
+ GridGenerator::hyper_cube (tria);
+ tria.refine_global (2);
+ tria.begin_active()->set_refine_flag();
+ tria.execute_coarsening_and_refinement();
+ check(tria);
+}
+
+
+
--- /dev/null
+
+DEAL::0 0
+DEAL::0 0
+DEAL::1 0
+DEAL::1 0
+DEAL::1 1
+DEAL::1 1
+DEAL::1 2
+DEAL::1 2
+DEAL::1 3
+DEAL::1 3
+DEAL::2 0
+DEAL::2 0
+DEAL::2 1
+DEAL::2 1
+DEAL::2 2
+DEAL::2 2
+DEAL::2 3
+DEAL::2 3
+DEAL::2 4
+DEAL::2 4
+DEAL::2 5
+DEAL::2 5
+DEAL::2 6
+DEAL::2 6
+DEAL::2 7
+DEAL::2 7
+DEAL::2 8
+DEAL::2 8
+DEAL::2 9
+DEAL::2 9
+DEAL::2 10
+DEAL::2 10
+DEAL::2 11
+DEAL::2 11
+DEAL::2 12
+DEAL::2 12
+DEAL::2 13
+DEAL::2 13
+DEAL::2 14
+DEAL::2 14
+DEAL::2 15
+DEAL::2 15
+DEAL::3 0
+DEAL::3 0
+DEAL::3 1
+DEAL::3 1
+DEAL::3 2
+DEAL::3 2
+DEAL::3 3
+DEAL::3 3
+DEAL::OK