Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
72d3374
interpolator base class, tests [breaking]
Fuad-HH Jan 18, 2025
a1a4196
working single mesh interpolation class
Fuad-HH Jan 22, 2025
3ea79c2
interpolator test compares each entry with expected
Fuad-HH Jan 22, 2025
c8a268e
interpolator test passes for mesh to mesh
Fuad-HH Jan 23, 2025
ab1e73e
adding c api
Fuad-HH Feb 20, 2025
c392bf4
add omega_h mesh handle struct
Fuad-HH Feb 21, 2025
8b78bf1
fortran api for interpolator
Fuad-HH Feb 21, 2025
69ad666
fortran and c api to read Omega_h mesh from file
Fuad-HH Feb 21, 2025
c87ffef
added test_interpolator_fortran
Fuad-HH Feb 21, 2025
7eeeaee
interpolator frotran api test correction
Fuad-HH Feb 21, 2025
2831e82
added pcms_interpolate function
Fuad-HH Feb 21, 2025
afd2480
test pcms interpolator api
Fuad-HH Feb 21, 2025
fdf58ed
point cloud based search working
Fuad-HH May 6, 2025
28e2406
point cloud search
Fuad-HH May 14, 2025
d4eb4b5
merge c and fortran api with develop
Fuad-HH May 19, 2025
c9557b9
mesh based and mixed interpolator for degas2 xgc coupling
Fuad-HH Sep 16, 2025
ed67fcc
minor parameter changes for better interpolation
Fuad-HH Sep 16, 2025
d8a8413
Merge branch 'mergecfortapi' of github.com:Fuad-HH/pcms into mergecfo…
Fuad-HH Sep 17, 2025
b91712c
get number of mesh elements from interpolation creating call
Fuad-HH Sep 17, 2025
bd842e2
add xgc node to degas2 centroid interpolation
Fuad-HH Sep 21, 2025
bb2dbd5
merge pcms interpolator and its c/fortran API with develop
Fuad-HH Sep 29, 2025
04a178b
fix merging error with interpolator normalization
Fuad-HH Sep 30, 2025
d9bd71f
fix interpolation class test partially (the values)
Fuad-HH Oct 9, 2025
53e53b1
divided point cloud support strcuture search
Fuad-HH Oct 10, 2025
cf8ff02
adj searches use helper functions to adapt radius
Fuad-HH Oct 10, 2025
3269492
clang-format on the changed source files
Fuad-HH Oct 10, 2025
679b493
replace prints with pcms::printInfo or Error
Fuad-HH Oct 14, 2025
5fd2ed2
interpolation parameters exposed to fortran api
Fuad-HH Oct 14, 2025
da24d7a
separate mpi comm for all mesh readers
Fuad-HH Oct 15, 2025
37d7b7f
remove assertion skip
Fuad-HH Nov 3, 2025
ebaa642
add printDebugInfo and fix typo
Fuad-HH Nov 3, 2025
fccd134
check pointers not pointing same array when copying
Fuad-HH Nov 3, 2025
7f9d9e3
add test case to test a real example of interpolation
Fuad-HH Nov 13, 2025
3cbfdf6
better parameters
Fuad-HH Nov 13, 2025
c981b25
add virtual destructor
Fuad-HH Nov 13, 2025
4039ee5
rename MLSMeshInterpolation
Fuad-HH Nov 13, 2025
2fdf849
Unify interpolator handles in C/Fortran API
Fuad-HH Nov 14, 2025
225fdf7
refactor ltx interpolation test, improved verification
Fuad-HH Nov 14, 2025
4013be7
merge develop
Fuad-HH Nov 14, 2025
5120c21
remove MPI_Comm_dup for omega_h reads
Fuad-HH Nov 20, 2025
ceb6334
minor refactorings
Fuad-HH Nov 20, 2025
ce86584
fix node file read
Fuad-HH Nov 20, 2025
0f09569
make decay_factor and lambda parameters
Fuad-HH Nov 21, 2025
833b2c4
remove degas2xgc c/fortran API
Fuad-HH Nov 21, 2025
acfd98d
replace mesh in interpolation test
Fuad-HH Nov 21, 2025
15a42ab
temporary fix for ltx interpolation test
Fuad-HH Nov 21, 2025
ce23d76
add PCMS_PRINT_ENABLED for printDebugInfo
Fuad-HH Nov 21, 2025
a2ab568
add doc to interpolation_base.h
Fuad-HH Nov 21, 2025
cbed4e1
add doc to interpolator.h
Fuad-HH Nov 21, 2025
35d20d4
temporary fix to print fail log
Fuad-HH Nov 21, 2025
b10cfb1
always print log
Fuad-HH Nov 21, 2025
e2f2287
Revert "always print log"
Fuad-HH Nov 21, 2025
38644f0
Revert "temporary fix to print fail log"
Fuad-HH Nov 21, 2025
ccdca5e
rename omega_h mesh handle api
Fuad-HH Dec 5, 2025
d2d3268
divide up mesh and library handle
Fuad-HH Dec 5, 2025
682cf37
separate header for mesh
Fuad-HH Dec 5, 2025
bc94d32
rename mesh and library handle
Fuad-HH Dec 7, 2025
a5d0f17
uint->unsigned
jacobmerson Dec 7, 2025
f7678fe
formatting with clang-format
jacobmerson Dec 7, 2025
fff5adc
add specific versions to workflow for redev and meshfields
jacobmerson Dec 7, 2025
1300e3f
Merge branch 'develop' into mergecfortapi
jacobmerson Dec 7, 2025
7bb09ba
Merge branch 'develop' into mergecfortapi
jacobmerson Dec 9, 2025
45cc9d5
add additional debugging output in ltx testcase
jacobmerson Dec 9, 2025
b59c425
make sure test log is always output
jacobmerson Dec 9, 2025
9e16b03
use git has for omega-h version in workflow until
jacobmerson Dec 9, 2025
fab3d06
change export name
Fuad-HH Dec 9, 2025
e357250
add kokkoskernel hint
Fuad-HH Dec 9, 2025
ea9549b
make cmake verbose
Fuad-HH Dec 9, 2025
ae4b8f4
debug-output
Fuad-HH Dec 9, 2025
e592902
make kokkoskernels private link
jacobmerson Dec 10, 2025
8f8d161
fix build so mls_interpolation.hpp does not need the impl included.
jacobmerson Dec 11, 2025
86715bb
add kokkos kernels link to unit test
jacobmerson Dec 11, 2025
3c8d25f
add interpolator target to pcms::pcms
jacobmerson Dec 11, 2025
4c3f7f6
rework capi targets
jacobmerson Dec 11, 2025
86ce66f
add debugging output to the installation test case
jacobmerson Dec 11, 2025
4189201
rework fortranapi targets
jacobmerson Dec 11, 2025
68774c6
update interpolator targets name
jacobmerson Dec 11, 2025
76b88bd
use pcms::pcms in example build directory
jacobmerson Dec 11, 2025
b7eee41
reorder config file to move interpolator target before c/fortran apis
jacobmerson Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/cmake-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ jobs:
with:
repo-name: 'omega_h'
repo-path: 'SCOREC/omega_h'
repo-ref: 'scorec-v11.0.0'
# set this to a version number when the following issue is closed
# https://github.com/SCOREC/omega_h/issues/195
repo-ref: 'f1eae45f11a166b3f01e2dace233643711ec92be'
cache: true
options: '-DCMAKE_CXX_COMPILER=`which mpicxx`
-DCMAKE_C_COMPILER=`which mpicc`
Expand All @@ -98,7 +100,7 @@ jobs:
with:
repo-name: 'meshFields'
repo-path: 'SCOREC/meshFields'
repo-ref: ''
repo-ref: 'b1482bbba288df210784b2345eae08e34faabdc4'
cache: true
options: '-DCMAKE_CXX_COMPILER=`which mpicxx`
-DCMAKE_C_COMPILER=`which mpicc`
Expand Down Expand Up @@ -220,16 +222,25 @@ jobs:
run: ctest --test-dir ${{ runner.temp }}/build-pcms --output-on-failure

- name: Print Test
if: always()
run: cat ${{ runner.temp }}/build-pcms/Testing/Temporary/LastTest.log

- name: Test PCMS Installation
shell: bash
run: |
# Configure and build the test
# it should only ask for pcms_DIR/ROOT to find all dependencies
ls ${{ runner.temp }}/build-pcms/install/lib/cmake/pcms
echo "-------- PCMS CONFIG -------------"
cat ${{ runner.temp }}/build-pcms/install/lib/cmake/pcms/pcms-config.cmake
echo "-------- PCMS TARGETS -------------"
cat ${{ runner.temp }}/build-pcms/install/lib/cmake/pcms/pcms-targets.cmake
echo "-------- PCMS INTERPOLATOR TARGETS -------------"
cat ${{ runner.temp }}/build-pcms/install/lib/cmake/pcms/pcms_interpolator-targets.cmake
export VERBOSE=1
cmake \
-B ${{github.workspace}}/examples/external-usage-example/build \
-S ${{github.workspace}}/examples/external-usage-example/ \
-Dpcms_DIR=${{ runner.temp }}/build-pcms/install/lib/cmake/pcms \

--debug-output
cmake --build ${{github.workspace}}/examples/external-usage-example/build
9 changes: 8 additions & 1 deletion config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
include(CMakeFindDependencyMacro)
find_dependency(redev CONFIG HINTS @redev_DIR@)
find_dependency(Kokkos CONFIG HINTS @Kokkos_DIR@)
find_dependency(KokkosKernels CONFIG HINTS @KokkosKernels_DIR@)
find_dependency(meshfields CONFIG HINTS @meshfields_DIR@)
find_dependency(ADIOS2 CONFIG HINTS @ADIOS2_DIR@)
find_dependency(MPI)
Expand All @@ -16,14 +17,20 @@ if(@PCMS_ENABLE_OMEGA_H@)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/pcms_core-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/pcms_interpolator-targets.cmake")

if(@PCMS_ENABLE_C@)
include("${CMAKE_CURRENT_LIST_DIR}/pcms_capi_core-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/pcms_capi_interpolator-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/pcms_capi-targets.cmake")
endif()

if(@PCMS_ENABLE_Fortran@)
include("${CMAKE_CURRENT_LIST_DIR}/pcms_fortranapi_core-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/pcms_fortranapi_interpolator-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/pcms_fortranapi-targets.cmake")
endif()

include("${CMAKE_CURRENT_LIST_DIR}/pcms-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/pcms_interpolator-targets.cmake")
# must be called at the end of the config file
check_required_components(pcms)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ if(PCMS_ENABLE_Fortran)
endif()

add_subdirectory(pcms/interpolator)
target_link_libraries(pcms_pcms INTERFACE pcms::interpolator)

install(
TARGETS pcms_pcms
Expand Down
68 changes: 60 additions & 8 deletions src/pcms/capi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
add_library(pcms_capi client.cpp kokkos.cpp)
add_library(pcms::capi ALIAS pcms_capi)
add_library(pcms_capi_core client.cpp kokkos.cpp)
add_library(pcms::capi::core ALIAS pcms_capi_core)

target_link_libraries(
pcms_capi
pcms_capi_core
PUBLIC MPI::MPI_C
PRIVATE pcms::core)

target_include_directories(
pcms_capi
pcms_capi_core
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>" # this makes our
# include path
# pcms/capi
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pcms/capi>")

set(CAPI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/client.h
set(CAPI_CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/client.h
${CMAKE_CURRENT_SOURCE_DIR}/kokkos.h)
set_target_properties(
pcms_capi PROPERTIES PUBLIC_HEADER "${CAPI_HEADERS}" OUTPUT_NAME pcmscapi
EXPORT_NAME capi)
pcms_capi_core PROPERTIES PUBLIC_HEADER "${CAPI_CORE_HEADERS}" OUTPUT_NAME pcmscapicore
EXPORT_NAME capi::core)

add_library(pcms_capi_interpolator mesh.cpp interpolator.cpp kokkos.cpp)
add_library(pcms::capi::interpolator ALIAS pcms_capi_interpolator)
target_link_libraries(pcms_capi_interpolator PUBLIC MPI::MPI_C PRIVATE pcms::interpolator)
target_include_directories(pcms_capi_interpolator
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>" # this makes the module path cpms/capi
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pcms/capi>")
set(CAPI_INTERPOLATOR_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/interpolator.h
${CMAKE_CURRENT_SOURCE_DIR}/mesh.h)
set_target_properties(pcms_capi_interpolator
PROPERTIES PUBLIC_HEADERS "${CAPI_INTERPOLATOR_HEADERS}"
OUTPUT_NAME pcmscapiinterpolator
EXPORT_NAME capi::interpolator)

# high level interface target
add_library(pcms_capi INTERFACE)
add_library(pcms::capi ALIAS pcms_capi)
set_target_properties(pcms_capi PROPERTIES EXPORT_NAME capi)
# link capi libraries to a high level interface library
target_link_libraries(pcms_capi INTERFACE pcms::capi::core)
target_link_libraries(pcms_capi INTERFACE pcms::capi::interpolator)
install(
TARGETS pcms_capi
EXPORT pcms_capi-targets
Expand All @@ -25,8 +48,37 @@ install(
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms/capi/)
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms)
install(
EXPORT pcms_capi-targets
NAMESPACE pcms::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms)

# library targets
install(
TARGETS pcms_capi_core
EXPORT pcms_capi_core-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms/capi/)
install(
EXPORT pcms_capi_core-targets
NAMESPACE pcms::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms)

install(
TARGETS pcms_capi_interpolator
EXPORT pcms_capi_interpolator-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms/capi/)
install(
EXPORT pcms_capi_interpolator-targets
NAMESPACE pcms::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms)
134 changes: 134 additions & 0 deletions src/pcms/capi/interpolator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//
// Created by hasanm4 on 2/17/25.
//
#include <pcms/capi/kokkos.h>
#include <pcms/capi/interpolator.h>
#include <pcms/interpolator/interpolation_base.h>
#include <Omega_h_file.hpp>
#include <Omega_h_library.hpp>
#include <Omega_h_mesh.hpp>
#include <pcms/print.h>

//[[nodiscard]]
PcmsInterpolatorHandle pcms_create_interpolator(PcmsOmegaHMeshHandle oh_mesh,
double radius)
{
auto* source_mesh = reinterpret_cast<Omega_h::Mesh*>(oh_mesh.mesh_handle);
auto* interpolator = new MLSMeshInterpolation(*source_mesh, radius);
return {reinterpret_cast<void*>(interpolator)};
}

PcmsInterpolatorHandle pcms_create_point_based_interpolator(
void* source_points, int source_points_size, void* target_points,
int target_points_size, double radius, int degree, int min_req_supports,
double lambda, double decay_factor)
{

auto source_points_view = pcms::Rank1View<double, pcms::HostMemorySpace>(
reinterpret_cast<double*>(source_points), source_points_size);
auto target_points_view = pcms::Rank1View<double, pcms::HostMemorySpace>(
reinterpret_cast<double*>(target_points), target_points_size);
auto* interpolator = new MLSPointCloudInterpolation(
source_points_view, target_points_view, 2, radius, min_req_supports, degree,
true, lambda, decay_factor);
return {reinterpret_cast<void*>(interpolator)};
}

Omega_h::HostRead<Omega_h::Real> read_mesh_centroids(const char* mesh_filename,
int& num_elements)
{
auto fname = std::string(mesh_filename);
fname = fname.erase(fname.find_last_not_of(" \n\r\t") + 1);
pcms::printInfo("The interpolator got dg2 mesh file: %s\n", fname.c_str());
auto mesh_lib = Omega_h::Library(nullptr, nullptr, MPI_COMM_SELF);
auto mesh = Omega_h::binary::read(fname, mesh_lib.world());
auto elem_centroids = getCentroids(mesh);
num_elements = mesh.nelems();
OMEGA_H_CHECK_PRINTF(num_elements * 2 == elem_centroids.size(),
"Mesh element centroids size does not match the number "
"of elements %d != %d\n",
num_elements * 2, elem_centroids.size());

pcms::printInfo("Number of element centroids: %d\n",
elem_centroids.size() / 2);
OMEGA_H_CHECK_PRINTF(mesh.dim() == 2, "Mesh dimension is not 2D %d\n",
mesh.dim());

return {elem_centroids};
}

void write_void_int_pointer(void* pointer, int value)
{
if (pointer) {
int* dg2_elem_count_int = reinterpret_cast<int*>(pointer);
*dg2_elem_count_int = value;
} else {
pcms::printError("Error: NULL pointer provided to write integer value\n");
}
}

PcmsInterpolatorHandle pcms_create_degas2xgcnode_interpolator(
void* target_points, int target_points_size, const char* dg2_mesh_filename,
double radius, void* dg2_elem_count, int degree, int min_req_supports,
double lambda, double decay_factor)
{
// same as above pcms_create_degas2xgc_interpolator but the target points are
// provided by the user this is useful when the corresponding xgc mesh is not
// available

int dg2_num_elems = 0;
Omega_h::HostRead<Omega_h::Real> dg2_elem_centroids_host =
read_mesh_centroids(dg2_mesh_filename, dg2_num_elems);
write_void_int_pointer(dg2_elem_count, dg2_num_elems);

return pcms_create_point_based_interpolator(
(void*)dg2_elem_centroids_host.data(), dg2_elem_centroids_host.size(),
target_points, target_points_size, radius, degree, min_req_supports, lambda,
decay_factor);
}

PcmsInterpolatorHandle pcms_create_xgcnodedegas2_interpolator(
const char* dg2_mesh_filename, void* source_points, int source_points_size,
double radius, void* dg2_elem_count, int degree, int min_req_supports,
double lambda, double decay_factor)
{
int dg2_num_elems = 0;
Omega_h::HostRead<Omega_h::Real> dg2_elem_centroids_host =
read_mesh_centroids(dg2_mesh_filename, dg2_num_elems);
write_void_int_pointer(dg2_elem_count, dg2_num_elems);

return pcms_create_point_based_interpolator(
source_points, source_points_size, (void*)dg2_elem_centroids_host.data(),
dg2_elem_centroids_host.size(), radius, degree, min_req_supports, lambda,
decay_factor);
}

void pcms_destroy_interpolator(PcmsInterpolatorHandle interpolator)
{
if (interpolator.pointer != nullptr) {
delete reinterpret_cast<InterpolationBase*>(interpolator.pointer);
}
}

void pcms_interpolate(PcmsInterpolatorHandle interpolator, void* input,
int input_size, void* output, int output_size)
{
auto* mls_interpolator =
reinterpret_cast<InterpolationBase*>(interpolator.pointer);

OMEGA_H_CHECK_PRINTF(
input_size == mls_interpolator->getSourceSize(),
"Input array size does not match the source size %d != %zu\n", input_size,
mls_interpolator->getSourceSize());
OMEGA_H_CHECK_PRINTF(
output_size == mls_interpolator->getTargetSize(),
"Output array size does not match the target size %d != %zu\n", output_size,
mls_interpolator->getTargetSize());

pcms::Rank1View<double, pcms::HostMemorySpace> input_array(
reinterpret_cast<double*>(input), input_size);
pcms::Rank1View<double, pcms::HostMemorySpace> output_array(
reinterpret_cast<double*>(output), output_size);

mls_interpolator->eval(input_array, output_array);
}
Loading