-
Notifications
You must be signed in to change notification settings - Fork 16
C and Fortran API for Interpolator #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 a1a4196
working single mesh interpolation class
Fuad-HH 3ea79c2
interpolator test compares each entry with expected
Fuad-HH c8a268e
interpolator test passes for mesh to mesh
Fuad-HH ab1e73e
adding c api
Fuad-HH c392bf4
add omega_h mesh handle struct
Fuad-HH 8b78bf1
fortran api for interpolator
Fuad-HH 69ad666
fortran and c api to read Omega_h mesh from file
Fuad-HH c87ffef
added test_interpolator_fortran
Fuad-HH 7eeeaee
interpolator frotran api test correction
Fuad-HH 2831e82
added pcms_interpolate function
Fuad-HH afd2480
test pcms interpolator api
Fuad-HH fdf58ed
point cloud based search working
Fuad-HH 28e2406
point cloud search
Fuad-HH d4eb4b5
merge c and fortran api with develop
Fuad-HH c9557b9
mesh based and mixed interpolator for degas2 xgc coupling
Fuad-HH ed67fcc
minor parameter changes for better interpolation
Fuad-HH d8a8413
Merge branch 'mergecfortapi' of github.com:Fuad-HH/pcms into mergecfo…
Fuad-HH b91712c
get number of mesh elements from interpolation creating call
Fuad-HH bd842e2
add xgc node to degas2 centroid interpolation
Fuad-HH bb2dbd5
merge pcms interpolator and its c/fortran API with develop
Fuad-HH 04a178b
fix merging error with interpolator normalization
Fuad-HH d9bd71f
fix interpolation class test partially (the values)
Fuad-HH 53e53b1
divided point cloud support strcuture search
Fuad-HH cf8ff02
adj searches use helper functions to adapt radius
Fuad-HH 3269492
clang-format on the changed source files
Fuad-HH 679b493
replace prints with pcms::printInfo or Error
Fuad-HH 5fd2ed2
interpolation parameters exposed to fortran api
Fuad-HH da24d7a
separate mpi comm for all mesh readers
Fuad-HH 37d7b7f
remove assertion skip
Fuad-HH ebaa642
add printDebugInfo and fix typo
Fuad-HH fccd134
check pointers not pointing same array when copying
Fuad-HH 7f9d9e3
add test case to test a real example of interpolation
Fuad-HH 3cbfdf6
better parameters
Fuad-HH c981b25
add virtual destructor
Fuad-HH 4039ee5
rename MLSMeshInterpolation
Fuad-HH 2fdf849
Unify interpolator handles in C/Fortran API
Fuad-HH 225fdf7
refactor ltx interpolation test, improved verification
Fuad-HH 4013be7
merge develop
Fuad-HH 5120c21
remove MPI_Comm_dup for omega_h reads
Fuad-HH ceb6334
minor refactorings
Fuad-HH ce86584
fix node file read
Fuad-HH 0f09569
make decay_factor and lambda parameters
Fuad-HH 833b2c4
remove degas2xgc c/fortran API
Fuad-HH acfd98d
replace mesh in interpolation test
Fuad-HH 15a42ab
temporary fix for ltx interpolation test
Fuad-HH ce23d76
add PCMS_PRINT_ENABLED for printDebugInfo
Fuad-HH a2ab568
add doc to interpolation_base.h
Fuad-HH cbed4e1
add doc to interpolator.h
Fuad-HH 35d20d4
temporary fix to print fail log
Fuad-HH b10cfb1
always print log
Fuad-HH e2f2287
Revert "always print log"
Fuad-HH 38644f0
Revert "temporary fix to print fail log"
Fuad-HH ccdca5e
rename omega_h mesh handle api
Fuad-HH d2d3268
divide up mesh and library handle
Fuad-HH 682cf37
separate header for mesh
Fuad-HH bc94d32
rename mesh and library handle
Fuad-HH a5d0f17
uint->unsigned
jacobmerson f7678fe
formatting with clang-format
jacobmerson fff5adc
add specific versions to workflow for redev and meshfields
jacobmerson 1300e3f
Merge branch 'develop' into mergecfortapi
jacobmerson 7bb09ba
Merge branch 'develop' into mergecfortapi
jacobmerson 45cc9d5
add additional debugging output in ltx testcase
jacobmerson b59c425
make sure test log is always output
jacobmerson 9e16b03
use git has for omega-h version in workflow until
jacobmerson fab3d06
change export name
Fuad-HH e357250
add kokkoskernel hint
Fuad-HH ea9549b
make cmake verbose
Fuad-HH ae4b8f4
debug-output
Fuad-HH e592902
make kokkoskernels private link
jacobmerson 8f8d161
fix build so mls_interpolation.hpp does not need the impl included.
jacobmerson 86715bb
add kokkos kernels link to unit test
jacobmerson 3c8d25f
add interpolator target to pcms::pcms
jacobmerson 4c3f7f6
rework capi targets
jacobmerson 86ce66f
add debugging output to the installation test case
jacobmerson 4189201
rework fortranapi targets
jacobmerson 68774c6
update interpolator targets name
jacobmerson 76b88bd
use pcms::pcms in example build directory
jacobmerson b7eee41
reorder config file to move interpolator target before c/fortran apis
jacobmerson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( | ||
Fuad-HH marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (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); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.