Previously, it used a reference to an array as an output argument. Now, we can just
return a std::array<...,dim>.
/**
* Compute numbers in x, y and z direction. Given an index <tt>n</tt> in the
- * d-dimensional polynomial space, compute the indices i,j,k such that
+ * d-dimensional polynomial space, return the indices i,j,k such that
* <i>p<sub>n</sub>(x,y,z) =
* p<sub>i</sub>(x)p<sub>j</sub>(y)p<sub>k</sub>(z)</i>.
+ *
+ * In 1d and 2d, obviously only i and i,j are returned.
*/
- void compute_index (const unsigned int n,
- unsigned int (&index)[dim>0?dim:1]) const;
+ std::array<unsigned int,dim>
+ compute_index (const unsigned int n) const;
private:
/**
/* -------------- declaration of explicit specializations --- */
template <>
-void PolynomialSpace<1>::compute_index(const unsigned int n,
- unsigned int (&index)[1]) const;
+std::array<unsigned int,1> PolynomialSpace<1>::compute_index(const unsigned int n) const;
template <>
-void PolynomialSpace<2>::compute_index(const unsigned int n,
- unsigned int (&index)[2]) const;
+std::array<unsigned int,2> PolynomialSpace<2>::compute_index(const unsigned int n) const;
template <>
-void PolynomialSpace<3>::compute_index(const unsigned int n,
- unsigned int (&index)[3]) const;
+std::array<unsigned int,3> PolynomialSpace<3>::compute_index(const unsigned int n) const;
void
PolynomialSpace<dim>::output_indices(StreamType &out) const
{
- unsigned int ix[dim];
for (unsigned int i=0; i<n_pols; ++i)
{
- compute_index(i,ix);
+ const std::array<unsigned int,dim> ix = compute_index(i);
out << i << "\t";
for (unsigned int d=0; d<dim; ++d)
out << ix[d] << " ";
PolynomialSpace<dim>::compute_derivative (const unsigned int i,
const Point<dim> &p) const
{
- unsigned int indices[dim];
- compute_index (i, indices);
+ const std::array<unsigned int,dim> indices = compute_index (i);
double v [dim][order+1];
{
/**
* For the <tt>n</tt>th polynomial $p_n(x,y,z)=x^i y^j z^k$ this function
* gives the degrees i,j,k in the x,y,z directions.
+ *
+ * In 1d and 2d, obviously only i and i,j are returned.
*/
- void directional_degrees(unsigned int n,
- unsigned int (°rees)[dim]) const;
+ std::array<unsigned int,dim>
+ directional_degrees(unsigned int n) const;
private:
template <int dim>
-inline void
-PolynomialsP<dim>::directional_degrees(unsigned int n,
- unsigned int (°rees)[dim]) const
+inline
+std::array<unsigned int,dim>
+PolynomialsP<dim>::directional_degrees(unsigned int n) const
{
- this->compute_index(n,degrees);
+ return this->compute_index(n);
}
DEAL_II_NAMESPACE_CLOSE
template <>
-void
+std::array<unsigned int,1>
PolynomialSpace<1>::
-compute_index (const unsigned int i,
- unsigned int (&index)[1]) const
+compute_index (const unsigned int i) const
{
Assert(i<index_map.size(),
ExcIndexRange(i,0,index_map.size()));
- const unsigned int n=index_map[i];
- index[0] = n;
+ return {index_map[i]};
}
template <>
-void
+std::array<unsigned int,2>
PolynomialSpace<2>::
-compute_index (const unsigned int i,
- unsigned int (&index)[2]) const
+compute_index (const unsigned int i) const
{
Assert(i<index_map.size(),
ExcIndexRange(i,0,index_map.size()));
unsigned int k=0;
for (unsigned int iy=0; iy<n_1d; ++iy)
if (n < k+n_1d-iy)
- {
- index[0] = n-k;
- index[1] = iy;
- return;
- }
+ return {n-k, iy};
else
k+=n_1d-iy;
+
+ Assert (false, ExcInternalError());
+ return {numbers::invalid_unsigned_int, numbers::invalid_unsigned_int};
}
template <>
-void
+std::array<unsigned int,3>
PolynomialSpace<3>::
-compute_index (const unsigned int i,
- unsigned int (&index)[3]) const
+compute_index (const unsigned int i) const
{
Assert(i<index_map.size(),
ExcIndexRange(i,0,index_map.size()));
for (unsigned int iz=0; iz<n_1d; ++iz)
for (unsigned int iy=0; iy<n_1d-iz; ++iy)
if (n < k+n_1d-iy-iz)
- {
- index[0] = n-k;
- index[1] = iy;
- index[2] = iz;
- return;
- }
+ return {n-k, iy, iz};
else
k += n_1d-iy-iz;
+
+ Assert (false, ExcInternalError());
+ return {numbers::invalid_unsigned_int, numbers::invalid_unsigned_int};
}
PolynomialSpace<dim>::compute_value (const unsigned int i,
const Point<dim> &p) const
{
- unsigned int ix[dim];
- compute_index(i,ix);
+ const auto ix = compute_index(i);
// take the product of the
// polynomials in the various space
// directions
PolynomialSpace<dim>::compute_grad (const unsigned int i,
const Point<dim> &p) const
{
- unsigned int ix[dim];
- compute_index(i,ix);
+ const auto ix = compute_index(i);
Tensor<1,dim> result;
for (unsigned int d=0; d<dim; ++d)
PolynomialSpace<dim>::compute_grad_grad (const unsigned int i,
const Point<dim> &p) const
{
- unsigned int ix[dim];
- compute_index(i,ix);
+ const auto ix = compute_index(i);
Tensor<2,dim> result;
for (unsigned int d=0; d<dim; ++d)
support_on_face=true;
else
{
- unsigned int degrees[2];
- this->poly_space.directional_degrees(shape_index, degrees);
+ const std::array<unsigned int,2> degrees
+ = this->poly_space.directional_degrees(shape_index);
+
if ((face_index==0 && degrees[1]==0) ||
(face_index==3 && degrees[0]==0))
support_on_face=true;
support_on_face=true;
else
{
- unsigned int degrees[3];
- this->poly_space.directional_degrees(shape_index, degrees);
+ const std::array<unsigned int,3> degrees
+ = this->poly_space.directional_degrees(shape_index);
+
if ((face_index==0 && degrees[1]==0) ||
(face_index==2 && degrees[2]==0) ||
(face_index==5 && degrees[0]==0))