Commit 99b346f6 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added overload of getEntityMeasure for hexahedrons

parent c8815636
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ getEntityCenter( const Mesh< MeshConfig, Device > & mesh,
/*
 * Get an arithmetic mean of the entity's subvertices.
 *
 * For an simplex entity this corresponds to the centroid of the entity, but
 * For a simplex entity this corresponds to the centroid of the entity, but
 * note that other shapes such as general polygons have different formulas for
 * the centroid: https://en.wikipedia.org/wiki/Centroid#Centroid_of_a_polygon
 */
+24 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <TNL/Meshes/Topologies/Triangle.h>
#include <TNL/Meshes/Topologies/Quadrangle.h>
#include <TNL/Meshes/Topologies/Tetrahedron.h>
#include <TNL/Meshes/Topologies/Hexahedron.h>

namespace TNL {
namespace Meshes {
@@ -148,5 +149,28 @@ getEntityMeasure( const Mesh< MeshConfig, Device > & mesh,
    return getTetrahedronVolume( v3 - v0, v2 - v0, v1 - v0 );
}

template< typename MeshConfig, typename Device >
__cuda_callable__
typename MeshConfig::RealType
getEntityMeasure( const Mesh< MeshConfig, Device > & mesh,
                  const MeshEntity< MeshConfig, Device, Topologies::Hexahedron > & entity )
{
    const auto& v0 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 0 ) );
    const auto& v1 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 1 ) );
    const auto& v2 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 2 ) );
    const auto& v3 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 3 ) );
    const auto& v4 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 4 ) );
    const auto& v5 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 5 ) );
    const auto& v6 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 6 ) );
    const auto& v7 = mesh.getPoint( entity.template getSubentityIndex< 0 >( 7 ) );
    // https://www.cfd-online.com/Forums/main/163122-volume-general-hexahedron.html#post574650
    return getTetrahedronVolume( v0 - v4, v3 - v4, v1 - v4 )
         + getTetrahedronVolume( v2 - v4, v3 - v4, v1 - v4 )
         + getTetrahedronVolume( v1 - v4, v2 - v4, v5 - v4 )
         + getTetrahedronVolume( v6 - v4, v2 - v4, v5 - v4 )
         + getTetrahedronVolume( v3 - v4, v2 - v4, v7 - v4 )
         + getTetrahedronVolume( v6 - v4, v2 - v4, v7 - v4 );
}

} // namespace Meshes
} // namespace TNL