Skip to content

Commit

Permalink
change class names for mapping/transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
rrsettgast committed Nov 4, 2023
1 parent d20aacf commit 80b6348
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 88 deletions.
3 changes: 1 addition & 2 deletions src/discretizations/unitTests/testParentElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include "../finiteElementMethod/parentElements/ParentElement.hpp"
#include "../finiteElementMethod/bases/LagrangeBasis.hpp"
#include "../spacing/Spacing.hpp"
#include "geometry/Cube.hpp"
#include "geometry/NCube.hpp"
#include "geometry/shapes/NCube.hpp"
#include "common/ShivaMacros.hpp"
#include "common/pmpl.hpp"

Expand Down
18 changes: 9 additions & 9 deletions src/geometry/mapping/LinearTransform.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* @file Cuboid.hpp
* @file LinearTransform.hpp
*/

#pragma once
Expand Down Expand Up @@ -29,10 +29,10 @@ namespace geometry
*
* The term cuboid is used here to define a 3-dimensional volume with 6
* quadralateral sides.
* <a href="https://en.wikipedia.org/wiki/Cuboid"> Cuboid (Wikipedia)</a>
* <a href="https://en.wikipedia.org/wiki/LinearTransform"> LinearTransform (Wikipedia)</a>
*/
template< typename REAL_TYPE >
class Cuboid
class LinearTransform
{
public:

Expand Down Expand Up @@ -141,8 +141,8 @@ namespace utilities
* @tparam REAL_TYPE The floating point type.
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void jacobian( Cuboid< REAL_TYPE > const &,//cell,
typename Cuboid< REAL_TYPE >::JacobianType::type & )//J )
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void jacobian( LinearTransform< REAL_TYPE > const &,//cell,
typename LinearTransform< REAL_TYPE >::JacobianType::type & )//J )
{}

/**
Expand All @@ -155,9 +155,9 @@ SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void jacobian( Cuboid< REAL_TYPE >
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void
jacobian( Cuboid< REAL_TYPE > const & cell,
jacobian( LinearTransform< REAL_TYPE > const & cell,
REAL_TYPE const (&pointCoordsParent)[3],
typename Cuboid< REAL_TYPE >::JacobianType::type & J )
typename LinearTransform< REAL_TYPE >::JacobianType::type & J )
{

cell.forVertices( [&J, pointCoordsParent ] ( auto const & index, REAL_TYPE const (&vertexCoord)[3] )
Expand Down Expand Up @@ -198,9 +198,9 @@ jacobian( Cuboid< REAL_TYPE > const & cell,
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void
inverseJacobian( Cuboid< REAL_TYPE > const & cell,
inverseJacobian( LinearTransform< REAL_TYPE > const & cell,
REAL_TYPE const (&parentCoords)[3],
typename Cuboid< REAL_TYPE >::JacobianType::type & invJ,
typename LinearTransform< REAL_TYPE >::JacobianType::type & invJ,
REAL_TYPE & detJ )
{
jacobian( cell, parentCoords, invJ );
Expand Down
18 changes: 9 additions & 9 deletions src/geometry/mapping/Scaling.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file RectangularCuboid.hpp
* @file Scaling.hpp
*/

#pragma once
Expand All @@ -13,7 +13,7 @@ namespace geometry
{

/**
* @brief Class definition for a RectangularCuboid geometry.
* @brief Class definition for a Scaling geometry.
* direction.
* @tparam REAL_TYPE The floating point type.
*
Expand All @@ -24,7 +24,7 @@ namespace geometry
*/
template< typename REAL_TYPE >
class RectangularCuboid
class Scaling
{
public:

Expand Down Expand Up @@ -93,10 +93,10 @@ namespace utilities
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void
jacobian( RectangularCuboid< REAL_TYPE > const & cell,
typename RectangularCuboid< REAL_TYPE >::JacobianType::type & J )
jacobian( Scaling< REAL_TYPE > const & cell,
typename Scaling< REAL_TYPE >::JacobianType::type & J )
{
typename RectangularCuboid< REAL_TYPE >::DataType const & h = cell.getLengths();
typename Scaling< REAL_TYPE >::DataType const & h = cell.getLengths();
J[0] = 0.5 * h[0];
J[1] = 0.5 * h[1];
J[2] = 0.5 * h[2];
Expand All @@ -113,11 +113,11 @@ jacobian( RectangularCuboid< REAL_TYPE > const & cell,
* @param detJ The determinant of the Jacobian transformation operator.
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void inverseJacobian( RectangularCuboid< REAL_TYPE > const & cell,
typename RectangularCuboid< REAL_TYPE >::JacobianType::type & invJ,
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void inverseJacobian( Scaling< REAL_TYPE > const & cell,
typename Scaling< REAL_TYPE >::JacobianType::type & invJ,
REAL_TYPE & detJ )
{
typename RectangularCuboid< REAL_TYPE >::DataType const & h = cell.getLengths();
typename Scaling< REAL_TYPE >::DataType const & h = cell.getLengths();
invJ[0] = 2.0 / h[0];
invJ[1] = 2.0 / h[1];
invJ[2] = 2.0 / h[2];
Expand Down
36 changes: 11 additions & 25 deletions src/geometry/mapping/UniformScaling.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file Cube.hpp
* @file UniformScaling.hpp
*/

#pragma once
Expand All @@ -13,35 +13,21 @@ namespace geometry
{

/**
* @brief Cube is a geometry type with a single length dimension in each
* direction.
* @brief UniformScaling is a transformation/mapping scales the size of a
* geometric object uniformly in each direction.
* @tparam REAL_TYPE The floating point type.
*
* A cube is a 3-dimensional volume that is...well...a cube.
* <a href="https://mathworld.wolfram.com/Cube.html"> Cube</a>
*/
template< typename REAL_TYPE >
class Cube
class UniformScaling
{
public:
/**
* @brief The number of dimension of the cube.
* @return The number dimension of the cube.
*/
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE int numDims() {return 3;};

/// Alias for the floating point type for the Jacobian transformation.
using JacobianType = Scalar< REAL_TYPE >;

/// Alias for the floating point type for the data members of the cube.
using DataType = REAL_TYPE;

/// Alias for the floating point type for the coordinates of the cube.
using CoordType = REAL_TYPE[3];

/// Alias for the index type of the cube.
using IndexType = MultiIndexRange< int, 2, 2, 2 >;

/**
* @brief Returns a boolean indicating whether the Jacobian is constant in
* the cell. This is used to determine whether the Jacobian should be
Expand Down Expand Up @@ -74,16 +60,16 @@ namespace utilities
{

/**
* @brief Calculates the Jacobian transormation of a cube from a cube with range from (-1,1) in each dimension.
* @brief Calculates the Jacobian transformation of a cube from a cube with range from (-1,1) in each dimension.
* @tparam REAL_TYPE The floating point type.
* @param cell The cube object
* @param J The Jacobian transformation.
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void jacobian( Cube< REAL_TYPE > const & cell,
typename Cube< REAL_TYPE >::JacobianType::type & J )
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void jacobian( UniformScaling< REAL_TYPE > const & cell,
typename UniformScaling< REAL_TYPE >::JacobianType::type & J )
{
typename Cube< REAL_TYPE >::DataType const & h = cell.getLength();
typename UniformScaling< REAL_TYPE >::DataType const & h = cell.getLength();
J = 0.5 * h;
}

Expand All @@ -95,11 +81,11 @@ SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void jacobian( Cube< REAL_TYPE > c
* @param detJ The determinant of the Jacobian transformation.
*/
template< typename REAL_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void inverseJacobian( Cube< REAL_TYPE > const & cell,
typename Cube< REAL_TYPE >::JacobianType::type & invJ,
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE void inverseJacobian( UniformScaling< REAL_TYPE > const & cell,
typename UniformScaling< REAL_TYPE >::JacobianType::type & invJ,
REAL_TYPE & detJ )
{
typename Cube< REAL_TYPE >::DataType const & h = cell.getLength();
typename UniformScaling< REAL_TYPE >::DataType const & h = cell.getLength();
invJ = 2 / h;
detJ = 0.125 * h * h * h;
}
Expand Down
28 changes: 14 additions & 14 deletions src/geometry/mapping/unitTests/testLinearTransform.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "../Cuboid.hpp"
#include "../geometryUtilities.hpp"
#include "../LinearTransform.hpp"
#include "../../geometryUtilities.hpp"
#include "common/pmpl.hpp"

#include <gtest/gtest.h>
Expand Down Expand Up @@ -80,9 +80,9 @@ constexpr double detJref[8] = { 1.9654823830313,
2.219082631125 };

template< typename REAL_TYPE >
SHIVA_HOST_DEVICE auto makeCuboid( REAL_TYPE const (&X)[8][3] )
SHIVA_HOST_DEVICE auto makeLinearTransform( REAL_TYPE const (&X)[8][3] )
{
Cuboid< REAL_TYPE > cell;
LinearTransform< REAL_TYPE > cell;
typename decltype(cell)::IndexType index;

forRange( index = {0, 0, 0}, [&cell, &X] ( auto const & i )
Expand All @@ -104,7 +104,7 @@ void testConstructionAndSettersHelper()
double * data = nullptr;
pmpl::genericKernelWrapper( 8 * 3, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto const cell = makeCuboid( Xref );
auto const cell = makeLinearTransform( Xref );
typename decltype(cell)::IndexType index{0, 0, 0};

forRange( index, [&cell, &kernelData] ( auto const & i )
Expand Down Expand Up @@ -137,7 +137,7 @@ void testConstructionAndSettersHelper()
}
pmpl::deallocateData( data );
}
TEST( testCuboid, testConstructionAndSetters )
TEST( testLinearTransform, testConstructionAndSetters )
{
testConstructionAndSettersHelper();
}
Expand All @@ -148,7 +148,7 @@ void testJacobianFunctionModifyLvalueRefArgHelper()
double * data = nullptr;
pmpl::genericKernelWrapper( 9 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeCuboid( Xref );
auto cell = makeLinearTransform( Xref );

for ( int q = 0; q < 8; ++q )
{
Expand Down Expand Up @@ -177,7 +177,7 @@ void testJacobianFunctionModifyLvalueRefArgHelper()
pmpl::deallocateData( data );
}

TEST( testCuboid, testJacobianFunctionModifyLvalueRefArg )
TEST( testLinearTransform, testJacobianFunctionModifyLvalueRefArg )
{
testJacobianFunctionModifyLvalueRefArgHelper();
}
Expand All @@ -188,7 +188,7 @@ void testJacobianFunctionReturnByValueHelper()
double * data = nullptr;
pmpl::genericKernelWrapper( 9 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeCuboid( Xref );
auto cell = makeLinearTransform( Xref );
for ( int q = 0; q < 8; ++q )
{
auto J = jacobian( cell, qCoords[q] );
Expand All @@ -215,7 +215,7 @@ void testJacobianFunctionReturnByValueHelper()
pmpl::deallocateData( data );
}

TEST( testCuboid, testJacobianFunctionReturnByValue )
TEST( testLinearTransform, testJacobianFunctionReturnByValue )
{
testJacobianFunctionReturnByValueHelper();
}
Expand All @@ -226,7 +226,7 @@ void testInvJacobianFunctionModifyLvalueRefArgHelper()
double * data = nullptr;
pmpl::genericKernelWrapper( 10 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeCuboid( Xref );
auto cell = makeLinearTransform( Xref );
for ( int q = 0; q < 8; ++q )
{
typename std::remove_reference_t< decltype(cell) >::JacobianType::type invJ = { {0} };
Expand Down Expand Up @@ -260,7 +260,7 @@ void testInvJacobianFunctionModifyLvalueRefArgHelper()

}

TEST( testCuboid, testInvJacobianFunctionModifyLvalueRefArg )
TEST( testLinearTransform, testInvJacobianFunctionModifyLvalueRefArg )
{
testInvJacobianFunctionModifyLvalueRefArgHelper();
}
Expand All @@ -271,7 +271,7 @@ void testInvJacobianFunctionReturnByValueHelper()
double * data = nullptr;
pmpl::genericKernelWrapper( 10 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeCuboid( Xref );
auto cell = makeLinearTransform( Xref );
for ( int q = 0; q < 8; ++q )
{
auto [ detJ, invJ ] = inverseJacobian( cell, qCoords[q] );
Expand Down Expand Up @@ -301,7 +301,7 @@ void testInvJacobianFunctionReturnByValueHelper()
pmpl::deallocateData( data );
}

TEST( testCuboid, testInvJacobianFunctionReturnByValue )
TEST( testLinearTransform, testInvJacobianFunctionReturnByValue )
{
testInvJacobianFunctionReturnByValueHelper();
}
Expand Down
Loading

0 comments on commit 80b6348

Please sign in to comment.