From 179a20d008cf425e967b68815a220e47f2eefc39 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Tue, 11 Aug 2020 22:52:24 +0200 Subject: [PATCH] Add back asserts in create_triangulation --- source/grid/tria.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 3805f69cb1..7ed283bf9b 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -2183,6 +2183,31 @@ namespace internal const SubCellData & subcelldata, Triangulation & tria) { + AssertThrow(vertices.size() > 0, ExcMessage("No vertices given")); + AssertThrow(cells.size() > 0, ExcMessage("No cells given")); + + // Check that all cells have positive volume. +#ifndef _MSC_VER + // TODO: The following code does not compile with MSVC. Find a way + // around it + if (dim == spacedim) + for (unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no) + { + // If we should check for distorted cells, then we permit them + // to exist. If a cell has negative measure, then it must be + // distorted (the converse is not necessarily true); hence + // throw an exception if no such cells should exist. + if (!tria.check_for_distorted_cells) + { + const double cell_measure = + GridTools::cell_measure(vertices, + ArrayView( + cells[cell_no].vertices)); + AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); + } + } +#endif + // clear old content tria.levels.clear(); tria.levels.push_back( -- 2.39.5