]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add zero-function.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 2 Apr 1998 12:19:43 +0000 (12:19 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 2 Apr 1998 12:19:43 +0000 (12:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@117 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/function.h
deal.II/base/source/function.cc
deal.II/deal.II/Attic/examples/poisson/poisson.cc
tests/big-tests/poisson/poisson.cc

index 5ecd440b722c8d6376a6ab735c552e33743a09f4..ef4f87b458e2f3a581c70e3ef30d33618c001330 100644 (file)
@@ -79,6 +79,50 @@ class Function {
 
 
 
+/**
+   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
index 7de474db45465c770fa4c6eafaad4ee388583208..20f52784f0217230b86c7a51d6f532d40ad979b7 100644 (file)
@@ -50,6 +50,50 @@ void Function<dim>::gradient_list (const vector<Point<dim> > &points,
 
 
 
+
+
+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>;
index 7f65197b9174363029b278183214335f00953ee2..ce07669646c8afc593d722c37a05e250f2702fb5 100644 (file)
@@ -170,11 +170,12 @@ int main () {
 
   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;
index 7f65197b9174363029b278183214335f00953ee2..ce07669646c8afc593d722c37a05e250f2702fb5 100644 (file)
@@ -170,11 +170,12 @@ int main () {
 
   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;

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.