diff --git a/src/blockforest/BlockNeighborhoodSection.h b/src/blockforest/BlockNeighborhoodSection.h index f39b5d1f2029ceed24aff5b79fcabd389ee6d1be..161e2f2e41ee782cbad25de3cea39b400b345847 100644 --- a/src/blockforest/BlockNeighborhoodSection.h +++ b/src/blockforest/BlockNeighborhoodSection.h @@ -25,7 +25,7 @@ #include "core/debug/Debug.h" #include "stencil/Directions.h" - +#include <array> namespace walberla { namespace blockforest { @@ -94,31 +94,28 @@ inline uint_t getBlockMaxNeighborhoodSectionSize( const uint_t sectionIndex ) -inline const uint_t * getFaceNeighborhoodSectionIndices() +inline const std::array<uint_t, 6> & getFaceNeighborhoodSectionIndices() { - static const uint_t faces[] = { uint_t(4), uint_t(10), uint_t(12), uint_t(13), uint_t(15), uint_t(21) }; + static std::array<uint_t, 6> faces{ { uint_t(4), uint_t(10), uint_t(12), uint_t(13), uint_t(15), uint_t(21) } }; return faces; } - -inline const uint_t * getEdgeNeighborhoodSectionIndices() +inline const std::array<uint_t,12> & getEdgeNeighborhoodSectionIndices() { - static const uint_t edges[] = { uint_t( 1), uint_t( 3), uint_t( 5), uint_t( 7), uint_t( 9), uint_t(11), - uint_t(14), uint_t(16), uint_t(18), uint_t(20), uint_t(22), uint_t(24) }; + static std::array<uint_t,12> edges{{ uint_t( 1), uint_t( 3), uint_t( 5), uint_t( 7), uint_t( 9), uint_t(11), + uint_t(14), uint_t(16), uint_t(18), uint_t(20), uint_t(22), uint_t(24) }}; return edges; } - -inline const uint_t * getCornerNeighborhoodSectionIndices() +inline const std::array<uint_t, 8> & getCornerNeighborhoodSectionIndices() { - static const uint_t corners[] = { uint_t( 0), uint_t( 2), uint_t( 6), uint_t( 8), - uint_t(17), uint_t(19), uint_t(23), uint_t(25) }; + static std::array<uint_t, 8> corners {{ uint_t( 0), uint_t( 2), uint_t( 6), uint_t( 8), + uint_t(17), uint_t(19), uint_t(23), uint_t(25) }}; return corners; } - } // namespace blockforest } // namespace walberla diff --git a/src/blockforest/loadbalancing/DynamicDiffusive.h b/src/blockforest/loadbalancing/DynamicDiffusive.h index b914bda506fbd87db247e4bc6389727ed13a5142..d9037070bad849a6a751f2ed4d72c26cba33bbd0 100644 --- a/src/blockforest/loadbalancing/DynamicDiffusive.h +++ b/src/blockforest/loadbalancing/DynamicDiffusive.h @@ -409,8 +409,8 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai const uint_t level = levelwise_ ? block->getLevel() : uint_t(0); if( level == l && targetProcess[i].second == blockforest.getProcess() ) { - const uint_t * faces = blockforest::getFaceNeighborhoodSectionIndices(); - for( uint_t j = uint_t(0); j != uint_t(6); ++j ) + auto faces = blockforest::getFaceNeighborhoodSectionIndices(); + for( uint_t j = uint_t(0); j != faces.size(); ++j ) { const uint_t sectionIndex = faces[j]; const uint_t sectionSize = block->getNeighborhoodSectionSize( sectionIndex ); @@ -427,8 +427,8 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai } } } - const uint_t * edges = blockforest::getEdgeNeighborhoodSectionIndices(); - for( uint_t j = uint_t(0); j != uint_t(12); ++j ) + auto edges = blockforest::getEdgeNeighborhoodSectionIndices(); + for( uint_t j = uint_t(0); j != edges.size(); ++j ) { const uint_t sectionIndex = edges[j]; const uint_t sectionSize = block->getNeighborhoodSectionSize( sectionIndex ); @@ -445,8 +445,8 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai } } } - const uint_t * corners = blockforest::getCornerNeighborhoodSectionIndices(); - for( uint_t j = uint_t(0); j != uint_t(8); ++j ) + auto corners = blockforest::getCornerNeighborhoodSectionIndices(); + for( uint_t j = uint_t(0); j != corners.size(); ++j ) { const uint_t sectionIndex = corners[j]; const uint_t sectionSize = block->getNeighborhoodSectionSize( sectionIndex ); @@ -655,8 +655,8 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai { if( regardConnectivity_ && iteration < disregardConnectivityStart_ ) { - const uint_t * faces = blockforest::getFaceNeighborhoodSectionIndices(); - for( uint_t j = uint_t(0); j != uint_t(6); ++j ) + auto faces = blockforest::getFaceNeighborhoodSectionIndices(); + for( uint_t j = uint_t(0); j != faces.size(); ++j ) { const uint_t sectionIndex = faces[j]; const uint_t sectionSize = block->getNeighborhoodSectionSize( sectionIndex ); @@ -675,8 +675,8 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai } } } - const uint_t * edges = blockforest::getEdgeNeighborhoodSectionIndices(); - for( uint_t j = uint_t(0); j != uint_t(12); ++j ) + auto edges = blockforest::getEdgeNeighborhoodSectionIndices(); + for( uint_t j = uint_t(0); j != edges.size(); ++j ) { const uint_t sectionIndex = edges[j]; const uint_t sectionSize = block->getNeighborhoodSectionSize( sectionIndex ); @@ -695,8 +695,8 @@ bool DynamicDiffusionBalance< PhantomData_T >::operator()( std::vector< std::pai } } } - const uint_t * corners = blockforest::getCornerNeighborhoodSectionIndices(); - for( uint_t j = uint_t(0); j != uint_t(8); ++j ) + auto corners = blockforest::getCornerNeighborhoodSectionIndices(); + for( uint_t j = uint_t(0); j != corners.size(); ++j ) { const uint_t sectionIndex = corners[j]; const uint_t sectionSize = block->getNeighborhoodSectionSize( sectionIndex ); diff --git a/src/pe/rigidbody/RigidBody.h b/src/pe/rigidbody/RigidBody.h index 119616748a90f49f94333ad14cf0d5335b35650e..004423cc12a1e14f3f9de124046895db2c0add15 100644 --- a/src/pe/rigidbody/RigidBody.h +++ b/src/pe/rigidbody/RigidBody.h @@ -1170,7 +1170,11 @@ const Vec3 RigidBody::accFromWF( real_t px, real_t py, real_t pz ) const } //************************************************************************************************* -inline id_t RigidBody::getTypeID() const{ +inline id_t RigidBody::getTypeID() const +{ + WALBERLA_ASSERT_LESS( typeID_, std::numeric_limits<id_t>::max(), "You are requesting the type " \ + " id of a body, but the static type id for the body has not yet been " \ + " initialized! Call SetBodyTypeIDs<BodyTypeTuple>::execute to initialize!" ); return typeID_; } diff --git a/tests/pe/CollisionTobiasGJK.cpp b/tests/pe/CollisionTobiasGJK.cpp index bed8bc4cebb963ccea415ffde4b7bcc45b1db31d..2c3fa052afaa27c40dc7de3145e6999ddd13d04c 100644 --- a/tests/pe/CollisionTobiasGJK.cpp +++ b/tests/pe/CollisionTobiasGJK.cpp @@ -48,7 +48,7 @@ using namespace walberla; using namespace walberla::pe; -typedef boost::tuple<Box, Capsule, Plane, Sphere, Union<boost::tuple<Sphere, Union<boost::tuple<Sphere>>>>, Ellipsoid> BodyTuple ; +typedef boost::tuple<Box, Capsule, Plane, Sphere, Union<boost::tuple<Sphere>>, Union<boost::tuple<Sphere, Union<boost::tuple<Sphere>>>>, Ellipsoid> BodyTuple ; bool gjkEPAcollideHybrid(GeomPrimitive &geom1, GeomPrimitive &geom2, Vec3& normal, Vec3& contactPoint, real_t& penetrationDepth) { diff --git a/tests/pe/SimpleCCD.cpp b/tests/pe/SimpleCCD.cpp index cd0095811a842b11aa2d3bc2d54d95c60d93a0b9..3bb6539082b84879307701ad0ceccc08a782bf48 100644 --- a/tests/pe/SimpleCCD.cpp +++ b/tests/pe/SimpleCCD.cpp @@ -19,18 +19,19 @@ //====================================================================================================================== #include "pe/Materials.h" -#include "pe/rigidbody/Sphere.h" #include "pe/Types.h" #include "pe/rigidbody/BodyStorage.h" +#include "pe/rigidbody/SetBodyTypeIDs.h" +#include "pe/rigidbody/Sphere.h" #include "pe/ccd/SimpleCCD.h" #include "pe/ccd/HashGrids.h" #include "pe/fcd/SimpleFCD.h" -#include "core/DataTypes.h" +#include "core/DataTypes.h" +#include "core/UniqueID.h" #include "core/timing/TimingPool.h" #include "core/debug/TestSubsystem.h" #include "core/math/Random.h" -#include "core/UniqueID.h" using namespace walberla; using namespace walberla::pe; @@ -43,6 +44,8 @@ int main( int argc, char** argv ) walberla::MPIManager::instance()->initializeMPI( &argc, &argv ); + SetBodyTypeIDs<BodyTuple>::execute(); + MaterialID iron = Material::find("iron"); BodyStorage globalStorage;