]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Also implement the vector-valued version
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Dec 2006 20:39:01 +0000 (20:39 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Dec 2006 20:39:01 +0000 (20:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@14256 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 0d6cf80373267068d6f8811638638d06ba81b47c..7c1eab5405507a1d62b9fda68ea8aeaffa6a9833 100644 (file)
@@ -1076,11 +1076,16 @@ namespace Functions
   {
     public:
                                       /**
-                                       * Constructor. The arguments are
-                                       * described in the general description
-                                       * of the class.
-                                       */
-      Monomial (const Tensor<1,dim> &exponents);
+                                       * Constructor. The first argument is
+                                       * explained in the general description
+                                       * of the class. The second argument
+                                       * denotes the number of vector
+                                       * components this object shall
+                                       * represent. All vector components
+                                       * will have the same value.
+                                       */
+      Monomial (const Tensor<1,dim> &exponents,
+               const unsigned int n_components = 1);
     
                                       /**
                                        * Function value at one point.
@@ -1088,6 +1093,18 @@ namespace Functions
       virtual double value (const Point<dim>   &p,
                            const unsigned int  component = 0) const;
       
+                                      /**
+                                       * Return all components of a
+                                       * vector-valued function at a
+                                       * given point.
+                                       *
+                                       * <tt>values</tt> shall have the right
+                                       * size beforehand,
+                                       * i.e. #n_components.
+                                       */
+      virtual void vector_value (const Point<dim>   &p,
+                                Vector<double>     &values) const;
+
                                       /**
                                        * Function values at multiple points.
                                        */
index d09a83e25e8104948f24dc79ff6c7e8d1af7875c..7fd8503d401ed7a890dbe016f6d6febd0da8de46 100644 (file)
@@ -1508,8 +1508,10 @@ namespace Functions
   
   template <int dim>
   Monomial<dim>::
-  Monomial (const Tensor<1,dim> &exponents)
+  Monomial (const Tensor<1,dim> &exponents,
+           const unsigned int   n_components)
                  :
+                 Function<dim> (n_components),
                  exponents (exponents)
   {}
   
@@ -1520,7 +1522,8 @@ namespace Functions
   Monomial<dim>::value (const Point<dim>   &p,
                        const unsigned int  component) const
   {
-    Assert (component==0, ExcIndexRange(component,0,1)) ;
+    Assert (component<this->n_components,
+           ExcIndexRange(component, 0, this->n_components)) ;
 
     double prod = 1;
     for (unsigned int s=0; s<dim; ++s)
@@ -1528,6 +1531,20 @@ namespace Functions
     
     return prod;
   }
+
+
+
+  template <int dim>
+  void
+  Monomial<dim>::vector_value (const Point<dim>   &p,
+                              Vector<double>     &values) const
+  {
+    Assert (values.size() == this->n_components,
+           ExcDimensionMismatch (values.size(), this->n_components));
+
+    for (unsigned int i=0; i<values.size(); ++i)
+      values(i) = Monomial<dim>::value(p,i);
+  }
   
   
   

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.