class SquareFunction : public Function<dim>
{
public:
- /**
- * Function value at one point.
- */
virtual double value (const Point<dim> &p,
- const unsigned int component = 0) const;
-
- /**
- * Function values at multiple points.
- */
+ const unsigned int component = 0) const;
+ virtual void vector_value (const Point<dim> &p,
+ Vector<double> &values) const;
virtual void value_list (const std::vector<Point<dim> > &points,
std::vector<double> &values,
const unsigned int component = 0) const;
-
- /**
- * Gradient at one point.
- */
virtual Tensor<1,dim> gradient (const Point<dim> &p,
const unsigned int component = 0) const;
-
- /**
- Gradients at multiple points.
- */
+ virtual void vector_gradient (const Point<dim> &p,
+ std::vector<Tensor<1,dim> > &gradient) const;
virtual void gradient_list (const std::vector<Point<dim> > &points,
std::vector<Tensor<1,dim> > &gradients,
const unsigned int component = 0) const;
-
- /**
- * Laplacian of the function at one point.
- */
virtual double laplacian (const Point<dim> &p,
const unsigned int component = 0) const;
-
- /**
- * Laplacian of the function at multiple points.
- */
virtual void laplacian_list (const std::vector<Point<dim> > &points,
std::vector<double> &values,
const unsigned int component = 0) const;
template <int dim>
-void Function<dim>::vector_value (const Point<dim> &,
- Vector<double> &) const
+void Function<dim>::vector_value (
+ const Point<dim>& p,
+ Vector<double>& v) const
{
- Assert (false, ExcPureFunctionCalled());
+ AssertDimension(v.size(), this->n_components);
+ for (unsigned int i=0;i<this->n_components;++i)
+ v(i) = value(p, i);
}
template <int dim>
-void Function<dim>::vector_gradient (const Point<dim> &,
- std::vector<Tensor<1,dim> > &) const
+void Function<dim>::vector_gradient (
+ const Point<dim>& p,
+ std::vector<Tensor<1,dim> >& v) const
{
- Assert (false, ExcPureFunctionCalled());
+ AssertDimension(v.size(), this->n_components);
+ for (unsigned int i=0;i<this->n_components;++i)
+ v[i] = gradient(p, i);
}
{
return p.square();
}
+
-
+ template<int dim>
+ void
+ SquareFunction<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &values) const
+ {
+ AssertDimension(values.size(), 1);
+ values(0) = p.square();
+ }
+
+
template<int dim>
void
SquareFunction<dim>::value_list (const std::vector<Point<dim> > &points,
SquareFunction<dim>::gradient (const Point<dim> &p,
const unsigned int) const
{
- return p*2;
+ return p*2.;
}
-
+ template<int dim>
+ void
+ SquareFunction<dim>::vector_gradient (
+ const Point<dim>& p,
+ std::vector<Tensor<1,dim> >& values) const
+ {
+ AssertDimension(values.size(), 1);
+ values[0] = p*2.;
+ }
+
+
+
template<int dim>
void
SquareFunction<dim>::gradient_list (const std::vector<Point<dim> > &points,
Tensor<1,2>
LSingularityFunction::gradient (const Point<2> &p,
- const unsigned int d) const
+ const unsigned int) const
{
double x = p(0);
double y = p(1);