From 224415381d74ca806a368b974bf3dbb8e4945243 Mon Sep 17 00:00:00 2001 From: Jason Sheldon Date: Thu, 6 Aug 2015 13:57:53 -0400 Subject: [PATCH] Added asserts to mapping fnc for cases when dim=1 or dim>3 --- include/deal.II/fe/mapping.h | 19 +++++++++------- source/fe/mapping.cc | 43 ++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/include/deal.II/fe/mapping.h b/include/deal.II/fe/mapping.h index 3d0d09e2ec..4cb023ce56 100644 --- a/include/deal.II/fe/mapping.h +++ b/include/deal.II/fe/mapping.h @@ -275,14 +275,17 @@ public: const typename Triangulation::cell_iterator &cell, const Point &p) const = 0; -/** - * Transforms the point @p p on the real @p cell to the corresponding point - * on the unit cell, and then projects it to a dim-1 point on the face with - * the given face number @p face_no. Ideally the point @p p is near the face - * @ face_no, but any point in the cell can technically be projected. - */ -virtual Point -transform_real_to_unit_projected_to_face ( + /** + * Transforms the point @p p on the real @p cell to the corresponding point + * on the unit cell, and then projects it to a dim-1 point on the face with + * the given face number @p face_no. Ideally the point @p p is near the face + * @ face_no, but any point in the cell can technically be projected. + * + * This function does not make physical sense when dim=1, + * so it throws an exception in this case. + */ + virtual Point + transform_real_to_unit_projected_to_face ( const typename Triangulation::cell_iterator &cell, const unsigned int &face_no, const Point &p) const; diff --git a/source/fe/mapping.cc b/source/fe/mapping.cc index 89bd005cdc..1a31ac021a 100644 --- a/source/fe/mapping.cc +++ b/source/fe/mapping.cc @@ -43,28 +43,35 @@ template Point Mapping:: transform_real_to_unit_projected_to_face ( - const typename Triangulation::cell_iterator &cell, - const unsigned int &face_no, - const Point &p) const + const typename Triangulation::cell_iterator &cell, + const unsigned int &face_no, + const Point &p) const { + //The function doesn't make physical sense for dim=1 + Assert(dim>1, ExcNotImplemented()); + //Not implemented for higher dimensions + Assert(3<=dim, ExcNotImplemented()); + Point unit_cell_pt = transform_real_to_unit_cell(cell, p); Point unit_face_pt; - if (dim==2) { - if (GeometryInfo::unit_normal_direction[face_no] == 0) - unit_face_pt = Point(unit_cell_pt(1)); - else if (GeometryInfo::unit_normal_direction[face_no] == 1) - unit_face_pt = Point(unit_cell_pt(0)); - } - else if (dim==3) { - if (GeometryInfo::unit_normal_direction[face_no] == 0) - unit_face_pt = Point(unit_cell_pt(1), unit_cell_pt(2)); - else if (GeometryInfo::unit_normal_direction[face_no] == 1) - unit_face_pt = Point(unit_cell_pt(0), unit_cell_pt(2)); - else if (GeometryInfo::unit_normal_direction[face_no] == 2) - unit_face_pt = Point(unit_cell_pt(0), unit_cell_pt(1)); - } + if (dim==2) + { + if (GeometryInfo::unit_normal_direction[face_no] == 0) + unit_face_pt = Point(unit_cell_pt(1)); + else if (GeometryInfo::unit_normal_direction[face_no] == 1) + unit_face_pt = Point(unit_cell_pt(0)); + } + else if (dim==3) + { + if (GeometryInfo::unit_normal_direction[face_no] == 0) + unit_face_pt = Point(unit_cell_pt(1), unit_cell_pt(2)); + else if (GeometryInfo::unit_normal_direction[face_no] == 1) + unit_face_pt = Point(unit_cell_pt(0), unit_cell_pt(2)); + else if (GeometryInfo::unit_normal_direction[face_no] == 2) + unit_face_pt = Point(unit_cell_pt(0), unit_cell_pt(1)); + } return unit_face_pt; } @@ -96,8 +103,6 @@ Mapping::InternalDataBase::memory_consumption () const } - - /*------------------------------ InternalData ------------------------------*/ -- 2.39.5