From: bangerth Date: Fri, 15 Dec 2006 20:39:01 +0000 (+0000) Subject: Also implement the vector-valued version X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c6a08f200b92800bb0bcdf9aa9b602c3c6f327f;p=dealii-svn.git Also implement the vector-valued version git-svn-id: https://svn.dealii.org/trunk@14256 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/function_lib.h b/deal.II/base/include/base/function_lib.h index 0d6cf80373..7c1eab5405 100644 --- a/deal.II/base/include/base/function_lib.h +++ b/deal.II/base/include/base/function_lib.h @@ -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 &p, const unsigned int component = 0) const; + /** + * Return all components of a + * vector-valued function at a + * given point. + * + * values shall have the right + * size beforehand, + * i.e. #n_components. + */ + virtual void vector_value (const Point &p, + Vector &values) const; + /** * Function values at multiple points. */ diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc index d09a83e25e..7fd8503d40 100644 --- a/deal.II/base/source/function_lib.cc +++ b/deal.II/base/source/function_lib.cc @@ -1508,8 +1508,10 @@ namespace Functions template Monomial:: - Monomial (const Tensor<1,dim> &exponents) + Monomial (const Tensor<1,dim> &exponents, + const unsigned int n_components) : + Function (n_components), exponents (exponents) {} @@ -1520,7 +1522,8 @@ namespace Functions Monomial::value (const Point &p, const unsigned int component) const { - Assert (component==0, ExcIndexRange(component,0,1)) ; + Assert (componentn_components, + ExcIndexRange(component, 0, this->n_components)) ; double prod = 1; for (unsigned int s=0; s + void + Monomial::vector_value (const Point &p, + Vector &values) const + { + Assert (values.size() == this->n_components, + ExcDimensionMismatch (values.size(), this->n_components)); + + for (unsigned int i=0; i::value(p,i); + }