From 454a08167dbc5d67dc43a6d91e1993e7b8405c07 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Thu, 18 Apr 2019 19:57:37 +0200 Subject: [PATCH] Added FunctionCutOffTensorProduct. --- include/deal.II/base/function_lib.h | 109 +++++++++++++++++++++++- source/base/function_lib_cutoff.cc | 79 ++++++++++++++++++ tests/base/function_cutoff_02.cc | 120 +++++++++++++++++++++++++++ tests/base/function_cutoff_02.output | 64 ++++++++++++++ 4 files changed, 369 insertions(+), 3 deletions(-) create mode 100644 tests/base/function_cutoff_02.cc create mode 100644 tests/base/function_cutoff_02.output diff --git a/include/deal.II/base/function_lib.h b/include/deal.II/base/function_lib.h index 0b36b2d4e3..ff38a07bc8 100644 --- a/include/deal.II/base/function_lib.h +++ b/include/deal.II/base/function_lib.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -946,6 +947,11 @@ namespace Functions const bool integrate_to_one = false, const double unitary_integral_value = 1.0); + /** + * Virtual destructor. + */ + virtual ~CutOffFunctionBase() = default; + /** * Move the center of the ball to new point p. * @@ -965,7 +971,7 @@ namespace Functions /** * Set the center of the ball to the point @p p. */ - void + virtual void set_center(const Point &p); /** @@ -973,7 +979,7 @@ namespace Functions * * @deprecated Use set_radius() instead. */ - void + virtual void set_radius(const double r); /** @@ -988,6 +994,12 @@ namespace Functions double get_radius() const; + /** + * Return a boolean indicating if this function integrates to one. + */ + bool + integrates_to_one() const; + protected: /** * Center of the integration ball. @@ -1008,7 +1020,7 @@ namespace Functions /** * Flag that controls wether we rescale the value when the radius changes. */ - const bool integrate_to_one; + bool integrate_to_one; /** * The reference integral value. Derived classes should specify what their @@ -1023,6 +1035,76 @@ namespace Functions }; + /** + * Tensor product of CutOffFunctionBase objects. + * + * Instead of using the distance to compute the cut-off function, this class + * performs a tensor product of the same CutOffFunctionBase object in each + * coordinate direction. + * + * @ingroup functions + * @author Luca Heltai, 2019. + */ + template + class CutOffFunctionTensorProduct : public CutOffFunctionBase + { + public: + /** + * Construct an empty CutOffFunctionTensorProduct object. + * + * Before you can use this class, you have to call the set_base() method + * with a class derived from the CutOffFunctionBase object. + * + * If you try to use this class before you call the set_base() method, + * and exception will be triggered. + */ + CutOffFunctionTensorProduct( + double radius = 1.0, + const Point & center = Point(), + const unsigned int n_components = 1, + const unsigned int select = CutOffFunctionBase::no_component, + const bool integrate_to_one = false); + + /** + * Initialize the class with an objet of type + * @tparam CutOffFunctionBaseType<1>. + */ + template