Skip to content

Commit

Permalink
Intrepid2: added tests for HGRAD basis
Browse files Browse the repository at this point in the history
  • Loading branch information
mperego committed Sep 21, 2024
1 parent b46d799 commit 8d49242
Show file tree
Hide file tree
Showing 65 changed files with 5,404 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,16 @@ namespace Intrepid2 {
Impl::Basis_HGRAD_QUAD_C1_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
});
break;
default: {}
case OPERATOR_CURL:
Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
Impl::Basis_HGRAD_QUAD_C1_FEM::Serial<OPERATOR_CURL>::getValues( output, input);
});
break;
default: {
INTREPID2_TEST_FOR_ABORT( true, ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_C1_FEM::getValues), Operator Type not supported.");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,17 @@ namespace Intrepid2 {
SerialGrad::getValues( output, input);
});
break;
default: {}
case OPERATOR_CURL:
Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
using SerialCurl = typename Impl::Basis_HGRAD_QUAD_DEG2_FEM<serendipity>::Serial<OPERATOR_CURL>;
SerialCurl::getValues( output, input);
});
break;
default: {
INTREPID2_TEST_FOR_ABORT( true, ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_DEG2_FEM::getValues), Operator Type not supported.");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,13 @@ namespace Intrepid2 {
Impl::Basis_HGRAD_QUAD_Cn_FEM::Serial<OPERATOR_CURL>::getValues( output, input, work, this->vinv_ );
});
break;
default: {}
default: {
INTREPID2_TEST_FOR_ABORT( true,
">>> ERROR (Basis_HGRAD_QUAD_Cn_FEM): getValues not implemented for this operator");
}
}
}
}// namespace Intrepid2

} // namespace Intrepid2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,16 @@ namespace Intrepid2 {
Impl::Basis_HGRAD_TRI_C1_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
});
break;
default: {}
case OPERATOR_CURL:
Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
Impl::Basis_HGRAD_TRI_C1_FEM::Serial<OPERATOR_CURL>::getValues( output, input);
});
break;
default: {
INTREPID2_TEST_FOR_ABORT( true, ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_C1_FEM::getValues), Operator Type not supported.");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,16 @@ namespace Intrepid2 {
Impl::Basis_HGRAD_TRI_C2_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
});
break;
default: {}
case OPERATOR_CURL:
Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
Impl::Basis_HGRAD_TRI_C2_FEM::Serial<OPERATOR_CURL>::getValues( output, input);
});
break;
default: {
INTREPID2_TEST_FOR_ABORT( true, ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_C2_FEM::getValues), Operator Type not supported.");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ Basis_HGRAD_TRI_Cn_FEM( const ordinal_type order,
Impl::Basis_HGRAD_TRI_Cn_FEM::Serial<OPERATOR_GRAD>::getValues( output, input, work, this->vinv_, this->basisDegree_);
});
break;
case OPERATOR_CURL:
Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
Impl::Basis_HGRAD_TRI_Cn_FEM::Serial<OPERATOR_CURL>::getValues( output, input, work, this->vinv_, this->basisDegree_);
});
break;
default: {
INTREPID2_TEST_FOR_ABORT( true,
">>> ERROR (Basis_HGRAD_TRI_Cn_FEM): getValues not implemented for this operator");
Expand All @@ -431,4 +439,5 @@ Basis_HGRAD_TRI_Cn_FEM( const ordinal_type order,
}

} // namespace Intrepid2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ namespace Intrepid2 {
Basis_HGRAD_WEDGE_DEG2_FEM<serendipity>::Serial<opType>::
getValues( OutputViewType output,
const inputViewType input ) {
typedef typename inputViewType::value_type value_type;
switch (opType) {
case OPERATOR_VALUE: {
const auto x = input(0);
const auto y = input(1);
const auto z = input(2);
const auto w = 1.0 - x - y;
const value_type x = input(0);
const value_type y = input(1);
const value_type z = input(2);
const value_type w = 1.0 - x - y;

// output is a rank-1 array with dimensions (basisCardinality_)
if constexpr (!serendipity) {
Expand Down Expand Up @@ -80,9 +81,9 @@ namespace Intrepid2 {
break;
}
case OPERATOR_GRAD: {
const auto x = input(0);
const auto y = input(1);
const auto z = input(2);
const value_type x = input(0);
const value_type y = input(1);
const value_type z = input(2);

if constexpr (!serendipity) {
output.access(0, 0) = ((-3 + 4*x + 4*y)*(-1 + z)*z)/2.;
Expand Down Expand Up @@ -158,7 +159,7 @@ namespace Intrepid2 {
output.access(17, 1) = 4*(-1 + x + 2*y)*(-1 + z*z);
output.access(17, 2) = 8*y*(-1 + x + y)*z;
} else {
const auto w = 1.0 - x - y;
const value_type w = 1.0 - x - y;

output.access(0, 0) = -(2.0*w - 1.0 - 0.5*z)*(1.0 - z);
output.access(0, 1) = -(2.0*w - 1.0 - 0.5*z)*(1.0 - z);
Expand Down Expand Up @@ -223,9 +224,9 @@ namespace Intrepid2 {
break;
}
case OPERATOR_D2: {
const auto x = input(0);
const auto y = input(1);
const auto z = input(2);
const value_type x = input(0);
const value_type y = input(1);
const value_type z = input(2);

if constexpr (!serendipity) {
output.access(0, 0) = 2.*(-1. + z)*z;
Expand Down Expand Up @@ -356,7 +357,7 @@ namespace Intrepid2 {

} else { //serendipity element

const auto w = 1.0 - x - y;
const value_type w = 1.0 - x - y;
output.access(0, 0) = 2.0*(1.0 - z);
output.access(0, 1) = 2.0*(1.0 - z);
output.access(0, 2) = 2.0*w - 0.5 - z;
Expand Down Expand Up @@ -466,9 +467,9 @@ namespace Intrepid2 {
}
case OPERATOR_D3: {
if constexpr (!serendipity) {
const auto x = input(0);
const auto y = input(1);
const auto z = input(2);
const value_type x = input(0);
const value_type y = input(1);
const value_type z = input(2);

output.access(0, 0) = 0.;
output.access(0, 1) = 0.;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
# value types
SET(Intrepid2_TEST_ETI_VALUETYPE_NAME "")
SET(Intrepid2_TEST_ETI_VALUETYPE "")
SET(Intrepid2_TEST_ETI_SACADO "")

LIST(APPEND Intrepid2_TEST_ETI_VALUETYPE_NAME "DOUBLE")
LIST(APPEND Intrepid2_TEST_ETI_VALUETYPE "double")
Expand Down Expand Up @@ -67,6 +68,7 @@ SET(Intrepid2_TEST_ETI_FILE "test_01")

SET(Intrepid2_TEST_ETI_DEVICE_NAME "")
SET(Intrepid2_TEST_ETI_DEVICE "")

IF(Kokkos_ENABLE_CUDA)
LIST(APPEND Intrepid2_TEST_ETI_DEVICE_NAME "CUDA")
LIST(APPEND Intrepid2_TEST_ETI_DEVICE "Kokkos::Device<Kokkos::Cuda,Kokkos::CudaSpace>")
Expand Down Expand Up @@ -106,3 +108,75 @@ IF (${ETI_DEVICE_COUNT} GREATER_EQUAL 0)
ENDFOREACH()
ENDFOREACH()
ENDIF()



# test
SET(Intrepid2_TEST_ETI_FILE "test_03")

# value types
SET(Intrepid2_TEST_ETI_VALUETYPE_NAME "")
SET(Intrepid2_TEST_ETI_VALUETYPE "")
SET(Intrepid2_TEST_ETI_SACADO "")

LIST(APPEND Intrepid2_TEST_ETI_VALUETYPE_NAME "DOUBLE_DOUBLE")
LIST(APPEND Intrepid2_TEST_ETI_VALUETYPE "double,double")
LIST(APPEND Intrepid2_TEST_ETI_SACADO "0")

IF (HAVE_INTREPID2_SACADO)
LIST(APPEND Intrepid2_TEST_ETI_VALUETYPE_NAME "DFAD_DFAD")
LIST(APPEND Intrepid2_TEST_ETI_VALUETYPE "Sacado::Fad::DFad<double>,Sacado::Fad::DFad<double> ")
LIST(APPEND Intrepid2_TEST_ETI_SACADO "33")
ENDIF()

LIST(LENGTH Intrepid2_TEST_ETI_VALUETYPE_NAME ETI_VALUETYPE_COUNT)
MATH(EXPR ETI_VALUETYPE_COUNT "${ETI_VALUETYPE_COUNT}-1")

# device
SET(Intrepid2_TEST_ETI_DEVICE_NAME "")
SET(Intrepid2_TEST_ETI_DEVICE "")
IF(Kokkos_ENABLE_SERIAL)
LIST(APPEND Intrepid2_TEST_ETI_DEVICE_NAME "Serial")
LIST(APPEND Intrepid2_TEST_ETI_DEVICE "Kokkos::Device<Kokkos::Serial,Kokkos::HostSpace>")
ENDIF()
IF(Kokkos_ENABLE_OPENMP)
LIST(APPEND Intrepid2_TEST_ETI_DEVICE_NAME "OpenMP")
LIST(APPEND Intrepid2_TEST_ETI_DEVICE "Kokkos::Device<Kokkos::OpenMP,Kokkos::HostSpace>")
ENDIF()
IF(Kokkos_ENABLE_CUDA)
LIST(APPEND Intrepid2_TEST_ETI_DEVICE_NAME "CUDA")
LIST(APPEND Intrepid2_TEST_ETI_DEVICE "Kokkos::Device<Kokkos::Cuda,Kokkos::CudaSpace>")
ENDIF()
IF(Kokkos_ENABLE_HIP)
LIST(APPEND Intrepid2_TEST_ETI_DEVICE_NAME "HIP")
LIST(APPEND Intrepid2_TEST_ETI_DEVICE "Kokkos::Device<Kokkos::HIP,Kokkos::HIPSpace>")
ENDIF()

LIST(LENGTH Intrepid2_TEST_ETI_DEVICE_NAME ETI_DEVICE_COUNT)
MATH(EXPR ETI_DEVICE_COUNT "${ETI_DEVICE_COUNT}-1")

FOREACH(I RANGE ${ETI_DEVICE_COUNT})
LIST(GET Intrepid2_TEST_ETI_DEVICE_NAME ${I} ETI_DEVICE_NAME)
LIST(GET Intrepid2_TEST_ETI_DEVICE ${I} ETI_DEVICE)
#MESSAGE(STATUS "Generating TEST HGRAD_HEX_C1_FEM for ${ETI_DEVICE_NAME} with ${ETI_DEVICE}")
FOREACH(J RANGE ${ETI_VALUETYPE_COUNT})
LIST(GET Intrepid2_TEST_ETI_VALUETYPE_NAME ${J} ETI_VALUETYPE_NAME)
LIST(GET Intrepid2_TEST_ETI_VALUETYPE ${J} ETI_VALUETYPE)
LIST(GET Intrepid2_TEST_ETI_SACADO ${J} ETI_SACADO)
FOREACH(ETI_FILE IN LISTS Intrepid2_TEST_ETI_FILE)
SET(ETI_NAME "${ETI_FILE}_${ETI_DEVICE_NAME}_${ETI_VALUETYPE_NAME}")
MESSAGE(STATUS "Generating TEST: HGRAD_HEX_C1_FEM ${ETI_NAME}.cpp")
CONFIGURE_FILE(eti/${ETI_FILE}_ETI.in ${ETI_NAME}.cpp)

TRIBITS_ADD_EXECUTABLE_AND_TEST(
${ETI_NAME}
SOURCES ${ETI_NAME}.cpp
ARGS PrintItAll
NUM_MPI_PROCS 1
PASS_REGULAR_EXPRESSION "TEST PASSED"
ADD_DIR_TO_NAME
)

ENDFOREACH()
ENDFOREACH()
ENDFOREACH()
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// @HEADER
// *****************************************************************************
// Intrepid2 Package
//
// Copyright 2007 NTESS and the Intrepid2 contributors.
// SPDX-License-Identifier: BSD-3-Clause
// *****************************************************************************
// @HEADER

/** \file test_03.cpp
\brief Unit test of Intrepid2::Basis_HGRAD_HEX_C1_FEM team-level getValues.
\author Kyungjoo Kim
*/

#include "Kokkos_Core.hpp"

#define ETI_SACADO @ETI_SACADO@
#if (ETI_SACADO != 0) /// SACADO
#include "Kokkos_ViewFactory.hpp"
#include "Sacado.hpp"
#endif

#if (ETI_SACADO == 0) /// double double
#define ConstructWithLabelOutView(obj, ...) obj(#obj, __VA_ARGS__)
#define ConstructWithLabelPointView(obj, ...) obj(#obj, __VA_ARGS__)
#elif (ETI_SACADO == 11 /* SFAD SFAD */ || ETI_SACADO == 33 /* DFAD DFAD */)
constexpr int num_deriv = 3;
#define ConstructWithLabelOutView(obj, ...) obj(#obj, __VA_ARGS__, num_deriv+1)
#define ConstructWithLabelPointView(obj, ...) obj(#obj, __VA_ARGS__, num_deriv+1)
#elif (ETI_SACADO == 23)
constexpr int num_deriv = 3;
#define ConstructWithLabelOutView(obj, ...) obj(#obj, __VA_ARGS__, num_deriv+1)
#define ConstructWithLabelPointView(obj, ...) obj(#obj, __VA_ARGS__, num_deriv+1)
#elif (ETI_SACADO == 20)
constexpr int num_deriv = 2;
#define ConstructWithLabelOutView(obj, ...) obj(#obj, __VA_ARGS__, num_deriv+1)
#define ConstructWithLabelPointView(obj, ...) obj(#obj, __VA_ARGS__)
#endif

#include "test_03.hpp"

int main(int argc, char *argv[]) {

const bool verbose = (argc-1) > 0;
Kokkos::initialize();

Intrepid2::Test::HGRAD_HEX_C1_FEM_Test03<@ETI_VALUETYPE@,@ETI_DEVICE@>(verbose);

Kokkos::finalize();
return 0;
}

Loading

0 comments on commit 8d49242

Please sign in to comment.