From: bangerth Date: Fri, 15 Dec 2006 19:57:14 +0000 (+0000) Subject: Functions::Monomial X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65cad848a1383beca949a4ce5b595ea06465c984;p=dealii-svn.git Functions::Monomial git-svn-id: https://svn.dealii.org/trunk@14255 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/function_lib.h b/deal.II/base/include/base/function_lib.h index 790e5018f1..0d6cf80373 100644 --- a/deal.II/base/include/base/function_lib.h +++ b/deal.II/base/include/base/function_lib.h @@ -1056,6 +1056,58 @@ namespace Functions virtual Tensor<1,dim> gradient (const Point &p, const unsigned int component = 0) const; }; + + + +/** + * A class that represents a function object for a monomial. Monomials are + * polynomials with only a single term, i.e. in 1-d they have the form + * $x^\alpha$, in 2-d the form $x_1^{\alpha_1}x_2^{\alpha_2}$, and in 3-d + * $x_1^{\alpha_1}x_2^{\alpha_2}x_3^{\alpha_3}$. Monomials are therefore + * described by a $dim$-tuple of exponents. Consequently, the class's + * constructor takes a Tensor<1,dim> to describe the set of exponents. Most of + * the time these exponents will of course be integers, but real exponents are + * of course equally valid. + * + * @author Wolfgang Bangerth, 2006 + */ + template + class Monomial : public Function + { + public: + /** + * Constructor. The arguments are + * described in the general description + * of the class. + */ + Monomial (const Tensor<1,dim> &exponents); + + /** + * Function value at one point. + */ + virtual double value (const Point &p, + const unsigned int component = 0) const; + + /** + * Function values at multiple points. + */ + virtual void value_list (const std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Function gradient at one point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + private: + /** + * The set of exponents. + */ + const Tensor<1,dim> exponents; + }; + } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc index e7aad17438..d09a83e25e 100644 --- a/deal.II/base/source/function_lib.cc +++ b/deal.II/base/source/function_lib.cc @@ -1498,6 +1498,78 @@ namespace Functions return sum; } + + + + +/* ---------------------- Monomial ----------------------- */ + + + + template + Monomial:: + Monomial (const Tensor<1,dim> &exponents) + : + exponents (exponents) + {} + + + + template + double + Monomial::value (const Point &p, + const unsigned int component) const + { + Assert (component==0, ExcIndexRange(component,0,1)) ; + + double prod = 1; + for (unsigned int s=0; s + Tensor<1,dim> + Monomial::gradient (const Point &p, + const unsigned int component) const + { + Assert (component==0, ExcIndexRange(component,0,1)) ; + + Tensor<1,dim> r; + for (unsigned int d=0; d + void + Monomial::value_list (const std::vector > &points, + std::vector &values, + const unsigned int component) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0; i::value (points[i], component); + } + // explicit instantiations @@ -1533,6 +1605,9 @@ namespace Functions template class FourierSineSum<3>; template class SlitSingularityFunction<2>; template class SlitSingularityFunction<3>; + template class Monomial<1>; + template class Monomial<2>; + template class Monomial<3>; } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index ade9c244f7..7c00e81909 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -397,10 +397,17 @@ inconvenience this causes.

base

    +
  1. New: The new Functions::Monomial class implements + monomials as a function object. +
    + (WB 2006/12/15) +

    +
  2. Fixed: If no substring is found with a width smaller than the given threshold, the Utilities::break_text_into_lines function now returns the smallest possible substring (larger than the threshold). -
    (Tobias Leicht 2006/12/13) +
    + (Tobias Leicht 2006/12/13)

  3. Changed: We used to set preprocessor variables