]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Exponential function
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 9 Jun 2000 20:49:36 +0000 (20:49 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 9 Jun 2000 20:49:36 +0000 (20:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@2997 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/function_lib.h
deal.II/base/source/function_lib.cc

index 45b06be82d31fc1287a5e442d9c67fdfaa7f0501..7c6b527f024c9232b5d7323ac5b244597183fc17 100644 (file)
@@ -127,6 +127,56 @@ class CosineFunction : public Function<dim>
 
 
 
+/**
+ * Product of exponential functions in each coordinate direction.
+ * @author Guido Kanschat, 1999
+ */
+template<int dim>
+class ExpFunction : public 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;
+};
+
+
+
 /**
  * Singularity on the L-shaped domain in 2D.
  * @author Guido Kanschat, 1999
index a7319a9e522b8ffdaa8b4de95db7c7c8b6582491..14f8f594eec2be1b4dcbfc34ad9330f7dd6ecc56 100644 (file)
@@ -333,6 +333,162 @@ CosineFunction<dim>::gradient_list (const vector<Point<dim> > &points,
 
 //////////////////////////////////////////////////////////////////////
 
+template<int dim>
+double
+ExpFunction<dim>::value (const Point<dim>   &p,
+                           const unsigned int) const
+{
+  switch(dim)
+    {
+      case 1:
+           return exp(p(0));
+      case 2:
+           return exp(p(0)) * exp(p(1));
+      case 3:
+           return exp(p(0)) * exp(p(1)) * exp(p(2));
+      default:
+           Assert(false, ExcNotImplemented());
+    }
+  return 0.;
+}
+
+template<int dim>
+void
+ExpFunction<dim>::value_list (const vector<Point<dim> > &points,
+                                vector<double>            &values,
+                                const unsigned int) const
+{
+  Assert (values.size() == points.size(),
+         ExcDimensionMismatch(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] = exp(p(0));
+               break;
+         case 2:
+               values[i] = exp(p(0)) * exp(p(1));
+               break;
+         case 3:
+               values[i] = exp(p(0)) * exp(p(1)) * exp(p(2));
+               break;
+         default:
+               Assert(false, ExcNotImplemented());
+       }
+    }
+}
+
+template<int dim>
+double
+ExpFunction<dim>::laplacian (const Point<dim>   &p,
+                           const unsigned int) const
+{
+  switch(dim)
+    {
+      case 1:
+           return exp(p(0));
+      case 2:
+           return 2 * exp(p(0)) * exp(p(1));
+      case 3:
+           return 3 * exp(p(0)) * exp(p(1)) * exp(p(2));
+      default:
+           Assert(false, ExcNotImplemented());
+    }
+  return 0.;
+}
+
+template<int dim>
+void
+ExpFunction<dim>::laplacian_list (const vector<Point<dim> > &points,
+                                    vector<double>            &values,
+                                    const unsigned int) const
+{
+  Assert (values.size() == points.size(),
+         ExcDimensionMismatch(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] = exp(p(0));
+               break;
+         case 2:
+               values[i] = 2 * exp(p(0)) * exp(p(1));
+               break;
+         case 3:
+               values[i] = 3 * exp(p(0)) * exp(p(1)) * exp(p(2));
+               break;
+         default:
+               Assert(false, ExcNotImplemented());
+       }
+    }
+}
+
+template<int dim>
+Tensor<1,dim>
+ExpFunction<dim>::gradient (const Point<dim>   &p,
+                              const unsigned int) const
+{
+  Tensor<1,dim> result;
+  switch(dim)
+    {
+      case 1:
+           result[0] = exp(p(0));
+           break;
+      case 2:
+           result[0] = exp(p(0)) * exp(p(1));
+           result[1] = exp(p(0)) * exp(p(1));
+           break;
+      case 3:
+           result[0] = exp(p(0)) * exp(p(1)) * exp(p(2));
+           result[1] = exp(p(0)) * exp(p(1)) * exp(p(2));
+           result[2] = exp(p(0)) * exp(p(1)) * exp(p(2));
+           break;
+      default:
+           Assert(false, ExcNotImplemented());
+    }
+  return result;
+}
+
+template<int dim>
+void
+ExpFunction<dim>::gradient_list (const vector<Point<dim> > &points,
+                                   vector<Tensor<1,dim> >    &gradients,
+                                   const unsigned int) const
+{
+  Assert (gradients.size() == points.size(),
+         ExcDimensionMismatch(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] = exp(p(0));
+               break;
+         case 2:
+               gradients[i][0] = exp(p(0)) * exp(p(1));
+               gradients[i][1] = exp(p(0)) * exp(p(1));
+               break;
+         case 3:
+               gradients[i][0] = exp(p(0)) * exp(p(1)) * exp(p(2));
+               gradients[i][1] = exp(p(0)) * exp(p(1)) * exp(p(2));
+               gradients[i][2] = exp(p(0)) * exp(p(1)) * exp(p(2));
+               break;
+         default:
+               Assert(false, ExcNotImplemented());
+       }
+    }
+}
+
+//////////////////////////////////////////////////////////////////////
+
 
 double
 LSingularityFunction::value (const Point<2>   &p,
@@ -520,3 +676,6 @@ template PillowFunction<3>;
 template CosineFunction<1>;
 template CosineFunction<2>;
 template CosineFunction<3>;
+template ExpFunction<1>;
+template ExpFunction<2>;
+template ExpFunction<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.