From: Thomas Richter Date: Thu, 12 Oct 2000 07:32:16 +0000 (+0000) Subject: check for point in cell X-Git-Tag: v8.0.0~20018 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d482bd750ffc74c6cf98e865ecc91de6aa9d0db;p=dealii.git check for point in cell git-svn-id: https://svn.dealii.org/trunk@3414 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 293e1d4b83..017e7f4edb 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -130,6 +130,9 @@ class TriaAccessor bool operator != (const TriaAccessor &) const; public: + + double ind_value; + /** * Data type to be used for passing * parameters from iterators to the @@ -1929,6 +1932,15 @@ class CellAccessor : public TriaObjectAccessor * of a cell). */ bool active () const; + + /** + * Test whether the point p is inside + * this cell. + * Up to now, this function is only + * implemented for 2d + */ + bool point_inside(const Point &p) const; + /** * Exception diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index a6f9354fc3..81c74c4352 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -1566,6 +1566,12 @@ void CellAccessor<1>::set_material_id (const unsigned char mat_id) const }; +template <> +bool CellAccessor<1>::point_inside (const Point<1> &) const +{ + Assert (false, ExcNotImplemented() ); +} + #endif @@ -1599,6 +1605,20 @@ void CellAccessor<2>::set_material_id (const unsigned char mat_id) const = mat_id; }; +template <> +bool CellAccessor<2>::point_inside (const Point<2> &p) const +{ + for (unsigned int k=0;k<4;++k) + { + const Point<2> to_p = p-vertex(k); + const Point<2> face = vertex((k+1)%4)-vertex(k); + if (-face(1)*to_p(0)+face(0)*to_p(1)<0) + return false; + } + return true; +} + + #endif @@ -1634,6 +1654,13 @@ void CellAccessor<3>::set_material_id (const unsigned char mat_id) const = mat_id; }; +template <> +bool CellAccessor<3>::point_inside (const Point<3> &) const +{ + Assert (false, ExcNotImplemented() ); +} + + #endif