DEAL_II_NAMESPACE_OPEN
+DeclExceptionMsg(
+ ExcCellNotCartesian,
+ "You are using MappingCartesian, but the incoming cell is not Cartesian.");
+
+
+
+/**
+ * Return whether the incoming cell is of Cartesian shape. This is determined by
+ * checking if the smallest BoundingBox that encloses the cell has the same
+ * vertices as the cell itself.
+ */
+template <class CellType>
+bool
+is_cartesian(const CellType &cell)
+{
+ if (!cell->reference_cell().is_hyper_cube())
+ return false;
+
+ const double tolerance = 1e-14 * cell->diameter();
+ const auto bounding_box = cell->bounding_box();
+
+ for (const unsigned int v : cell->vertex_indices())
+ if (cell->vertex(v).distance(bounding_box.vertex(v)) > tolerance)
+ return false;
+
+ return true;
+}
+
template <int dim, int spacedim>
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim>
&output_data) const
{
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
+
// convert data object to internal data for this class. fails with
// an exception if that is not possible
Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr,
if (update_flags == update_default)
return;
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
+
Assert(update_flags & update_inverse_jacobians ||
update_flags & update_jacobians ||
update_flags & update_quadrature_points,
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim>
&output_data) const
{
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
AssertDimension(quadrature.size(), 1);
// convert data object to internal
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim>
&output_data) const
{
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
+
// convert data object to internal data for this class. fails with
// an exception if that is not possible
Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr,
&output_data) const
{
AssertDimension(dim, spacedim);
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
// Convert data object to internal data for this class. Fails with an
// exception if that is not possible.
const typename Triangulation<dim, spacedim>::cell_iterator &cell,
const Point<dim> & p) const
{
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
+
Tensor<1, dim> length;
const Point<dim> start = cell->vertex(0);
switch (dim)
const typename Triangulation<dim, spacedim>::cell_iterator &cell,
const Point<spacedim> & p) const
{
+ Assert(is_cartesian(cell), ExcCellNotCartesian());
+
if (dim != spacedim)
Assert(false, ExcNotImplemented());
const Point<dim> &start = cell->vertex(0);