16 #include <deal.II/base/polynomials_piecewise.h> 19 DEAL_II_NAMESPACE_OPEN
26 template <
typename number>
28 const unsigned int n_intervals,
29 const unsigned int interval,
30 const bool spans_next_interval)
32 polynomial (coefficients_on_interval),
33 n_intervals (n_intervals),
35 spans_two_intervals (spans_next_interval)
43 template <
typename number>
46 std::vector<number> &values)
const 50 value(x,values.size()-1,&values[0]);
55 template <
typename number>
58 const unsigned int n_derivatives,
63 double derivative_change_sign = 1.;
66 const number step = 1./n_intervals;
68 if (spans_two_intervals)
70 const double offset = step * interval;
71 if (x<offset || x>offset+step+step)
73 for (
unsigned int k=0; k<=n_derivatives; ++k)
77 else if (x<offset+step)
81 derivative_change_sign = -1.;
82 y = offset+step+step-x;
87 const double offset = step * interval;
88 if (x<offset || x>offset+step)
90 for (
unsigned int k=0; k<=n_derivatives; ++k)
100 if ((std::abs(y)<1e-14 && (interval > 0 ||
101 derivative_change_sign == -1.))
103 (std::abs(y-step)<1e-14 &&
104 (interval < n_intervals-1 || derivative_change_sign == -1.)))
106 values[0] = value(x);
107 for (
unsigned int d=1; d<=n_derivatives; ++d)
113 polynomial.value(y, n_derivatives, values);
116 for (
unsigned int j=1; j<=n_derivatives; j+=2)
117 values[j] *= derivative_change_sign;
122 std::vector<PiecewisePolynomial<double> >
124 const unsigned int base_degree)
126 std::vector<Polynomial<double> > p_base =
127 LagrangeEquidistant::generate_complete_basis(base_degree);
128 for (
unsigned int i=0; i<p_base.size(); ++i)
129 p_base[i].scale(n_subdivisions);
131 std::vector<PiecewisePolynomial<double> > p;
132 p.reserve (n_subdivisions * base_degree + 1);
136 for (
unsigned int s=0; s<n_subdivisions; ++s)
137 for (
unsigned int i=0; i<base_degree; ++i)
140 i==(base_degree-1) &&
141 s<n_subdivisions-1));
151 template class PiecewisePolynomial<float>;
152 template class PiecewisePolynomial<double>;
153 template class PiecewisePolynomial<long double>;
156 DEAL_II_NAMESPACE_CLOSE
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
std::vector< PiecewisePolynomial< double > > generate_complete_Lagrange_basis_on_subdivisions(const unsigned int n_subdivisions, const unsigned int base_degree)
PiecewisePolynomial(const Polynomial< number > &coefficients_on_interval, const unsigned int n_intervals, const unsigned int interval, const bool spans_next_interval)
static ::ExceptionBase & ExcZero()