From e2eef0208f8a4b353801524f4de6f2fc215d86b6 Mon Sep 17 00:00:00 2001 From: Lukas Korous Date: Tue, 13 Jan 2015 14:04:39 +0100 Subject: [PATCH] Add minimal workaround for Visual Studio DoFHandler problems. --- include/deal.II/hp/dof_handler.h | 9 ++++++ source/hp/dof_handler.cc | 55 +++++++++++++++++++------------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/include/deal.II/hp/dof_handler.h b/include/deal.II/hp/dof_handler.h index 32bd48cf35..46c1edcf08 100644 --- a/include/deal.II/hp/dof_handler.h +++ b/include/deal.II/hp/dof_handler.h @@ -152,7 +152,11 @@ namespace hp * * @ingroup Iterators */ +#ifndef _MSC_VER typedef typename ActiveSelector::active_cell_iterator active_cell_iterator; +#else + typedef TriaActiveIterator < dealii::DoFCellAccessor < DoFHandler < dim, spacedim >, false > > active_cell_iterator; +#endif typedef typename LevelSelector::cell_iterator level_cell_iterator; @@ -182,7 +186,12 @@ namespace hp * * @ingroup Iterators */ +#ifndef _MSC_VER typedef typename ActiveSelector::cell_iterator cell_iterator; +#else + typedef TriaIterator < dealii::DoFCellAccessor < DoFHandler < dim, spacedim >, false > > cell_iterator; +#endif + typedef typename ActiveSelector::face_iterator face_iterator; typedef typename ActiveSelector::active_face_iterator active_face_iterator; diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 29b0a69e55..975c3f228e 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -33,6 +33,17 @@ DEAL_II_NAMESPACE_OPEN +// The following is necessary for compilation under Visual Studio which is unable to correctly +// distinguish between dealii::DoFHandler and dealii::hp::DoFHandler. +// Plus it makes code in dof_handler.cc easier to read. +// Requires C++11 support which is in Visual Studio 2013 and newer. +#if _MSC_VER >= 1800 +template using HpDoFHandler = ::dealii::hp::DoFHandler; +#else +// When using older Visual Studio or a different compiler just fall back. +#define HpDoFHandler DoFHandler +#endif + namespace parallel { namespace distributed @@ -227,7 +238,7 @@ namespace internal vertex_fe_association (dof_handler.finite_elements->size(), std::vector (dof_handler.tria->n_vertices(), false)); - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int v=0; v::vertices_per_cell; ++v) vertex_fe_association[cell->active_fe_index()][cell->vertex_index(v)] @@ -401,7 +412,7 @@ namespace internal if (fe.dofs_per_line > 0) for (unsigned int l=0; l::lines_per_cell; ++l) { - typename DoFHandler::line_iterator + typename HpDoFHandler::line_iterator line = cell->line(l); if (line->dof_index(0,fe_index) == @@ -464,7 +475,7 @@ namespace internal if (fe.dofs_per_line > 0) for (unsigned int l=0; l::lines_per_cell; ++l) { - typename DoFHandler::line_iterator + typename HpDoFHandler::line_iterator line = cell->line(l); if (line->dof_index(0,fe_index) == @@ -477,7 +488,7 @@ namespace internal if (fe.dofs_per_quad > 0) for (unsigned int q=0; q::quads_per_cell; ++q) { - typename DoFHandler::quad_iterator + typename HpDoFHandler::quad_iterator quad = cell->quad(q); if (quad->dof_index(0,fe_index) == @@ -587,7 +598,7 @@ namespace internal types::global_dof_index next_free_dof = 0; types::global_dof_index cache_size = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell) if (!cell->has_children()) @@ -618,7 +629,7 @@ namespace internal for (unsigned int level=0; leveln_levels(); ++level) { types::global_dof_index counter = 0; - for (typename DoFHandler::cell_iterator + for (typename HpDoFHandler::cell_iterator cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell) if (!cell->has_children()) @@ -715,7 +726,7 @@ namespace internal types::global_dof_index next_free_dof = 0; types::global_dof_index cache_size = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell) if (!cell->has_children()) @@ -746,7 +757,7 @@ namespace internal for (unsigned int level=0; leveln_levels(); ++level) { types::global_dof_index counter = 0; - for (typename DoFHandler::cell_iterator + for (typename HpDoFHandler::cell_iterator cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell) if (!cell->has_children()) @@ -804,7 +815,7 @@ namespace internal // on each level unsigned int n_line_slots = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (! cell->face(face)->user_flag_set()) @@ -884,7 +895,7 @@ namespace internal unsigned int next_free_line_slot = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (! cell->face(face)->user_flag_set()) @@ -1091,7 +1102,7 @@ namespace internal types::global_dof_index next_free_dof = 0; types::global_dof_index cache_size = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell) if (!cell->has_children()) @@ -1122,7 +1133,7 @@ namespace internal for (unsigned int level=0; leveln_levels(); ++level) { types::global_dof_index counter = 0; - for (typename DoFHandler::cell_iterator + for (typename HpDoFHandler::cell_iterator cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell) if (!cell->has_children()) @@ -1179,7 +1190,7 @@ namespace internal // class) we will have to store unsigned int n_quad_slots = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (! cell->face(face)->user_flag_set()) @@ -1266,7 +1277,7 @@ namespace internal unsigned int next_free_quad_slot = 0; - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (! cell->face(face)->user_flag_set()) @@ -1420,7 +1431,7 @@ namespace internal std::vector (dof_handler.tria->n_raw_lines(), false)); - for (typename DoFHandler::active_cell_iterator + for (typename HpDoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int l=0; l::lines_per_cell; ++l) @@ -1683,7 +1694,7 @@ namespace hp template typename DoFHandler::cell_iterator - DoFHandler::begin (const unsigned int level) const + DoFHandler::begin(const unsigned int level) const { return cell_iterator (*this->get_tria().begin(level), this); @@ -1952,8 +1963,8 @@ namespace hp // boundaries of dimension dim-2, // and so every boundary line is // also part of a boundary face. - typename DoFHandler::active_cell_iterator cell = this->begin_active (), - endc = this->end(); + typename HpDoFHandler::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->at_boundary(f)) @@ -1986,8 +1997,8 @@ namespace hp std::vector dofs_on_face; dofs_on_face.reserve (this->get_fe ().max_dofs_per_face()); - typename DoFHandler::active_cell_iterator cell = this->begin_active (), - endc = this->end(); + typename HpDoFHandler::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->at_boundary(f) && @@ -2022,8 +2033,8 @@ namespace hp std::vector dofs_on_face; dofs_on_face.reserve (this->get_fe ().max_dofs_per_face()); - typename DoFHandler::active_cell_iterator cell = this->begin_active (), - endc = this->end(); + typename HpDoFHandler::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->at_boundary(f) && -- 2.39.5