From: Guido Kanschat Date: Sun, 13 Sep 2009 17:47:26 +0000 (+0000) Subject: extend cosine to vector valued X-Git-Tag: v8.0.0~7122 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51c3b8f3ade0a9c6b7c8b7a15c54cc356d798c26;p=dealii.git extend cosine to vector valued git-svn-id: https://svn.dealii.org/trunk@19451 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 61a404d47a..a263ccb28a 100644 --- a/deal.II/base/include/base/function_lib.h +++ b/deal.II/base/include/base/function_lib.h @@ -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 &p, const unsigned int component = 0) const; - /** - * Values at multiple points. - */ virtual void value_list (const std::vector > &points, std::vector &values, const unsigned int component = 0) const; - /** - * Gradient at a single point. - */ + virtual void vector_value_list (const std::vector >& points, + std::vector >& values) const; + virtual Tensor<1,dim> gradient (const Point &p, const unsigned int component = 0) const; - /** - * Gradients at multiple points. - */ virtual void gradient_list (const std::vector > &points, std::vector > &gradients, const unsigned int component = 0) const; - /** - * Laplacian at a single point. - */ virtual double laplacian (const Point &p, const unsigned int component = 0) const; - /** - * Laplacian at multiple points. - */ virtual void laplacian_list (const std::vector > &points, std::vector &values, const unsigned int component = 0) const; diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc index b69879023c..f26398e5a4 100644 --- a/deal.II/base/source/function_lib.cc +++ b/deal.II/base/source/function_lib.cc @@ -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 + CosineFunction::CosineFunction (const unsigned int n_components) + : + Function (n_components) +{} + + + template double CosineFunction::value (const Point &p, @@ -441,26 +449,29 @@ namespace Functions Assert (values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i + void + CosineFunction::vector_value_list ( + const std::vector > &points, + std::vector > &values) const + { + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& 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 double CosineFunction::laplacian (const Point &p, @@ -490,23 +501,7 @@ namespace Functions ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0;i& 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 diff --git a/deal.II/deal.II/source/dofs/block_info.cc b/deal.II/deal.II/source/dofs/block_info.cc index f6b27d9798..212de36fae 100644 --- a/deal.II/deal.II/source/dofs/block_info.cc +++ b/deal.II/deal.II/source/dofs/block_info.cc @@ -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