From 8424f686e99d9106b91a16bd0c0e0bd4cdea95c7 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 24 Apr 2003 22:57:45 +0000 Subject: [PATCH] GeometryInfo::child_cell_from_point git-svn-id: https://svn.dealii.org/trunk@7472 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/geometry_info.h | 120 +++++++++++++++++++ deal.II/doc/news/2002/c-3-4.html | 9 ++ 2 files changed, 129 insertions(+) diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index 7a07383468..0c1774e960 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -320,6 +320,31 @@ struct GeometryInfo<1> */ static unsigned int vertices_adjacent_to_line (const unsigned int line, const unsigned int vertex); + + /** + * Given a point @p{p} in unit + * coordinates, return the number + * of the child cell in which it + * would lie in. If the point + * lies on the interface of two + * children, return any one of + * their indices. The result is + * always less than + * @p{GeometryInfo::children_per_cell}. + * + * The order of child cells is + * described the documentation of + * the @ref{Triangulation} class. + */ + static unsigned int child_cell_from_point (const Point<1> &p); + + /** + * Exception + */ + DeclException1 (ExcInvalidCoordinate, + double, + << "The coordinates must satisfy 0 <= x_i <= 1, " + << "but here we have x_i=" << arg1); }; @@ -519,6 +544,31 @@ struct GeometryInfo<2> */ static unsigned int vertices_adjacent_to_line (const unsigned int line, const unsigned int vertex); + + /** + * Given a point @p{p} in unit + * coordinates, return the number + * of the child cell in which it + * would lie in. If the point + * lies on the interface of two + * children, return any one of + * their indices. The result is + * always less than + * @p{GeometryInfo::children_per_cell}. + * + * The order of child cells is + * described the documentation of + * the @ref{Triangulation} class. + */ + static unsigned int child_cell_from_point (const Point<2> &p); + + /** + * Exception + */ + DeclException1 (ExcInvalidCoordinate, + double, + << "The coordinates must satisfy 0 <= x_i <= 1, " + << "but here we have x_i=" << arg1); }; @@ -716,6 +766,31 @@ struct GeometryInfo<3> */ static unsigned int vertices_adjacent_to_line (const unsigned int line, const unsigned int vertex); + + /** + * Given a point @p{p} in unit + * coordinates, return the number + * of the child cell in which it + * would lie in. If the point + * lies on the interface of two + * children, return any one of + * their indices. The result is + * always less than + * @p{GeometryInfo::children_per_cell}. + * + * The order of child cells is + * described the documentation of + * the @ref{Triangulation} class. + */ + static unsigned int child_cell_from_point (const Point<3> &p); + + /** + * Exception + */ + DeclException1 (ExcInvalidCoordinate, + double, + << "The coordinates must satisfy 0 <= x_i <= 1, " + << "but here we have x_i=" << arg1); }; @@ -910,5 +985,50 @@ GeometryInfo<3>::vertices_adjacent_to_line (const unsigned int line, +inline +unsigned int +GeometryInfo<1>::child_cell_from_point (const Point<1> &p) +{ + Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0])); + + return (p[0] <= 0.5 ? 0 : 1); +} + + + +inline +unsigned int +GeometryInfo<2>::child_cell_from_point (const Point<2> &p) +{ + Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0])); + Assert ((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1])); + + return (p[0] <= 0.5 ? + (p[1] <= 0.5 ? 0 : 3) : + (p[1] <= 0.5 ? 1 : 2)); +} + + + +inline +unsigned int +GeometryInfo<3>::child_cell_from_point (const Point<3> &p) +{ + Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0])); + Assert ((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1])); + Assert ((p[2] >= 0) && (p[2] <= 1), ExcInvalidCoordinate(p[2])); + + return (p[0] <= 0.5 ? + (p[1] <= 0.5 ? + (p[2] <= 0.5 ? 0 : 3) : + (p[2] <= 0.5 ? 4 : 7)) : + (p[1] <= 0.5 ? + (p[2] <= 0.5 ? 1 : 2) : + (p[2] <= 0.5 ? 5 : 6))); +} + + + + #endif diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 3118dcd396..8e50daa5be 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -756,6 +756,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + New: The GeometryInfo classes now + have a static member function child_cell_from_point that, given a point + in the unit cell, returns which child cell it is on. +
    + (WB 2003/04/24) +

    +
  2. New: There are now functions recursively_set/clear_user_pointer that -- 2.39.5