From: Peter Munch Date: Tue, 11 Aug 2020 20:52:24 +0000 (+0200) Subject: Add back asserts in create_triangulation X-Git-Tag: v9.3.0-rc1~1193^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=179a20d008cf425e967b68815a220e47f2eefc39;p=dealii.git Add back asserts in create_triangulation --- 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(