/**
* Constructor which should be provided with @p center defining the origin
* of the coordinate system.
+ *
+ * Note that components of this function are treated as entirely separate
+ * quantities -- not as the components of a vector that will be
+ * re-interpreted in a different coordinate system.
*/
- Spherical(const Point<dim> ¢er = Point<dim>());
+ Spherical(const Point<dim> ¢er = Point<dim>(),
+ const unsigned int n_components=1);
/**
* Return the value of the function at the given point.
* Return the value at point @p sp. Here, @p sp is provided in spherical
* coordinates.
*/
- virtual double svalue(const std_cxx11::array<double, dim> &sp) const;
+ virtual double svalue(const std_cxx11::array<double, dim> &sp,
+ const unsigned int component) const;
/**
* Return the gradient in spherical coordinates.
* The returned object should contain derivatives in the following order:
* $\{ f_{,r},\, f_{,\theta},\, f_{,\phi}\}$.
*/
- virtual std_cxx11::array<double, dim> sgradient(const std_cxx11::array<double, dim> &sp) const;
+ virtual std_cxx11::array<double, dim> sgradient(const std_cxx11::array<double, dim> &sp,
+ const unsigned int component) const;
/**
* Return the Hessian in spherical coordinates.
* The returned object should contain derivatives in the following order:
* $\{ f_{,rr},\, f_{,\theta\theta},\, f_{,\phi\phi},\, f_{,r\theta},\, f_{,r\phi},\, f_{,\theta\phi}\}$.
*/
- virtual std_cxx11::array<double, 6> shessian (const std_cxx11::array<double, dim> &sp) const;
+ virtual std_cxx11::array<double, 6> shessian (const std_cxx11::array<double, dim> &sp,
+ const unsigned int component) const;
/**
* A vector from the origin to the center of spherical coordinate system.
template <int dim>
- Spherical<dim>::Spherical(const Point<dim> &p)
+ Spherical<dim>::Spherical(const Point<dim> &p,
+ const unsigned int n_components)
:
- Function<dim>(1),
+ Function<dim>(n_components),
coordinate_system_offset(p)
{
AssertThrow(dim==3,
template <int dim>
double
Spherical<dim>::value (const Point<dim> &p_,
- const unsigned int) const
+ const unsigned int component) const
{
const Point<dim> p = p_ - coordinate_system_offset;
const std_cxx11::array<double, dim> sp = GeometricUtilities::Coordinates::to_spherical(p);
- return svalue(sp);
+ return svalue(sp, component);
}
template <int dim>
Tensor<1,dim>
Spherical<dim>::gradient (const Point<dim> &p_,
- const unsigned int) const
+ const unsigned int component) const
{
const Point<dim> p = p_ - coordinate_system_offset;
const std_cxx11::array<double, dim> sp = GeometricUtilities::Coordinates::to_spherical(p);
- const std_cxx11::array<double, dim> sg = sgradient(sp);
+ const std_cxx11::array<double, dim> sg = sgradient(sp, component);
// somewhat backwards, but we need cos/sin's for unit vectors
const double cos_theta = std::cos(sp[1]);
template <int dim>
SymmetricTensor<2,dim>
Spherical<dim>::hessian (const Point<dim> &p_,
- const unsigned int /* component */) const
+ const unsigned int component) const
{
const Point<dim> p = p_ - coordinate_system_offset;
const std_cxx11::array<double, dim> sp = GeometricUtilities::Coordinates::to_spherical(p);
- const std_cxx11::array<double, dim> sg = sgradient(sp);
- const std_cxx11::array<double, 6> sh = shessian(sp);
+ const std_cxx11::array<double, dim> sg = sgradient(sp, component);
+ const std_cxx11::array<double, 6> sh = shessian(sp, component);
// somewhat backwards, but we need cos/sin's for unit vectors
const double cos_theta = std::cos(sp[1]);
template <int dim>
double
- Spherical<dim>::svalue(const std_cxx11::array<double, dim> & /* sp */) const
+ Spherical<dim>::svalue(const std_cxx11::array<double, dim> & /* sp */,
+ const unsigned int /*component*/) const
{
AssertThrow(false,
ExcNotImplemented());
template <int dim>
std_cxx11::array<double, dim>
- Spherical<dim>::sgradient(const std_cxx11::array<double, dim> & /* sp */) const
+ Spherical<dim>::sgradient(const std_cxx11::array<double, dim> & /* sp */,
+ const unsigned int /*component*/) const
{
AssertThrow(false,
ExcNotImplemented());
template <int dim>
std_cxx11::array<double, 6>
- Spherical<dim>::shessian (const std_cxx11::array<double, dim> & /* sp */) const
+ Spherical<dim>::shessian (const std_cxx11::array<double, dim> & /* sp */,
+ const unsigned int /*component*/) const
{
AssertThrow(false,
ExcNotImplemented());
{}
private:
- virtual double svalue(const std_cxx11::array<double, dim> &sp) const
+ virtual double svalue(const std_cxx11::array<double, dim> &sp,
+ const unsigned int) const
{
return std::exp(-Z*sp[0]);
}
- virtual std_cxx11::array<double, dim> sgradient(const std_cxx11::array<double, dim> &sp) const
+ virtual std_cxx11::array<double, dim> sgradient(const std_cxx11::array<double, dim> &sp,
+ const unsigned int) const
{
std_cxx11::array<double, dim> res;
res[0] = -Z*std::exp(-Z*sp[0]);
return res;
}
- virtual std_cxx11::array<double, 6> shessian (const std_cxx11::array<double, dim> &sp) const
+ virtual std_cxx11::array<double, 6> shessian (const std_cxx11::array<double, dim> &sp,
+ const unsigned int) const
{
std_cxx11::array<double, 6> res;
res[0] = Z*Z*std::exp(-Z*sp[0]);
{}
private:
- virtual double svalue(const std_cxx11::array<double, dim> &sp) const
+ virtual double svalue(const std_cxx11::array<double, dim> &sp,
+ const unsigned int) const
{
return sp[0]*sp[0]*std::cos(sp[1])*std::sin(sp[2]);
}
- virtual std_cxx11::array<double, dim> sgradient(const std_cxx11::array<double, dim> &sp) const
+ virtual std_cxx11::array<double, dim> sgradient(const std_cxx11::array<double, dim> &sp,
+ const unsigned int) const
{
std_cxx11::array<double, dim> res;
const double r = sp[0];
return res;
}
- virtual std_cxx11::array<double, 6> shessian (const std_cxx11::array<double, dim> &sp) const
+ virtual std_cxx11::array<double, 6> shessian (const std_cxx11::array<double, dim> &sp,
+ const unsigned int) const
{
std_cxx11::array<double, 6> res;
const double r = sp[0];