From 798c0e5beddeba94d7c4d76c2afa2fb1c405e6ad Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 7 May 2016 08:07:27 -0400 Subject: [PATCH] Add extra checks based on the cell measure. --- doc/news/changes.h | 8 ++++++++ source/grid/tria.cc | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/doc/news/changes.h b/doc/news/changes.h index 241540efc4..7718a459df 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -120,6 +120,14 @@ inconvenience this causes.

General

    +
  1. Improved: The method Triangulation::create_triangulation will now throw an + exception if any cells have negative measure. This check is not run if the + triangulation keeps track of distorted cells or if the codimension is not zero. + This check was previously only run in 3D. +
    + (David Wells, 2016/05/07) +
  2. +
  3. New: Add a collection of classes to manage user's quadrature point data: CellDataStorage, TransferableQuadraturePointData and parallel::distributed::ContinuousQuadratureDataTransfer. diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 31c8f22f87..8f6cc849fd 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -1637,6 +1637,23 @@ namespace internal triangulation.vertices = v; triangulation.vertices_used = std::vector (v.size(), true); + // Check that all cells have positive volume. This check is not run in + // the codimension one or two cases since cell_measure is not + // implemented for those. +#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 + (triangulation.vertices, cells[cell_no].vertices); + AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); + } + } +#endif + + // store the indices of the lines // which are adjacent to a given // vertex @@ -1815,6 +1832,22 @@ namespace internal triangulation.vertices = v; triangulation.vertices_used = std::vector (v.size(), true); + // Check that all cells have positive volume. This check is not run in + // the codimension one or two cases since cell_measure is not + // implemented for those. +#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 + (triangulation.vertices, cells[cell_no].vertices); + AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); + } + } +#endif + // make up a list of the needed // lines each line is a pair of // vertices. The list is kept @@ -2186,9 +2219,11 @@ namespace internal #ifndef _MSC_VER //TODO: The following code does not compile with MSVC. Find a way around it for (unsigned int cell_no = 0; cell_no= 0, - ExcGridHasInvalidCell(cell_no)); + { + const double cell_measure = GridTools::cell_measure<3, spacedim> + (triangulation.vertices, cells[cell_no].vertices); + AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); + } #endif /////////////////////////////////////// -- 2.39.5