From fc3bb20e275326e98bf777d4c5eb3593717365e6 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Thu, 14 Sep 2017 10:42:19 +0200 Subject: [PATCH] Rene's comments. --- include/deal.II/grid/tria_info_cache.h | 4 +- include/deal.II/grid/tria_info_cache_flags.h | 76 ++++++++++---------- source/grid/tria_info_cache.cc | 18 +++-- source/grid/tria_info_cache.inst.in | 4 +- 4 files changed, 54 insertions(+), 48 deletions(-) diff --git a/include/deal.II/grid/tria_info_cache.h b/include/deal.II/grid/tria_info_cache.h index 9a9febfe82..d48b5209d0 100644 --- a/include/deal.II/grid/tria_info_cache.h +++ b/include/deal.II/grid/tria_info_cache.h @@ -44,7 +44,7 @@ DEAL_II_NAMESPACE_OPEN * missing TriangulationInfoCacheFlags flag), an Assertion is thrown. * * Notice that this class only notices if the underlying Triangulation has - * changed due to a Triangulation::Signals::any_change() signal beeing triggered. + * changed due to a Triangulation::Signals::any_change() signal being triggered. * * If the triangulation changes due to a MappingQEulerian being passed to this * class, or because you manually change some vertex locations, then some of @@ -64,7 +64,7 @@ public: * TriangulationInfoCacheFlags. If you provide the optional `mapping` * argument, then this is used whenever a mapping is required. * - * @param tria The triangulation to work on + * @param tria The triangulation for which to store information * @param flags TriangulationInfoCacheFlags that specify what to cache * @param mapping The mapping to use when computing cached objects */ diff --git a/include/deal.II/grid/tria_info_cache_flags.h b/include/deal.II/grid/tria_info_cache_flags.h index ddc0234b6c..181b2f3815 100644 --- a/include/deal.II/grid/tria_info_cache_flags.h +++ b/include/deal.II/grid/tria_info_cache_flags.h @@ -22,14 +22,14 @@ DEAL_II_NAMESPACE_OPEN /** - * The enum type given to the TriangulationInfoCache class to select what - * information to cache. - * - * You can select more than one flag by concatenation using the bitwise or - * operator|(TriangulationInfoCacheFlags,TriangulationInfoCacheFlags). - * - * @author Luca Heltai, 2017. - */ + * The enum type given to the TriangulationInfoCache class to select what + * information to cache. + * + * You can select more than one flag by concatenation using the bitwise or + * operator|(TriangulationInfoCacheFlags,TriangulationInfoCacheFlags). + * + * @author Luca Heltai, 2017. + */ enum TriangulationInfoCacheFlags { /** @@ -45,10 +45,10 @@ enum TriangulationInfoCacheFlags /** - * Output operator which outputs assemble flags as a set of or'd text values. - * - * @ref TriangulationInfoCacheFlags - */ + * Output operator which outputs assemble flags as a set of or'd text values. + * + * @ref TriangulationInfoCacheFlags + */ template inline StreamType &operator << (StreamType &s, TriangulationInfoCacheFlags u) @@ -60,14 +60,14 @@ StreamType &operator << (StreamType &s, TriangulationInfoCacheFlags u) /** - * Global operator which returns an object in which all bits are set which are - * either set in the first or the second argument. This operator exists since - * if it did not then the result of the bit-or operator | would be an - * integer which would in turn trigger a compiler warning when we tried to - * assign it to an object of type TriangulationInfoCacheFlags. - * - * @ref TriangulationInfoCacheFlags - */ + * Global operator which returns an object in which all bits are set which are + * either set in the first or the second argument. This operator exists since + * if it did not then the result of the bit-or operator | would be an + * integer which would in turn trigger a compiler warning when we tried to + * assign it to an object of type TriangulationInfoCacheFlags. + * + * @ref TriangulationInfoCacheFlags + */ inline TriangulationInfoCacheFlags operator | (TriangulationInfoCacheFlags f1, TriangulationInfoCacheFlags f2) @@ -81,11 +81,11 @@ operator | (TriangulationInfoCacheFlags f1, TriangulationInfoCacheFlags f2) /** - * Global operator which sets the bits from the second argument also in the - * first one. - * - * @ref TriangulationInfoCacheFlags - */ + * Global operator which sets the bits from the second argument also in the + * first one. + * + * @ref TriangulationInfoCacheFlags + */ inline TriangulationInfoCacheFlags & operator |= (TriangulationInfoCacheFlags &f1, TriangulationInfoCacheFlags f2) @@ -96,14 +96,14 @@ operator |= (TriangulationInfoCacheFlags &f1, TriangulationInfoCacheFlags f2) /** - * Global operator which returns an object in which all bits are set which are - * set in the first as well as the second argument. This operator exists since - * if it did not then the result of the bit-and operator & would be - * an integer which would in turn trigger a compiler warning when we tried to - * assign it to an object of type TriangulationInfoCacheFlags. - * - * @ref TriangulationInfoCacheFlags - */ + * Global operator which returns an object in which all bits are set which are + * set in the first as well as the second argument. This operator exists since + * if it did not then the result of the bit-and operator & would be + * an integer which would in turn trigger a compiler warning when we tried to + * assign it to an object of type TriangulationInfoCacheFlags. + * + * @ref TriangulationInfoCacheFlags + */ inline TriangulationInfoCacheFlags operator & (TriangulationInfoCacheFlags f1, TriangulationInfoCacheFlags f2) @@ -115,11 +115,11 @@ operator & (TriangulationInfoCacheFlags f1, TriangulationInfoCacheFlags f2) /** - * Global operator which clears all the bits in the first argument if they are - * not also set in the second argument. - * - * @ref TriangulationInfoCacheFlags - */ + * Global operator which clears all the bits in the first argument if they are + * not also set in the second argument. + * + * @ref TriangulationInfoCacheFlags + */ inline TriangulationInfoCacheFlags & operator &= (TriangulationInfoCacheFlags &f1, TriangulationInfoCacheFlags f2) diff --git a/source/grid/tria_info_cache.cc b/source/grid/tria_info_cache.cc index 3f4c759e62..5be00323a0 100644 --- a/source/grid/tria_info_cache.cc +++ b/source/grid/tria_info_cache.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2016 by the deal.II authors +// Copyright (C) 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -19,7 +19,8 @@ DEAL_II_NAMESPACE_OPEN template -TriangulationInfoCache::TriangulationInfoCache(const Triangulation &tria, +TriangulationInfoCache::TriangulationInfoCache( + const Triangulation &tria, const TriangulationInfoCacheFlags &flags, const Mapping &mapping) : tria(&tria), @@ -30,15 +31,20 @@ TriangulationInfoCache::TriangulationInfoCache(const Triangulation { update(); }); + + if(tria.n_active_cells()>0) + update(); } + + template void TriangulationInfoCache::update(bool topology_is_unchanged) { - if (cache_vertex_to_cell_map & flags) - { - vertex_to_cells = GridTools::vertex_to_cell_map(*tria); - } + if(topology_is_unchanged == false) { + if (cache_vertex_to_cell_map & flags) + vertex_to_cells = GridTools::vertex_to_cell_map(*tria); + } } template diff --git a/source/grid/tria_info_cache.inst.in b/source/grid/tria_info_cache.inst.in index b55e5ef223..7f03011ace 100644 --- a/source/grid/tria_info_cache.inst.in +++ b/source/grid/tria_info_cache.inst.in @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2010 - 2016 by the deal.II authors +// Copyright (C) 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -15,7 +15,7 @@ -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension template class TriangulationInfoCache; -- 2.39.5