]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added asserts to mapping fnc for cases when dim=1 or dim>3
authorJason Sheldon <Jason.Sheldon@psu.edu>
Thu, 6 Aug 2015 17:57:53 +0000 (13:57 -0400)
committerJason Sheldon <Jason.Sheldon@psu.edu>
Thu, 6 Aug 2015 21:49:31 +0000 (17:49 -0400)
include/deal.II/fe/mapping.h
source/fe/mapping.cc

index 3d0d09e2ecd49df5ef073e64c16c41e84b692dae..4cb023ce56d20069bb130feb3b26076f59a42eb2 100644 (file)
@@ -275,14 +275,17 @@ public:
     const typename Triangulation<dim,spacedim>::cell_iterator &cell,
     const Point<spacedim>                            &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<dim-1>
-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<dim-1>
+  transform_real_to_unit_projected_to_face (
     const typename Triangulation<dim,spacedim>::cell_iterator &cell,
     const unsigned int &face_no,
     const Point<spacedim> &p) const;
index 89bd005cdc38e63a6f87f5f91ede415dd6d25123..1a31ac021aae2688c94c8b88fc094b69460db281 100644 (file)
@@ -43,28 +43,35 @@ template<int dim, int spacedim>
 Point<dim-1>
 Mapping<dim,spacedim>::
 transform_real_to_unit_projected_to_face (
-    const typename Triangulation<dim,spacedim>::cell_iterator &cell,
-    const unsigned int &face_no,
-    const Point<spacedim> &p) const
+  const typename Triangulation<dim,spacedim>::cell_iterator &cell,
+  const unsigned int &face_no,
+  const Point<spacedim> &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<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
 
   Point<dim-1> unit_face_pt;
 
-  if (dim==2) {
-    if (GeometryInfo<dim>::unit_normal_direction[face_no] == 0)
-      unit_face_pt = Point<dim-1>(unit_cell_pt(1));
-    else if (GeometryInfo<dim>::unit_normal_direction[face_no] == 1)
-      unit_face_pt = Point<dim-1>(unit_cell_pt(0));
-  }
-  else if (dim==3) {
-    if (GeometryInfo<dim>::unit_normal_direction[face_no] == 0)
-      unit_face_pt = Point<dim-1>(unit_cell_pt(1), unit_cell_pt(2));
-    else if (GeometryInfo<dim>::unit_normal_direction[face_no] == 1)
-      unit_face_pt = Point<dim-1>(unit_cell_pt(0), unit_cell_pt(2));
-    else if (GeometryInfo<dim>::unit_normal_direction[face_no] == 2)
-      unit_face_pt = Point<dim-1>(unit_cell_pt(0), unit_cell_pt(1));
-  }
+  if (dim==2)
+    {
+      if (GeometryInfo<dim>::unit_normal_direction[face_no] == 0)
+        unit_face_pt = Point<dim-1>(unit_cell_pt(1));
+      else if (GeometryInfo<dim>::unit_normal_direction[face_no] == 1)
+        unit_face_pt = Point<dim-1>(unit_cell_pt(0));
+    }
+  else if (dim==3)
+    {
+      if (GeometryInfo<dim>::unit_normal_direction[face_no] == 0)
+        unit_face_pt = Point<dim-1>(unit_cell_pt(1), unit_cell_pt(2));
+      else if (GeometryInfo<dim>::unit_normal_direction[face_no] == 1)
+        unit_face_pt = Point<dim-1>(unit_cell_pt(0), unit_cell_pt(2));
+      else if (GeometryInfo<dim>::unit_normal_direction[face_no] == 2)
+        unit_face_pt = Point<dim-1>(unit_cell_pt(0), unit_cell_pt(1));
+    }
 
   return unit_face_pt;
 }
@@ -96,8 +103,6 @@ Mapping<dim, spacedim>::InternalDataBase::memory_consumption () const
 }
 
 
-
-
 /*------------------------------ InternalData ------------------------------*/
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.