]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new function_lib
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 2 Nov 1999 16:14:25 +0000 (16:14 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 2 Nov 1999 16:14:25 +0000 (16:14 +0000)
git-svn-id: https://svn.dealii.org/trunk@1818 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/Todo
deal.II/base/include/base/function_lib.h [new file with mode: 0644]
deal.II/base/source/function_lib.cc [new file with mode: 0644]

index 3f13b27f5af7d01702b2582892deea8a0a7a3502..785d4d250776655c633018e96b3edfb3c726d8ef 100644 (file)
@@ -10,7 +10,10 @@ Move the exceptions in the Tensor package (tensor_base.h and tensor.h)
 
 Think about the determinant function in the tensor package. Is it
   useful, can it be generalized?
-
+> There are only non-zero alternating real valued n-forms, so a determinant
+> exists only for Tensor<dim,dim>
+> Alternating exterior forms of lower index return tensors.
+> Guido
 
 Put Tensor<1,dim>::array_size directly into the array type. At
   present, egcs 1.1.2 chokes on that.
@@ -24,8 +27,9 @@ Check the pattern matching in the parameter handler module using
 
 Fill in docs for the timer class. Hopefully finally find a way to
   let it measure times larger than half an hour.
-
+> Operating system dependence. Grrr. Guido
 
 Review the TensorIndex class. Better documentation, remove general
   template. Move constructors to the back of the file, rather than
   inline in the classes. Find out whether it is really needed.
+> Remove !? Guido
diff --git a/deal.II/base/include/base/function_lib.h b/deal.II/base/include/base/function_lib.h
new file mode 100644 (file)
index 0000000..011ccd1
--- /dev/null
@@ -0,0 +1,63 @@
+// $Id$
+// Copyright Guido Kanschat, University of Minnesota, 1999
+
+#ifndef __base__function_lib_h
+#define __base__function_lib_h
+
+#include <base/function.h>
+
+/**
+ * n-quadratic pillow on the unit square.
+ *
+ * This is a function for testing the implementation. It has zero
+ * boundary values on the domain $(-1,1)^d$. In the inside, it is the
+ * product of $x_i^2-1$.
+ *
+ * Together with the function, its derivatives and Laplacian are defined.
+ * @author: Guido Kanschat, 1999
+ */
+template<int dim>
+class PillowFunction : Function<dim>
+{
+  public:
+                                    /**
+                                     * The value at a single point.
+                                     */
+    virtual double value (const Point<dim>   &p,
+                         const unsigned int  component = 0) const;
+
+                                    /**
+                                     * Values at multiple points.
+                                     */
+    virtual void value_list (const vector<Point<dim> > &points,
+                            vector<double>            &values,
+                            const unsigned int         component = 0) const;
+
+                                    /**
+                                     * Gradient at a single point.
+                                     */
+    virtual Tensor<1,dim> gradient (const Point<dim>   &p,
+                                   const unsigned int  component = 0) const;
+
+                                    /**
+                                     * Gradients at multiple points.
+                                     */
+    virtual void gradient_list (const vector<Point<dim> > &points,
+                               vector<Tensor<1,dim> >    &gradients,
+                               const unsigned int         component = 0) const;
+
+                                    /**
+                                     * Laplacian at a single point.
+                                     */
+    double laplacian(const Point<dim>   &p,
+                    const unsigned int  component = 0) const;
+
+                                    /**
+                                     * Laplacian at multiple points.
+                                     */
+    void laplacian_list(const vector<Point<dim> > &points,
+                  vector<double>            &values,
+                  const unsigned int         component = 0) const;
+};
+
+#endif
diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc
new file mode 100644 (file)
index 0000000..8dd51ed
--- /dev/null
@@ -0,0 +1,168 @@
+// $Id$
+// (c) Guido Kanschat, 1999
+
+#include <base/point.h>
+#include <base/function_lib.h>
+
+//TODO: Derivatives in 3d wrong
+
+template<int dim>
+double
+PillowFunction<dim>::value (const Point<dim>   &p,
+                           const unsigned int) const
+{
+  switch(dim)
+    {
+      case 1:
+           return 1.-p(0)*p(0);
+      case 2:
+           return (1.-p(0)*p(0))*(1.-p(1)*p(1));
+      case 3:
+           return (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2));
+      default:
+           Assert(false, ExcNotImplemented());
+    }
+  return 0.;
+}
+
+template<int dim>
+void
+PillowFunction<dim>::value_list (const vector<Point<dim> > &points,
+                                vector<double>            &values,
+                                const unsigned int) const
+{
+  Assert (values.size() == points.size(),
+         ExcVectorHasWrongSize(values.size(), points.size()));
+
+  for (unsigned int i=0;i<points.size();++i)
+    {
+      const Point<dim>& p = points[i];
+      switch(dim)
+       {
+         case 1:
+               values[i] = 1.-p(0)*p(0);
+               break;
+         case 2:
+               values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1));
+               break;
+         case 3:
+               values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2));
+               break;
+         default:
+               Assert(false, ExcNotImplemented());
+       }
+    }
+}
+
+template<int dim>
+double
+PillowFunction<dim>::laplacian (const Point<dim>   &p,
+                           const unsigned int) const
+{
+  switch(dim)
+    {
+      case 1:
+           return 2.;
+      case 2:
+           return 2.*((1.-p(0)*p(0))+(1.-p(1)*p(1)));
+      case 3:
+           return 2.*((1.-p(0)*p(0))*(1.-p(1)*p(1))
+                      +(1.-p(1)*p(1))*(1.-p(2)*p(2))
+                      +(1.-p(2)*p(2))*(1.-p(0)*p(0)));
+      default:
+           Assert(false, ExcNotImplemented());
+    }
+  return 0.;
+}
+
+template<int dim>
+void
+PillowFunction<dim>::laplacian_list (const vector<Point<dim> > &points,
+                                    vector<double>            &values,
+                                    const unsigned int) const
+{
+  Assert (values.size() == points.size(),
+         ExcVectorHasWrongSize(values.size(), points.size()));
+
+  for (unsigned int i=0;i<points.size();++i)
+    {
+      const Point<dim>& p = points[i];
+      switch(dim)
+       {
+         case 1:
+               values[i] = 2.;
+               break;
+         case 2:
+               values[i] = 2.*((1.-p(0)*p(0))+(1.-p(1)*p(1)));
+               break;
+         case 3:
+               values[i] = 2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))+(1.-p(2)*p(2)));
+               break;
+         default:
+               Assert(false, ExcNotImplemented());
+       }
+    }
+}
+
+template<int dim>
+Tensor<1,dim>
+PillowFunction<dim>::gradient (const Point<dim>   &p,
+                              const unsigned int) const
+{
+  Tensor<1,dim> result;
+  switch(dim)
+    {
+      case 1:
+           result[0] = 2.*p(0);
+           break;
+      case 2:
+           result[0] = 2.*p(0)*(1.-p(1)*p(1));
+           result[1] = 2.*p(1)*(1.-p(0)*p(0));
+           break;
+      case 3:
+           result[0] = 2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2));
+           result[1] = 2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2));
+           result[2] = 2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1));
+           break;
+      default:
+           Assert(false, ExcNotImplemented());
+    }
+  return result;
+}
+
+template<int dim>
+void
+PillowFunction<dim>::gradient_list (const vector<Point<dim> > &points,
+                                   vector<Tensor<1,dim> >    &gradients,
+                                   const unsigned int) const
+{
+  Assert (gradients.size() == points.size(),
+         ExcVectorHasWrongSize(gradients.size(), points.size()));
+
+  for (unsigned int i=0;i<points.size();++i)
+    {
+      const Point<dim>& p = points[i];
+      switch(dim)
+       {
+         case 1:
+               gradients[i][0] = 2.*p(0);
+               break;
+         case 2:
+               gradients[i][0] = 2.*p(0)*(1.-p(1)*p(1));
+               gradients[i][1] = 2.*p(1)*(1.-p(0)*p(0));
+               return;
+         case 3:
+               gradients[i][0] = 2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2));
+               gradients[i][1] = 2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2));
+               gradients[i][2] = 2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1));
+               break;
+         default:
+               Assert(false, ExcNotImplemented());
+       }
+    }
+}
+
+template PillowFunction<1>;
+template PillowFunction<2>;
+template PillowFunction<3>;
+

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.