From 094330e14990b17fece250256ba2b1d12ff7d4f9 Mon Sep 17 00:00:00 2001 From: kanschat Date: Sun, 27 May 2007 21:18:14 +0000 Subject: [PATCH] remove specializations of TriaLevel for lower dimensions specialization in 3D cannot be avoided, unless TriaObjects is improved git-svn-id: https://svn.dealii.org/trunk@14717 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/grid/tria_accessor.templates.h | 38 ++-- deal.II/deal.II/include/grid/tria_levels.h | 152 +++++----------- deal.II/deal.II/include/grid/tria_objects.h | 2 +- deal.II/deal.II/source/grid/tria.cc | 98 +++++----- deal.II/deal.II/source/grid/tria_accessor.cc | 36 ++-- .../source/grid/tria_levels.all_dimensions.cc | 83 +-------- deal.II/deal.II/source/grid/tria_levels.cc | 169 ++++++++++++++++-- deal.II/deal.II/source/hp/dof_handler.cc | 12 +- 8 files changed, 290 insertions(+), 300 deletions(-) diff --git a/deal.II/deal.II/include/grid/tria_accessor.templates.h b/deal.II/deal.II/include/grid/tria_accessor.templates.h index 12e354bfa3..15549f863c 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -252,7 +252,7 @@ inline internal::Triangulation::TriaObjects & TriaObjectAccessor<1,1>::lines() const { - return this->tria->levels[this->present_level]->lines; + return this->tria->levels[this->present_level]->cells; } @@ -448,7 +448,7 @@ TriaObjectAccessor<1,1>::operator ++ () // the vector? while (this->present_index >= - static_cast(this->tria->levels[this->present_level]->lines.cells.size())) + static_cast(this->tria->levels[this->present_level]->cells.cells.size())) { // no -> go one level up until we find // one with more than zero cells @@ -503,7 +503,7 @@ TriaObjectAccessor<1,1>::operator -- () return; } // else - this->present_index = this->tria->levels[this->present_level]->lines.cells.size()-1; + this->present_index = this->tria->levels[this->present_level]->cells.cells.size()-1; } } @@ -534,7 +534,7 @@ inline internal::Triangulation::TriaObjects & TriaObjectAccessor<2,2>::quads() const { - return this->tria->levels[this->present_level]->quads; + return this->tria->levels[this->present_level]->cells; } @@ -862,7 +862,7 @@ TriaObjectAccessor<3,3>::used () const { Assert (this->state() == IteratorState::valid, TriaAccessorExceptions::ExcDereferenceInvalidObject()); - return this->tria->levels[this->present_level]->hexes.used[this->present_index]; + return this->tria->levels[this->present_level]->cells.used[this->present_index]; } @@ -873,7 +873,7 @@ bool TriaObjectAccessor<3,3>::user_flag_set () const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); - return this->tria->levels[this->present_level]->hexes.user_flags[this->present_index]; + return this->tria->levels[this->present_level]->cells.user_flags[this->present_index]; } @@ -884,7 +884,7 @@ void TriaObjectAccessor<3,3>::set_user_flag () const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = true; + this->tria->levels[this->present_level]->cells.user_flags[this->present_index] = true; } @@ -894,7 +894,7 @@ inline void TriaObjectAccessor<3,3>::clear_user_flag () const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = false; + this->tria->levels[this->present_level]->cells.user_flags[this->present_index] = false; } @@ -989,7 +989,7 @@ TriaObjectAccessor<3,3>::quad_index (const unsigned int i) const { Assert (i<6, ExcIndexRange(i,0,6)); - return this->tria->levels[this->present_level]->hexes.cells[this->present_index].face(i); + return this->tria->levels[this->present_level]->cells.cells[this->present_index].face(i); } @@ -1001,7 +1001,7 @@ TriaObjectAccessor<3,3>::has_children () const { Assert (this->state() == IteratorState::valid, TriaAccessorExceptions::ExcDereferenceInvalidObject()); - return (this->tria->levels[this->present_level]->hexes.children[this->present_index] != -1); + return (this->tria->levels[this->present_level]->cells.children[this->present_index] != -1); } @@ -1011,7 +1011,7 @@ int TriaObjectAccessor<3,3>::child_index (const unsigned int i) const { Assert (i<8, ExcIndexRange(i,0,8)); Assert (has_children(), TriaAccessorExceptions::ExcCellHasNoChildren()); - return this->tria->levels[this->present_level]->hexes.children[this->present_index]+i; + return this->tria->levels[this->present_level]->cells.children[this->present_index]+i; } @@ -1080,11 +1080,11 @@ face_orientation (const unsigned int face) const ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face < this->tria->levels[this->present_level] - ->hexes.face_orientations.size(), + ->cells.face_orientations.size(), ExcInternalError()); return (this->tria->levels[this->present_level] - ->hexes.face_orientations[this->present_index * + ->cells.face_orientations[this->present_index * GeometryInfo<3>::faces_per_cell + face]); } @@ -1101,11 +1101,11 @@ face_flip (const unsigned int face) const ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face < this->tria->levels[this->present_level] - ->hexes.face_flips.size(), + ->cells.face_flips.size(), ExcInternalError()); return (this->tria->levels[this->present_level] - ->hexes.face_flips[this->present_index * + ->cells.face_flips[this->present_index * GeometryInfo<3>::faces_per_cell + face]); } @@ -1122,11 +1122,11 @@ face_rotation (const unsigned int face) const ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face < this->tria->levels[this->present_level] - ->hexes.face_rotations.size(), + ->cells.face_rotations.size(), ExcInternalError()); return (this->tria->levels[this->present_level] - ->hexes.face_rotations[this->present_index * + ->cells.face_rotations[this->present_index * GeometryInfo<3>::faces_per_cell + face]); } @@ -1231,7 +1231,7 @@ TriaObjectAccessor<3,3>::operator ++ () // the vector? while (this->present_index >= - static_cast(this->tria->levels[this->present_level]->hexes.cells.size())) + static_cast(this->tria->levels[this->present_level]->cells.cells.size())) { // no -> go one level up ++this->present_level; @@ -1268,7 +1268,7 @@ TriaObjectAccessor<3,3>::operator -- () return; } // else - this->present_index = this->tria->levels[this->present_level]->hexes.cells.size()-1; + this->present_index = this->tria->levels[this->present_level]->cells.cells.size()-1; } } diff --git a/deal.II/deal.II/include/grid/tria_levels.h b/deal.II/deal.II/include/grid/tria_levels.h index 8d6405561d..68acb12e98 100644 --- a/deal.II/deal.II/include/grid/tria_levels.h +++ b/deal.II/deal.II/include/grid/tria_levels.h @@ -26,34 +26,16 @@ namespace internal { namespace Triangulation { - -/** - * General template for information belonging to one level of a multilevel - * hierarchy of a triangulation. However, only the cells are really - * level-based data if anisotropic rfeinement is allowed. Therefore, only the - * information concerning cells is considered here, the information concerning - * cell-faces can be found in the TriaFaces classes. - * - * This template is only declared to allow - * specializations for different dimensions. - * - * @ingroup grid - */ - template - class TriaLevel - { - }; - - /** * Store all information which belongs to one level of the multilevel * hierarchy. * - * In TriaLevel<0> all data is stored which is not dependent on the + * In TriaLevel, all cell data is stored which is not dependent on the * dimension, e.g. a field to store the refinement flag for the cells - * (what a cell actually is is declared elsewhere), etc. Actually, it - * is only cell-based data, like neighborship info or refinement - * flags. There is another field, which may fit in here, namely the + * (what a cell actually is is declared elsewhere), etc. See also + * TriaObjects for non leveloriented data. + * + * There is another field, which may fit in here, namely the * material data (for cells) or the boundary indicators (for faces), * but since we need for a line or quad either boundary information or * material data, we store them with the lines and quads rather than @@ -63,10 +45,10 @@ namespace internal * material data for cells. * * @ingroup grid - * @author Wolfgang Bangerth, 1998 + * @author Wolfgang Bangerth, Guido Kanschat, 1998, 2007 */ - template <> - class TriaLevel<0> + template + class TriaLevel { public: /** @@ -186,6 +168,13 @@ namespace internal * of this object. */ unsigned int memory_consumption () const; + + /** + * The object containing the data on lines and + * related functions + */ + TriaObjects > cells; + /** * Exception @@ -203,97 +192,52 @@ namespace internal << "The containers have sizes " << arg1 << " and " << arg2 << ", which is not as expected."); }; - - - + +//TODO: Replace TriaObjectsHex to avoid this specialization + /** - * Store all information which belongs to one level of the multilevel hierarchy. - * - * In one dimension, this contains the lines on this level. - * - * @ingroup grid - * @author Wolfgang Bangerth, 1998 + * Specialization of TriaLevels for 3D. Since we need TriaObjectsHex + * instead of TriaObjects. Refer to the documentation of the template + * for details. */ - template <> - class TriaLevel<1> : public TriaLevel<0> - + template<> + class TriaLevel<3> { public: - /** - * The object containing the data on lines and - * related functions - */ - TriaObjects lines; - - public: - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. - */ + std::vector refine_flags; + std::vector coarsen_flags; + std::vector > neighbors; + std::vector subdomain_ids; + void reserve_space (const unsigned int total_cells, + const unsigned int dimension); + void monitor_memory (const unsigned int true_dimension) const; unsigned int memory_consumption () const; - }; - + TriaObjectsHex cells; -/** - * Store all information which belongs to one level of the multilevel hierarchy. - * - * In 2D this is a vector ocontains the quads on this level. - * - * @ingroup grid - * @author Wolfgang Bangerth, 1998 - */ - template <> - class TriaLevel<2> : public TriaLevel<0> - { - public: - /** - * The object containing the data on quads and - * related functions - */ - TriaObjects quads; - - public: - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. + /** + * Exception */ - unsigned int memory_consumption () const; - }; - - - -/** - * Store all information which belongs to one level of the multilevel hierarchy. - * - * In 3D this contains the hexahedra on this levels, - * - * @ingroup grid - * @author Wolfgang Bangerth, 1998, 2003 - */ - template <> - class TriaLevel<3> : public TriaLevel<0> - { - public: - /** - * The object containing the data on hexes and - * related functions - */ - TriaObjectsHex hexes; - - public: - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. + DeclException3 (ExcMemoryWasted, + char*, int, int, + << "The container " << arg1 << " contains " + << arg2 << " elements, but it`s capacity is " + << arg3 << "."); + /** + * Exception */ - unsigned int memory_consumption () const; + DeclException2 (ExcMemoryInexact, + int, int, + << "The containers have sizes " << arg1 << " and " + << arg2 << ", which is not as expected."); }; + + } } + + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/deal.II/deal.II/include/grid/tria_objects.h b/deal.II/deal.II/include/grid/tria_objects.h index defdce2a0c..cfc33e0b58 100644 --- a/deal.II/deal.II/include/grid/tria_objects.h +++ b/deal.II/deal.II/include/grid/tria_objects.h @@ -283,7 +283,7 @@ namespace internal * @ingroup grid */ - class TriaObjectsHex: public TriaObjects + class TriaObjectsHex: public TriaObjects > { public: diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index f8bf1d9ce7..4d8e5a6377 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -309,9 +309,8 @@ void Triangulation<1>::create_triangulation (const std::vector > &v, // reserve enough space levels.push_back (new internal::Triangulation::TriaLevel); - levels[0]->internal::Triangulation::TriaLevel<0> - ::reserve_space (cells.size(), dim); - levels[0]->lines.reserve_space (cells.size()); + levels[0]->reserve_space (cells.size(), dim); + levels[0]->cells.reserve_space (cells.size()); // make up cells raw_line_iterator next_free_line = begin_raw_line (); @@ -594,10 +593,9 @@ void Triangulation<2>::create_triangulation (const std::vector > &v, // reserve enough space levels.push_back (new internal::Triangulation::TriaLevel); faces = new internal::Triangulation::TriaFaces; - levels[0]->internal::Triangulation::TriaLevel<0> - ::reserve_space (cells.size(), dim); + levels[0]->reserve_space (cells.size(), dim); faces->lines.reserve_space (needed_lines.size()); - levels[0]->quads.reserve_space (cells.size()); + levels[0]->cells.reserve_space (cells.size()); // make up lines if (true) @@ -1018,8 +1016,7 @@ Triangulation<3>::create_triangulation (const std::vector > &v, // reserve enough space levels.push_back (new internal::Triangulation::TriaLevel); faces = new internal::Triangulation::TriaFaces; - levels[0]->internal::Triangulation::TriaLevel<0> - ::reserve_space (cells.size(), dim); + levels[0]->reserve_space (cells.size(), dim); faces->lines.reserve_space (needed_lines.size()); // make up lines @@ -1228,7 +1225,7 @@ Triangulation<3>::create_triangulation (const std::vector > &v, ///////////////////////////////// // finally create the cells - levels[0]->hexes.reserve_space (cells.size()); + levels[0]->cells.reserve_space (cells.size()); // store for each quad index the // adjacent cells @@ -2127,7 +2124,7 @@ template <> void Triangulation<1>::clear_user_data () { for (unsigned int level=0;levellines.clear_user_data(); + levels[level]->cells.clear_user_data(); } @@ -2167,7 +2164,7 @@ template <> void Triangulation<2>::clear_user_data () { for (unsigned int level=0;levelquads.clear_user_data(); + levels[level]->cells.clear_user_data(); faces->lines.clear_user_data(); } @@ -2204,7 +2201,7 @@ template <> void Triangulation<3>::clear_user_data () { for (unsigned int level=0;levelhexes.clear_user_data(); + levels[level]->cells.clear_user_data(); faces->quads.clear_user_data(); faces->lines.clear_user_data(); } @@ -3769,7 +3766,7 @@ Triangulation<1>::begin_raw_line (const unsigned int level) const { Assert (levellines.cells.size() == 0) + if (levels[level]->cells.cells.size() == 0) return end_line (); return raw_line_iterator (const_cast*>(this), @@ -3802,7 +3799,7 @@ Triangulation<2>::begin_raw_quad (const unsigned int level) const { Assert (levelquads.cells.size() == 0) + if (levels[level]->cells.cells.size() == 0) return end_quad(); return raw_quad_iterator (const_cast*>(this), @@ -3819,7 +3816,7 @@ Triangulation::begin_raw_hex (const unsigned int level) const { Assert (levelhexes.cells.size() == 0) + if (levels[level]->cells.cells.size() == 0) return end_hex(); return raw_hex_iterator (const_cast*>(this), @@ -3978,12 +3975,12 @@ Triangulation<1>::raw_line_iterator Triangulation<1>::last_raw_line (const unsigned int level) const { Assert (levellines.cells.size() != 0, + Assert (levels[level]->cells.cells.size() != 0, ExcEmptyLevel (level)); return raw_line_iterator (const_cast*>(this), level, - levels[level]->lines.cells.size()-1); + levels[level]->cells.cells.size()-1); } #endif @@ -4008,11 +4005,11 @@ Triangulation<2>::last_raw_quad (const unsigned int level) const { Assert (levelquads.cells.size() != 0, + Assert (levels[level]->cells.cells.size() != 0, ExcEmptyLevel (level)); return raw_quad_iterator (const_cast*>(this), level, - levels[level]->quads.cells.size()-1); + levels[level]->cells.cells.size()-1); } #endif @@ -4024,12 +4021,12 @@ Triangulation::last_raw_hex (const unsigned int level) const { Assert (levelhexes.cells.size() != 0, + Assert (levels[level]->cells.cells.size() != 0, ExcEmptyLevel (level)); return raw_hex_iterator (const_cast*>(this), level, - levels[level]->hexes.cells.size()-1); + levels[level]->cells.cells.size()-1); } @@ -4505,7 +4502,7 @@ template <> unsigned int Triangulation<1>::n_raw_lines (const unsigned int level) const { Assert(level < n_levels(), ExcIndexRange(level,0,n_levels())); - return levels[level]->lines.cells.size(); + return levels[level]->cells.cells.size(); } @@ -4632,7 +4629,7 @@ template <> unsigned int Triangulation<2>::n_raw_quads (const unsigned int level) const { Assert(level < n_levels(), ExcIndexRange(level,0,n_levels())); - return levels[level]->quads.cells.size(); + return levels[level]->cells.cells.size(); } #endif @@ -4753,7 +4750,7 @@ template unsigned int Triangulation::n_raw_hexs (const unsigned int level) const { Assert(level < n_levels(), ExcIndexRange(level,0,n_levels())); - return levels[level]->hexes.cells.size(); + return levels[level]->cells.cells.size(); } @@ -4983,8 +4980,8 @@ Triangulation<1>::execute_refinement () // count number of used cells // on the next higher level const unsigned int used_cells - = std::count_if (levels[level+1]->lines.used.begin(), - levels[level+1]->lines.used.end(), + = std::count_if (levels[level+1]->cells.used.begin(), + levels[level+1]->cells.used.end(), std::bind2nd (std::equal_to(), true)); // reserve space for the @@ -4993,15 +4990,13 @@ Triangulation<1>::execute_refinement () // level as well as for the // 2*flagged_cells that will be // created on that level - levels[level+1]-> - internal::Triangulation::TriaLevel<0> - ::reserve_space (used_cells+ - GeometryInfo<1>::children_per_cell * - flagged_cells, 1); + levels[level+1]->reserve_space( + used_cells+ + GeometryInfo<1>::children_per_cell * flagged_cells, 1); // reserve space for // 2*flagged_cells new lines on // the next higher level - levels[level+1]->lines. + levels[level+1]->cells. reserve_space (GeometryInfo<1>::children_per_cell*flagged_cells); needed_vertices += flagged_cells; @@ -5173,7 +5168,7 @@ Triangulation<1>::execute_refinement () #ifdef DEBUG for (unsigned int level=0; levellines.monitor_memory (1); + levels[level]->cells.monitor_memory (1); // check whether really all // refinement flags are reset (also @@ -5287,8 +5282,8 @@ Triangulation<2>::execute_refinement () // count number of used cells // on the next higher level const unsigned int used_cells - = std::count_if (levels[level+1]->quads.used.begin(), - levels[level+1]->quads.used.end(), + = std::count_if (levels[level+1]->cells.used.begin(), + levels[level+1]->cells.used.end(), std::bind2nd (std::equal_to(), true)); @@ -5298,15 +5293,13 @@ Triangulation<2>::execute_refinement () // level as well as for the // 4*flagged_cells that will be // created on that level - levels[level+1]-> - internal::Triangulation::TriaLevel<0> - ::reserve_space (used_cells+4*flagged_cells, 2); + levels[level+1]->reserve_space (used_cells+4*flagged_cells, 2); // reserve space for // 4*flagged_cells // new quads on the next higher // level - levels[level+1]->quads. + levels[level+1]->cells. reserve_space (4*flagged_cells); } @@ -5859,7 +5852,7 @@ Triangulation<2>::execute_refinement () #ifdef DEBUG for (unsigned int level=0; levelquads.monitor_memory (2); + levels[level]->cells.monitor_memory (2); // check whether really all // refinement flags are reset (also @@ -5993,8 +5986,8 @@ Triangulation<3>::execute_refinement () // count number of used cells on // the next higher level const unsigned int used_cells - = std::count_if (levels[level+1]->hexes.used.begin(), - levels[level+1]->hexes.used.end(), + = std::count_if (levels[level+1]->cells.used.begin(), + levels[level+1]->cells.used.end(), std::bind2nd (std::equal_to(), true)); @@ -6004,15 +5997,12 @@ Triangulation<3>::execute_refinement () // level as well as for the // 8*flagged_cells that will be // created on that level - levels[level+1]-> - internal::Triangulation::TriaLevel<0> - ::reserve_space (used_cells+8*flagged_cells, 3); + levels[level+1]->reserve_space (used_cells+8*flagged_cells, 3); // reserve space for // 8*flagged_cells // new hexes on the next higher // level - levels[level+1]->hexes. - reserve_space (8*flagged_cells); + levels[level+1]->cells.reserve_space (8*flagged_cells); } // now count the quads and @@ -7607,7 +7597,7 @@ Triangulation<3>::execute_refinement () #ifdef DEBUG for (unsigned int level=0; levelhexes.monitor_memory (3); + levels[level]->cells.monitor_memory (3); // check whether really all // refinement flags are reset (also @@ -9650,7 +9640,7 @@ void Triangulation<1>::update_number_cache_lines () { // count lines on this level number_cache.n_lines_level[level] = 0; - if (levels[level]->lines.cells.size() != 0) + if (levels[level]->cells.cells.size() != 0) { line_iterator line = begin_line (level), endc = (level == levels.size()-1 ? @@ -9672,7 +9662,7 @@ void Triangulation<1>::update_number_cache_lines () { // count lines on this level number_cache.n_active_lines_level[level] = 0; - if (levels[level]->lines.cells.size() != 0) + if (levels[level]->cells.cells.size() != 0) { active_line_iterator line = begin_active_line (level), endc = end_active_line (level); @@ -9741,7 +9731,7 @@ void Triangulation<2>::update_number_cache_quads () { // count quads on this level number_cache.n_quads_level[level] = 0; - if (levels[level]->quads.cells.size() != 0) + if (levels[level]->cells.cells.size() != 0) { quad_iterator quad = begin_quad (level), endc = (level == levels.size()-1 ? @@ -9763,7 +9753,7 @@ void Triangulation<2>::update_number_cache_quads () { // count quads on this level number_cache.n_active_quads_level[level] = 0; - if (levels[level]->quads.cells.size() != 0) + if (levels[level]->cells.cells.size() != 0) { active_quad_iterator quad = begin_active_quad (level), endc = end_active_quad (level); @@ -9849,7 +9839,7 @@ void Triangulation::update_number_cache_hexes () { // count hexes on this level number_cache.n_hexes_level[level] = 0; - if (levels[level]->hexes.cells.size() != 0) + if (levels[level]->cells.cells.size() != 0) { hex_iterator hex = begin_hex (level), endc = (level == levels.size()-1 ? @@ -9871,7 +9861,7 @@ void Triangulation::update_number_cache_hexes () { // count hexes on this level number_cache.n_active_hexes_level[level] = 0; - if (levels[level]->hexes.cells.size() != 0) + if (levels[level]->cells.cells.size() != 0) { active_hex_iterator hex = begin_active_hex (level), endc = end_active_hex (level); diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 95b071aa09..243e6a2d95 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -845,7 +845,7 @@ void TriaObjectAccessor<3, 3>::set (const internal::Triangulation::Hexahedron &hex) const { this->tria->levels[this->present_level] - ->hexes.cells[this->present_index] = hex; + ->cells.cells[this->present_index] = hex; } #endif @@ -890,7 +890,7 @@ void TriaObjectAccessor<3, 3>::set_used_flag () const { Assert (this->state() == IteratorState::valid, TriaAccessorExceptions::ExcDereferenceInvalidObject()); - this->tria->levels[this->present_level]->hexes.used[this->present_index] = true; + this->tria->levels[this->present_level]->cells.used[this->present_index] = true; } @@ -899,7 +899,7 @@ void TriaObjectAccessor<3, 3>::clear_used_flag () const { Assert (this->state() == IteratorState::valid, TriaAccessorExceptions::ExcDereferenceInvalidObject()); - this->tria->levels[this->present_level]->hexes.used[this->present_index] = false; + this->tria->levels[this->present_level]->cells.used[this->present_index] = false; } #endif @@ -934,7 +934,7 @@ template <> void TriaObjectAccessor<3, 3>::set_user_pointer (void *p) const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index) = p; + this->tria->levels[this->present_level]->cells.user_pointer(this->present_index) = p; } @@ -942,7 +942,7 @@ template <> void TriaObjectAccessor<3, 3>::clear_user_pointer () const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index) = 0; + this->tria->levels[this->present_level]->cells.user_pointer(this->present_index) = 0; } @@ -950,7 +950,7 @@ template <> void * TriaObjectAccessor<3, 3>::user_pointer () const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - return this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index); + return this->tria->levels[this->present_level]->cells.user_pointer(this->present_index); } @@ -958,7 +958,7 @@ template <> void TriaObjectAccessor<3, 3>::set_user_index (unsigned int p) const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.user_index(this->present_index) = p; + this->tria->levels[this->present_level]->cells.user_index(this->present_index) = p; } @@ -966,7 +966,7 @@ template <> void TriaObjectAccessor<3, 3>::clear_user_index () const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.user_index(this->present_index) = 0; + this->tria->levels[this->present_level]->cells.user_index(this->present_index) = 0; } @@ -974,7 +974,7 @@ template <> unsigned int TriaObjectAccessor<3, 3>::user_index () const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - return this->tria->levels[this->present_level]->hexes.user_index(this->present_index); + return this->tria->levels[this->present_level]->cells.user_index(this->present_index); } #endif @@ -1040,7 +1040,7 @@ void TriaObjectAccessor<3, 3>::set_children (const int index) const (!has_children() && (index>=0)), TriaAccessorExceptions::ExcCantSetChildren(index)); - this->tria->levels[this->present_level]->hexes.children[this->present_index] = index; + this->tria->levels[this->present_level]->cells.children[this->present_index] = index; } #endif @@ -1824,11 +1824,11 @@ set_face_orientation (const unsigned int face, ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face < this->tria->levels[this->present_level] - ->hexes.face_orientations.size(), + ->cells.face_orientations.size(), ExcInternalError()); this->tria->levels[this->present_level] - ->hexes.face_orientations[this->present_index * + ->cells.face_orientations[this->present_index * GeometryInfo<3>::faces_per_cell + face] = orientation; @@ -1846,11 +1846,11 @@ set_face_flip (const unsigned int face, ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face < this->tria->levels[this->present_level] - ->hexes.face_flips.size(), + ->cells.face_flips.size(), ExcInternalError()); this->tria->levels[this->present_level] - ->hexes.face_flips[this->present_index * + ->cells.face_flips[this->present_index * GeometryInfo<3>::faces_per_cell + face] = flip; @@ -1868,11 +1868,11 @@ set_face_rotation (const unsigned int face, ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face < this->tria->levels[this->present_level] - ->hexes.face_rotations.size(), + ->cells.face_rotations.size(), ExcInternalError()); this->tria->levels[this->present_level] - ->hexes.face_rotations[this->present_index * + ->cells.face_rotations[this->present_index * GeometryInfo<3>::faces_per_cell + face] = rotation; @@ -2087,14 +2087,14 @@ template <> unsigned char CellAccessor<3>::material_id () const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); - return this->tria->levels[this->present_level]->hexes.material_id[this->present_index]; + return this->tria->levels[this->present_level]->cells.material_id[this->present_index]; } template <> void CellAccessor<3>::set_material_id (const unsigned char mat_id) const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); - this->tria->levels[this->present_level]->hexes.material_id[this->present_index] + this->tria->levels[this->present_level]->cells.material_id[this->present_index] = mat_id; } diff --git a/deal.II/deal.II/source/grid/tria_levels.all_dimensions.cc b/deal.II/deal.II/source/grid/tria_levels.all_dimensions.cc index 45e6f2bf80..6df0e384d7 100644 --- a/deal.II/deal.II/source/grid/tria_levels.all_dimensions.cc +++ b/deal.II/deal.II/source/grid/tria_levels.all_dimensions.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2006 by the deal.II authors +// Copyright (C) 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -21,86 +21,7 @@ namespace internal { namespace Triangulation { - - void - TriaLevel<0>::reserve_space (const unsigned int total_cells, - const unsigned int dimension) - { - // we need space for total_cells - // cells. Maybe we have more already - // with those cells which are unused, - // so only allocate new space if needed. - // - // note that all arrays should have equal - // sizes (checked by @p{monitor_memory} - if (total_cells > refine_flags.size()) - { - refine_flags.reserve (total_cells); - refine_flags.insert (refine_flags.end(), - total_cells - refine_flags.size(), - false); - - coarsen_flags.reserve (total_cells); - coarsen_flags.insert (coarsen_flags.end(), - total_cells - coarsen_flags.size(), - false); - - subdomain_ids.reserve (total_cells); - subdomain_ids.insert (subdomain_ids.end(), - total_cells - subdomain_ids.size(), - 0); - - neighbors.reserve (total_cells*(2*dimension)); - neighbors.insert (neighbors.end(), - total_cells*(2*dimension) - neighbors.size(), - std::make_pair(-1,-1)); - }; - } - - - - void - TriaLevel<0>::monitor_memory (const unsigned int true_dimension) const - { - // check that we have not allocated - // too much memory. note that bool - // vectors allocate their memory in - // chunks of whole integers, so - // they may over-allocate by up to - // as many elements as an integer - // has bits - Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 || - refine_flags.size()::memory_consumption () const - { - return (MemoryConsumption::memory_consumption (refine_flags) + - MemoryConsumption::memory_consumption (coarsen_flags) + - MemoryConsumption::memory_consumption (neighbors)); - } - + } } diff --git a/deal.II/deal.II/source/grid/tria_levels.cc b/deal.II/deal.II/source/grid/tria_levels.cc index 81de320c5d..9f044db9bb 100644 --- a/deal.II/deal.II/source/grid/tria_levels.cc +++ b/deal.II/deal.II/source/grid/tria_levels.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2006 by the deal.II authors +// Copyright (C) 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,42 +22,177 @@ namespace internal { namespace Triangulation { + template + void + TriaLevel::reserve_space (const unsigned int total_cells, + const unsigned int dimension) + { + // we need space for total_cells + // cells. Maybe we have more already + // with those cells which are unused, + // so only allocate new space if needed. + // + // note that all arrays should have equal + // sizes (checked by @p{monitor_memory} + if (total_cells > refine_flags.size()) + { + refine_flags.reserve (total_cells); + refine_flags.insert (refine_flags.end(), + total_cells - refine_flags.size(), + false); + + coarsen_flags.reserve (total_cells); + coarsen_flags.insert (coarsen_flags.end(), + total_cells - coarsen_flags.size(), + false); + + subdomain_ids.reserve (total_cells); + subdomain_ids.insert (subdomain_ids.end(), + total_cells - subdomain_ids.size(), + 0); + + neighbors.reserve (total_cells*(2*dimension)); + neighbors.insert (neighbors.end(), + total_cells*(2*dimension) - neighbors.size(), + std::make_pair(-1,-1)); + }; + } -#if deal_II_dimension == 1 - unsigned int - TriaLevel<1>::memory_consumption () const + template + void + TriaLevel::monitor_memory (const unsigned int true_dimension) const { - return (TriaLevel<0>::memory_consumption() + - MemoryConsumption::memory_consumption (lines)); + // check that we have not allocated + // too much memory. note that bool + // vectors allocate their memory in + // chunks of whole integers, so + // they may over-allocate by up to + // as many elements as an integer + // has bits + Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 || + refine_flags.size() unsigned int - TriaLevel<2>::memory_consumption () const + TriaLevel::memory_consumption () const { - return (TriaLevel<0>::memory_consumption() + - MemoryConsumption::memory_consumption (quads)); + return (MemoryConsumption::memory_consumption (refine_flags) + + MemoryConsumption::memory_consumption (coarsen_flags) + + MemoryConsumption::memory_consumption (neighbors) + + MemoryConsumption::memory_consumption (cells)); } -#endif - +// This specialization should be only temporary, until the TriaObjects +// classes are straightened out. + #if deal_II_dimension == 3 + void + TriaLevel<3>::reserve_space (const unsigned int total_cells, + const unsigned int dimension) + { + // we need space for total_cells + // cells. Maybe we have more already + // with those cells which are unused, + // so only allocate new space if needed. + // + // note that all arrays should have equal + // sizes (checked by @p{monitor_memory} + if (total_cells > refine_flags.size()) + { + refine_flags.reserve (total_cells); + refine_flags.insert (refine_flags.end(), + total_cells - refine_flags.size(), + false); + + coarsen_flags.reserve (total_cells); + coarsen_flags.insert (coarsen_flags.end(), + total_cells - coarsen_flags.size(), + false); + + subdomain_ids.reserve (total_cells); + subdomain_ids.insert (subdomain_ids.end(), + total_cells - subdomain_ids.size(), + 0); + + neighbors.reserve (total_cells*(2*dimension)); + neighbors.insert (neighbors.end(), + total_cells*(2*dimension) - neighbors.size(), + std::make_pair(-1,-1)); + }; + } + + + void + TriaLevel<3>::monitor_memory (const unsigned int true_dimension) const + { + // check that we have not allocated + // too much memory. note that bool + // vectors allocate their memory in + // chunks of whole integers, so + // they may over-allocate by up to + // as many elements as an integer + // has bits + Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 || + refine_flags.size()::memory_consumption () const { - return (TriaLevel<0>::memory_consumption() + - MemoryConsumption::memory_consumption (hexes)); + return (MemoryConsumption::memory_consumption (refine_flags) + + MemoryConsumption::memory_consumption (coarsen_flags) + + MemoryConsumption::memory_consumption (neighbors) + + MemoryConsumption::memory_consumption (cells)); } #endif - + } } + +template class internal::Triangulation::TriaLevel; + + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/deal.II/source/hp/dof_handler.cc b/deal.II/deal.II/source/hp/dof_handler.cc index 33d6c7572f..d229c18a76 100644 --- a/deal.II/deal.II/source/hp/dof_handler.cc +++ b/deal.II/deal.II/source/hp/dof_handler.cc @@ -4345,8 +4345,8 @@ namespace hp new std::vector (lines_on_level); // Check for each cell, if it has children. - transform (tria.levels[i]->lines.children.begin (), - tria.levels[i]->lines.children.end (), + transform (tria.levels[i]->cells.children.begin (), + tria.levels[i]->cells.children.end (), has_children_level->begin (), std::bind2nd (std::not_equal_to(), -1)); @@ -4374,8 +4374,8 @@ namespace hp new std::vector (quads_on_level); // Check for each cell, if it has children. - std::transform (tria.levels[i]->quads.children.begin (), - tria.levels[i]->quads.children.end (), + std::transform (tria.levels[i]->cells.children.begin (), + tria.levels[i]->cells.children.end (), has_children_level->begin (), std::bind2nd (std::not_equal_to(), -1)); @@ -4403,8 +4403,8 @@ namespace hp // Check for each cell, if it // has children. - transform (tria.levels[i]->hexes.children.begin (), - tria.levels[i]->hexes.children.end (), + transform (tria.levels[i]->cells.children.begin (), + tria.levels[i]->cells.children.end (), has_children_level->begin (), std::bind2nd (std::not_equal_to(), -1)); -- 2.39.5