// $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
{
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;
// $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
}
//////////////////////////////////////////////////////////////////////
-
+
+ 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,
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,
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>
// $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