+/**
+ Provide a function which always returns zero. Obviously, also the derivates
+ of this function are zero.
+
+ This function is of use when you want to implement homogeneous boundary
+ conditions.
+*/
+template <int dim>
+class ZeroFunction : public Function<dim> {
+ public:
+ /**
+ * Return the value of the function
+ * at the given point.
+ */
+ virtual double operator () (const Point<dim> &p) const;
+
+ /**
+ * Set #values# to the point values
+ * of the function at the #points#.
+ * It is assumed that #values# be
+ * empty.
+ */
+ virtual void value_list (const vector<Point<dim> > &points,
+ vector<double> &values) const;
+
+ /**
+ * Return the gradient of the function
+ * at the given point.
+ */
+ virtual Point<dim> gradient (const Point<dim> &p) const;
+
+ /**
+ * Set #gradients# to the gradients of
+ * the function at the #points#.
+ * It is assumed that #values# be
+ * empty.
+ */
+ virtual void gradient_list (const vector<Point<dim> > &points,
+ vector<Point<dim> > &gradients) const;
+};
+
+
+
+
/*---------------------------- function.h ---------------------------*/
/* end of #ifndef __function_H */
#endif
+
+
+template <int dim>
+double ZeroFunction<dim>::operator () (const Point<dim> &) const {
+ return 0.;
+};
+
+
+
+template <int dim>
+void ZeroFunction<dim>::value_list (const vector<Point<dim> > &points,
+ vector<double> &values) const {
+ Assert (values.size() == 0,
+ ExcVectorNotEmpty());
+
+ values.reserve (points.size());
+ values.insert (values.begin(), points.size(), 0.);
+};
+
+
+
+template <int dim>
+Point<dim> ZeroFunction<dim>::gradient (const Point<dim> &) const {
+ return Point<dim>();
+};
+
+
+
+template <int dim>
+void ZeroFunction<dim>::gradient_list (const vector<Point<dim> > &points,
+ vector<Point<dim> > &values) const {
+ Assert (values.size() == 0,
+ ExcVectorNotEmpty());
+
+ values.reserve (points.size());
+ values.insert (values.begin(), points.size(), Point<dim>());
+};
+
+
+
+
// explicit instantiations
template class Function<1>;
template class Function<2>;
+
+template class ZeroFunction<1>;
+template class ZeroFunction<2>;
cout << "Assembling matrices..." << endl;
FEValues<2>::UpdateStruct update_flags;
- update_flags.q_points = true;
- update_flags.gradients = true;
- update_flags.jacobians = true;
- update_flags.JxW_values = true;
+ update_flags.q_points = update_flags.gradients = true;
+ update_flags.jacobians = update_flags.JxW_values = true;
+
ProblemBase<2>::DirichletBC dirichlet_bc;
+ ZeroFunction<2> zero;
+ dirichlet_bc[0] = &zero;
problem.assemble (equation, quadrature, fe, update_flags, dirichlet_bc);
cout << "Solving..." << endl;
cout << "Assembling matrices..." << endl;
FEValues<2>::UpdateStruct update_flags;
- update_flags.q_points = true;
- update_flags.gradients = true;
- update_flags.jacobians = true;
- update_flags.JxW_values = true;
+ update_flags.q_points = update_flags.gradients = true;
+ update_flags.jacobians = update_flags.JxW_values = true;
+
ProblemBase<2>::DirichletBC dirichlet_bc;
+ ZeroFunction<2> zero;
+ dirichlet_bc[0] = &zero;
problem.assemble (equation, quadrature, fe, update_flags, dirichlet_bc);
cout << "Solving..." << endl;