From cc2d745e3595b1b11d1e683932fec7af8b57a0cf Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 1 May 2003 23:48:00 +0000 Subject: [PATCH] GeometryInfo::child_to_cell_coordinates git-svn-id: https://svn.dealii.org/trunk@7541 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/geometry_info.h | 82 ++++++++++++++++++++ deal.II/doc/news/2002/c-3-4.html | 4 +- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index 98074da542..890c45cf2f 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -355,6 +355,17 @@ struct GeometryInfo<1> static Point<1> cell_to_child_coordinates (const Point<1> &p, const unsigned int child_index); + /** + * The reverse function to the + * one above: take a point in the + * coordinate system of the + * child, and transform it to the + * coordinate system of the + * mother cell. + */ + static Point<1> child_to_cell_coordinates (const Point<1> &p, + const unsigned int child_index); + /** * Return true if the given point * is inside the unit cell of the @@ -604,6 +615,17 @@ struct GeometryInfo<2> static Point<2> cell_to_child_coordinates (const Point<2> &p, const unsigned int child_index); + /** + * The reverse function to the + * one above: take a point in the + * coordinate system of the + * child, and transform it to the + * coordinate system of the + * mother cell. + */ + static Point<2> child_to_cell_coordinates (const Point<2> &p, + const unsigned int child_index); + /** * Return true if the given point * is inside the unit cell of the @@ -851,6 +873,17 @@ struct GeometryInfo<3> static Point<3> cell_to_child_coordinates (const Point<3> &p, const unsigned int child_index); + /** + * The reverse function to the + * one above: take a point in the + * coordinate system of the + * child, and transform it to the + * coordinate system of the + * mother cell. + */ + static Point<3> child_to_cell_coordinates (const Point<3> &p, + const unsigned int child_index); + /** * Return true if the given point * is inside the unit cell of the @@ -1152,6 +1185,55 @@ GeometryInfo<3>::cell_to_child_coordinates (const Point<3> &p, +inline +Point<1> +GeometryInfo<1>::child_to_cell_coordinates (const Point<1> &p, + const unsigned int child_index) +{ + 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); +} + + + +inline +Point<2> +GeometryInfo<2>::child_to_cell_coordinates (const Point<2> &p, + const unsigned int child_index) +{ + 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); +} + + + +inline +Point<3> +GeometryInfo<3>::child_to_cell_coordinates (const Point<3> &p, + const unsigned int child_index) +{ + 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); +} + + + inline bool GeometryInfo<1>::is_inside_unit_cell (const Point<1> &p) diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index eeb178e667..b9e79035dd 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -763,7 +763,9 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK in the unit cell, returns which child cell it is on; cell_to_child_coordinates that transforms coordinates between the unit coordinate systems from the mother - to the child cell; and child_to_cell_coordinates that does + exactly the opposite; and is_inside_unit_cell that tells whether a given point is inside the unit cell.
-- 2.39.5