From: wolf Date: Thu, 1 May 2003 21:42:40 +0000 (+0000) Subject: cell_to_child_coordinates, is_inside_unit_cell X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a62eb317d72343b49959db598797707f36c6fad;p=dealii-svn.git cell_to_child_coordinates, is_inside_unit_cell git-svn-id: https://svn.dealii.org/trunk@7536 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index 0c1774e960..efec19a07c 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -338,6 +338,30 @@ struct GeometryInfo<1> */ static unsigned int child_cell_from_point (const Point<1> &p); + /** + * Given coordinates @p{p} on the + * unit cell, return the values + * of the coordinates of this + * point in the coordinate system + * of the given child. Neither + * original nor returned + * coordinates need actually be + * inside the cell, we simply + * perform a scale-and-shift + * operation with a shift that + * depends on the number of the + * child. + */ + static Point<1> cell_to_child_coordinates (const Point<1> &p, + const unsigned int child_index); + + /** + * Return true if the given point + * is inside the unit cell of the + * present space dimension. + */ + static bool is_inside_unit_cell (const Point<1> &p); + /** * Exception */ @@ -562,6 +586,31 @@ struct GeometryInfo<2> */ static unsigned int child_cell_from_point (const Point<2> &p); + + /** + * Given coordinates @p{p} on the + * unit cell, return the values + * of the coordinates of this + * point in the coordinate system + * of the given child. Neither + * original nor returned + * coordinates need actually be + * inside the cell, we simply + * perform a scale-and-shift + * operation with a shift that + * depends on the number of the + * child. + */ + static Point<2> cell_to_child_coordinates (const Point<2> &p, + const unsigned int child_index); + + /** + * Return true if the given point + * is inside the unit cell of the + * present space dimension. + */ + static bool is_inside_unit_cell (const Point<2> &p); + /** * Exception */ @@ -784,6 +833,31 @@ struct GeometryInfo<3> */ static unsigned int child_cell_from_point (const Point<3> &p); + + /** + * Given coordinates @p{p} on the + * unit cell, return the values + * of the coordinates of this + * point in the coordinate system + * of the given child. Neither + * original nor returned + * coordinates need actually be + * inside the cell, we simply + * perform a scale-and-shift + * operation with a shift that + * depends on the number of the + * child. + */ + static Point<3> cell_to_child_coordinates (const Point<3> &p, + const unsigned int child_index); + + /** + * Return true if the given point + * is inside the unit cell of the + * present space dimension. + */ + static bool is_inside_unit_cell (const Point<3> &p); + /** * Exception */ @@ -1029,6 +1103,83 @@ GeometryInfo<3>::child_cell_from_point (const Point<3> &p) +inline +Point<1> +GeometryInfo<1>::cell_to_child_coordinates (const Point<1> &p, + const unsigned int child_index) +{ + Assert (child_index < GeometryInfo::children_per_cell, + ExcIndexRange (child_index, GeometryInfo::children_per_cell)); + const double x = p[0]*2 - (child_index == 1 ? 1. : 0.); + return Point(x); +} + + + +inline +Point<2> +GeometryInfo<2>::cell_to_child_coordinates (const Point<2> &p, + const unsigned int child_index) +{ + Assert (child_index < GeometryInfo::children_per_cell, + ExcIndexRange (child_index, 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); +} + + + +inline +Point<3> +GeometryInfo<3>::cell_to_child_coordinates (const Point<3> &p, + const unsigned int child_index) +{ + Assert (child_index < GeometryInfo::children_per_cell, + ExcIndexRange (child_index, 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); +} + + + +inline +bool +GeometryInfo<1>::is_inside_unit_cell (const Point<1> &p) +{ + return (p[0] >= 0.) && (p[0] <= 1.); +} + + + +inline +bool +GeometryInfo<2>::is_inside_unit_cell (const Point<2> &p) +{ + return (p[0] >= 0.) && (p[0] <= 1.) && + (p[1] >= 0.) && (p[1] <= 1.); +} + + + +inline +bool +GeometryInfo<3>::is_inside_unit_cell (const Point<3> &p) +{ + return (p[0] >= 0.) && (p[0] <= 1.) && + (p[1] >= 0.) && (p[1] <= 1.) && + (p[2] >= 0.) && (p[2] <= 1.); +} + #endif