From: guido Date: Mon, 28 Aug 2000 04:03:02 +0000 (+0000) Subject: offset parameter for PillowFunction X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43a550f78a8abd090cf3b1f8fdd1e51346fb7204;p=dealii-svn.git offset parameter for PillowFunction git-svn-id: https://svn.dealii.org/trunk@3277 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 ff84da5146..299a9beb8c 100644 --- a/deal.II/base/include/base/function_lib.h +++ b/deal.II/base/include/base/function_lib.h @@ -80,6 +80,9 @@ class SquareFunction : public Function * boundary values on the domain $(-1,1)^d$. In the inside, it is the * product of $x_i^2-1$. * + * Providing a non-zero argument to the constructor, the whole function + * can be offset by a constant. + * * Together with the function, its derivatives and Laplacian are defined. * * @author: Guido Kanschat, 1999 @@ -88,6 +91,13 @@ 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. */ @@ -126,6 +136,8 @@ class PillowFunction : public Function virtual void laplacian_list (const vector > &points, vector &values, const unsigned int component = 0) const; + private: + const double offset; }; diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc index 478bd1caf1..03eaca928a 100644 --- a/deal.II/base/source/function_lib.cc +++ b/deal.II/base/source/function_lib.cc @@ -108,6 +108,13 @@ SquareFunction::gradient_list (const vector > &points, ////////////////////////////////////////////////////////////////////// +template +PillowFunction::PillowFunction (const double offset) + : + offset(offset) +{} + + template double PillowFunction::value (const Point &p, @@ -116,11 +123,11 @@ PillowFunction::value (const Point &p, switch(dim) { case 1: - return 1.-p(0)*p(0); + return 1.-p(0)*p(0)+offset; case 2: - return (1.-p(0)*p(0))*(1.-p(1)*p(1)); + 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)); + return (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; default: Assert(false, ExcNotImplemented()); } @@ -142,13 +149,13 @@ PillowFunction::value_list (const vector > &points, switch(dim) { case 1: - values[i] = 1.-p(0)*p(0); + values[i] = 1.-p(0)*p(0)+offset; break; case 2: - values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1)); + 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)); + values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; break; default: Assert(false, ExcNotImplemented());