From 4b052725828965f91b8668a9dffa942683d2b64c Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 8 Feb 2002 16:21:13 +0000 Subject: [PATCH] improved structure for cutoff functions git-svn-id: https://svn.dealii.org/trunk@5482 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/function_lib.h | 143 ++++++++++----------- deal.II/base/source/function_lib_cutoff.cc | 47 +++++-- 2 files changed, 104 insertions(+), 86 deletions(-) diff --git a/deal.II/base/include/base/function_lib.h b/deal.II/base/include/base/function_lib.h index 06345b2564..81e77418b9 100644 --- a/deal.II/base/include/base/function_lib.h +++ b/deal.II/base/include/base/function_lib.h @@ -785,6 +785,71 @@ namespace Functions }; +/** + * Base function for cut-off function. This class stores the center + * and the radius of the supporting ball of a cut-off function. It + * also stores the number of the non-zero component, if the function + * is vector-valued. + * + * @author Guido Kanschat, 2002 + */ + template + class CutOffFunctionBase : public Function + { + public: + /** + * Constructor. Arguments are the + * center of the ball and its + * radius. + * + * If an argument @p{select} is + * given and not -1, the + * cut-off function will be + * non-zero for this component + * only. + */ + CutOffFunctionBase (const double radius = 1., + Point = Point(), + const unsigned int n_components = 1, + const unsigned int select = no_component); + + /** + * Move the center of the ball + * to new point @p{p}. + */ + void new_center (const Point& p); + + /** + * Set the radius of the ball to @p{r}. + */ + void new_radius (const double r); + + protected: + /** + * Center of the integration ball. + */ + const Point center; + + /** + * Radius of the ball. + */ + const double radius; + + /** + * Component selected. If + * @p{no_component}, the function is + * the same in all components. + */ + const unsigned int selected; + /** + * Value for no selected component. + */ + static const unsigned int no_component = static_cast(-1); + + }; + + + /** * Cut-off function in L-infinity for an arbitrary ball. This * function is the characteristic function of a ball around @p{center} @@ -794,7 +859,7 @@ namespace Functions * @author Guido Kanschat, 2001, 2002 */ template - class CutOffFunctionLinfty : public Function + class CutOffFunctionLinfty : public CutOffFunctionBase { public: /** @@ -831,28 +896,6 @@ namespace Functions */ virtual void vector_value_list (const typename std::vector > &points, std::vector > &values) const; - - private: - /** - * Center of the integration ball. - */ - const Point center; - - /** - * Radius of the ball. - */ - const double radius; - - /** - * Component selected. If - * @p{no_component}, the function is - * the same in all components. - */ - const unsigned int selected; - /** - * Value for no selected component. - */ - static const unsigned int no_component = static_cast(-1); }; @@ -865,7 +908,7 @@ namespace Functions * @author Guido Kanschat, 2001, 2002 */ template - class CutOffFunctionW1 : public Function + class CutOffFunctionW1 : public CutOffFunctionBase { public: /** @@ -902,29 +945,6 @@ namespace Functions */ virtual void vector_value_list (const typename std::vector > &points, std::vector > &values) const; - - private: - /** - * Center of the integration ball. - */ - const Point center; - - /** - * Radius of the ball. - */ - const double radius; - - /** - * Component selected. If - * @p{no_component}, the - * function is the same in all - * components. - */ - const unsigned int selected; - /** - * Value for no selected component. - */ - static const unsigned int no_component = static_cast(-1); }; @@ -938,7 +958,7 @@ namespace Functions * @author Guido Kanschat, 2001, 2002 */ template - class CutOffFunctionCinfty : public Function + class CutOffFunctionCinfty : public CutOffFunctionBase { public: /** @@ -981,32 +1001,7 @@ namespace Functions */ virtual Tensor<1,dim> gradient (const Point &p, const unsigned int component = 0) const; - - private: - /** - * Center of the integration ball. - */ - const Point center; - - /** - * Radius of the ball. - */ - const double radius; - - /** - * Component selected. If - * @p{no_component}, the function is - * the same in all components. - */ - const unsigned int selected; - - /** - * Value for no selected component. - */ - static const unsigned int no_component = static_cast(-1); }; - -}; - +} #endif diff --git a/deal.II/base/source/function_lib_cutoff.cc b/deal.II/base/source/function_lib_cutoff.cc index 3270004be8..7c04aa7025 100644 --- a/deal.II/base/source/function_lib_cutoff.cc +++ b/deal.II/base/source/function_lib_cutoff.cc @@ -39,12 +39,14 @@ namespace Functions { using namespace std; + + template - CutOffFunctionLinfty::CutOffFunctionLinfty (const double r, - const Point p, - const unsigned int n_components, - const unsigned int select) + CutOffFunctionBase::CutOffFunctionBase (const double r, + const Point p, + const unsigned int n_components, + unsigned int select) : Function (n_components), center(p), @@ -53,6 +55,33 @@ namespace Functions {} + template + void + CutOffFunctionBase::new_center (const Point& p) + { + center = p; + } + + + template + void + CutOffFunctionBase::new_radius (const double r) + { + radius = r; + } + +////////////////////////////////////////////////////////////////////// + + template + CutOffFunctionLinfty::CutOffFunctionLinfty (const double r, + const Point p, + const unsigned int n_components, + unsigned int select) + : + CutOffFunctionBase (r, p, n_components, select) + {} + + template double CutOffFunctionLinfty::value (const Point &p, @@ -113,10 +142,7 @@ namespace Functions const unsigned int n_components, const unsigned int select) : - Function (n_components), - center(p), - radius(r), - selected(select) + CutOffFunctionBase (r, p, n_components, select) {} @@ -185,10 +211,7 @@ namespace Functions const unsigned int n_components, const unsigned int select) : - Function (n_components), - center(p), - radius(r), - selected(select) + CutOffFunctionBase (r, p, n_components, select) {} -- 2.39.5