From: guido Date: Thu, 8 Jun 2006 08:01:20 +0000 (+0000) Subject: simplify face_to_equivalent_cell_index and add face_to_cell_index X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0569ae968d803174de77c9380950f53b008854c0;p=dealii-svn.git simplify face_to_equivalent_cell_index and add face_to_cell_index git-svn-id: https://svn.dealii.org/trunk@13205 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe_base.h b/deal.II/deal.II/include/fe/fe_base.h index 421d62bca7..e48f7c0d2c 100644 --- a/deal.II/deal.II/include/fe/fe_base.h +++ b/deal.II/deal.II/include/fe/fe_base.h @@ -396,6 +396,25 @@ class FiniteElementData bool conforms (const Conformity) const; /** + * Given an index in the natural + * ordering of indices on a face, + * return the index of the same + * degree of freedom on the cell. + * + */ + unsigned int face_to_cell_index(unsigned int face_index, + unsigned int face, + bool orientation = true) const; + + /** + * @deprecated This function is + * just a special version of + * face_to_cell_index for the face + * zero. It is therefore of + * limited use in aplications and + * most of the time, the other + * function is what is required. + * * Given an index in the natural * ordering of indices on a face, * return the index of an @@ -423,6 +442,7 @@ class FiniteElementData * if (fe.is_primitive(fe.face_to_equivalent_cell_index(i))) * ... do whatever * @endcode + * */ unsigned int face_to_equivalent_cell_index (const unsigned int index) const; @@ -535,7 +555,7 @@ FiniteElementData<1>:: face_to_equivalent_cell_index (const unsigned int index) const { Assert (index < dofs_per_face, - ExcIndexRange (index, 0, dofs_per_vertex)); + ExcIndexRange (index, 0, dofs_per_face)); return index; } @@ -548,17 +568,11 @@ FiniteElementData<2>:: face_to_equivalent_cell_index (const unsigned int index) const { Assert (index < dofs_per_face, - ExcIndexRange (index, 0, dofs_per_vertex)); - return (index < (GeometryInfo<2>::vertices_per_face * - this->dofs_per_vertex) - ? - index - : - GeometryInfo<2>::vertices_per_cell * - this->dofs_per_vertex + - (index - - GeometryInfo<2>::vertices_per_face * - this->dofs_per_vertex)); + ExcIndexRange (index, 0, dofs_per_face)); + return (index < (this->first_face_line_index) + ? index + : this->first_line_index + + (index - this->first_face_line_index)); } @@ -571,34 +585,15 @@ FiniteElementData<3>:: face_to_equivalent_cell_index (const unsigned int index) const { Assert (index < dofs_per_face, - ExcIndexRange (index, 0, dofs_per_vertex)); + ExcIndexRange (index, 0, dofs_per_face)); return (index < (GeometryInfo<3>::vertices_per_face * this->dofs_per_vertex) - ? - index - : - (index < (GeometryInfo<3>::vertices_per_face * - this->dofs_per_vertex - + - GeometryInfo<3>::lines_per_face * - this->dofs_per_line) - ? - GeometryInfo<3>::vertices_per_cell * - this->dofs_per_vertex + - (index - - GeometryInfo<3>::vertices_per_face * - this->dofs_per_vertex) - : - GeometryInfo<3>::vertices_per_cell * - this->dofs_per_vertex + - GeometryInfo<3>::lines_per_cell * - this->dofs_per_line + - (index - - GeometryInfo<3>::vertices_per_face * - this->dofs_per_vertex - - - GeometryInfo<3>::lines_per_face * - this->dofs_per_line))); + ? index + : (index < (this->first_face_quad_index) + ? this->first_line_index + + (index - this->first_face_line_index) + : this->first_quad_index + + (index - this->first_face_quad_index))); } diff --git a/deal.II/deal.II/source/fe/fe_data.cc b/deal.II/deal.II/source/fe/fe_data.cc index defac8ce05..5287f6f951 100644 --- a/deal.II/deal.II/source/fe/fe_data.cc +++ b/deal.II/deal.II/source/fe/fe_data.cc @@ -97,6 +97,46 @@ bool FiniteElementData::operator== (const FiniteElementData &f) const (conforming_space == f.conforming_space)); } +template +unsigned int +FiniteElementData::face_to_cell_index( + unsigned int face_index, + unsigned int face, + bool orientation) const +{ + Assert(face_index < this->dofs_per_face, + ExcIndexRange(face_index, 0, this->dofs_per_face)); + Assert(face < GeometryInfo::faces_per_cell, + ExcIndexRange(face, 0, GeometryInfo::faces_per_cell)); + + // DoF on a vertex + if (face_index < this->first_face_line_index) + { + // Vertex number on the face + const unsigned int face_vertex = face_index / this->dofs_per_vertex; + return face_index % this->dofs_per_vertex + + GeometryInfo::face_to_cell_vertices(face, face_vertex, orientation) + * this->dofs_per_vertex; + } + // Else, DoF on a line? + if (face_index < this->first_face_quad_index) + { + // Ignore vertex dofs + const unsigned int index = face_index - this->first_face_line_index; + // Line number on the face + const unsigned int face_line = index / this->dofs_per_line; + return this->first_line_index + index % this->dofs_per_line + + GeometryInfo::face_to_cell_lines(face, face_line, orientation) + * this->dofs_per_line; + } + // Else, DoF is on a quad + + // Ignore vertex and line dofs + const unsigned int index = face_index - this->first_face_quad_index; + return this->first_quad_index + index + + face * this->dofs_per_quad; +} + template class FiniteElementData<1>; template class FiniteElementData<2>;