diff --git a/src/mesh/MeshOperations.h b/src/mesh/MeshOperations.h index cd4cf4f3fc0ac94d7f425f44be296438a1b0b897..03a00f219d1f4ae325ed8094c956c26545495a30 100644 --- a/src/mesh/MeshOperations.h +++ b/src/mesh/MeshOperations.h @@ -25,8 +25,7 @@ #include "TriangleMeshes.h" #include "core/math/GenericAABB.h" - -#include <boost/logic/tribool.hpp> +#include "core/Optional.h" #include <set> #include <iterator> @@ -72,13 +71,13 @@ template< typename MeshType > void findConnectedVertices( const MeshType & mesh, const typename MeshType::FaceHandle & face, std::vector< typename MeshType::VertexHandle > & outVertices ); template< typename DistanceObject, typename T, typename U > -boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError ); +walberla::optional< bool > isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError ); template< typename DistanceObject, typename T, typename U > -boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError ); +walberla::optional< bool > fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const T & maxError ); template< typename DistanceObject, typename T, typename U, typename V > -boost::logic::tribool intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance ); +walberla::optional< bool > intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance ); template< typename MeshType, typename InputIterator > typename MeshType::Point principalComponent( const MeshType & mesh, InputIterator beginFh, InputIterator endFh, const uint_t iterations = uint_t(10) ); @@ -341,7 +340,7 @@ void findConnectedVertices( const MeshType & mesh, const typename MeshType::Face template< typename DistanceObject, typename T, typename U > -boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError ) +walberla::optional< bool > isIntersecting( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError ) { typedef typename DistanceObject::Scalar Scalar; @@ -388,7 +387,7 @@ boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, con if( error < maxErrorScalar ) { - return boost::logic::indeterminate; // we still don't know if there is an intersection but the error margin is already small enough + return walberla::nullopt; // we still don't know if there is an intersection but the error margin is already small enough } const auto & min = curAabb.minCorner(); @@ -413,7 +412,7 @@ boost::logic::tribool isIntersecting( const DistanceObject & distanceObject, con template< typename DistanceObject, typename T, typename U > -boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError ) +walberla::optional< bool > fullyCoversAABB( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError ) { typedef typename DistanceObject::Scalar Scalar; @@ -459,7 +458,7 @@ boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, co if( error < maxErrorScalar ) { - return boost::logic::indeterminate; // we still don't know if there is an intersection but the error margin is already small enough + return walberla::nullopt; // we still don't know if there is an intersection but the error margin is already small enough } const auto & min = curAabb.minCorner(); @@ -484,7 +483,7 @@ boost::logic::tribool fullyCoversAABB( const DistanceObject & distanceObject, co template< typename DistanceObject, typename T, typename U, typename V > -boost::logic::tribool intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance ) +walberla::optional< bool > intersectsSurface( const DistanceObject & distanceObject, const math::GenericAABB< T > & aabb, const U & maxError, const V & surfaceDistance ) { typedef typename DistanceObject::Scalar Scalar; @@ -532,7 +531,7 @@ boost::logic::tribool intersectsSurface( const DistanceObject & distanceObject, if(error < maxErrorScalar) { - return boost::logic::indeterminate; // we still don't know if there is an intersection but the error margin is already small enough + return walberla::nullopt; // we still don't know if there is an intersection but the error margin is already small enough } const auto & min = curAabb.minCorner(); @@ -609,4 +608,4 @@ typename MeshType::Point principalComponent( const MeshType & mesh, const uint_t } // namespace mesh -} // namespace walberla \ No newline at end of file +} // namespace walberla diff --git a/src/mesh/blockforest/RefinementSelection.h b/src/mesh/blockforest/RefinementSelection.h index 30493d9e6871a135a794eccaf349b7bc1241b787..4c29773540998dac4b29f27cb7c39e7add96e175 100644 --- a/src/mesh/blockforest/RefinementSelection.h +++ b/src/mesh/blockforest/RefinementSelection.h @@ -30,6 +30,7 @@ #include "core/cell/CellInterval.h" #include "core/mpi/MPIManager.h" #include "core/mpi/Reduce.h" +#include "core/Optional.h" #include <random> #include <vector> @@ -101,8 +102,8 @@ inline void walberla::mesh::RefinementSelection<DistanceObject>::operator()( blo if( blockLevel >= level_ ) continue; - boost::tribool intersects = intersectsSurface( *distanceObject_, blocks[ shuffle[ii] ]->getAABB(), maxError_, distance_ ); - if( indeterminate( intersects ) || intersects ) + walberla::optional< bool > intersects = intersectsSurface( *distanceObject_, blocks[ shuffle[ii] ]->getAABB(), maxError_, distance_ ); + if( intersects.value_or( true ) ) refine[ shuffle[ ii ] ] = uint8_t( 1 ); } diff --git a/tests/mesh/MeshAABBIntersectionTest.cpp b/tests/mesh/MeshAABBIntersectionTest.cpp index e1286dbc679c767b940076bbacb0e817e65f48b0..967c8ce218eacfd56c3ef49bda339772528f0c21 100644 --- a/tests/mesh/MeshAABBIntersectionTest.cpp +++ b/tests/mesh/MeshAABBIntersectionTest.cpp @@ -23,6 +23,7 @@ #include "core/logging/Logging.h" #include "core/math/AABB.h" #include "core/mpi/Environment.h" +#include "core/Optional.h" #include "mesh/MeshIO.h" #include "mesh/MeshOperations.h" @@ -50,7 +51,7 @@ void runTests( const uint_t numAABBs ) TriangleDistance<MeshType> triDist( mesh ); - WALBERLA_CHECK( isIntersecting( triDist, meshAABB, real_t(0) ).value, boost::logic::tribool::true_value ); + WALBERLA_CHECK( isIntersecting( triDist, meshAABB, real_t(0) ).value_or( false ) ); std::mt19937 rng( uint32_t(42) ); @@ -60,19 +61,18 @@ void runTests( const uint_t numAABBs ) const real_t maxErr = real_t(1e-2); - boost::tribool result = isIntersecting( triDist, testAABB, maxErr ); + walberla::optional< bool > result = isIntersecting( triDist, testAABB, maxErr ); - if(result) + if ( result.has_value() ) { - WALBERLA_CHECK( meshAABB.intersects( testAABB ), "Box#: " << i ); - } - else if(!result) - { - WALBERLA_CHECK( !meshAABB.intersects( testAABB ), "Box#: " << i ); - } - else - { - WALBERLA_ASSERT( boost::logic::indeterminate( result ) ); + if(result.value()) + { + WALBERLA_CHECK( meshAABB.intersects( testAABB ), "Box#: " << i ); + } + else if(!result.value()) + { + WALBERLA_CHECK( !meshAABB.intersects( testAABB ), "Box#: " << i ); + } } } }