From 9be5779d5006cdbbd09985cdf48011da6b586912 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Mon, 12 Jan 2015 14:31:33 +0100 Subject: [PATCH] Added set_all_* functions to tria. --- doc/news/changes.h | 9 +++ include/deal.II/grid/tria.h | 23 ++++++ source/grid/tria.cc | 24 ++++++ tests/manifold/set_all_manifold_ids_01.cc | 77 +++++++++++++++++++ tests/manifold/set_all_manifold_ids_01.output | 62 +++++++++++++++ tests/manifold/set_all_manifold_ids_02.cc | 77 +++++++++++++++++++ tests/manifold/set_all_manifold_ids_02.output | 62 +++++++++++++++ 7 files changed, 334 insertions(+) create mode 100644 tests/manifold/set_all_manifold_ids_01.cc create mode 100644 tests/manifold/set_all_manifold_ids_01.output create mode 100644 tests/manifold/set_all_manifold_ids_02.cc create mode 100644 tests/manifold/set_all_manifold_ids_02.output diff --git a/doc/news/changes.h b/doc/news/changes.h index ee01cf9ebc..50a97d6a32 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -145,6 +145,15 @@ inconvenience this causes.

Specific improvements

    +
  1. New: Triangulation::set_all_manifold_ids() and + Triangulation::set_all_manifold_ids_on_boundaries() + set all manifold ids on every object or on every + boundary object respectively. +
    + (Luca Heltai, 2015/01/12) +
  2. + +
  3. New: GridTools::copy_boundary_to_manifold_id() and GridTools::copy_material_to_manifold_id() copy boundary_ids and material_ids to manifold_ids for diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index 891f9a9164..db4e1ed164 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -1627,6 +1627,29 @@ public: */ void set_manifold (const types::manifold_id number); + /** + * Set the manifold_id of all of cells and faces to the given + * argument. + * + * @ingroup manifold + * + * @see + * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" + */ + void set_all_manifold_ids (const types::manifold_id &number); + + /** + * Set the manifold_id of all of boundary faces to the given + * argument. + * + * @ingroup manifold + * + * @see + * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" + */ + void set_all_manifold_ids_on_boundary (const types::manifold_id &number); + + /** * Return a constant reference to a boundary object used for this * triangulation. Number is the same as in @p set_boundary diff --git a/source/grid/tria.cc b/source/grid/tria.cc index d7ab4f648a..785a5408b7 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -8770,6 +8770,30 @@ Triangulation::set_manifold (const types::manifold_id m_number) manifold.erase(m_number); } +template +void +Triangulation::set_all_manifold_ids (const types::manifold_id &m_number) +{ + typename Triangulation::active_cell_iterator + cell=this->begin_active(), endc=this->end(); + + for (; cell != endc; ++cell) + cell->set_all_manifold_ids(m_number); +} + + +template +void +Triangulation::set_all_manifold_ids_on_boundary (const types::manifold_id &m_number) +{ + typename Triangulation::active_cell_iterator + cell=this->begin_active(), endc=this->end(); + + for (; cell != endc; ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->at_boundary()) + cell->face(f)->set_all_manifold_ids(m_number); +} template diff --git a/tests/manifold/set_all_manifold_ids_01.cc b/tests/manifold/set_all_manifold_ids_01.cc new file mode 100644 index 0000000000..a8a7c85957 --- /dev/null +++ b/tests/manifold/set_all_manifold_ids_01.cc @@ -0,0 +1,77 @@ +//------------------------------------------------------------ +// Copyright (C) 2015, the deal.II authors +// +// This file is subject to LGPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//------------------------------------------------------------ + + +#include "../tests.h" +#include +#include + + +// all include files you need here +#include +#include +#include +#include +#include +#include +#include + +template +void print_info(Triangulation &tria) { + typename Triangulation::active_cell_iterator cell; + + for (cell = tria.begin_active(); cell != tria.end(); ++cell) + { + deallog << "cell: " << cell + << ", material_id: " + << (int)cell->material_id() + << ", manifold_id: " + << (int)cell->manifold_id() << std::endl; + + for (unsigned int f=0; f::faces_per_cell; ++f) + deallog << "face: " << cell->face(f) + << ", boundary_id: " + << (int)cell->face(f)->boundary_indicator() + << ", manifold_id: " + << (int)cell->face(f)->manifold_id() << std::endl; + } +} + + +// Helper function +template +void test() +{ + deallog << "Testing dim=" << dim + << ", spacedim="<< spacedim << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube (tria, 0., 1.); + + deallog << "Original mesh ==============================" << std::endl; + print_info(tria); + tria.set_all_manifold_ids(1); + deallog << "Modified mesh ==============================" << std::endl; + print_info(tria); +} + +int main () +{ + initlog(true); + + test<1,1>(); + test<1,2>(); + test<2,2>(); + test<2,3>(); + test<3,3>(); + + return 0; +} + diff --git a/tests/manifold/set_all_manifold_ids_01.output b/tests/manifold/set_all_manifold_ids_01.output new file mode 100644 index 0000000000..03d0fdf98f --- /dev/null +++ b/tests/manifold/set_all_manifold_ids_01.output @@ -0,0 +1,62 @@ + +DEAL::Testing dim=1, spacedim=1 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 1, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 1, manifold_id: 1 +DEAL::Testing dim=1, spacedim=2 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 1, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 1, manifold_id: 1 +DEAL::Testing dim=2, spacedim=2 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 3, boundary_id: 0, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 0, manifold_id: 1 +DEAL::face: 2, boundary_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 3, boundary_id: 0, manifold_id: 1 +DEAL::Testing dim=2, spacedim=3 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 3, boundary_id: 0, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 0, manifold_id: 1 +DEAL::face: 2, boundary_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 3, boundary_id: 0, manifold_id: 1 +DEAL::Testing dim=3, spacedim=3 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: -1 +DEAL::face: 3, boundary_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 4, boundary_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: -1 +DEAL::face: 5, boundary_id: 0, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: 1 +DEAL::face: 2, boundary_id: 0, manifold_id: 1 +DEAL::face: 3, boundary_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 4, boundary_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 0, manifold_id: 1 +DEAL::face: 5, boundary_id: 0, manifold_id: 1 diff --git a/tests/manifold/set_all_manifold_ids_02.cc b/tests/manifold/set_all_manifold_ids_02.cc new file mode 100644 index 0000000000..7d0130b2ef --- /dev/null +++ b/tests/manifold/set_all_manifold_ids_02.cc @@ -0,0 +1,77 @@ +//------------------------------------------------------------ +// Copyright (C) 2015, the deal.II authors +// +// This file is subject to LGPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//------------------------------------------------------------ + + +#include "../tests.h" +#include +#include + + +// all include files you need here +#include +#include +#include +#include +#include +#include +#include + +template +void print_info(Triangulation &tria) { + typename Triangulation::active_cell_iterator cell; + + for (cell = tria.begin_active(); cell != tria.end(); ++cell) + { + deallog << "cell: " << cell + << ", material_id: " + << (int)cell->material_id() + << ", manifold_id: " + << (int)cell->manifold_id() << std::endl; + + for (unsigned int f=0; f::faces_per_cell; ++f) + deallog << "face: " << cell->face(f) + << ", boundary_id: " + << (int)cell->face(f)->boundary_indicator() + << ", manifold_id: " + << (int)cell->face(f)->manifold_id() << std::endl; + } +} + + +// Helper function +template +void test() +{ + deallog << "Testing dim=" << dim + << ", spacedim="<< spacedim << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube (tria, 0., 1.); + + deallog << "Original mesh ==============================" << std::endl; + print_info(tria); + tria.set_all_manifold_ids_on_boundary(1); + deallog << "Modified mesh ==============================" << std::endl; + print_info(tria); +} + +int main () +{ + initlog(true); + + test<1,1>(); + test<1,2>(); + test<2,2>(); + test<2,3>(); + test<3,3>(); + + return 0; +} + diff --git a/tests/manifold/set_all_manifold_ids_02.output b/tests/manifold/set_all_manifold_ids_02.output new file mode 100644 index 0000000000..34d3465616 --- /dev/null +++ b/tests/manifold/set_all_manifold_ids_02.output @@ -0,0 +1,62 @@ + +DEAL::Testing dim=1, spacedim=1 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 1, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 1, manifold_id: 1 +DEAL::Testing dim=1, spacedim=2 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 1, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 1, manifold_id: 1 +DEAL::Testing dim=2, spacedim=2 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 3, boundary_id: 0, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: 1 +DEAL::face: 2, boundary_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 3, boundary_id: 0, manifold_id: 1 +DEAL::Testing dim=2, spacedim=3 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 3, boundary_id: 0, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: 1 +DEAL::face: 2, boundary_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 3, boundary_id: 0, manifold_id: 1 +DEAL::Testing dim=3, spacedim=3 +DEAL::Original mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: -1 +DEAL::face: 3, boundary_id: 0, manifold_id: -1 +DEAL::face: 0, boundary_id: 0, manifold_id: -1 +DEAL::face: 4, boundary_id: 0, manifold_id: -1 +DEAL::face: 1, boundary_id: 0, manifold_id: -1 +DEAL::face: 5, boundary_id: 0, manifold_id: -1 +DEAL::Modified mesh ============================== +DEAL::cell: 0.0, material_id: 0, manifold_id: -1 +DEAL::face: 2, boundary_id: 0, manifold_id: 1 +DEAL::face: 3, boundary_id: 0, manifold_id: 1 +DEAL::face: 0, boundary_id: 0, manifold_id: 1 +DEAL::face: 4, boundary_id: 0, manifold_id: 1 +DEAL::face: 1, boundary_id: 0, manifold_id: 1 +DEAL::face: 5, boundary_id: 0, manifold_id: 1 -- 2.39.5