From 5c4e9eb00296acec39b73fc68ce6ccc91713779f Mon Sep 17 00:00:00 2001 From: Ralf Hartmann Date: Mon, 14 Mar 2005 18:07:26 +0000 Subject: [PATCH] Simplification of implementation of cell_to_child_coordinates and child_to_cell_coordinates functions. Implementation is now even dimension independent. git-svn-id: https://svn.dealii.org/trunk@10132 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/geometry_info.h | 36 +++++--------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index 169446576d..d15d50a48a 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -1597,8 +1597,8 @@ GeometryInfo<1>::cell_to_child_coordinates (const Point<1> &p, { Assert (child_index < GeometryInfo::children_per_cell, ExcIndexRange (child_index, 0, GeometryInfo::children_per_cell)); - const double x = p[0]*2 - (child_index == 1 ? 1. : 0.); - return Point(x); + + return 2*p - unit_cell_vertex(child_index); } @@ -1610,11 +1610,8 @@ GeometryInfo<2>::cell_to_child_coordinates (const Point<2> &p, { Assert (child_index < GeometryInfo::children_per_cell, ExcIndexRange (child_index, 0, GeometryInfo::children_per_cell)); - - const double x = p[0]*2 - ((child_index == 1) || (child_index == 2) ? 1. : 0.); - const double y = p[1]*2 - ((child_index == 2) || (child_index == 3) ? 1. : 0.); - return Point(x,y); + return 2*p - unit_cell_vertex(child_index); } @@ -1626,15 +1623,8 @@ GeometryInfo<3>::cell_to_child_coordinates (const Point<3> &p, { Assert (child_index < GeometryInfo::children_per_cell, ExcIndexRange (child_index, 0, GeometryInfo::children_per_cell)); - - const double x = p[0]*2 - ((child_index == 1) || (child_index == 2) || - (child_index == 5) || (child_index == 6) ? 1. : 0.); - const double y = p[1]*2 - ((child_index == 4) || (child_index == 5) || - (child_index == 6) || (child_index == 7) ? 1. : 0.); - const double z = p[2]*2 - ((child_index == 2) || (child_index == 3) || - (child_index == 6) || (child_index == 7) ? 1. : 0.); - return Point(x,y,z); + return 2*p - unit_cell_vertex(child_index); } @@ -1646,8 +1636,8 @@ GeometryInfo<1>::child_to_cell_coordinates (const Point<1> &p, { Assert (child_index < GeometryInfo::children_per_cell, ExcIndexRange (child_index, 0, GeometryInfo::children_per_cell)); - const double x = p[0]/2 + (child_index == 1 ? .5 : 0.); - return Point(x); + + return (p + unit_cell_vertex(child_index))/2; } @@ -1659,11 +1649,8 @@ GeometryInfo<2>::child_to_cell_coordinates (const Point<2> &p, { Assert (child_index < GeometryInfo::children_per_cell, ExcIndexRange (child_index, 0, GeometryInfo::children_per_cell)); - - const double x = p[0]/2 + ((child_index == 1) || (child_index == 2) ? .5 : 0.); - const double y = p[1]/2 + ((child_index == 2) || (child_index == 3) ? .5 : 0.); - return Point(x,y); + return (p + unit_cell_vertex(child_index))/2; } @@ -1675,15 +1662,8 @@ GeometryInfo<3>::child_to_cell_coordinates (const Point<3> &p, { Assert (child_index < GeometryInfo::children_per_cell, ExcIndexRange (child_index, 0, GeometryInfo::children_per_cell)); - - const double x = p[0]/2 + ((child_index == 1) || (child_index == 2) || - (child_index == 5) || (child_index == 6) ? .5 : 0.); - const double y = p[1]/2 + ((child_index == 4) || (child_index == 5) || - (child_index == 6) || (child_index == 7) ? .5 : 0.); - const double z = p[2]/2 + ((child_index == 2) || (child_index == 3) || - (child_index == 6) || (child_index == 7) ? .5 : 0.); - return Point(x,y,z); + return (p + unit_cell_vertex(child_index))/2; } -- 2.39.5