]> https://gitweb.dealii.org/ - dealii.git/commitdiff
extend cosine to vector valued
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 13 Sep 2009 17:47:26 +0000 (17:47 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 13 Sep 2009 17:47:26 +0000 (17:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@19451 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 61a404d47a6e9aa9c6349f80179282a689154360..a263ccb28a6d1df15667a0e51c4d23d93de80641 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -219,40 +219,34 @@ namespace Functions
   {
     public:
                                       /**
-                                       * The value at a single point.
+                                       * Constructor which allows to
+                                       * optionally generate a vector
+                                       * valued cosine function with
+                                       * the same value in each
+                                       * component.
                                        */
+      CosineFunction (const unsigned int n_components = 1);
+      
       virtual double value (const Point<dim>   &p,
                            const unsigned int  component = 0) const;
       
-                                      /**
-                                       * Values at multiple points.
-                                       */
       virtual void value_list (const std::vector<Point<dim> > &points,
                               std::vector<double>            &values,
                               const unsigned int              component = 0) const;
       
-                                      /**
-                                       * Gradient at a single point.
-                                       */
+      virtual void vector_value_list (const std::vector<Point<dim> >& points,
+                                     std::vector<Vector<double> >& values) const;
+      
       virtual Tensor<1,dim> gradient (const Point<dim>   &p,
                                      const unsigned int  component = 0) const;
       
-                                      /**
-                                       * Gradients at multiple points.
-                                       */
       virtual void gradient_list (const std::vector<Point<dim> > &points,
                                  std::vector<Tensor<1,dim> >    &gradients,
                                  const unsigned int              component = 0) const;
       
-                                      /**
-                                       * Laplacian at a single point.
-                                       */
       virtual double laplacian (const Point<dim>   &p,
                                const unsigned int  component = 0) const;
       
-                                      /**
-                                       * Laplacian at multiple points.
-                                       */
       virtual void laplacian_list (const std::vector<Point<dim> > &points,
                                   std::vector<double>            &values,
                                   const unsigned int              component = 0) const;
index b69879023cd87d1f8095e990d3817019b88fbd70..f26398e5a4897bdac76060360a6d63990eab927c 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -412,7 +412,15 @@ namespace Functions
   }
   
 //////////////////////////////////////////////////////////////////////
-  
+
+  template <int dim>
+  CosineFunction<dim>::CosineFunction (const unsigned int n_components)
+                 :
+               Function<dim> (n_components)
+{}
+
+
+
   template<int dim>
   double
   CosineFunction<dim>::value (const Point<dim>   &p,
@@ -441,26 +449,29 @@ namespace Functions
     Assert (values.size() == points.size(),
            ExcDimensionMismatch(values.size(), points.size()));
     
+    for (unsigned int i=0;i<points.size();++i)
+      values[i] = value(points[i]);
+  }
+  
+  
+  template<int dim>
+  void
+  CosineFunction<dim>::vector_value_list (
+    const std::vector<Point<dim> > &points,
+    std::vector<Vector<double> >   &values) 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] = std::cos(M_PI_2*p(0));
-                 break;
-           case 2:
-                 values[i] = std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1));
-                 break;
-           case 3:
-                 values[i] = std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2));
-                 break;
-           default:
-                 Assert(false, ExcNotImplemented());
-         }
+       const double v = value(points[i]);
+       for (unsigned int k=0;k<values[i].size();++k)
+         values[i](k) = v;
       }
   }
   
+  
   template<int dim>
   double
   CosineFunction<dim>::laplacian (const Point<dim>   &p,
@@ -490,23 +501,7 @@ namespace Functions
            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] = -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0));
-                 break;
-           case 2:
-                 values[i] = -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1));
-                 break;
-           case 3:
-                 values[i] = -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2));
-                 break;
-           default:
-                 Assert(false, ExcNotImplemented());
-         }
-      }
+      values[i] = laplacian(points[i]);
   }
   
   template<int dim>
index f6b27d979883fa6858d3572ad9d4529d2a473f35..212de36faee4f253bcf4134f17acfcdd8af2a76b 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer

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.