Commit cb3153d0 authored by Graham, Aaron's avatar Graham, Aaron
Browse files

Remove unneeded interfaces from PointType

parent 749d3f3f
Pipeline #156740 passed with stage
in 2 minutes and 5 seconds
......@@ -32,9 +32,6 @@ PUBLIC :: innerAngle
PUBLIC :: outerAngle
PUBLIC :: OPERATOR(+)
PUBLIC :: OPERATOR(-)
PUBLIC :: OPERATOR(*)
PUBLIC :: OPERATOR(/)
PUBLIC :: OPERATOR(**)
PUBLIC :: OPERATOR(==)
PUBLIC :: OPERATOR(/=)
PUBLIC :: OPERATOR(.APPROXEQA.)
......@@ -140,36 +137,6 @@ INTERFACE OPERATOR(-)
MODULE PROCEDURE subtract_PointType
ENDINTERFACE
!> @brief Generic interface for multiplication operator (*)
!>
!> Adds multiplication capability for point types
INTERFACE OPERATOR(*)
!> @copybrief GeomPoints::multiply_PointType
!> @copydetails GeomPoints::multiply_PointType
MODULE PROCEDURE multiply_PointType
ENDINTERFACE
!> @brief Generic interface for division operator (/)
!>
!> Adds division capability for point types
INTERFACE OPERATOR(/)
!> @copybrief GeomPoints::divide_PointType
!> @copydetails GeomPoints::divide_PointType
MODULE PROCEDURE divide_PointType
ENDINTERFACE
!> @brief Generic interface for exponentiation operator (**)
!>
!> Adds exponentiation capability for point types
INTERFACE OPERATOR(**)
!> @copybrief GeomPoints::exponentiate_PointType_integer
!> @copydetails GeomPoints::exponentiate_PointType_integer
MODULE PROCEDURE exponentiate_PointType_integer
!> @copybrief GeomPoints::exponentiate_PointType_real
!> @copydetails GeomPoints::exponentiate_PointType_real
MODULE PROCEDURE exponentiate_PointType_real
ENDINTERFACE
!> @brief Generic interface for 'is equal to' operator (==)
!>
!> Adds 'is equal to' capability for point types
......@@ -304,8 +271,8 @@ ENDSUBROUTINE clear_PointType
!> greater point dimensions.
ELEMENTAL SUBROUTINE RotateQtrClockwise_PointType(p,nrot)
CLASS(PointType),INTENT(INOUT) :: p
INTEGER(SIK),INTENT(IN) :: nrot
INTEGER(SIK),INTENT(IN) :: nrot
IF(ALLOCATED(p%coord) .AND. p%dim >= 2) &
CALL RotateQtrClockwise(p%coord(1),p%coord(2),nrot)
ENDSUBROUTINE RotateQtrClockwise_PointType
......@@ -371,124 +338,6 @@ ELEMENTAL FUNCTION subtract_PointType(p0,p1) RESULT(p)
ENDFUNCTION subtract_PointType
!
!-------------------------------------------------------------------------------
!> @brief Defines the multiplication operation between two points e.g. @c p=p0*p1
!> @param p0 the first point
!> @param p1 the second point
!> @returns @c p the return point value
!>
!> Function is elemental so it can be used on an array of points.
ELEMENTAL FUNCTION multiply_PointType(p0,p1) RESULT(p)
TYPE(PointType),INTENT(IN) :: p0,p1
TYPE(PointType) :: p
CALL p%clear()
IF(p0%dim == p1%dim .AND. p0%dim > 0) THEN
p%dim=p0%dim
ALLOCATE(p%coord(p%dim))
SELECTCASE(p%dim) !Explicit unrolling, this may improve performance
CASE(1)
p%coord(1)=p0%coord(1)*p1%coord(1)
CASE(2)
p%coord(1)=p0%coord(1)*p1%coord(1)
p%coord(2)=p0%coord(2)*p1%coord(2)
CASE(3)
p%coord(1)=p0%coord(1)*p1%coord(1)
p%coord(2)=p0%coord(2)*p1%coord(2)
p%coord(3)=p0%coord(3)*p1%coord(3)
CASE DEFAULT
p%coord=p0%coord*p1%coord
ENDSELECT
ENDIF
ENDFUNCTION multiply_PointType
!
!-------------------------------------------------------------------------------
!> @brief Defines the multiplication operation between two points e.g. @c p=p0/p1
!> @param p0 the first point
!> @param p1 the second point
!> @returns @c p the return point value
!>
!> Function is elemental so it can be used on an array of points.
ELEMENTAL FUNCTION divide_PointType(p0,p1) RESULT(p)
TYPE(PointType),INTENT(IN) :: p0,p1
TYPE(PointType) :: p
CALL p%clear()
IF(p0%dim == p1%dim .AND. p0%dim > 0) THEN
p%dim=p0%dim
ALLOCATE(p%coord(p%dim))
SELECTCASE(p%dim) !Explicit unrolling, this may improve performance
CASE(1)
p%coord(1)=p0%coord(1)/p1%coord(1)
CASE(2)
p%coord(1)=p0%coord(1)/p1%coord(1)
p%coord(2)=p0%coord(2)/p1%coord(2)
CASE(3)
p%coord(1)=p0%coord(1)/p1%coord(1)
p%coord(2)=p0%coord(2)/p1%coord(2)
p%coord(3)=p0%coord(3)/p1%coord(3)
CASE DEFAULT
p%coord=p0%coord/p1%coord
ENDSELECT
ENDIF
ENDFUNCTION divide_PointType
!
!-------------------------------------------------------------------------------
!> @brief Defines the exponentiation operation of a point e.g. @c p=p0**n
!> @param p0 the first point
!> @param n the exponent
!> @returns @c p the return point value
!>
!> Function is elemental so it can be used on an array of points.
ELEMENTAL FUNCTION exponentiate_PointType_integer(p0,n) RESULT(p)
TYPE(PointType),INTENT(IN) :: p0
INTEGER(SIK),INTENT(IN) :: n
TYPE(PointType) :: p
CALL p%clear()
p%dim=p0%dim
ALLOCATE(p%coord(p%dim))
SELECTCASE(p%dim) !Explicit unrolling, this may improve performance
CASE(1)
p%coord(1)=p0%coord(1)**n
CASE(2)
p%coord(1)=p0%coord(1)**n
p%coord(2)=p0%coord(2)**n
CASE(3)
p%coord(1)=p0%coord(1)**n
p%coord(2)=p0%coord(2)**n
p%coord(3)=p0%coord(3)**n
CASE DEFAULT
p%coord=p0%coord**n
ENDSELECT
ENDFUNCTION exponentiate_PointType_integer
!
!-------------------------------------------------------------------------------
!> @brief Defines the exponentiation operation of a point e.g. @c p=p0**n
!> @param p0 the first point
!> @param n the exponent
!> @returns @c p the return point value
!>
!> Function is elemental so it can be used on an array of points.
ELEMENTAL FUNCTION exponentiate_PointType_real(p0,n) RESULT(p)
TYPE(PointType),INTENT(IN) :: p0
REAL(SRK),INTENT(IN) :: n
TYPE(PointType) :: p
CALL p%clear()
p%dim=p0%dim
ALLOCATE(p%coord(p%dim))
SELECTCASE(p%dim) !Explicit unrolling, this may improve performance
CASE(1)
p%coord(1)=p0%coord(1)**n
CASE(2)
p%coord(1)=p0%coord(1)**n
p%coord(2)=p0%coord(2)**n
CASE(3)
p%coord(1)=p0%coord(1)**n
p%coord(2)=p0%coord(2)**n
p%coord(3)=p0%coord(3)**n
CASE DEFAULT
p%coord=p0%coord**n
ENDSELECT
ENDFUNCTION exponentiate_PointType_real
!
!-------------------------------------------------------------------------------
!> @brief Defines the 'is equal to' operation between two points e.g. @c p0==p1
!> @param p0 the first point
!> @param p1 the second point
......
......@@ -468,150 +468,6 @@ SUBROUTINE TestPoints
bool = .NOT.(point2%dim /= 0 .OR. ALLOCATED(point2%coord))
ASSERT(bool, 'Mismatched PointType OPERATOR(-)')
!Test subtraction
COMPONENT_TEST('OPERATOR(*)')
CALL point2%init(DIM=1,X=0.5_SRK)
CALL point3%init(DIM=1,X=0.1_SRK)
point=point2*point3
ASSERT_EQ(point%dim,1,'1-D OPERATOR(*) dim')
ASSERT_APPROXEQA(point%coord(1),0.05_SRK,'1-D OPERATOR(*) coord(1)')
CALL point2%clear()
CALL point3%clear()
CALL point2%init(DIM=2,X=0.5_SRK,Y=0.6_SRK)
CALL point3%init(DIM=2,X=0.3_SRK,Y=0.2_SRK)
point=point2*point3
ASSERT_EQ(point%dim,2,'2-D OPERATOR(*) dim')
ASSERT_APPROXEQA(point%coord(1),0.15_SRK,'2-D OPERATOR(*) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.12_SRK,'2-D OPERATOR(*) coord(2)')
CALL point2%clear()
CALL point3%clear()
CALL point2%init(DIM=3,X=0.5_SRK,Y=0.6_SRK,Z=0.7_SRK)
CALL point3%init(DIM=3,X=0.3_SRK,Y=0.2_SRK,Z=0.1_SRK)
point=point2*point3
ASSERT_EQ(point%dim,3,'3-D OPERATOR(*) dim')
ASSERT_APPROXEQA(point%coord(1),0.15_SRK,'3-D OPERATOR(*) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.12_SRK,'3-D OPERATOR(*) coord(2)')
ASSERT_APPROXEQA(point%coord(3),0.07_SRK,'3-D OPERATOR(*) coord(3)')
CALL point2%clear()
CALL point3%clear()
CALL point2%init(DIM=4,COORD=[0.5_SRK,0.6_SRK,0.7_SRK,0.8_SRK])
CALL point3%init(DIM=4,COORD=[0.3_SRK,0.2_SRK,0.1_SRK,0.8_SRK])
point=point2*point3
ASSERT_EQ(point%dim,4,'4-D OPERATOR(*) dim')
ASSERT_APPROXEQA(point%coord(1),0.15_SRK,'4-D OPERATOR(*) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.12_SRK,'4-D OPERATOR(*) coord(2)')
ASSERT_APPROXEQA(point%coord(3),0.07_SRK,'4-D OPERATOR(*) coord(3)')
ASSERT_APPROXEQA(point%coord(4),0.64_SRK,'4-D OPERATOR(*) coord(4)')
CALL point2%clear()
CALL point3%clear()
!Test subtraction
COMPONENT_TEST('OPERATOR(/)')
CALL point2%init(DIM=1,X=0.5_SRK)
CALL point3%init(DIM=1,X=0.1_SRK)
point=point2/point3
ASSERT_EQ(point%dim,1,'1-D OPERATOR(/) dim')
ASSERT_APPROXEQA(point%coord(1),5.0_SRK,'1-D OPERATOR(/) coord(1)')
CALL point2%clear()
CALL point3%clear()
CALL point2%init(DIM=2,X=0.6_SRK,Y=0.6_SRK)
CALL point3%init(DIM=2,X=0.3_SRK,Y=0.2_SRK)
point=point2/point3
ASSERT_EQ(point%dim,2,'2-D OPERATOR(/) dim')
ASSERT_APPROXEQA(point%coord(1),2.0_SRK,'2-D OPERATOR(/) coord(1)')
ASSERT_APPROXEQA(point%coord(2),3.0_SRK,'2-D OPERATOR(/) coord(2)')
CALL point2%clear()
CALL point3%clear()
CALL point2%init(DIM=3,X=0.6_SRK,Y=0.6_SRK,Z=0.7_SRK)
CALL point3%init(DIM=3,X=0.3_SRK,Y=0.2_SRK,Z=0.1_SRK)
point=point2/point3
ASSERT_EQ(point%dim,3,'3-D OPERATOR(/) dim')
ASSERT_APPROXEQA(point%coord(1),2.0_SRK,'3-D OPERATOR(/) coord(1)')
ASSERT_APPROXEQA(point%coord(2),3.0_SRK,'3-D OPERATOR(/) coord(2)')
ASSERT_APPROXEQA(point%coord(3),7.0_SRK,'3-D OPERATOR(/) coord(3)')
CALL point2%clear()
CALL point3%clear()
CALL point2%init(DIM=4,COORD=[0.6_SRK,0.6_SRK,0.7_SRK,0.8_SRK])
CALL point3%init(DIM=4,COORD=[0.3_SRK,0.2_SRK,0.1_SRK,0.8_SRK])
point=point2/point3
ASSERT_EQ(point%dim,4,'4-D OPERATOR(/) dim')
ASSERT_APPROXEQA(point%coord(1),2.0_SRK,'4-D OPERATOR(/) coord(1)')
ASSERT_APPROXEQA(point%coord(2),3.0_SRK,'4-D OPERATOR(/) coord(2)')
ASSERT_APPROXEQA(point%coord(3),7.0_SRK,'4-D OPERATOR(/) coord(3)')
ASSERT_APPROXEQA(point%coord(4),1.0_SRK,'4-D OPERATOR(/) coord(4)')
CALL point2%clear()
CALL point3%clear()
!Test subtraction
COMPONENT_TEST('OPERATOR(**) real')
CALL point2%init(DIM=1,X=5.0_SRK)
point=point2**2.0_SRK
ASSERT_EQ(point%dim,1,'1-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),25.0_SRK,'1-D OPERATOR(**) coord(1)')
CALL point2%clear()
CALL point2%init(DIM=2,X=0.6_SRK,Y=0.5_SRK)
point=point2**2.0_SRK
ASSERT_EQ(point%dim,2,'2-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),0.36_SRK,'2-D OPERATOR(**) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.25_SRK,'2-D OPERATOR(**) coord(2)')
CALL point2%clear()
CALL point2%init(DIM=3,X=0.6_SRK,Y=0.6_SRK,Z=0.7_SRK)
point=point2**2.0_SRK
ASSERT_EQ(point%dim,3,'3-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),0.36_SRK,'3-D OPERATOR(**) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.36_SRK,'3-D OPERATOR(**) coord(2)')
ASSERT_APPROXEQA(point%coord(3),0.49_SRK,'3-D OPERATOR(**) coord(3)')
CALL point2%clear()
CALL point2%init(DIM=4,COORD=[0.6_SRK,0.6_SRK,0.7_SRK,0.8_SRK])
point=point2**2.0_SRK
ASSERT_EQ(point%dim,4,'4-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),0.36_SRK,'4-D OPERATOR(**) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.36_SRK,'4-D OPERATOR(**) coord(2)')
ASSERT_APPROXEQA(point%coord(3),0.49_SRK,'4-D OPERATOR(**) coord(3)')
ASSERT_APPROXEQA(point%coord(4),0.64_SRK,'4-D OPERATOR(**) coord(4)')
CALL point2%clear()
!Test subtraction
COMPONENT_TEST('OPERATOR(**) integer')
CALL point2%init(DIM=1,X=5.0_SRK)
point=point2**2_SIK
ASSERT_EQ(point%dim,1,'1-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),25.0_SRK,'1-D OPERATOR(**) coord(1)')
CALL point2%clear()
CALL point2%init(DIM=2,X=0.6_SRK,Y=0.5_SRK)
point=point2**2_SIK
ASSERT_EQ(point%dim,2,'2-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),0.36_SRK,'2-D OPERATOR(**) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.25_SRK,'2-D OPERATOR(**) coord(2)')
CALL point2%clear()
CALL point2%init(DIM=3,X=0.6_SRK,Y=0.6_SRK,Z=0.7_SRK)
point=point2**2_SIK
ASSERT_EQ(point%dim,3,'3-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),0.36_SRK,'3-D OPERATOR(**) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.36_SRK,'3-D OPERATOR(**) coord(2)')
ASSERT_APPROXEQA(point%coord(3),0.49_SRK,'3-D OPERATOR(**) coord(3)')
CALL point2%clear()
CALL point2%init(DIM=4,COORD=[0.6_SRK,0.6_SRK,0.7_SRK,0.8_SRK])
point=point2**2_SIK
ASSERT_EQ(point%dim,4,'4-D OPERATOR(**) dim')
ASSERT_APPROXEQA(point%coord(1),0.36_SRK,'4-D OPERATOR(**) coord(1)')
ASSERT_APPROXEQA(point%coord(2),0.36_SRK,'4-D OPERATOR(**) coord(2)')
ASSERT_APPROXEQA(point%coord(3),0.49_SRK,'4-D OPERATOR(**) coord(3)')
ASSERT_APPROXEQA(point%coord(4),0.64_SRK,'4-D OPERATOR(**) coord(4)')
CALL point2%clear()
COMPONENT_TEST('OPERATOR(==)')
CALL point2%init(DIM=4,COORD=(/0.5_SRK,0.6_SRK,0.7_SRK,0.8_SRK/))
CALL point3%init(DIM=4,COORD=(/0.5_SRK,0.6_SRK,0.7_SRK,0.80000000000002_SRK/))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment