diff --git a/src/mesh/MeshOperations.h b/src/mesh/MeshOperations.h index 1cbe3037cecfe42d9e039abbaa903a3f03295994..9c5033b28fb0e4f55c5f0563a73015c20caa624d 100644 --- a/src/mesh/MeshOperations.h +++ b/src/mesh/MeshOperations.h @@ -61,7 +61,7 @@ template< typename MeshType > typename MeshType::Point computeCentroid( const MeshType & mesh ); template< typename MeshType > -Matrix3<typename MeshType::Scalar> computeIntertiaTensor( const MeshType & mesh ); +Matrix3<typename MeshType::Scalar> computeInertiaTensor( const MeshType & mesh ); template< typename MeshType > typename MeshType::Point computeCentroid( const MeshType & mesh, const typename MeshType::FaceHandle fh ); @@ -253,9 +253,9 @@ typename MeshType::Point computeCentroid( const MeshType & mesh ) template< typename MeshType > -Matrix3<typename MeshType::Scalar> computeIntertiaTensor( const MeshType & mesh ) +Matrix3<typename MeshType::Scalar> computeInertiaTensor( const MeshType & mesh ) { - static_assert( MeshType::IsTriMesh == 1, "computeIntertiaTensor only works with triangular meshes!" ); + static_assert( MeshType::IsTriMesh == 1, "computeInertiaTensor only works with triangular meshes!" ); typedef typename MeshType::Point Point; typedef typename MeshType::Scalar Scalar; diff --git a/src/mesh/pe/rigid_body/ConvexPolyhedron.cpp b/src/mesh/pe/rigid_body/ConvexPolyhedron.cpp index 85dab4d29ff4ec6ad359a463cb801e6d592ec301..248d2498beaf366a6c7a63bf4641f9fa6ce89e42 100644 --- a/src/mesh/pe/rigid_body/ConvexPolyhedron.cpp +++ b/src/mesh/pe/rigid_body/ConvexPolyhedron.cpp @@ -97,7 +97,7 @@ void ConvexPolyhedron::init( const Vec3& gpos, const Vec3& rpos, const Quat& q, } else { // sets inverse mass and interatio tensor - setMassAndInertia( getVolume() * Material::getDensity( getMaterial() ), mesh::computeIntertiaTensor( mesh_ ) ); + setMassAndInertia( getVolume() * Material::getDensity( getMaterial() ), mesh::computeInertiaTensor( mesh_ ) ); } setCommunicating( communicating ); setFinite( true ); diff --git a/tests/mesh/MeshOperationsTest.cpp b/tests/mesh/MeshOperationsTest.cpp index b3558bd306a0b911af1e497f0ef9bd3b06bb44da..b12d6fb3325541d6f8792015e460f30b9b1886d3 100644 --- a/tests/mesh/MeshOperationsTest.cpp +++ b/tests/mesh/MeshOperationsTest.cpp @@ -91,7 +91,7 @@ void testCube() WALBERLA_CHECK_FLOAT_EQUAL( centroid[1], aabbCenter[1] ); WALBERLA_CHECK_FLOAT_EQUAL( centroid[2], aabbCenter[2] ); - Matrix3<Scalar> inertiaTensor = computeIntertiaTensor(mesh); + Matrix3<Scalar> inertiaTensor = computeInertiaTensor(mesh); WALBERLA_CHECK_FLOAT_EQUAL( inertiaTensor(0,0), ( aabb.ySize() * aabb.ySize() + aabb.zSize() * aabb.zSize() ) / ( real_t(12) * aabb.volume() ) ); WALBERLA_CHECK_FLOAT_EQUAL( inertiaTensor(1,1), ( aabb.xSize() * aabb.xSize() + aabb.zSize() * aabb.zSize() ) / ( real_t(12) * aabb.volume() ) ); WALBERLA_CHECK_FLOAT_EQUAL( inertiaTensor(2,2), ( aabb.xSize() * aabb.xSize() + aabb.ySize() * aabb.ySize() ) / ( real_t(12) * aabb.volume() ) ); @@ -116,7 +116,7 @@ void testCube() WALBERLA_CHECK_FLOAT_EQUAL( centroid[1], aabbCenter[1] ); WALBERLA_CHECK_FLOAT_EQUAL( centroid[2], aabbCenter[2] ); - inertiaTensor = computeIntertiaTensor(mesh); + inertiaTensor = computeInertiaTensor(mesh); WALBERLA_CHECK_FLOAT_EQUAL( inertiaTensor(0,0), aabb.volume() * ( aabb.ySize() * aabb.ySize() + aabb.zSize() * aabb.zSize() ) / real_t(12) ); WALBERLA_CHECK_FLOAT_EQUAL( inertiaTensor(1,1), aabb.volume() * ( aabb.xSize() * aabb.xSize() + aabb.zSize() * aabb.zSize() ) / real_t(12) ); WALBERLA_CHECK_FLOAT_EQUAL( inertiaTensor(2,2), aabb.volume() * ( aabb.xSize() * aabb.xSize() + aabb.ySize() * aabb.ySize() ) / real_t(12) ); diff --git a/tests/mesh/NumericIntegrationTest.cpp b/tests/mesh/NumericIntegrationTest.cpp index 7bbbc6f0beb992756425e638106c3dce49bf5e26..fe706b7439a48900da9436c56e239febbf9e801d 100644 --- a/tests/mesh/NumericIntegrationTest.cpp +++ b/tests/mesh/NumericIntegrationTest.cpp @@ -86,7 +86,7 @@ Matrix3<real_t> inertiaTensorNumeric( const ContainmentT & body, const AABB & aa { Vector3<real_t> pointOfReference = aabb.min() + Vector3<real_t>( real_t(0.5) * spacing ); - math::KahanAccumulator<real_t> intertiaTensor[6]; + math::KahanAccumulator<real_t> inertiaTensor[6]; uint_t numPoints = 0; for(grid_generator::SCIterator it( aabb, pointOfReference, spacing ); it != grid_generator::SCIterator(); ++it) @@ -98,19 +98,19 @@ Matrix3<real_t> inertiaTensorNumeric( const ContainmentT & body, const AABB & aa const real_t & y = p[1]; const real_t & z = p[2]; - intertiaTensor[0] += y*y + z*z; - intertiaTensor[1] += -x*y; - intertiaTensor[2] += -x*z; - intertiaTensor[3] += x*x + z*z; - intertiaTensor[4] += -y*z; - intertiaTensor[5] += x*x + y*y; + inertiaTensor[0] += y*y + z*z; + inertiaTensor[1] += -x*y; + inertiaTensor[2] += -x*z; + inertiaTensor[3] += x*x + z*z; + inertiaTensor[4] += -y*z; + inertiaTensor[5] += x*x + y*y; ++numPoints; } } - return Matrix3<real_t>( intertiaTensor[0].get(), intertiaTensor[1].get(), intertiaTensor[2].get(), - intertiaTensor[1].get(), intertiaTensor[3].get(), intertiaTensor[4].get(), - intertiaTensor[2].get(), intertiaTensor[4].get(), intertiaTensor[5].get() ) * (spacing * spacing * spacing); + return Matrix3<real_t>( inertiaTensor[0].get(), inertiaTensor[1].get(), inertiaTensor[2].get(), + inertiaTensor[1].get(), inertiaTensor[3].get(), inertiaTensor[4].get(), + inertiaTensor[2].get(), inertiaTensor[4].get(), inertiaTensor[5].get() ) * (spacing * spacing * spacing); } @@ -147,10 +147,10 @@ void testNumeric( const shared_ptr<MeshType> & mesh ) WALBERLA_CHECK( std::fabs( numericCentroid[0] - geometricalCentroid[0] ) < real_t(0.001) || std::fabs( real_t(1) - numericCentroid[1] / geometricalCentroid[1] ) < real_t(0.001) ); WALBERLA_CHECK( std::fabs( numericCentroid[0] - geometricalCentroid[0] ) < real_t(0.001) || std::fabs( real_t(1) - numericCentroid[2] / geometricalCentroid[2] ) < real_t(0.001) ); - WALBERLA_LOG_INFO("Computing numeric intertia tensor"); + WALBERLA_LOG_INFO("Computing numeric inertia tensor"); Matrix3<real_t> numericTensor = inertiaTensorNumeric(*containmentOctree, aabb, spacing ); - WALBERLA_LOG_INFO("Computing geometrical intertia tensor"); - Matrix3<real_t> geometricalTensor = computeIntertiaTensor(*mesh); + WALBERLA_LOG_INFO("Computing geometrical inertia tensor"); + Matrix3<real_t> geometricalTensor = computeInertiaTensor(*mesh); WALBERLA_LOG_INFO("Numerical tensor:\n" << numericTensor << "\n" << "Geometrical tensor:\n" << geometricalTensor << "\n" << "Difference:\n" << numericTensor - geometricalTensor ); diff --git a/tests/pe/VolumeInertia.cpp b/tests/pe/VolumeInertia.cpp index becd6ddd37b8fbd8380d4bf20def053a6b40b1c4..6deebadad13baf8921848700e28170d483b9cada 100644 --- a/tests/pe/VolumeInertia.cpp +++ b/tests/pe/VolumeInertia.cpp @@ -36,7 +36,7 @@ void calcNumeric( const ContainmentT & body, const AABB & aabb, const real_t spa uint_t volume = 0; math::KahanAccumulator<real_t> centroid[3]; - math::KahanAccumulator<real_t> intertiaTensor[6]; + math::KahanAccumulator<real_t> inertiaTensor[6]; uint_t numPoints = 0; for(grid_generator::SCIterator it( aabb, pointOfReference, spacing ); it != grid_generator::SCIterator(); ++it) @@ -57,12 +57,12 @@ void calcNumeric( const ContainmentT & body, const AABB & aabb, const real_t spa const real_t & y = p[1]; const real_t & z = p[2]; - intertiaTensor[0] += y*y + z*z; - intertiaTensor[1] += -x*y; - intertiaTensor[2] += -x*z; - intertiaTensor[3] += x*x + z*z; - intertiaTensor[4] += -y*z; - intertiaTensor[5] += x*x + y*y; + inertiaTensor[0] += y*y + z*z; + inertiaTensor[1] += -x*y; + inertiaTensor[2] += -x*z; + inertiaTensor[3] += x*x + z*z; + inertiaTensor[4] += -y*z; + inertiaTensor[5] += x*x + y*y; ++numPoints; } } @@ -71,9 +71,9 @@ void calcNumeric( const ContainmentT & body, const AABB & aabb, const real_t spa auto dm = dV * Material::getDensity( body.getMaterial() ); outVolume = real_c(volume) * dV; outCOM = Vec3( centroid[0].get(), centroid[1].get(), centroid[2].get() ) / real_c(numPoints); - outInertia = Mat3( intertiaTensor[0].get(), intertiaTensor[1].get(), intertiaTensor[2].get(), - intertiaTensor[1].get(), intertiaTensor[3].get(), intertiaTensor[4].get(), - intertiaTensor[2].get(), intertiaTensor[4].get(), intertiaTensor[5].get() ) * dm; + outInertia = Mat3( inertiaTensor[0].get(), inertiaTensor[1].get(), inertiaTensor[2].get(), + inertiaTensor[1].get(), inertiaTensor[3].get(), inertiaTensor[4].get(), + inertiaTensor[2].get(), inertiaTensor[4].get(), inertiaTensor[5].get() ) * dm; } int main( int argc, char ** argv )