From 16003b0a48e5f45026848691547de4cadec74519 Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 5 Nov 2012 00:38:43 +0000 Subject: [PATCH] Partial merge from the parallel_mg branch: introduce level subdomain ids. git-svn-id: https://svn.dealii.org/trunk@27377 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/doxygen/headers/glossary.h | 12 +++++++++++- deal.II/doc/news/changes.h | 7 +++++++ deal.II/include/deal.II/grid/tria_accessor.h | 11 +++++++++++ deal.II/include/deal.II/grid/tria_levels.h | 7 +++++++ deal.II/source/grid/tria_accessor.cc | 19 +++++++++++++++++++ deal.II/source/grid/tria_levels.cc | 11 +++++++++++ 6 files changed, 66 insertions(+), 1 deletion(-) diff --git a/deal.II/doc/doxygen/headers/glossary.h b/deal.II/doc/doxygen/headers/glossary.h index 61e76626e0..b16d3bdcab 100644 --- a/deal.II/doc/doxygen/headers/glossary.h +++ b/deal.II/doc/doxygen/headers/glossary.h @@ -1024,7 +1024,9 @@ Article{JK10, *
Each cell of a triangulation has associated with it a property called * the "subdomain id" that can be queried using a call like * cell-@>subdomain_id() and that can be set for example by using - * cell-@>set_subdomain_id(13). While in principle this property + * cell-@>set_subdomain_id(13). (These calls resolve to + * CellAccessor::subdomain_id() and CellAccessor::set_subdomain_id(), respectively.) + * While in principle this property * can be used in any way application programs deem useful (it is simply an * integer associated with each cell that can indicate whatever you want), at * least for programs that run in %parallel it usually denotes the processor a @@ -1058,6 +1060,14 @@ Article{JK10, * one refinement level. These cells are called "artificial" (see * @ref GlossArtificialCell "here") and have the special subdomain id value * types::artificial_subdomain_id. + * + * In addition to regular subdomain ids, there is a second, closely related set + * of flags that are associated with each cell: "level subdomain ids." + * These exist not only for active cells but, in fact, for every cell in + * a mesh hierarchy. Their meaning is entirely analogous to the regular + * subdomain ids, but they are read and written by the + * CellAccessor::level_subdomain_id() and CellAccessor::set_level_subdomain_id() + * functions. *
* * diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 3b3c5f43f4..fe01bd696f 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -154,6 +154,13 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. New: In addition to the regular subdomain ids (see +@ref GlossSubdomainId) there is now a second set of flags called +"level subdomain ids" that also assigns a subdomain to every cell +in a multigrid hierarchy. +
    +(Timo Heister, 2012/11/04) +
  2. Changed: GridOut::write_xfig has been improved in a number of ways. In particular, one can now color cells based on a number of different criteria that can be set in GridOutFlags::XFig. diff --git a/deal.II/include/deal.II/grid/tria_accessor.h b/deal.II/include/deal.II/grid/tria_accessor.h index 62003d3cd0..0da7234b2c 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.h +++ b/deal.II/include/deal.II/grid/tria_accessor.h @@ -2699,6 +2699,17 @@ class CellAccessor : public TriaAccessor */ void set_subdomain_id (const types::subdomain_id new_subdomain_id) const; + /** + * Get the level subdomain id of this cell. This is used for parallel multigrid. + */ + types::subdomain_id_t level_subdomain_id () const; + + /** + * Set the level subdomain id of this cell. This is used for parallel multigrid. + */ + void set_level_subdomain_id (const types::subdomain_id_t new_level_subdomain_id) const; + + /** * Set the subdomain id of this * cell and all its children (and diff --git a/deal.II/include/deal.II/grid/tria_levels.h b/deal.II/include/deal.II/grid/tria_levels.h index 24bf5a87a7..e5df347d20 100644 --- a/deal.II/include/deal.II/grid/tria_levels.h +++ b/deal.II/include/deal.II/grid/tria_levels.h @@ -140,6 +140,11 @@ namespace internal */ std::vector subdomain_ids; + /** + * for parallel multigrid + */ + std::vector level_subdomain_ids; + /** * One integer for every consecutive * pair of cells to store which @@ -243,6 +248,7 @@ namespace internal std::vector coarsen_flags; std::vector > neighbors; std::vector subdomain_ids; + std::vector level_subdomain_ids; std::vector parents; // The following is not used @@ -296,6 +302,7 @@ namespace internal ar & refine_flags & coarsen_flags; ar & neighbors; ar & subdomain_ids; + ar & level_subdomain_ids; ar & parents; ar & direction_flags; ar & cells; diff --git a/deal.II/source/grid/tria_accessor.cc b/deal.II/source/grid/tria_accessor.cc index 8607915042..ae18629a53 100644 --- a/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/source/grid/tria_accessor.cc @@ -1332,6 +1332,25 @@ CellAccessor::set_subdomain_id (const types::subdomain_id new_sub } +template +types::subdomain_id_t CellAccessor::level_subdomain_id () const +{ + Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); + return this->tria->levels[this->present_level]->level_subdomain_ids[this->present_index]; +} + + + +template +void +CellAccessor::set_level_subdomain_id (const types::subdomain_id_t new_level_subdomain_id) const +{ + Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); + this->tria->levels[this->present_level]->level_subdomain_ids[this->present_index] + = new_level_subdomain_id; +} + + template bool CellAccessor::direction_flag () const { diff --git a/deal.II/source/grid/tria_levels.cc b/deal.II/source/grid/tria_levels.cc index ab18a3da81..7962a9a561 100644 --- a/deal.II/source/grid/tria_levels.cc +++ b/deal.II/source/grid/tria_levels.cc @@ -52,6 +52,11 @@ namespace internal total_cells - subdomain_ids.size(), 0); + level_subdomain_ids.reserve (total_cells); + level_subdomain_ids.insert (level_subdomain_ids.end(), + total_cells - level_subdomain_ids.size(), + 0); + if (dimension < space_dimension) { direction_flags.reserve (total_cells); @@ -122,6 +127,7 @@ namespace internal MemoryConsumption::memory_consumption (coarsen_flags) + MemoryConsumption::memory_consumption (neighbors) + MemoryConsumption::memory_consumption (subdomain_ids) + + MemoryConsumption::memory_consumption (level_subdomain_ids) + MemoryConsumption::memory_consumption (parents) + MemoryConsumption::memory_consumption (direction_flags) + MemoryConsumption::memory_consumption (cells)); @@ -159,6 +165,11 @@ namespace internal total_cells - subdomain_ids.size(), 0); + level_subdomain_ids.reserve (total_cells); + level_subdomain_ids.insert (level_subdomain_ids.end(), + total_cells - level_subdomain_ids.size(), + 0); + if (dimension < space_dimension) { direction_flags.reserve (total_cells); -- 2.39.5