Exception thrown during mesh refinement

29 views
Skip to first unread message

Claire

unread,
Jun 12, 2018, 5:51:26 AM6/12/18
to deal.II User Group
Dear all,

I recently experienced an error when I added an upper limit for the number of cells (i.e. defining max_n_cells) using the function refine_and_coarsen_fixed_fraction.

The message that I get is the following:

    Mesh refinement ...
   
    --------------------------------------------------------
An error occurred in line <292> of file </home/claire/Logiciels/dealii/tmp/unpack/deal.II-master/source/grid/grid_refinement.cc> in function
    void dealii::GridRefinement::refine_and_coarsen_fixed_number(dealii::Triangulation<dim, spacedim>&, const VectorType&, double, double, unsigned int) [with int dim = 3; VectorType = dealii::Vector<float>; int spacedim = 3]
The violated condition was:
    top_fraction+bottom_fraction <= 1
Additional information:
    (none)

Stacktrace:
-----------
#0  /home/claire/Logiciels/dealii/deal.II-master/lib/libdeal_II.g.so.9.0.0-pre: void dealii::GridRefinement::refine_and_coarsen_fixed_number<3, dealii::Vector<float>, 3>(dealii::Triangulation<3, 3>&, dealii::Vector<float> const&, double, double, unsigned int)
#1  /home/claire/Logiciels/dealii/deal.II-master/lib/libdeal_II.g.so.9.0.0-pre: void dealii::GridRefinement::refine_and_coarsen_fixed_fraction<3, dealii::Vector<float>, 3>(dealii::Triangulation<3, 3>&, dealii::Vector<float> const&, double, double, unsigned int)
#2  ./ThermoMech: Manager<3>::refine_mesh(std::vector<dealii::Vector<double>, std::allocator<dealii::Vector<double> > >&, unsigned int, unsigned int)
#3  ./ThermoMech: ThermoMechSolver<3>::run()
#4  ./ThermoMech: main
--------------------------------------------------------

Abandon (core dumped)

Looking at the source code, it seems that the problem comes from the call to the function refine_and_coarsen_fixed_number using the top_fraction and bottom_fraction defined in the function refine_and_coarsen_fixed_fraction

    const unsigned int refine_cells  = pp - tmp.begin(),
                       coarsen_cells = tmp.end() - qq;

    if (static_cast<unsigned int>
        (tria.n_active_cells()
         + refine_cells * (GeometryInfo<dim>::max_children_per_cell - 1)
         - (coarsen_cells *
            (GeometryInfo<dim>::max_children_per_cell - 1) /
            GeometryInfo<dim>::max_children_per_cell))
        >
        max_n_cells)
      {
        refine_and_coarsen_fixed_number (tria,
                                         criteria,
                                         1.*refine_cells/criteria.size(),
                                         1.*coarsen_cells/criteria.size(),
                                         max_n_cells);
        return;
      }

I am sorry that could not figure out the origin of the error...
I currently use 0.6 as top fraction and 0.4 as bottom fraction
Are those fractions wrong and responsible for the triggered exception, or is there any other possible explanation?
If you need any more information, please don't hesitate to ask.

Thanks a lot in advance for all the help or suggestions that I may get.

Best,

Claire


Daniel Arndt

unread,
Jun 12, 2018, 9:14:05 AM6/12/18
to deal.II User Group
Claire,


I recently experienced an error when I added an upper limit for the number of cells (i.e. defining max_n_cells) using the function refine_and_coarsen_fixed_fraction.

The message that I get is the following:

    Mesh refinement ...
   
    --------------------------------------------------------
An error occurred in line <292> of file </home/claire/Logiciels/dealii/tmp/unpack/deal.II-master/source/grid/grid_refinement.cc> in function
    void dealii::GridRefinement::refine_and_coarsen_fixed_number(dealii::Triangulation<dim, spacedim>&, const VectorType&, double, double, unsigned int) [with int dim = 3; VectorType = dealii::Vector<float>; int spacedim = 3]
The violated condition was:
    top_fraction+bottom_fraction <= 1
Additional information:
    (none)
The assertion is there to make sure that there are no cells that are marked for refinement and coarsening at the same time.
Testing for equality with floating point numbers is not stable. Hence, it is not overly surprising that choosing 0.6 as top fraction and 0.4 as bottom fraction
turs out to be problematic. It seems that 0.6+0.4 is slightly larger than 1.0 here.
In the end, a choice where you decide to either coarsen or refine each cell is very unusual. If you really want to do that you should decrease one of the fractions
slightly such that the sum is clearly below 1. (0.59 and 0.4 should work for example).

Best,
Daniel

Claire

unread,
Jun 13, 2018, 8:03:02 AM6/13/18
to deal.II User Group
Dear Daniel,

Thanks a lot for your answer, I got where my mistake was.

Best,

Claire

Wolfgang Bangerth

unread,
Jun 19, 2018, 5:18:13 PM6/19/18
to dea...@googlegroups.com

> An error occurred in line <292> of file
> </home/claire/Logiciels/dealii/tmp/unpack/deal.II-master/source/grid/grid_refinement.cc>
> in function
> void
> dealii::GridRefinement::refine_and_coarsen_fixed_number(dealii::Triangulation<dim,
> spacedim>&, const VectorType&, double, double, unsigned int) [with int dim
> = 3; VectorType = dealii::Vector<float>; int spacedim = 3]
> The violated condition was:
> top_fraction+bottom_fraction <= 1
> Additional information:
> (none)
>
> The assertion is there to make sure that there are no cells that are marked
> for refinement and coarsening at the same time.
> Testing for equality with floating point numbers is not stable. Hence, it is
> not overly surprising that choosing 0.6 as top fraction and 0.4 as bottom fraction
> turs out to be problematic. It seems that 0.6+0.4 is slightly larger than 1.0
> here.
> In the end, a choice where you decide to either coarsen or refine each cell is
> very unusual. If you really want to do that you should decrease one of the
> fractions
> slightly such that the sum is clearly below 1. (0.59 and 0.4 should work for
> example).

I've taken the opportunity to allow this in the following pull request:
https://github.com/dealii/dealii/pull/6795

Cheers
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Reply all
Reply to author
Forward
0 new messages