template <int dim>
class ScalarPolynomial : public ScalarPolynomialsBase<dim>
{
- static_assert(dim == 2 || dim == 3, "Dimension not supported!");
-
public:
/**
* Make the dimension available to the outside.
/**
* Integration rule for simplex entities.
*
- * Following number of quadrature points are currently supported:
+ * Following number of quadrature points are currently supported for 2D and
+ * 3D:
* - 2D: 1, 3, 7
* - 3D: 1, 4, 10
*
- * @ingroup simplex
+ * For 1D, the quadrature rule degenerates to a `QGauss<1>(n_points)`.
+ *
+ * @ingroup simplex
*/
template <int dim>
class PGauss : public QSimplex<dim>
unsigned int
compute_n_polynomials(const unsigned int dim, const unsigned int degree)
{
- if (dim == 2)
+ if (dim == 1)
+ {
+ if (degree == 1)
+ return 2;
+ if (degree == 2)
+ return 3;
+ }
+ else if (dim == 2)
{
if (degree == 1)
return 3;
ScalarPolynomial<dim>::compute_value(const unsigned int i,
const Point<dim> & p) const
{
- if (dim == 2)
+ if (dim == 1)
{
if (this->degree() == 1)
{
if (i == 0)
+ return 1.0 - p[0];
+ else if (i == 1)
return p[0];
+ }
+ else if (this->degree() == 2)
+ {
+ if (i == 0)
+ return 2.0 * p[0] * p[0] - 3.0 * p[0] + 1;
else if (i == 1)
- return p[1];
+ return 2.0 * p[0] * p[0] - p[0];
else if (i == 2)
+ return -4.0 * p[0] * p[0] + 4.0 * p[0];
+ }
+ }
+ else if (dim == 2)
+ {
+ if (this->degree() == 1)
+ {
+ if (i == 0)
return 1.0 - p[0] - p[1];
+ else if (i == 1)
+ return p[0];
+ else if (i == 2)
+ return p[1];
}
else if (this->degree() == 2)
{
- const double t1 = p[0];
- const double t2 = p[1];
- const double t3 = 1.0 - p[0] - p[1];
+ const double t1 = 1.0 - p[0] - p[1];
+ const double t2 = p[0];
+ const double t3 = p[1];
if (i == 0)
return t1 * (2.0 * t1 - 1.0);
{
Tensor<1, dim> grad;
- if (dim == 2)
+ if (dim == 1)
+ {
+ if (this->degree() == 1)
+ {
+ if (i == 0)
+ grad[0] = -1.0;
+ else if (i == 1)
+ grad[0] = 1.0;
+ }
+ else if (this->degree() == 2)
+ {
+ if (i == 0)
+ grad[0] = 4.0 * p[0] - 3.0;
+ else if (i == 1)
+ grad[0] = 4.0 * p[0] - 1.0;
+ else if (i == 2)
+ grad[0] = -8.0 * p[0] + 4.0;
+ }
+ else
+ {
+ Assert(false, ExcNotImplemented());
+ }
+ }
+ else if (dim == 2)
{
if (this->degree() == 1)
{
if (i == 0)
{
- grad[0] = +1.0;
- grad[1] = +0.0;
+ grad[0] = -1.0;
+ grad[1] = -1.0;
}
else if (i == 1)
{
- grad[0] = +0.0;
- grad[1] = +1.0;
+ grad[0] = +1.0;
+ grad[1] = +0.0;
}
else if (i == 2)
{
- grad[0] = -1.0;
- grad[1] = -1.0;
+ grad[0] = +0.0;
+ grad[1] = +1.0;
}
else
{
}
else if (this->degree() == 2)
{
- if (i == 2)
+ if (i == 0)
{
grad[0] = -3.0 + 4.0 * (p[0] + p[1]);
grad[1] = -3.0 + 4.0 * (p[0] + p[1]);
}
- else if (i == 0)
+ else if (i == 1)
{
grad[0] = 4.0 * p[0] - 1.0;
grad[1] = 0.0;
}
- else if (i == 1)
+ else if (i == 2)
{
grad[0] = 0.0;
grad[1] = 4.0 * p[1] - 1.0;
}
- else if (i == 5)
+ else if (i == 3)
{
grad[0] = 4.0 * (1.0 - 2.0 * p[0] - p[1]);
grad[1] = -4.0 * p[0];
}
- else if (i == 3)
+ else if (i == 4)
{
grad[0] = 4.0 * p[1];
grad[1] = 4.0 * p[0];
}
- else if (i == 4)
+ else if (i == 5)
{
grad[0] = -4.0 * p[1];
grad[1] = 4.0 * (1.0 - p[0] - 2.0 * p[1]);
return std::make_unique<ScalarPolynomial<dim>>(*this);
}
+ template class ScalarPolynomial<1>;
template class ScalarPolynomial<2>;
template class ScalarPolynomial<3>;
: QSimplex<dim>(Quadrature<dim>())
{
// fill quadrature points and quadrature weights
+ if (dim == 1)
+ {
+ const dealii::QGauss<dim> quad(n_points);
- if (dim == 2)
+ this->quadrature_points = quad.get_points();
+ this->weights = quad.get_weights();
+ }
+ else if (dim == 2)
{
if (n_points == 1)
{
} // namespace Simplex
+template class Simplex::PGauss<1>;
template class Simplex::PGauss<2>;
template class Simplex::PGauss<3>;
{
initlog();
+ {
+ deallog.push("1d-1");
+ test<1>(1);
+ deallog.pop();
+ }
+ {
+ deallog.push("1d-2");
+ test<1>(2);
+ deallog.pop();
+ }
{
deallog.push("2d-1");
test<2>(1);
-DEAL:2d-1::0.211325 0.211325 0.577350
-DEAL:2d-1::1.00000 0.00000 0.00000 1.00000 -1.00000 -1.00000
-DEAL:2d-1::0.788675 0.211325 2.77556e-17
-DEAL:2d-1::1.00000 0.00000 0.00000 1.00000 -1.00000 -1.00000
-DEAL:2d-1::0.211325 0.788675 0.00000
-DEAL:2d-1::1.00000 0.00000 0.00000 1.00000 -1.00000 -1.00000
-DEAL:2d-2::-0.0872983 -0.0872983 0.425403 0.0508067 0.349193 0.349193
-DEAL:2d-2::-0.549193 0.00000 0.00000 -0.549193 -2.09839 -2.09839 0.450807 0.450807 -0.450807 2.64758 2.64758 -0.450807
-DEAL:2d-2::0.00000 -0.0872983 -0.0872983 0.225403 0.174597 0.774597
-DEAL:2d-2::1.00000 0.00000 0.00000 -0.549193 -0.549193 -0.549193 0.450807 2.00000 -0.450807 1.09839 -0.450807 -2.00000
-DEAL:2d-2::0.687298 -0.0872983 1.38778e-17 0.400000 -6.25620e-18 -4.92550e-17
-DEAL:2d-2::2.54919 0.00000 0.00000 -0.549193 1.00000 1.00000 0.450807 3.54919 -0.450807 -0.450807 -3.54919 -3.54919
-DEAL:2d-2::-0.0872983 0.00000 -0.0872983 0.225403 0.774597 0.174597
-DEAL:2d-2::-0.549193 0.00000 0.00000 1.00000 -0.549193 -0.549193 2.00000 0.450807 -2.00000 -0.450807 1.09839 -0.450807
-DEAL:2d-2::0.00000 0.00000 0.00000 1.00000 0.00000 0.00000
-DEAL:2d-2::1.00000 0.00000 0.00000 1.00000 1.00000 1.00000 2.00000 2.00000 -2.00000 -2.00000 -2.00000 -2.00000
-DEAL:2d-2::-0.0872983 0.687298 0.00000 0.400000 0.00000 0.00000
-DEAL:2d-2::-0.549193 0.00000 0.00000 2.54919 1.00000 1.00000 3.54919 0.450807 -3.54919 -3.54919 -0.450807 -0.450807
+DEAL:1d-1::0.788675 0.211325
+DEAL:1d-1::-1.00000 1.00000
+DEAL:1d-1::0.211325 0.788675
+DEAL:1d-1::-1.00000 1.00000
+DEAL:1d-2::0.687298 -0.0872983 0.400000
+DEAL:1d-2::-2.54919 -0.549193 3.09839
+DEAL:1d-2::0.00000 0.00000 1.00000
+DEAL:1d-2::-1.00000 1.00000 0.00000
+DEAL:1d-2::-0.0872983 0.687298 0.400000
+DEAL:1d-2::0.549193 2.54919 -3.09839
+DEAL:2d-1::0.577350 0.211325 0.211325
+DEAL:2d-1::-1.00000 -1.00000 1.00000 0.00000 0.00000 1.00000
+DEAL:2d-1::2.77556e-17 0.788675 0.211325
+DEAL:2d-1::-1.00000 -1.00000 1.00000 0.00000 0.00000 1.00000
+DEAL:2d-1::0.00000 0.211325 0.788675
+DEAL:2d-1::-1.00000 -1.00000 1.00000 0.00000 0.00000 1.00000
+DEAL:2d-2::0.425403 -0.0872983 -0.0872983 0.349193 0.0508067 0.349193
+DEAL:2d-2::-2.09839 -2.09839 -0.549193 0.00000 0.00000 -0.549193 2.64758 -0.450807 0.450807 0.450807 -0.450807 2.64758
+DEAL:2d-2::-0.0872983 0.00000 -0.0872983 0.774597 0.225403 0.174597
+DEAL:2d-2::-0.549193 -0.549193 1.00000 0.00000 0.00000 -0.549193 -0.450807 -2.00000 0.450807 2.00000 -0.450807 1.09839
+DEAL:2d-2::1.38778e-17 0.687298 -0.0872983 -4.92550e-17 0.400000 -6.25620e-18
+DEAL:2d-2::1.00000 1.00000 2.54919 0.00000 0.00000 -0.549193 -3.54919 -3.54919 0.450807 3.54919 -0.450807 -0.450807
+DEAL:2d-2::-0.0872983 -0.0872983 0.00000 0.174597 0.225403 0.774597
+DEAL:2d-2::-0.549193 -0.549193 -0.549193 0.00000 0.00000 1.00000 1.09839 -0.450807 2.00000 0.450807 -2.00000 -0.450807
+DEAL:2d-2::0.00000 0.00000 0.00000 0.00000 1.00000 0.00000
+DEAL:2d-2::1.00000 1.00000 1.00000 0.00000 0.00000 1.00000 -2.00000 -2.00000 2.00000 2.00000 -2.00000 -2.00000
+DEAL:2d-2::0.00000 -0.0872983 0.687298 0.00000 0.400000 0.00000
+DEAL:2d-2::1.00000 1.00000 -0.549193 0.00000 0.00000 2.54919 -0.450807 -0.450807 3.54919 0.450807 -3.54919 -3.54919
DEAL:3d-1::0.366025 0.211325 0.211325 0.211325
DEAL:3d-1::-1.00000 -1.00000 -1.00000 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000
DEAL:3d-2::0.214315 -0.0872983 -0.0872983 -0.0872983 0.298387 0.0508067 0.298387 0.298387 0.0508067 0.0508067
{
initlog();
+ {
+ deallog.push("1d-1");
+ test<1>(1 /*n_points*/);
+ deallog.pop();
+ }
+ {
+ deallog.push("1d-2");
+ test<1>(2);
+ deallog.pop();
+ }
+ {
+ deallog.push("1d-3");
+ test<1>(2);
+ deallog.pop();
+ }
{
deallog.push("2d-1");
- test<2>(1 /*n_points*/);
+ test<2>(1);
deallog.pop();
}
{
+DEAL:1d-1::0.500000 1.00000
+DEAL:1d-2::0.211325 0.500000
+DEAL:1d-2::0.788675 0.500000
+DEAL:1d-3::0.211325 0.500000
+DEAL:1d-3::0.788675 0.500000
DEAL:2d-1::0.333333 0.333333 1.00000
DEAL:2d-3::0.666667 0.166667 0.166667
DEAL:2d-3::0.166667 0.666667 0.166667