From 34c2089ceac977436aa044591828f1cb85dd3f51 Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 18 Jul 2001 10:10:38 +0000 Subject: [PATCH] Wrap all instances of conceret functions into a namespace of their own. git-svn-id: https://svn.dealii.org/trunk@4850 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/function_lib.h | 1078 +++++----- deal.II/base/source/function_lib.cc | 2416 +++++++++++----------- deal.II/doc/news/2001/c-3-1.html | 12 +- 3 files changed, 1767 insertions(+), 1739 deletions(-) diff --git a/deal.II/base/include/base/function_lib.h b/deal.II/base/include/base/function_lib.h index 10c42f8e52..9c08e2ae25 100644 --- a/deal.II/base/include/base/function_lib.h +++ b/deal.II/base/include/base/function_lib.h @@ -18,6 +18,17 @@ +/** + * Namespace implementing some concrete classes derived from the + * @ref{Function} class that describe actual functions. This is rather + * a collection of classes that we have needed for our own programs + * once and thought they might be useful to others as well at some + * point. + */ +namespace Functions +{ + + /** * The distance to the origin squared. * @@ -27,104 +38,104 @@ * * @author: Guido Kanschat, 1999 */ -template -class SquareFunction : public Function -{ - public: - /** - * 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 typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at one point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - Gradients at multiple points. - */ - virtual void gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian of the function at one point. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - - /** - * Laplacian of the function at multiple points. - */ - virtual void laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; -}; - - - + template + class SquareFunction : public Function + { + public: + /** + * 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 typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at one point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + Gradients at multiple points. + */ + virtual void gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian of the function at one point. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + + /** + * Laplacian of the function at multiple points. + */ + virtual void laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + }; + + + /** * The function @p{xy}. This function serves as an example for * a vanishing Laplacian. * * @author: Guido Kanschat, 2000 */ -template -class Q1WedgeFunction : public Function -{ - public: - /** - * 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 typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at one point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - Gradients at multiple points. - */ - virtual void gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian of the function at one point. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - - /** - * Laplacian of the function at multiple points. - */ - virtual void laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; -}; - - - + template + class Q1WedgeFunction : public Function + { + public: + /** + * 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 typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at one point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + Gradients at multiple points. + */ + virtual void gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian of the function at one point. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + + /** + * Laplacian of the function at multiple points. + */ + virtual void laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + }; + + + /** * d-quadratic pillow on the unit hypercube. * @@ -139,176 +150,176 @@ class Q1WedgeFunction : public Function * * @author: Guido Kanschat, 1999 */ -template -class PillowFunction : public Function -{ - public: - /** - * Constructor. Provide a - * constant that will be added to - * each function value. - */ - PillowFunction (const double offset=0.); - - /** - * The value at a single point. - */ - virtual double value (const Point &p, - const unsigned int component = 0) const; - - /** - * Values at multiple points. - */ - virtual void value_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at a single point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - * Gradients at multiple points. - */ - virtual void gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian at a single point. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - - /** - * Laplacian at multiple points. - */ - virtual void laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - private: - const double offset; -}; - - - + template + class PillowFunction : public Function + { + public: + /** + * Constructor. Provide a + * constant that will be added to + * each function value. + */ + PillowFunction (const double offset=0.); + + /** + * The value at a single point. + */ + virtual double value (const Point &p, + const unsigned int component = 0) const; + + /** + * Values at multiple points. + */ + virtual void value_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at a single point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + * Gradients at multiple points. + */ + virtual void gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian at a single point. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + + /** + * Laplacian at multiple points. + */ + virtual void laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + private: + const double offset; + }; + + + /** * Cosine-shaped pillow function. * This is another function with zero boundary values on $[-1,1]^d$. In the interior * it is the product of $\cos(\pi/2 x_i)$. * @author Guido Kanschat, 1999 */ -template -class CosineFunction : public Function -{ - public: - /** - * The value at a single point. - */ - virtual double value (const Point &p, - const unsigned int component = 0) const; - - /** - * Values at multiple points. - */ - virtual void value_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at a single point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - * Gradients at multiple points. - */ - virtual void gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian at a single point. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - - /** - * Laplacian at multiple points. - */ - virtual void laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at a single point. - */ - virtual Tensor<2,dim> hessian (const Point &p, - const unsigned int component = 0) const; - - /** - * Gradients at multiple points. - */ - virtual void hessian_list (const typename std::vector > &points, - typename std::vector > &hessians, + template + class CosineFunction : public Function + { + public: + /** + * The value at a single point. + */ + virtual double value (const Point &p, + const unsigned int component = 0) const; + + /** + * Values at multiple points. + */ + virtual void value_list (const typename std::vector > &points, + std::vector &values, const unsigned int component = 0) const; -}; - - - + + /** + * Gradient at a single point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + * Gradients at multiple points. + */ + virtual void gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian at a single point. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + + /** + * Laplacian at multiple points. + */ + virtual void laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at a single point. + */ + virtual Tensor<2,dim> hessian (const Point &p, + const unsigned int component = 0) const; + + /** + * Gradients at multiple points. + */ + virtual void hessian_list (const typename std::vector > &points, + typename std::vector > &hessians, + const unsigned int component = 0) const; + }; + + + /** * Product of exponential functions in each coordinate direction. * @author Guido Kanschat, 1999 */ -template -class ExpFunction : public Function -{ - public: - /** - * The value at a single point. - */ - virtual double value (const Point &p, - const unsigned int component = 0) const; - - /** - * Values at multiple points. - */ - virtual void value_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at a single point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - * Gradients at multiple points. - */ - virtual void gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian at a single point. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - - /** - * Laplacian at multiple points. - */ - virtual void laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; -}; - - - + template + class ExpFunction : public Function + { + public: + /** + * The value at a single point. + */ + virtual double value (const Point &p, + const unsigned int component = 0) const; + + /** + * Values at multiple points. + */ + virtual void value_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at a single point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + * Gradients at multiple points. + */ + virtual void gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian at a single point. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + + /** + * Laplacian at multiple points. + */ + virtual void laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + }; + + + /** * Singularity on the L-shaped domain in 2D. * @@ -316,51 +327,51 @@ class ExpFunction : public Function * * @author Guido Kanschat, 1999 */ -class LSingularityFunction : public Function<2> -{ - public: - /** - * The value at a single point. - */ - virtual double value (const Point<2> &p, - const unsigned int component = 0) const; - - /** - * Values at multiple points. - */ - virtual void value_list (const std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at a single point. - */ - virtual Tensor<1,2> gradient (const Point<2> &p, - const unsigned int component = 0) const; - - /** - * Gradients at multiple points. - */ - virtual void gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian at a single point. - */ - virtual double laplacian (const Point<2> &p, - const unsigned int component = 0) const; - - /** - * Laplacian at multiple points. - */ - virtual void laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; -}; - - - + class LSingularityFunction : public Function<2> + { + public: + /** + * The value at a single point. + */ + virtual double value (const Point<2> &p, + const unsigned int component = 0) const; + + /** + * Values at multiple points. + */ + virtual void value_list (const std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at a single point. + */ + virtual Tensor<1,2> gradient (const Point<2> &p, + const unsigned int component = 0) const; + + /** + * Gradients at multiple points. + */ + virtual void gradient_list (const std::vector > &points, + std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian at a single point. + */ + virtual double laplacian (const Point<2> &p, + const unsigned int component = 0) const; + + /** + * Laplacian at multiple points. + */ + virtual void laplacian_list (const std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + }; + + + /** * Singularity on the slit domain in 2D. * @@ -368,50 +379,50 @@ class LSingularityFunction : public Function<2> * * @author Guido Kanschat, 1999 */ -class SlitSingularityFunction : public Function<2> -{ - public: - /** - * The value at a single point. - */ - virtual double value (const Point<2> &p, - const unsigned int component = 0) const; - - /** - * Values at multiple points. - */ - virtual void value_list (const std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at a single point. - */ - virtual Tensor<1,2> gradient (const Point<2> &p, - const unsigned int component = 0) const; - - /** - * Gradients at multiple points. - */ - virtual void gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian at a single point. - */ - virtual double laplacian (const Point<2> &p, - const unsigned int component = 0) const; - - /** - * Laplacian at multiple points. - */ - virtual void laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; -}; - - + class SlitSingularityFunction : public Function<2> + { + public: + /** + * The value at a single point. + */ + virtual double value (const Point<2> &p, + const unsigned int component = 0) const; + + /** + * Values at multiple points. + */ + virtual void value_list (const std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at a single point. + */ + virtual Tensor<1,2> gradient (const Point<2> &p, + const unsigned int component = 0) const; + + /** + * Gradients at multiple points. + */ + virtual void gradient_list (const std::vector > &points, + std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian at a single point. + */ + virtual double laplacian (const Point<2> &p, + const unsigned int component = 0) const; + + /** + * Laplacian at multiple points. + */ + virtual void laplacian_list (const std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + }; + + /** * A jump in x-direction transported into some direction. * @@ -426,105 +437,105 @@ class SlitSingularityFunction : public Function<2> * * @author: Guido Kanschat, 2000 */ -template -class JumpFunction : public Function -{ - public: - /** - * Constructor. Provide the - * advection direction here and - * the steepness of the slope. - */ - JumpFunction (const Point &direction, - const double steepness); - - /** - * 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 typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Gradient at one point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - Gradients at multiple points. - */ - virtual void gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int component = 0) const; - - /** - * Laplacian of the function at one point. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - - /** - * Laplacian of the function at multiple points. - */ - virtual void laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int component = 0) const; - - /** - * Determine an estimate for - * the memory consumption (in - * bytes) of this - * object. Since sometimes - * the size of objects can - * not be determined exactly - * (for example: what is the - * memory consumption of an - * STL @p{std::map} type with a - * certain number of - * elements?), this is only - * an estimate. however often - * quite close to the true - * value. - */ - unsigned int memory_consumption () const; - - protected: - /** - * Advection vector. - */ - const Point direction; - - /** - * Steepness (maximal derivative) - * of the slope. - */ - const double steepness; - - /** - * Advection angle. - */ - double angle; - - /** - * Sine of @p{angle}. - */ - double sine; - - /** - * Cosine of @p{angle}. - */ - double cosine; -}; - - - + template + class JumpFunction : public Function + { + public: + /** + * Constructor. Provide the + * advection direction here and + * the steepness of the slope. + */ + JumpFunction (const Point &direction, + const double steepness); + + /** + * 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 typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Gradient at one point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + Gradients at multiple points. + */ + virtual void gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int component = 0) const; + + /** + * Laplacian of the function at one point. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + + /** + * Laplacian of the function at multiple points. + */ + virtual void laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int component = 0) const; + + /** + * Determine an estimate for + * the memory consumption (in + * bytes) of this + * object. Since sometimes + * the size of objects can + * not be determined exactly + * (for example: what is the + * memory consumption of an + * STL @p{std::map} type with a + * certain number of + * elements?), this is only + * an estimate. however often + * quite close to the true + * value. + */ + unsigned int memory_consumption () const; + + protected: + /** + * Advection vector. + */ + const Point direction; + + /** + * Steepness (maximal derivative) + * of the slope. + */ + const double steepness; + + /** + * Advection angle. + */ + double angle; + + /** + * Sine of @p{angle}. + */ + double sine; + + /** + * Cosine of @p{angle}. + */ + double cosine; + }; + + + /** * Given a wavenumber vector generate a cosine function. The * wavenumber coefficient is given as a @p{d}-dimensional point @p{k} @@ -536,54 +547,54 @@ class JumpFunction : public Function * * @author Wolfgang Bangerth, 2001 */ -template -class FourierCosineFunction : public Function -{ - public: - /** - * Constructor. Take the Fourier - * coefficients in each space - * direction as argument. - */ - FourierCosineFunction (const Point &fourier_coefficients); - - /** - * Return the value of the - * function at the given - * point. Unless there is only - * one component (i.e. the - * function is scalar), you - * should state the component you - * want to have evaluated; it - * defaults to zero, i.e. the - * first component. - */ - virtual double value (const Point &p, - const unsigned int component = 0) const; - - /** - * Return the gradient of the - * specified component of the - * function at the given point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - * Compute the Laplacian of a - * given component at point @p{p}. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - private: - /** - * Stored Fourier coefficients. - */ - const Point fourier_coefficients; -}; - - - + template + class FourierCosineFunction : public Function + { + public: + /** + * Constructor. Take the Fourier + * coefficients in each space + * direction as argument. + */ + FourierCosineFunction (const Point &fourier_coefficients); + + /** + * Return the value of the + * function at the given + * point. Unless there is only + * one component (i.e. the + * function is scalar), you + * should state the component you + * want to have evaluated; it + * defaults to zero, i.e. the + * first component. + */ + virtual double value (const Point &p, + const unsigned int component = 0) const; + + /** + * Return the gradient of the + * specified component of the + * function at the given point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + * Compute the Laplacian of a + * given component at point @p{p}. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + private: + /** + * Stored Fourier coefficients. + */ + const Point fourier_coefficients; + }; + + + /** * Given a wavenumber vector generate a sine function. The * wavenumber coefficient is given as a @p{d}-dimensional point @p{k} @@ -595,53 +606,54 @@ class FourierCosineFunction : public Function * * @author Wolfgang Bangerth, 2001 */ -template -class FourierSineFunction : public Function -{ - public: - /** - * Constructor. Take the Fourier - * coefficients in each space - * direction as argument. - */ - FourierSineFunction (const Point &fourier_coefficients); - - /** - * Return the value of the - * function at the given - * point. Unless there is only - * one component (i.e. the - * function is scalar), you - * should state the component you - * want to have evaluated; it - * defaults to zero, i.e. the - * first component. - */ - virtual double value (const Point &p, - const unsigned int component = 0) const; - - /** - * Return the gradient of the - * specified component of the - * function at the given point. - */ - virtual Tensor<1,dim> gradient (const Point &p, - const unsigned int component = 0) const; - - /** - * Compute the Laplacian of a - * given component at point @p{p}. - */ - virtual double laplacian (const Point &p, - const unsigned int component = 0) const; - private: - /** - * Stored Fourier coefficients. - */ - const Point fourier_coefficients; + template + class FourierSineFunction : public Function + { + public: + /** + * Constructor. Take the Fourier + * coefficients in each space + * direction as argument. + */ + FourierSineFunction (const Point &fourier_coefficients); + + /** + * Return the value of the + * function at the given + * point. Unless there is only + * one component (i.e. the + * function is scalar), you + * should state the component you + * want to have evaluated; it + * defaults to zero, i.e. the + * first component. + */ + virtual double value (const Point &p, + const unsigned int component = 0) const; + + /** + * Return the gradient of the + * specified component of the + * function at the given point. + */ + virtual Tensor<1,dim> gradient (const Point &p, + const unsigned int component = 0) const; + + /** + * Compute the Laplacian of a + * given component at point @p{p}. + */ + virtual double laplacian (const Point &p, + const unsigned int component = 0) const; + private: + /** + * Stored Fourier coefficients. + */ + const Point fourier_coefficients; + }; + + }; - - #endif diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc index 5da39ec8f9..042e0362df 100644 --- a/deal.II/base/source/function_lib.cc +++ b/deal.II/base/source/function_lib.cc @@ -31,1251 +31,1257 @@ -template -double -SquareFunction::value (const Point &p, - const unsigned int) const +namespace Functions { - return p.square(); -} - - + + + template + double + SquareFunction::value (const Point &p, + const unsigned int) const + { + return p.square(); + } + + // if necessary try to work around a bug in the IBM xlC compiler #ifdef XLC_WORK_AROUND_STD_BUG -using namespace std; + using namespace std; #endif - -template -void -SquareFunction::value_list (const typename std::vector > &points, - std::vector &values, + + template + void + SquareFunction::value_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + values[i] = p.square(); + } + } + + + template + double + SquareFunction::laplacian (const Point &, + const unsigned int) const + { + return 2*dim; + } + + + template + void + SquareFunction::laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i + Tensor<1,dim> + SquareFunction::gradient (const Point &p, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - values[i] = p.square(); - } -} - - -template -double -SquareFunction::laplacian (const Point &, - const unsigned int) const -{ - return 2*dim; -} - - -template -void -SquareFunction::laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i -Tensor<1,dim> -SquareFunction::gradient (const Point &p, + { + return p*2; + } + + + + template + void + SquareFunction::gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0; i + double + Q1WedgeFunction::value (const Point &p, const unsigned int) const -{ - return p*2; -} - - - -template -void -SquareFunction::gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, + { + return p(0)*p(1); + } + + + + template + void + Q1WedgeFunction::value_list (const typename std::vector > &points, + std::vector &values, const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0; i& p = points[i]; + values[i] = p(0)*p(1); + } + } + + + template + double + Q1WedgeFunction::laplacian (const Point &, + const unsigned int) const + { + return 0.; + } + + + template + void + Q1WedgeFunction::laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i + Tensor<1,dim> + Q1WedgeFunction::gradient (const Point &p, + const unsigned int) const + { + Tensor<1,dim> erg; + erg[0] = p(1); + erg[1] = p(0); + return erg; + } + + + + template + void + Q1WedgeFunction::gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0; i -double -Q1WedgeFunction::value (const Point &p, - const unsigned int) const -{ - return p(0)*p(1); -} - - - -template -void -Q1WedgeFunction::value_list (const typename std::vector > &points, - std::vector &values, + + + template + PillowFunction::PillowFunction (const double offset) + : + offset(offset) + {} + + + template + double + PillowFunction::value (const Point &p, + const unsigned int) const + { + switch(dim) + { + case 1: + return 1.-p(0)*p(0)+offset; + case 2: + return (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; + case 3: + return (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; + default: + Assert(false, ExcNotImplemented()); + } + return 0.; + } + + template + void + PillowFunction::value_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + values[i] = 1.-p(0)*p(0)+offset; + break; + case 2: + values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; + break; + case 3: + values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + + + + template + double + PillowFunction::laplacian (const Point &p, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - values[i] = p(0)*p(1); - } -} - - -template -double -Q1WedgeFunction::laplacian (const Point &, + { + switch(dim) + { + case 1: + return -2.; + case 2: + return -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); + case 3: + return -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) + +(1.-p(1)*p(1))*(1.-p(2)*p(2)) + +(1.-p(2)*p(2))*(1.-p(0)*p(0))); + default: + Assert(false, ExcNotImplemented()); + } + return 0.; + } + + template + void + PillowFunction::laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + values[i] = -2.; + break; + case 2: + values[i] = -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); + break; + case 3: + values[i] = -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) + +(1.-p(1)*p(1))*(1.-p(2)*p(2)) + +(1.-p(2)*p(2))*(1.-p(0)*p(0))); + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + + template + Tensor<1,dim> + PillowFunction::gradient (const Point &p, const unsigned int) const -{ - return 0.; -} - - -template -void -Q1WedgeFunction::laplacian_list (const typename std::vector > &points, - std::vector &values, + { + Tensor<1,dim> result; + switch(dim) + { + case 1: + result[0] = -2.*p(0); + break; + case 2: + result[0] = -2.*p(0)*(1.-p(1)*p(1)); + result[1] = -2.*p(1)*(1.-p(0)*p(0)); + break; + case 3: + result[0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); + result[1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); + result[2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); + break; + default: + Assert(false, ExcNotImplemented()); + } + return result; + } + + template + void + PillowFunction::gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i -Tensor<1,dim> -Q1WedgeFunction::gradient (const Point &p, - const unsigned int) const -{ - Tensor<1,dim> erg; - erg[0] = p(1); - erg[1] = p(0); - return erg; -} - - - -template -void -Q1WedgeFunction::gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0; i& p = points[i]; + switch(dim) + { + case 1: + gradients[i][0] = -2.*p(0); + break; + case 2: + gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1)); + gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0)); + break; + case 3: + gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); + gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); + gradients[i][2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + ////////////////////////////////////////////////////////////////////// - - -template -PillowFunction::PillowFunction (const double offset) - : - offset(offset) -{} - - -template -double -PillowFunction::value (const Point &p, - const unsigned int) const -{ - switch(dim) - { - case 1: - return 1.-p(0)*p(0)+offset; - case 2: - return (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; - case 3: - return (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; - default: - Assert(false, ExcNotImplemented()); - } - return 0.; -} - -template -void -PillowFunction::value_list (const typename std::vector > &points, - std::vector &values, + + template + double + CosineFunction::value (const Point &p, + const unsigned int) const + { + switch(dim) + { + case 1: + return std::cos(M_PI_2*p(0)); + case 2: + return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + case 3: + return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + default: + Assert(false, ExcNotImplemented()); + } + return 0.; + } + + template + void + CosineFunction::value_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + values[i] = std::cos(M_PI_2*p(0)); + break; + case 2: + values[i] = std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + break; + case 3: + values[i] = std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + + template + double + CosineFunction::laplacian (const Point &p, + const unsigned int) const + { + switch(dim) + { + case 1: + return -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)); + case 2: + return -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + case 3: + return -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + default: + Assert(false, ExcNotImplemented()); + } + return 0.; + } + + template + void + CosineFunction::laplacian_list (const typename std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + values[i] = -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)); + break; + case 2: + values[i] = -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + break; + case 3: + values[i] = -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + + template + Tensor<1,dim> + CosineFunction::gradient (const Point &p, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = 1.-p(0)*p(0)+offset; - break; - case 2: - values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; - break; - case 3: - values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - - - -template -double -PillowFunction::laplacian (const Point &p, + { + Tensor<1,dim> result; + switch(dim) + { + case 1: + result[0] = -M_PI_2* std::sin(M_PI_2*p(0)); + break; + case 2: + result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + break; + case 3: + result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + result[2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } + return result; + } + + template + void + CosineFunction::gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)); + break; + case 2: + gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + break; + case 3: + gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + gradients[i][2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + + template + Tensor<2,dim> + CosineFunction::hessian (const Point &p, const unsigned int) const -{ - switch(dim) - { - case 1: - return -2.; - case 2: - return -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); - case 3: - return -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) - +(1.-p(1)*p(1))*(1.-p(2)*p(2)) - +(1.-p(2)*p(2))*(1.-p(0)*p(0))); - default: - Assert(false, ExcNotImplemented()); - } - return 0.; -} - -template -void -PillowFunction::laplacian_list (const typename std::vector > &points, - std::vector &values, + { + const double pi2 = M_PI_2*M_PI_2; + + Tensor<2,dim> result; + switch(dim) + { + case 1: + result[0][0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + if (true) + { + const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + result[0][0] = coco; + result[1][1] = coco; + result[0][1] = sisi; + result[1][0] = sisi; + } + break; + case 3: + if (true) + { + const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + + result[0][0] = cococo; + result[1][1] = cococo; + result[2][2] = cococo; + result[0][1] = sisico; + result[1][0] = sisico; + result[0][2] = sicosi; + result[2][0] = sicosi; + result[1][2] = cosisi; + result[2][1] = cosisi; + } + break; + default: + Assert(false, ExcNotImplemented()); + } + return result; + } + + template + void + CosineFunction::hessian_list (const typename std::vector > &points, + typename std::vector > &hessians, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = -2.; - break; - case 2: - values[i] = -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); - break; - case 3: - values[i] = -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) - +(1.-p(1)*p(1))*(1.-p(2)*p(2)) - +(1.-p(2)*p(2))*(1.-p(0)*p(0))); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - -template -Tensor<1,dim> -PillowFunction::gradient (const Point &p, - const unsigned int) const -{ - Tensor<1,dim> result; - switch(dim) - { - case 1: - result[0] = -2.*p(0); - break; - case 2: - result[0] = -2.*p(0)*(1.-p(1)*p(1)); - result[1] = -2.*p(1)*(1.-p(0)*p(0)); - break; - case 3: - result[0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); - result[1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); - result[2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); - break; - default: - Assert(false, ExcNotImplemented()); - } - return result; -} - -template -void -PillowFunction::gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = -2.*p(0); - break; - case 2: - gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1)); - gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0)); - break; - case 3: - gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); - gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); - gradients[i][2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - + { + Assert (hessians.size() == points.size(), + ExcDimensionMismatch(hessians.size(), points.size())); + + const double pi2 = M_PI_2*M_PI_2; + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + hessians[i][0][0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + if (true) + { + const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + hessians[i][0][0] = coco; + hessians[i][1][1] = coco; + hessians[i][0][1] = sisi; + hessians[i][1][0] = sisi; + } + break; + case 3: + if (true) + { + const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + + hessians[i][0][0] = cococo; + hessians[i][1][1] = cococo; + hessians[i][2][2] = cococo; + hessians[i][0][1] = sisico; + hessians[i][1][0] = sisico; + hessians[i][0][2] = sicosi; + hessians[i][2][0] = sicosi; + hessians[i][1][2] = cosisi; + hessians[i][2][1] = cosisi; + } + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + ////////////////////////////////////////////////////////////////////// - -template -double -CosineFunction::value (const Point &p, - const unsigned int) const -{ - switch(dim) - { - case 1: - return std::cos(M_PI_2*p(0)); - case 2: - return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - case 3: - return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - default: - Assert(false, ExcNotImplemented()); - } - return 0.; -} - -template -void -CosineFunction::value_list (const typename std::vector > &points, - std::vector &values, - const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = std::cos(M_PI_2*p(0)); - break; - case 2: - values[i] = std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - break; - case 3: - values[i] = std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - -template -double -CosineFunction::laplacian (const Point &p, + + template + double + ExpFunction::value (const Point &p, + const unsigned int) const + { + switch(dim) + { + case 1: + return std::exp(p(0)); + case 2: + return std::exp(p(0)) * std::exp(p(1)); + case 3: + return std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + default: + Assert(false, ExcNotImplemented()); + } + return 0.; + } + + template + void + ExpFunction::value_list (const typename std::vector > &points, + std::vector &values, const unsigned int) const -{ - switch(dim) - { - case 1: - return -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)); - case 2: - return -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - case 3: - return -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - default: - Assert(false, ExcNotImplemented()); - } - return 0.; -} - -template -void -CosineFunction::laplacian_list (const typename std::vector > &points, - std::vector &values, - const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)); - break; - case 2: - values[i] = -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - break; - case 3: - values[i] = -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - -template -Tensor<1,dim> -CosineFunction::gradient (const Point &p, + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) + { + case 1: + values[i] = std::exp(p(0)); + break; + case 2: + values[i] = std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + values[i] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } + } + } + + template + double + ExpFunction::laplacian (const Point &p, const unsigned int) const -{ - Tensor<1,dim> result; - switch(dim) - { - case 1: - result[0] = -M_PI_2* std::sin(M_PI_2*p(0)); - break; - case 2: - result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - break; - case 3: - result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - result[2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - return result; -} - -template -void -CosineFunction::gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, + { + switch(dim) + { + case 1: + return std::exp(p(0)); + case 2: + return 2 * std::exp(p(0)) * std::exp(p(1)); + case 3: + return 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + default: + Assert(false, ExcNotImplemented()); + } + return 0.; + } + + template + void + ExpFunction::laplacian_list (const typename std::vector > &points, + std::vector &values, const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)); - break; - case 2: - gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - break; - case 3: - gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - gradients[i][2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - -template -Tensor<2,dim> -CosineFunction::hessian (const Point &p, - const unsigned int) const -{ - const double pi2 = M_PI_2*M_PI_2; - - Tensor<2,dim> result; - switch(dim) - { - case 1: - result[0][0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - if (true) + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) { - const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - result[0][0] = coco; - result[1][1] = coco; - result[0][1] = sisi; - result[1][0] = sisi; + case 1: + values[i] = std::exp(p(0)); + break; + case 2: + values[i] = 2 * std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + values[i] = 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); } - break; - case 3: - if (true) + } + } + + template + Tensor<1,dim> + ExpFunction::gradient (const Point &p, + const unsigned int) const + { + Tensor<1,dim> result; + switch(dim) + { + case 1: + result[0] = std::exp(p(0)); + break; + case 2: + result[0] = std::exp(p(0)) * std::exp(p(1)); + result[1] = std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + result[0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + result[1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + result[2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } + return result; + } + + template + void + ExpFunction::gradient_list (const typename std::vector > &points, + typename std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + switch(dim) { - const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - - result[0][0] = cococo; - result[1][1] = cococo; - result[2][2] = cococo; - result[0][1] = sisico; - result[1][0] = sisico; - result[0][2] = sicosi; - result[2][0] = sicosi; - result[1][2] = cosisi; - result[2][1] = cosisi; + case 1: + gradients[i][0] = std::exp(p(0)); + break; + case 2: + gradients[i][0] = std::exp(p(0)) * std::exp(p(1)); + gradients[i][1] = std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + gradients[i][0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + gradients[i][1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + gradients[i][2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); } - break; - default: - Assert(false, ExcNotImplemented()); - } - return result; -} - -template -void -CosineFunction::hessian_list (const typename std::vector > &points, - typename std::vector > &hessians, - const unsigned int) const -{ - Assert (hessians.size() == points.size(), - ExcDimensionMismatch(hessians.size(), points.size())); - - const double pi2 = M_PI_2*M_PI_2; - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - hessians[i][0][0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - if (true) - { - const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - hessians[i][0][0] = coco; - hessians[i][1][1] = coco; - hessians[i][0][1] = sisi; - hessians[i][1][0] = sisi; - } - break; - case 3: - if (true) - { - const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - - hessians[i][0][0] = cococo; - hessians[i][1][1] = cococo; - hessians[i][2][2] = cococo; - hessians[i][0][1] = sisico; - hessians[i][1][0] = sisico; - hessians[i][0][2] = sicosi; - hessians[i][2][0] = sicosi; - hessians[i][1][2] = cosisi; - hessians[i][2][1] = cosisi; - } - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - + } + } + ////////////////////////////////////////////////////////////////////// - -template -double -ExpFunction::value (const Point &p, - const unsigned int) const -{ - switch(dim) - { - case 1: - return std::exp(p(0)); - case 2: - return std::exp(p(0)) * std::exp(p(1)); - case 3: - return std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - default: - Assert(false, ExcNotImplemented()); - } - return 0.; -} - -template -void -ExpFunction::value_list (const typename std::vector > &points, - std::vector &values, - const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = std::exp(p(0)); - break; - case 2: - values[i] = std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - values[i] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - -template -double -ExpFunction::laplacian (const Point &p, - const unsigned int) const -{ - switch(dim) - { - case 1: - return std::exp(p(0)); - case 2: - return 2 * std::exp(p(0)) * std::exp(p(1)); - case 3: - return 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - default: - Assert(false, ExcNotImplemented()); - } - return 0.; -} - -template -void -ExpFunction::laplacian_list (const typename std::vector > &points, - std::vector &values, + + + double + LSingularityFunction::value (const Point<2> &p, + const unsigned int) const + { + double x = p(0); + double y = p(1); + + if ((x>=0) && (y>=0)) + return 0.; + + double phi = std::atan2(y,-x)+M_PI; + double r2 = x*x+y*y; + + return std::pow(r2,1./3.) * std::sin(2./3.*phi); + } + + + void + LSingularityFunction::value_list (const std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i=0) && (y>=0)) + values[i] = 0.; + else + { + double phi = std::atan2(y,-x)+M_PI; + double r2 = x*x+y*y; + + values[i] = std::pow(r2,1./3.) * std::sin(2./3.*phi); + } + } + } + + + double + LSingularityFunction::laplacian (const Point<2> &, + const unsigned int) const + { + return 0.; + } + + + void + LSingularityFunction::laplacian_list (const std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i + LSingularityFunction::gradient (const Point<2> &p, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = std::exp(p(0)); - break; - case 2: - values[i] = 2 * std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - values[i] = 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - -template -Tensor<1,dim> -ExpFunction::gradient (const Point &p, - const unsigned int) const -{ - Tensor<1,dim> result; - switch(dim) - { - case 1: - result[0] = std::exp(p(0)); - break; - case 2: - result[0] = std::exp(p(0)) * std::exp(p(1)); - result[1] = std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - result[0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - result[1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - result[2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - return result; -} - -template -void -ExpFunction::gradient_list (const typename std::vector > &points, - typename std::vector > &gradients, - const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = std::exp(p(0)); - break; - case 2: - gradients[i][0] = std::exp(p(0)) * std::exp(p(1)); - gradients[i][1] = std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - gradients[i][0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - gradients[i][1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - gradients[i][2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } - } -} - + { + double x = p(0); + double y = p(1); + double phi = std::atan2(y,-x)+M_PI; + double r43 = std::pow(x*x+y*y,2./3.); + + Tensor<1,2> result; + result[0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; + result[1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; + return result; + } + + + void + LSingularityFunction::gradient_list (const std::vector > &points, + std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(y,-x)+M_PI; + double r43 = std::pow(x*x+y*y,2./3.); + + gradients[i][0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; + gradients[i][1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; + } + } + ////////////////////////////////////////////////////////////////////// - - -double -LSingularityFunction::value (const Point<2> &p, - const unsigned int) const -{ - double x = p(0); - double y = p(1); - - if ((x>=0) && (y>=0)) - return 0.; - double phi = std::atan2(y,-x)+M_PI; - double r2 = x*x+y*y; - - return std::pow(r2,1./3.) * std::sin(2./3.*phi); -} - - -void -LSingularityFunction::value_list (const std::vector > &points, - std::vector &values, + + double + SlitSingularityFunction::value (const Point<2> &p, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i=0) && (y>=0)) - values[i] = 0.; - else - { - double phi = std::atan2(y,-x)+M_PI; - double r2 = x*x+y*y; - - values[i] = std::pow(r2,1./3.) * std::sin(2./3.*phi); - } - } -} - - -double -LSingularityFunction::laplacian (const Point<2> &, - const unsigned int) const -{ - return 0.; -} - - -void -LSingularityFunction::laplacian_list (const std::vector > &points, - std::vector &values, + { + double x = p(0); + double y = p(1); + + double phi = std::atan2(x,y)+M_PI; + double r2 = x*x+y*y; + + return std::pow(r2,.25) * std::sin(.5*phi); + } + + + void + SlitSingularityFunction::value_list (const std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i &, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i -LSingularityFunction::gradient (const Point<2> &p, - const unsigned int) const -{ - double x = p(0); - double y = p(1); - double phi = std::atan2(y,-x)+M_PI; - double r43 = std::pow(x*x+y*y,2./3.); - - Tensor<1,2> result; - result[0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; - result[1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; - return result; -} - - -void -LSingularityFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, + { + return 0.; + } + + + void + SlitSingularityFunction::laplacian_list (const std::vector > &points, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0;i + SlitSingularityFunction::gradient (const Point<2> &p, const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(y,-x)+M_PI; - double r43 = std::pow(x*x+y*y,2./3.); - - gradients[i][0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; - gradients[i][1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; - } -} - + { + double x = p(0); + double y = p(1); + double phi = std::atan2(x,y)+M_PI; + double r64 = std::pow(x*x+y*y,3./4.); + + + Tensor<1,2> result; + result[0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; + result[1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; + return result; + } + + + void + SlitSingularityFunction::gradient_list (const std::vector > &points, + std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0;i& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(x,y)+M_PI; + double r64 = std::pow(x*x+y*y,3./4.); + + gradients[i][0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; + gradients[i][1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; + } + } + ////////////////////////////////////////////////////////////////////// - - -double -SlitSingularityFunction::value (const Point<2> &p, + + template + JumpFunction::JumpFunction(const Point &direction, + const double steepness) + : + direction(direction), + steepness(steepness) + { + switch (dim) + { + case 1: + angle = 0; + break; + case 2: + angle = std::atan2(direction(0),direction(1)); + break; + case 3: + Assert(false, ExcNotImplemented()); + } + sine = std::sin(angle); + cosine = std::cos(angle); + } + + + + template + double + JumpFunction::value (const Point &p, + const unsigned int) const + { + double x = steepness*(-cosine*p(0)+sine*p(1)); + return -std::atan(x); + } + + + + template + void + JumpFunction::value_list (const typename std::vector > &p, + std::vector &values, + const unsigned int) const + { + Assert (values.size() == p.size(), + ExcDimensionMismatch(values.size(), p.size())); + + for (unsigned int i=0;i + double + JumpFunction::laplacian (const Point &p, const unsigned int) const -{ - double x = p(0); - double y = p(1); - - double phi = std::atan2(x,y)+M_PI; - double r2 = x*x+y*y; - - return std::pow(r2,.25) * std::sin(.5*phi); -} - - -void -SlitSingularityFunction::value_list (const std::vector > &points, - std::vector &values, + { + double x = steepness*(-cosine*p(0)+sine*p(1)); + double r = 1+x*x; + return 2*steepness*steepness*x/(r*r); + } + + + template + void + JumpFunction::laplacian_list (const typename std::vector > &p, + std::vector &values, const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i &, - const unsigned int) const -{ - return 0.; -} - - -void -SlitSingularityFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0;i -SlitSingularityFunction::gradient (const Point<2> &p, - const unsigned int) const -{ - double x = p(0); - double y = p(1); - double phi = std::atan2(x,y)+M_PI; - double r64 = std::pow(x*x+y*y,3./4.); + { + Assert (values.size() == p.size(), + ExcDimensionMismatch(values.size(), p.size())); + + double f = 2*steepness*steepness; + + for (unsigned int i=0;i result; - result[0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; - result[1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; - return result; -} - - -void -SlitSingularityFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(x,y)+M_PI; - double r64 = std::pow(x*x+y*y,3./4.); - - gradients[i][0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; - gradients[i][1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; - } -} - -////////////////////////////////////////////////////////////////////// - -template -JumpFunction::JumpFunction(const Point &direction, - const double steepness) - : - direction(direction), - steepness(steepness) -{ - switch (dim) - { - case 1: - angle = 0; - break; - case 2: - angle = std::atan2(direction(0),direction(1)); - break; - case 3: - Assert(false, ExcNotImplemented()); - } - sine = std::sin(angle); - cosine = std::cos(angle); -} - - - -template -double -JumpFunction::value (const Point &p, - const unsigned int) const -{ - double x = steepness*(-cosine*p(0)+sine*p(1)); - return -std::atan(x); -} - - - -template -void -JumpFunction::value_list (const typename std::vector > &p, - std::vector &values, + + template + Tensor<1,dim> + JumpFunction::gradient (const Point &p, const unsigned int) const -{ - Assert (values.size() == p.size(), - ExcDimensionMismatch(values.size(), p.size())); - - for (unsigned int i=0;i -double -JumpFunction::laplacian (const Point &p, - const unsigned int) const -{ - double x = steepness*(-cosine*p(0)+sine*p(1)); - double r = 1+x*x; - return 2*steepness*steepness*x/(r*r); -} - - -template -void -JumpFunction::laplacian_list (const typename std::vector > &p, - std::vector &values, - const unsigned int) const -{ - Assert (values.size() == p.size(), - ExcDimensionMismatch(values.size(), p.size())); - - double f = 2*steepness*steepness; - - for (unsigned int i=0;i -Tensor<1,dim> -JumpFunction::gradient (const Point &p, - const unsigned int) const -{ - double x = steepness*(-cosine*p(0)+sine*p(1)); - double r = -steepness*(1+x*x); - Tensor<1,dim> erg; - erg[0] = cosine*r; - erg[1] = sine*r; - return erg; -} - - - -template -void -JumpFunction::gradient_list (const typename std::vector > &p, - typename std::vector > &gradients, - const unsigned int) const -{ - Assert (gradients.size() == p.size(), - ExcDimensionMismatch(gradients.size(), p.size())); - - for (unsigned int i=0; i -unsigned int -JumpFunction::memory_consumption () const -{ - // only simple data elements, so - // use sizeof operator - return sizeof (*this); -}; - - - - - + { + double x = steepness*(-cosine*p(0)+sine*p(1)); + double r = -steepness*(1+x*x); + Tensor<1,dim> erg; + erg[0] = cosine*r; + erg[1] = sine*r; + return erg; + } + + + + template + void + JumpFunction::gradient_list (const typename std::vector > &p, + typename std::vector > &gradients, + const unsigned int) const + { + Assert (gradients.size() == p.size(), + ExcDimensionMismatch(gradients.size(), p.size())); + + for (unsigned int i=0; i + unsigned int + JumpFunction::memory_consumption () const + { + // only simple data elements, so + // use sizeof operator + return sizeof (*this); + }; + + + + + /* ---------------------- FourierSineFunction ----------------------- */ - - -template -FourierCosineFunction:: -FourierCosineFunction (const Point &fourier_coefficients) - : - Function (1), - fourier_coefficients (fourier_coefficients) -{}; - - - -template -double -FourierCosineFunction::value (const Point &p, + + + template + FourierCosineFunction:: + FourierCosineFunction (const Point &fourier_coefficients) + : + Function (1), + fourier_coefficients (fourier_coefficients) + {}; + + + + template + double + FourierCosineFunction::value (const Point &p, + const unsigned int component) const + { + Assert (component==0, ExcIndexRange(component,0,1)); + double val=1; + for (unsigned int i=0; i + Tensor<1,dim> + FourierCosineFunction::gradient (const Point &p, + const unsigned int component) const + { + Assert (component==0, ExcIndexRange(component,0,1)); + Tensor<1,dim> grad; + for (unsigned int i=0; i + double + FourierCosineFunction::laplacian (const Point &p, + const unsigned int component) const + { + Assert (component==0, ExcIndexRange(component,0,1)); + double val = -(fourier_coefficients*fourier_coefficients); + for (unsigned int i=0; i + FourierSineFunction:: + FourierSineFunction (const Point &fourier_coefficients) + : + Function (1), + fourier_coefficients (fourier_coefficients) + {}; + + + + template + double + FourierSineFunction::value (const Point &p, const unsigned int component) const -{ - Assert (component==0, ExcIndexRange(component,0,1)); - double val=1; - for (unsigned int i=0; i -Tensor<1,dim> -FourierCosineFunction::gradient (const Point &p, + { + Assert (component==0, ExcIndexRange(component,0,1)); + double val=1; + for (unsigned int i=0; i + Tensor<1,dim> + FourierSineFunction::gradient (const Point &p, const unsigned int component) const -{ - Assert (component==0, ExcIndexRange(component,0,1)); - Tensor<1,dim> grad; - for (unsigned int i=0; i grad; + for (unsigned int i=0; i -double -FourierCosineFunction::laplacian (const Point &p, + + + template + double + FourierSineFunction::laplacian (const Point &p, const unsigned int component) const -{ - Assert (component==0, ExcIndexRange(component,0,1)); - double val = -(fourier_coefficients*fourier_coefficients); - for (unsigned int i=0; i -FourierSineFunction:: -FourierSineFunction (const Point &fourier_coefficients) - : - Function (1), - fourier_coefficients (fourier_coefficients) -{}; - - - -template -double -FourierSineFunction::value (const Point &p, - const unsigned int component) const -{ - Assert (component==0, ExcIndexRange(component,0,1)); - double val=1; - for (unsigned int i=0; i -Tensor<1,dim> -FourierSineFunction::gradient (const Point &p, - const unsigned int component) const -{ - Assert (component==0, ExcIndexRange(component,0,1)); - Tensor<1,dim> grad; - for (unsigned int i=0; i; + template class SquareFunction<2>; + template class SquareFunction<3>; + template class Q1WedgeFunction<1>; + template class Q1WedgeFunction<2>; + template class Q1WedgeFunction<3>; + template class PillowFunction<1>; + template class PillowFunction<2>; + template class PillowFunction<3>; + template class CosineFunction<1>; + template class CosineFunction<2>; + template class CosineFunction<3>; + template class ExpFunction<1>; + template class ExpFunction<2>; + template class ExpFunction<3>; + template class JumpFunction<1>; + template class JumpFunction<2>; + template class JumpFunction<3>; + template class FourierCosineFunction<1>; + template class FourierCosineFunction<2>; + template class FourierCosineFunction<3>; + template class FourierSineFunction<1>; + template class FourierSineFunction<2>; + template class FourierSineFunction<3>; + - return grad; -}; - - - -template -double -FourierSineFunction::laplacian (const Point &p, - const unsigned int component) const -{ - Assert (component==0, ExcIndexRange(component,0,1)); - double val = -(fourier_coefficients*fourier_coefficients); - for (unsigned int i=0; i; -template class SquareFunction<2>; -template class SquareFunction<3>; -template class Q1WedgeFunction<1>; -template class Q1WedgeFunction<2>; -template class Q1WedgeFunction<3>; -template class PillowFunction<1>; -template class PillowFunction<2>; -template class PillowFunction<3>; -template class CosineFunction<1>; -template class CosineFunction<2>; -template class CosineFunction<3>; -template class ExpFunction<1>; -template class ExpFunction<2>; -template class ExpFunction<3>; -template class JumpFunction<1>; -template class JumpFunction<2>; -template class JumpFunction<3>; -template class FourierCosineFunction<1>; -template class FourierCosineFunction<2>; -template class FourierCosineFunction<3>; -template class FourierSineFunction<1>; -template class FourierSineFunction<2>; -template class FourierSineFunction<3>; - diff --git a/deal.II/doc/news/2001/c-3-1.html b/deal.II/doc/news/2001/c-3-1.html index d1595b8c44..5355aa3020 100644 --- a/deal.II/doc/news/2001/c-3-1.html +++ b/deal.II/doc/news/2001/c-3-1.html @@ -158,12 +158,22 @@ documentation, etc.

base

    +
  1. + Changed: The examples classes in the base directory are now + moved into a namespace Functions of + their own. This improves encapsulation, but also keeps the + documentation of these functions together, as they were + previously scrambled all over the screen in the documentation + page of the base library. +
    + (WB 2001/07/18) +

  2. New: classes FourierSineFunction and FourierCosineFunction, resembling one mode of a Fourier decomposition.
    - (GK 2001/07/18) + (WB 2001/07/18)

  3. New: class vector2d was introduced -- 2.39.5