From aca066cca84355f96b39e983989e1559105e9d72 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 27 Jun 2005 15:03:21 +0000 Subject: [PATCH] Split a function to avoid a pointless warning in this code for 1d: else if (dim == 3) { // see whether the // given line is on the // given face. for (unsigned int l=0; l::lines_per_face; ++l) if (GeometryInfo<3>::face_to_cell_lines(face_index, l) == line_index) return true; Both gcc and icc complain that the loop condition is always false in 1d, missing the fact that this loop is only ever executed if dim!=1... git-svn-id: https://svn.dealii.org/trunk@10953 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/fe/fe_q.cc | 204 ++++++++++++++++-------------- 1 file changed, 109 insertions(+), 95 deletions(-) diff --git a/deal.II/deal.II/source/fe/fe_q.cc b/deal.II/deal.II/source/fe/fe_q.cc index ea58894af9..06ef2603eb 100644 --- a/deal.II/deal.II/source/fe/fe_q.cc +++ b/deal.II/deal.II/source/fe/fe_q.cc @@ -1081,16 +1081,17 @@ FE_Q::initialize_restriction () // Data field initialization //--------------------------------------------------------------------------- +#if deal_II_dimension == 1 -template +template <> bool -FE_Q::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const +FE_Q<1>::has_support_on_face (const unsigned int shape_index, + const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, ExcIndexRange (shape_index, 0, this->dofs_per_cell)); - Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + Assert (face_index < GeometryInfo<1>::faces_per_cell, + ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); // in 1d, things are simple. since @@ -1099,101 +1100,113 @@ FE_Q::has_support_on_face (const unsigned int shape_index, // class, the first is on vertex 0 // (==face 0 in some sense), the // second on face 1: - if (dim==1) - return (((shape_index == 0) && (face_index == 0)) || - ((shape_index == 1) && (face_index == 1))); - else - // more dimensions - { - // first, special-case interior - // shape functions, since they - // have no support no-where on - // the boundary - if (((dim==2) && (shape_index>=this->first_quad_index)) - || - ((dim==3) && (shape_index>=this->first_hex_index))) - return false; + return (((shape_index == 0) && (face_index == 0)) || + ((shape_index == 1) && (face_index == 1))); +} + + +#else + + +template +bool +FE_Q::has_support_on_face (const unsigned int shape_index, + const unsigned int face_index) const +{ + Assert (shape_index < this->dofs_per_cell, + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + Assert (face_index < GeometryInfo::faces_per_cell, + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + + + // first, special-case interior + // shape functions, since they + // have no support no-where on + // the boundary + if (((dim==2) && (shape_index>=this->first_quad_index)) + || + ((dim==3) && (shape_index>=this->first_hex_index))) + return false; - // let's see whether this is a - // vertex - if (shape_index < this->first_line_index) - { - // for Q elements, there is - // one dof per vertex, so - // shape_index==vertex_number. check - // whether this vertex is - // on the given face. thus, - // for each face, give a - // list of vertices - const unsigned int vertex_no = shape_index; - Assert (vertex_no < GeometryInfo::vertices_per_cell, - ExcInternalError()); - - for (unsigned int v=0; v::vertices_per_face; ++v) - if (GeometryInfo::face_to_cell_vertices(face_index, v) == vertex_no) - return true; - - return false; - } - else if (shape_index < this->first_quad_index) - // ok, dof is on a line + // let's see whether this is a + // vertex + if (shape_index < this->first_line_index) + { + // for Q elements, there is + // one dof per vertex, so + // shape_index==vertex_number. check + // whether this vertex is + // on the given face. thus, + // for each face, give a + // list of vertices + const unsigned int vertex_no = shape_index; + Assert (vertex_no < GeometryInfo::vertices_per_cell, + ExcInternalError()); + + for (unsigned int v=0; v::vertices_per_face; ++v) + if (GeometryInfo::face_to_cell_vertices(face_index, v) == vertex_no) + return true; + + return false; + } + else if (shape_index < this->first_quad_index) + // ok, dof is on a line + { + const unsigned int line_index + = (shape_index - this->first_line_index) / this->dofs_per_line; + Assert (line_index < GeometryInfo::lines_per_cell, + ExcInternalError()); + + // in 2d, the line is the + // face, so get the line + // index + if (dim == 2) + return (line_index == face_index); + else if (dim == 3) { - const unsigned int line_index - = (shape_index - this->first_line_index) / this->dofs_per_line; - Assert (line_index < GeometryInfo::lines_per_cell, - ExcInternalError()); - - // in 2d, the line is the - // face, so get the line - // index - if (dim == 2) - return (line_index == face_index); - else if (dim == 3) - { - // see whether the - // given line is on the - // given face. - for (unsigned int l=0; l::lines_per_face; ++l) - if (GeometryInfo<3>::face_to_cell_lines(face_index, l) == line_index) - return true; - - return false; - } - else - Assert (false, ExcNotImplemented()); + // see whether the + // given line is on the + // given face. + for (unsigned int l=0; l::lines_per_face; ++l) + if (GeometryInfo<3>::face_to_cell_lines(face_index, l) == line_index) + return true; + + return false; } - else if (shape_index < this->first_hex_index) - // dof is on a quad - { - const unsigned int quad_index - = (shape_index - this->first_quad_index) / this->dofs_per_quad; - Assert (static_cast(quad_index) < - static_cast(GeometryInfo::quads_per_cell), - ExcInternalError()); + else + Assert (false, ExcNotImplemented()); + } + else if (shape_index < this->first_hex_index) + // dof is on a quad + { + const unsigned int quad_index + = (shape_index - this->first_quad_index) / this->dofs_per_quad; + Assert (static_cast(quad_index) < + static_cast(GeometryInfo::quads_per_cell), + ExcInternalError()); - // in 2d, cell bubble are - // zero on all faces. but - // we have treated this - // case above already - Assert (dim != 2, ExcInternalError()); - - // in 3d, - // quad_index=face_index - if (dim == 3) - return (quad_index == face_index); - else - Assert (false, ExcNotImplemented()); - } + // in 2d, cell bubble are + // zero on all faces. but + // we have treated this + // case above already + Assert (dim != 2, ExcInternalError()); + + // in 3d, + // quad_index=face_index + if (dim == 3) + return (quad_index == face_index); else - // dof on hex - { - // can only happen in 3d, - // but this case has - // already been covered - // above - Assert (false, ExcNotImplemented()); - return false; - } + Assert (false, ExcNotImplemented()); + } + else + // dof on hex + { + // can only happen in 3d, + // but this case has + // already been covered + // above + Assert (false, ExcNotImplemented()); + return false; } // we should not have gotten here @@ -1201,6 +1214,7 @@ FE_Q::has_support_on_face (const unsigned int shape_index, return false; } +#endif template -- 2.39.5