#include <deal.II/base/array_view.h>
#include <deal.II/base/geometry_info.h>
+#include <deal.II/base/tensor.h>
DEAL_II_NAMESPACE_OPEN
*/
Type(const CellKinds kind);
+ /**
+ * Return the dimension of the reference cell represented by the current
+ * object.
+ */
+ unsigned int
+ get_dimension() const;
+
+ /**
+ * Compute the value of the $i$-th linear shape function at location $\xi$
+ * for the current reference-cell type.
+ */
+ template <int dim>
+ double
+ d_linear_shape_function(const Point<dim> &xi, const unsigned int i) const;
+
+ /**
+ * Compute the gradient of the $i$-th linear shape function at location
+ * $\xi$ for the current reference-cell type.
+ */
+ template <int dim>
+ Tensor<1, dim>
+ d_linear_shape_function_gradient(const Point<dim> & xi,
+ const unsigned int i) const;
+
+ /*
+ * Return $i$-th unit tangential vector of a face of the reference cell.
+ * The vectors are arranged such that the
+ * cross product between the two vectors returns the unit normal vector.
+ *
+ * @pre $i$ must be between zero and `dim-1`.
+ */
+ template <int dim>
+ Tensor<1, dim>
+ unit_tangential_vectors(const unsigned int face_no,
+ const unsigned int i) const;
+
+ /**
+ * Determine the orientation of the current entity described by its
+ * vertices @p var_1 relative to an entity described by @p var_0.
+ */
+ template <typename T, std::size_t N>
+ unsigned char
+ compute_orientation(const std::array<T, N> &vertices_0,
+ const std::array<T, N> &vertices_1) const;
+
+ /**
+ * Inverse function of compute_orientation().
+ */
+ template <typename T, std::size_t N>
+ std::array<T, N>
+ permute_according_orientation(const std::array<T, N> &vertices,
+ const unsigned int orientation) const;
+
+ /**
+ * Return a text representation of the reference cell represented by the
+ * current object.
+ */
+ std::string
+ to_string() const;
+
/**
* Conversion operator to an integer.
*/
- /**
- * Return the dimension of the given reference-cell type @p type.
- */
inline unsigned int
- get_dimension(const Type &type)
+ Type::get_dimension() const
{
- switch (type)
+ switch (kind)
{
case Type::Vertex:
return 0;
}
}
+
+
/**
* Convert the given reference cell type to a string.
*/
inline std::string
- to_string(const Type &type)
+ Type::to_string() const
{
- switch (type)
+ switch (kind)
{
case Type::Vertex:
return "Vertex";
}
- /**
- * Compute the value of the $i$-th linear shape function at location $\xi$ for
- * a given reference-cell type.
- */
+
template <int dim>
inline double
- d_linear_shape_function(const Type & reference_cell,
- const Point<dim> & xi,
- const unsigned int i)
+ Type::d_linear_shape_function(const Point<dim> & xi,
+ const unsigned int i) const
{
- if (reference_cell == get_hypercube(dim))
+ AssertDimension(dim, get_dimension());
+ if (*this == get_hypercube(dim))
return GeometryInfo<dim>::d_linear_shape_function(xi, i);
- if (reference_cell ==
- Type::Tri) // see also Simplex::ScalarPolynomial::compute_value
+ if (*this == Type::Tri) // see also Simplex::ScalarPolynomial::compute_value
{
switch (i)
{
}
}
- if (reference_cell ==
- Type::Tet) // see also Simplex::ScalarPolynomial::compute_value
+ if (*this == Type::Tet) // see also Simplex::ScalarPolynomial::compute_value
{
switch (i)
{
}
}
- if (reference_cell ==
+ if (*this ==
Type::Wedge) // see also Simplex::ScalarWedgePolynomial::compute_value
{
- return d_linear_shape_function<2>(Type::Tri,
- Point<2>(xi[std::min(0, dim - 1)],
- xi[std::min(1, dim - 1)]),
- i % 3) *
- d_linear_shape_function<1>(Type::Line,
- Point<1>(xi[std::min(2, dim - 1)]),
- i / 3);
+ return Type(Type::Tri).d_linear_shape_function<2>(
+ Point<2>(xi[std::min(0, dim - 1)], xi[std::min(1, dim - 1)]),
+ i % 3) *
+ Type(Type::Line)
+ .d_linear_shape_function<1>(Point<1>(xi[std::min(2, dim - 1)]),
+ i / 3);
}
- if (reference_cell ==
+ if (*this ==
Type::Pyramid) // see also
// Simplex::ScalarPyramidPolynomial::compute_value
{
return 0.0;
}
- /**
- * Compute the gradient of the $i$-th linear shape function at location $\xi$
- * for a given reference-cell type.
- */
+
+
template <int dim>
inline Tensor<1, dim>
- d_linear_shape_function_gradient(const Type & reference_cell,
- const Point<dim> & xi,
- const unsigned int i)
+ Type::d_linear_shape_function_gradient(const Point<dim> & xi,
+ const unsigned int i) const
{
- if (reference_cell == get_hypercube(dim))
+ AssertDimension(dim, get_dimension());
+ if (*this == get_hypercube(dim))
return GeometryInfo<dim>::d_linear_shape_function_gradient(xi, i);
- if (reference_cell ==
- Type::Tri) // see also Simplex::ScalarPolynomial::compute_grad
+ if (*this == Type::Tri) // see also Simplex::ScalarPolynomial::compute_grad
{
switch (i)
{
return Point<dim>(+0.0, +0.0, +0.0);
}
- /**
- * Return i-th unit tangential vector of a face of the reference cell.
- * The vectors are arranged such that the
- * cross product between the two vectors returns the unit normal vector.
- */
+
template <int dim>
inline Tensor<1, dim>
- unit_tangential_vectors(const Type & reference_cell,
- const unsigned int face_no,
- const unsigned int i)
+ Type::unit_tangential_vectors(const unsigned int face_no,
+ const unsigned int i) const
{
- AssertDimension(dim, get_dimension(reference_cell));
+ AssertDimension(dim, get_dimension());
AssertIndexRange(i, dim - 1);
- if (reference_cell == get_hypercube(dim))
+ if (*this == get_hypercube(dim))
{
AssertIndexRange(face_no, GeometryInfo<dim>::faces_per_cell);
return GeometryInfo<dim>::unit_tangential_vectors[face_no][i];
}
- else if (reference_cell == Type::Tri)
+ else if (*this == Type::Tri)
{
AssertIndexRange(face_no, 3);
static const std::array<Tensor<1, dim>, 3> table = {
return table[face_no];
}
- else if (reference_cell == Type::Tet)
+ else if (*this == Type::Tet)
{
AssertIndexRange(face_no, 4);
static const std::array<std::array<Tensor<1, dim>, 2>, 4> table = {
return table[face_no][i];
}
- else if (reference_cell == Type::Wedge)
+ else if (*this == Type::Wedge)
{
AssertIndexRange(face_no, 5);
static const std::array<std::array<Tensor<1, dim>, 2>, 5> table = {
return table[face_no][i];
}
- else if (reference_cell == Type::Pyramid)
+ else if (*this == Type::Pyramid)
{
AssertIndexRange(face_no, 5);
static const std::array<std::array<Tensor<1, dim>, 2>, 5> table = {
inline Tensor<1, dim>
unit_normal_vectors(const Type &reference_cell, const unsigned int face_no)
{
- AssertDimension(dim, get_dimension(reference_cell));
+ AssertDimension(dim, reference_cell.get_dimension());
if (reference_cell == get_hypercube(dim))
{
else if (dim == 2)
{
const auto tangential =
- unit_tangential_vectors<dim>(reference_cell, face_no, 0);
+ reference_cell.unit_tangential_vectors<dim>(face_no, 0);
Tensor<1, dim> result;
else if (dim == 3)
{
return cross_product_3d(
- unit_tangential_vectors<dim>(reference_cell, face_no, 0),
- unit_tangential_vectors<dim>(reference_cell, face_no, 1));
+ reference_cell.unit_tangential_vectors<dim>(face_no, 0),
+ reference_cell.unit_tangential_vectors<dim>(face_no, 1));
}
Assert(false, ExcNotImplemented());
- /**
- * Determine the orientation of an entity of @p type described by its
- * vertices @p var_1 relative to an entity described by @p var_0.
- */
template <typename T, std::size_t N>
inline unsigned char
- compute_orientation(const ReferenceCell::Type entity_type,
- const std::array<T, N> & vertices_0,
- const std::array<T, N> & vertices_1)
+ Type::compute_orientation(const std::array<T, N> &vertices_0,
+ const std::array<T, N> &vertices_1) const
{
AssertIndexRange(
- ReferenceCell::internal::Info::get_cell(entity_type).n_vertices(), N + 1);
- if (entity_type == ReferenceCell::Type::Line)
+ ReferenceCell::internal::Info::get_cell(*this).n_vertices(), N + 1);
+ if (*this == ReferenceCell::Type::Line)
{
const std::array<T, 2> i{{vertices_0[0], vertices_0[1]}};
const std::array<T, 2> j{{vertices_1[0], vertices_1[1]}};
if (i == std::array<T, 2>{{j[1], j[0]}})
return 0;
}
- else if (entity_type == ReferenceCell::Type::Tri)
+ else if (*this == ReferenceCell::Type::Tri)
{
const std::array<T, 3> i{{vertices_0[0], vertices_0[1], vertices_0[2]}};
const std::array<T, 3> j{{vertices_1[0], vertices_1[1], vertices_1[2]}};
if (i == std::array<T, 3>{{j[1], j[0], j[2]}})
return 4;
}
- else if (entity_type == ReferenceCell::Type::Quad)
+ else if (*this == ReferenceCell::Type::Quad)
{
const std::array<T, 4> i{
{vertices_0[0], vertices_0[1], vertices_0[2], vertices_0[3]}};
return 6;
}
- Assert(
- false,
- (internal::NoPermutation<T, N>(entity_type, vertices_0, vertices_1)));
+ Assert(false,
+ (internal::NoPermutation<T, N>(*this, vertices_0, vertices_1)));
return -1;
}
- /**
- * Inverse function of compute_orientation().
- */
+
+
template <typename T, std::size_t N>
inline std::array<T, N>
- permute_according_orientation(const ReferenceCell::Type entity_type,
- const std::array<T, N> & vertices,
- const unsigned int orientation)
+ Type::permute_according_orientation(const std::array<T, N> &vertices,
+ const unsigned int orientation) const
{
std::array<T, 4> temp;
- if (entity_type == ReferenceCell::Type::Line)
+ if (*this == ReferenceCell::Type::Line)
{
switch (orientation)
{
Assert(false, ExcNotImplemented());
}
}
- else if (entity_type == ReferenceCell::Type::Tri)
+ else if (*this == ReferenceCell::Type::Tri)
{
switch (orientation)
{
Assert(false, ExcNotImplemented());
}
}
- else if (entity_type == ReferenceCell::Type::Quad)
+ else if (*this == ReferenceCell::Type::Quad)
{
switch (orientation)
{