From: kanschat Date: Tue, 5 Jun 2007 21:24:20 +0000 (+0000) Subject: add face_orientation() to TriaObjects X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ebf41cd04c24b11637259129036fea4b4a076a5;p=dealii-svn.git add face_orientation() to TriaObjects git-svn-id: https://svn.dealii.org/trunk@14755 0785d39b-7218-0410-832d-ea1e28bc413d --- 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 31769431e6..2e184ee1d7 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -232,11 +232,11 @@ TriaAccessor::get_triangulation () const template inline -TriaObjectAccessor<1,dim>:: -TriaObjectAccessor (const Triangulation *parent, - const int level, - const int index, - const AccessorData *local_data) +TriaObjectAccessor<1,dim>::TriaObjectAccessor ( + const Triangulation *parent, + const int level, + const int index, + const AccessorData *local_data) : TriaAccessor<1,dim> (parent, level, index, local_data) { @@ -513,11 +513,11 @@ TriaObjectAccessor<1,1>::operator -- () template inline -TriaObjectAccessor<2,dim>:: -TriaObjectAccessor (const Triangulation *parent, - const int level, - const int index, - const AccessorData *local_data) +TriaObjectAccessor<2,dim>::TriaObjectAccessor ( + const Triangulation *parent, + const int level, + const int index, + const AccessorData *local_data) : TriaAccessor<2,dim> (parent, level, index, local_data) { @@ -725,18 +725,12 @@ inline bool TriaObjectAccessor<2,3>::line_orientation (const unsigned int line) const { - // we cannot use the objects() function here, + // we cannot use the objects() function here, // since it returns a reference to // TriaObjects, but we need a // (reference to) TriaObjectsQuad3D Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - Assert (line::lines_per_cell, - ExcIndexRange (line, 0, GeometryInfo<2>::lines_per_cell)); - Assert (this->present_index * GeometryInfo<2>::lines_per_cell + line - < this->tria->faces->quads.line_orientations.size(), - ExcInternalError()); - return this->tria->faces->quads. - line_orientations[this->present_index * GeometryInfo<2>::lines_per_cell + line]; + return this->tria->faces->quads.face_orientation(this->present_index, line); } @@ -841,11 +835,11 @@ TriaObjectAccessor<2,2>::operator -- () template inline -TriaObjectAccessor<3,dim>:: -TriaObjectAccessor (const Triangulation *parent, - const int level, - const int index, - const AccessorData *local_data) +TriaObjectAccessor<3,dim>::TriaObjectAccessor ( + const Triangulation *parent, + const int level, + const int index, + const AccessorData *local_data) : TriaAccessor<3,dim> (parent, level, index, local_data) { @@ -1072,29 +1066,18 @@ TriaObjectAccessor<3,dim>::max_refinement_depth () const template <> inline bool -TriaObjectAccessor<3, 3>:: -face_orientation (const unsigned int face) const +TriaObjectAccessor<3, 3>::face_orientation (const unsigned int face) const { - Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); - Assert (face::faces_per_cell, - ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell)); - Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face - < this->tria->levels[this->present_level] - ->cells.face_orientations.size(), - ExcInternalError()); - + Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); return (this->tria->levels[this->present_level] - ->cells.face_orientations[this->present_index * - GeometryInfo<3>::faces_per_cell - + face]); + ->cells.face_orientation(this->present_index, face)); } template <> inline bool -TriaObjectAccessor<3, 3>:: -face_flip (const unsigned int face) const +TriaObjectAccessor<3, 3>::face_flip (const unsigned int face) const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); Assert (face::faces_per_cell, @@ -1114,8 +1097,7 @@ face_flip (const unsigned int face) const template <> inline bool -TriaObjectAccessor<3, 3>:: -face_rotation (const unsigned int face) const +TriaObjectAccessor<3, 3>::face_rotation (const unsigned int face) const { Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); Assert (face::faces_per_cell, @@ -1135,8 +1117,7 @@ face_rotation (const unsigned int face) const template <> inline bool -TriaObjectAccessor<3, 3>:: -line_orientation (const unsigned int line) const +TriaObjectAccessor<3, 3>::line_orientation (const unsigned int line) const { const int dim=3; Assert (used(), TriaAccessorExceptions::ExcCellNotUsed()); @@ -1278,11 +1259,11 @@ TriaObjectAccessor<3,3>::operator -- () template inline -CellAccessor:: -CellAccessor (const Triangulation *parent, - const int level, - const int index, - const AccessorData *local_data) +CellAccessor::CellAccessor ( + const Triangulation *parent, + const int level, + const int index, + const AccessorData *local_data) : TriaObjectAccessor (parent, level, index, local_data) {} diff --git a/deal.II/deal.II/include/grid/tria_objects.h b/deal.II/deal.II/include/grid/tria_objects.h index 9db759b4f0..88557e6adf 100644 --- a/deal.II/deal.II/include/grid/tria_objects.h +++ b/deal.II/deal.II/include/grid/tria_objects.h @@ -154,13 +154,26 @@ namespace internal * cell. The return * value is true, if * the normal vector points - * the usual way and - * false else. + * the usual way + * (GeometryInfo::unit_normal_orientation) + * and false else. * * The result is always * true in this - * class, but derived vlasses + * class, but derived classes * will reimplement this. + * + * @warning There is a bug in + * the class hierarchy right + * now. Avoid ever calling + * this function through a + * reference, since you might + * end up with the base class + * function instead of the + * derived class. Still, we + * do not want to make it + * virtual for efficiency + * reasons. */ bool face_orientation(const unsigned int cell, const unsigned int face) const; @@ -304,6 +317,21 @@ namespace internal class TriaObjectsHex: public TriaObjects > { public: + /** + * The orientation of the + * face number face + * of the cell with number + * cell. The return + * value is true, if + * the normal vector points + * the usual way + * (GeometryInfo::unit_normal_orientation) + * and false if they + * point in opposite + * direction. + */ + bool face_orientation(const unsigned int cell, const unsigned int face) const; + /** * For edges, we enforce a @@ -406,6 +434,21 @@ namespace internal class TriaObjectsQuad3D: public TriaObjects { public: + /** + * The orientation of the + * face number face + * of the cell with number + * cell. The return + * value is true, if + * the normal vector points + * the usual way + * (GeometryInfo::unit_normal_orientation) + * and false if they + * point in opposite + * direction. + */ + bool face_orientation(const unsigned int cell, const unsigned int face) const; + /** * In effect, this field has @@ -450,16 +493,21 @@ namespace internal unsigned int memory_consumption () const; }; - +//----------------------------------------------------------------------// + template - bool TriaObjects::face_orientation(const unsigned int, const unsigned int) const + inline + bool + TriaObjects::face_orientation(const unsigned int, const unsigned int) const { return true; } template - void*& TriaObjects::user_pointer (const unsigned int i) + inline + void*& + TriaObjects::user_pointer (const unsigned int i) { #ifdef DEBUG Assert(user_data_type == data_unknown || user_data_type == data_pointer, @@ -472,7 +520,9 @@ namespace internal template - const void* TriaObjects::user_pointer (const unsigned int i) const + inline + const void* + TriaObjects::user_pointer (const unsigned int i) const { #ifdef DEBUG Assert(user_data_type == data_unknown || user_data_type == data_pointer, @@ -485,7 +535,9 @@ namespace internal template - unsigned int& TriaObjects::user_index (const unsigned int i) + inline + unsigned int& + TriaObjects::user_index (const unsigned int i) { #ifdef DEBUG Assert(user_data_type == data_unknown || user_data_type == data_index, @@ -496,13 +548,17 @@ namespace internal return user_data[i].i; } + template + inline TriaObjects::TriaObjects() : user_data_type(data_unknown) {} - + + template + inline unsigned int TriaObjects::user_index (const unsigned int i) const { #ifdef DEBUG @@ -516,13 +572,40 @@ namespace internal template + inline void TriaObjects::clear_user_data () { user_data_type = data_unknown; for (unsigned int i=0;i::faces_per_cell, + ExcIndexRange(0, cell, face_orientations.size() / GeometryInfo<3>::faces_per_cell)); + Assert (face < GeometryInfo<3>::faces_per_cell, + ExcIndexRange(0, face, GeometryInfo<3>::faces_per_cell)); + + return face_orientations[cell * GeometryInfo<3>::faces_per_cell + + face]; + } + +//----------------------------------------------------------------------// + + inline + bool + TriaObjectsQuad3D::face_orientation(const unsigned int cell, const unsigned int face) const + { + return line_orientations[cell * GeometryInfo<2>::faces_per_cell + + face]; + } + + } }