From 84e2856aa11615d2707daa7daedd1680792475f7 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 11 May 2010 03:47:29 +0000 Subject: [PATCH] Patch from James Avery: TriaAccessor::extent_in_direction. git-svn-id: https://svn.dealii.org/trunk@21113 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria_accessor.h | 20 ++++++++ deal.II/deal.II/source/grid/tria_accessor.cc | 50 ++++++++++++++++++++ deal.II/doc/news/changes.h | 8 +++- 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 705777b361..a900482b44 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -1243,6 +1243,24 @@ class TriaAccessor : public TriaAccessorBase */ double diameter () const; + /** + * Length of an object in the direction + * of the given axis, specified in the + * local coordinate system. See the + * documentation of GeometryInfo for the + * meaning and enumeration of the local + * axes. + * + * Note that the "length" of an object + * can be interpreted in a variety of + * ways. Here, we choose it as the + * maximal length of any of the edges of + * the object that are parallel to the + * chosen axis on the reference cell. + */ + double extent_in_direction (const unsigned int axis) const; + + /** * Center of the object. The center of an * object is defined to be the average of @@ -1255,6 +1273,8 @@ class TriaAccessor : public TriaAccessorBase * object if higher order mappings are * used. */ + + Point center () const; /** diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 4f6ab581b5..9458c3ec36 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -1013,6 +1013,56 @@ measure () const } +#if deal_II_dimension == 1 + +template <> +double TriaAccessor<1,1,1>::extent_in_direction(const unsigned int axis) const +{ + Assert (axis == 0, ExcIndexRange (axis, 0, 1)); + + return this->diameter(); +} + +#elsif deal_II_dimension == 2 + +template <> +double TriaAccessor<2,2,2>::extent_in_direction(const unsigned int axis) const +{ + const unsigned int lines[2][2] = {{2,3}, /// Lines along x-axis, see GeometryInfo + {0,1}};/// Lines along y-axis + + Assert (axis < 2, ExcIndexRange (axis, 0, 2)); + + return std::max(this->line(lines[axis][0])->diameter(), + this->line(lines[axis][1])->diameter()); +} + +#elsif deal_II_dimension == 3 + +template <> +double TriaAccessor<3,3,3>::extent_in_direction(const unsigned int axis) const +{ + const unsigned int lines[3][4] = {{2,3,6,7}, /// Lines along x-axis, see GeometryInfo + {0,1,4,5}, /// Lines along y-axis + {8,9,10,11}}; /// Lines along z-axis + + Assert (axis < 3, ExcIndexRange (axis, 0, 3)); + + double lengths[4] = { this->line(lines[axis][0])->diameter(), + this->line(lines[axis][1])->diameter(), + this->line(lines[axis][2])->diameter(), + this->line(lines[axis][3])->diameter() }; + + return std::max(std::max(lengths[0], lengths[1]), + std::max(lengths[2], lengths[3])); +} + +#else + +// Not implemented for higher dimensions + +#endif + /*------------------------ Functions: CellAccessor<1> -----------------------*/ diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 607fa3ac4a..c2e85013b5 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -629,9 +629,15 @@ inconvenience this causes.

deal.II

    +
  1. +

    New: TriaAccessor::extent_in_direction() returns the length + of an object in a given direction. +
    + (James Avery 2010/05/10) +

  2. +
  3. New: There is a new function DoFTools::extract_dofs_with_support_on_boundary(). - fixed.
    (WB 2010/05/07)

  4. -- 2.39.5