Skip to content

Commit aa7bd0f

Browse files
authored
Merge pull request #53 from SCOREC/cws/integration
add support for linear and quadratic triangle integration
2 parents c7bcb47 + 7a61674 commit aa7bd0f

13 files changed

+970
-220
lines changed

CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(CMakePackageConfigHelpers)
77

88
option(MeshFields_USE_Cabana "Build with the Cabana storage backend" OFF)
99

10+
find_package(Kokkos REQUIRED)
1011
find_package(Omega_h REQUIRED)
1112
#Clear the omegah compilation flags that it passes to cuda. Using the
1213
# kokkos target, and nvcc_wrapper, provide sufficient flags.
@@ -17,11 +18,14 @@ if(MeshFields_USE_Cabana)
1718
endif()
1819

1920
set(MESHFIELD_HEADERS
21+
src/MeshField_Defines.hpp
2022
src/MeshField_Utility.hpp
2123
src/MeshField_Macros.hpp
2224
src/KokkosController.hpp
2325
src/MeshField_Element.hpp
26+
src/MeshField_Integrate.hpp
2427
src/MeshField_Shape.hpp
28+
src/MeshField_ShapeField.hpp
2529
src/MeshField_Fail.hpp
2630
src/MeshField_For.hpp
2731
src/MeshField_Reduce.hpp
@@ -42,12 +46,13 @@ set(MESHFIELD_SOURCES
4246

4347
add_library(meshfields ${MESHFIELD_SOURCES})
4448

45-
target_compile_features(meshfields INTERFACE cxx_std_17)
49+
target_compile_features(meshfields INTERFACE cxx_std_20)
4650
target_include_directories(meshfields
4751
PUBLIC
4852
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>" # for MeshField_Config.hpp
4953
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
5054
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
55+
target_link_libraries(meshfields INTERFACE Kokkos::kokkos)
5156
target_link_libraries(meshfields INTERFACE Omega_h::omega_h)
5257
if(Kokkos_ENABLE_CUDA)
5358
target_compile_options(meshfields INTERFACE "--expt-relaxed-constexpr")
@@ -159,8 +164,10 @@ endfunction()
159164
meshfields_add_exe(KokkosTests test/testKokkos.cpp)
160165
meshfields_add_exe(SerializationTests test/testSerialize.cpp)
161166
meshfields_add_exe(ElementTests test/testElement.cpp)
167+
meshfields_add_exe(ElementJacobian1d test/testElementJacobian1d.cpp)
168+
meshfields_add_exe(ElementJacobian2d test/testElementJacobian2d.cpp)
169+
meshfields_add_exe(CountIntegrator test/testCountIntegrator.cpp)
162170
meshfields_add_exe(OmegahElementTests test/testOmegahElement.cpp)
163-
meshfields_add_exe(OmegahCoordFieldTest test/testOmegahCoordField.cpp)
164171
meshfields_add_exe(ExceptionTest test/testExceptions.cpp)
165172

166173
if(MeshFields_USE_Cabana)
@@ -173,8 +180,10 @@ endif()
173180
test_func(KokkosTests ./KokkosTests)
174181
test_func(SerializationTests ./SerializationTests)
175182
test_func(ElementTests ./ElementTests)
183+
test_func(ElementJacobian1d ./ElementJacobian1d)
184+
test_func(ElementJacobian2d ./ElementJacobian2d)
185+
test_func(CountIntegrator ./CountIntegrator)
176186
test_func(OmegahElementTests ./OmegahElementTests)
177-
test_func(OmegahCoordFieldTest ./OmegahCoordFieldTest)
178187
if(MeshFields_USE_EXCEPTIONS)
179188
# exception caught - no error
180189
test_func(ExceptionTest ./ExceptionTest)

src/MeshField.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ template <typename ExecutionSpace, template <typename...> typename Controller =
3636
MeshField::KokkosController>
3737
decltype(MeshField::CreateCoordinateField<ExecutionSpace, Controller>(
3838
MeshField::MeshInfo()))
39-
createCoordinateField(MeshField::MeshInfo mesh_info, Omega_h::Reals coords) {
39+
createCoordinateField(const MeshField::MeshInfo &mesh_info,
40+
Omega_h::Reals coords) {
4041
const auto meshDim = mesh_info.dim;
4142
auto coordField =
4243
MeshField::CreateCoordinateField<ExecutionSpace, Controller>(mesh_info);
@@ -49,6 +50,11 @@ createCoordinateField(MeshField::MeshInfo mesh_info, Omega_h::Reals coords) {
4950
return coordField;
5051
}
5152

53+
} // anonymous namespace
54+
55+
namespace MeshField {
56+
57+
namespace Omegah {
5258
struct LinearTriangleToVertexField {
5359
Omega_h::LOs triVerts;
5460
LinearTriangleToVertexField(Omega_h::Mesh &mesh)
@@ -159,9 +165,7 @@ template <int ShapeOrder> auto getTriangleElement(Omega_h::Mesh &mesh) {
159165
}
160166
}
161167

162-
} // namespace
163-
164-
namespace MeshField {
168+
} // namespace Omegah
165169

166170
template <typename ExecutionSpace, template <typename...> typename Controller =
167171
MeshField::KokkosController>
@@ -210,9 +214,9 @@ class OmegahMeshField {
210214
}
211215

212216
// evaluate a field at the specified local coordinate for each triangle
213-
template <typename AnalyticFunction, typename ViewType, typename ShapeField>
217+
template <typename ViewType, typename ShapeField>
214218
auto triangleLocalPointEval(ViewType localCoords, size_t NumPtsPerElem,
215-
AnalyticFunction func, ShapeField field) {
219+
ShapeField field) {
216220
const auto MeshDim = 2;
217221
if (mesh.dim() != MeshDim) {
218222
MeshField::fail("input mesh must be 2d\n");
@@ -222,7 +226,7 @@ class OmegahMeshField {
222226
MeshField::fail("input field order must be 1 or 2\n");
223227
}
224228

225-
const auto [shp, map] = getTriangleElement<ShapeOrder>(mesh);
229+
const auto [shp, map] = Omegah::getTriangleElement<ShapeOrder>(mesh);
226230

227231
MeshField::FieldElement f(meshInfo.numTri, field, shp, map);
228232
auto offsets = createOffsets(meshInfo.numTri, NumPtsPerElem);

0 commit comments

Comments
 (0)