* 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
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.
*/
virtual void laplacian_list (const vector<Point<dim> > &points,
vector<double> &values,
const unsigned int component = 0) const;
+ private:
+ const double offset;
};
//////////////////////////////////////////////////////////////////////
+template<int dim>
+PillowFunction<dim>::PillowFunction (const double offset)
+ :
+ offset(offset)
+{}
+
+
template<int dim>
double
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());
}
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());