Skip to content
Snippets Groups Projects
Commit 4864409a authored by Robert K's avatar Robert K
Browse files

[bugfix][CoarsestVolume] catch exception in case `father` is not

implemented.
parent bb4336f1
No related branches found
No related tags found
No related merge requests found
Pipeline #66195 passed
......@@ -161,13 +161,24 @@ namespace Fem
typedef std::pair< double, double > VolumePairType;
template <class Entity>
double findCoarsestVolume( const Entity& entity, const bool hasGridHierarchy ) const
double findCoarsestVolume( const Entity& entity, const bool hasGridHierarchy, bool& hasFather ) const
{
// go to father, if possible
// otherwise write min and max volume on backup/restore
if( hasGridHierarchy && entity.level() > 0 )
if( hasGridHierarchy && (entity.level() > 0) && hasFather )
{
return findCoarsestVolume( entity.father(), hasGridHierarchy );
double vol = 0.0;
// grids without hierarchy do not implement father method,
// but throw and exception instead
try {
vol = findCoarsestVolume( entity.father(), hasGridHierarchy, hasFather );
}
catch (const Dune::NotImplemented& e )
{
hasFather = false;
vol = entity.geometry().volume();
}
return vol;
}
else // return entity's volume
return entity.geometry().volume();
......@@ -181,6 +192,7 @@ namespace Fem
typedef typename GridPart :: GridType GridType ;
const bool hasGridHierarchy = Fem :: GridPartCapabilities :: hasGrid< GridPart > :: v;
bool hasFather = true; // will be set to false if father () fails
double weight = Dune::DGFGridInfo<GridType>::refineWeight();
// if weight is not set, use 1/(2^d)
......@@ -194,7 +206,7 @@ namespace Fem
for( const auto& en : elements( gridPart ) )
{
const double volume = findCoarsestVolume( en, hasGridHierarchy );
const double volume = findCoarsestVolume( en, hasGridHierarchy, hasFather );
minVolume[ 0 ] = std::min( minVolume[ 0 ], volume );
maxVolume[ 0 ] = std::max( maxVolume[ 0 ], volume );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment