]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
offset parameter for PillowFunction
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 Aug 2000 04:03:02 +0000 (04:03 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 Aug 2000 04:03:02 +0000 (04:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@3277 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/function_lib.h
deal.II/base/source/function_lib.cc

index ff84da5146966b8454de90fbe582fa5ac5a635ca..299a9beb8c88cdfa3ccd0cc22fcf82a847da8d42 100644 (file)
@@ -80,6 +80,9 @@ class SquareFunction : public Function<dim>
  * 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<int dim>
 class PillowFunction : public Function<dim>
 {
   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<dim>
     virtual void laplacian_list (const vector<Point<dim> > &points,
                                 vector<double>            &values,
                                 const unsigned int         component = 0) const;
+  private:
+    const double offset;
 };
 
 
index 478bd1caf13ad29c370a16ad391ebea30819602a..03eaca928a179d9b8a1a32e64715dcf52bfca440 100644 (file)
@@ -108,6 +108,13 @@ SquareFunction<dim>::gradient_list (const vector<Point<dim> > &points,
 //////////////////////////////////////////////////////////////////////
 
 
+template<int dim>
+PillowFunction<dim>::PillowFunction (const double offset)
+               :
+               offset(offset)
+{}
+
+
 template<int dim>
 double
 PillowFunction<dim>::value (const Point<dim>   &p,
@@ -116,11 +123,11 @@ PillowFunction<dim>::value (const Point<dim>   &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<dim>::value_list (const vector<Point<dim> > &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());

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.