PACMAN 0.1.0
Portable Algorithms for Coupling, Mapping, and Adaptive iNterpolation
Loading...
Searching...
No Matches
fortran_interface.h File Reference

Plain-C shim declarations for the Fortran ISO C bindings interface. More...

Go to the source code of this file.

Enumerations

enum  PACMAN_ExecSpace {
  PACMAN_SERIAL = 0x00 , PACMAN_OPENMP = 0x01 , PACMAN_THREADS = 0x02 , PACMAN_CUDA = 0x03 ,
  PACMAN_HIP = 0x04 , PACMAN_SYCL = 0x05
}
 Execution space selectors, matching PACMAN::ExecSpaces. More...
 
enum  PACMAN_RbfFunction {
  PACMAN_WENDLANDC0 = 0x10 , PACMAN_WENDLANDC2 = 0x11 , PACMAN_WENDLANDC4 = 0x12 , PACMAN_WENDLANDC6 = 0x13 ,
  PACMAN_WENDLANDC8 = 0x14
}
 RBF basis-function selectors, matching PACMAN::RbfFunctions. More...
 
enum  PACMAN_FeMethod {
  PACMAN_FE_NEAREST_NEAREST = 0xF0 , PACMAN_FE_INTERP_CLAMP = 0xF1 , PACMAN_FE_INTERP_NEAREST = 0xF2 , PACMAN_FE_INTERP_ZEROFILL = 0xF3 ,
  PACMAN_FE_INTERP_EXTRAP = 0xF4 , PACMAN_MLS = 0xF6
}
 FE method selectors, matching PACMAN::TransferMethods. More...
 

Functions

void pacman_kokkos_initialize_c (void)
 Initialize Kokkos with default settings.
 
void pacman_kokkos_finalize_c (void)
 Finalize Kokkos.
 
int pacman_best_execspace_c (void)
 Return the best execution space available in the current build.
 
int pacman_rbf_interpolate_c (int spaceDimension, int execSpace, int rbfFunction, const double *sourcePoints, int nSourcePoints, const double *sourceValues, const double *targetPoints, int nTargetPoints, double *targetValues)
 C shim for PACMAN::rbf_interpolate.
 
int pacman_fe_interpolate_c (int spaceDimension, int execSpace, int method, const double *sourcePoints, int nSourcePoints, const double *sourceValues, const int *connVal, int connValSize, const int *connOff, int connOffSize, const int *cellTypes, const double *targetPoints, int nTargetPoints, double *targetValues, int *targetStatus)
 C shim for PACMAN::fe_interpolate.
 
int pacman_mls_interpolate_c (int spaceDimension, int execSpace, const double *sourcePoints, int nSourcePoints, const double *sourceValues, const double *targetPoints, int nTargetPoints, double *targetValues)
 C shim for PACMAN::mls_interpolate.
 
int pacman_vtk_to_pacman_cell_type_c (const int *vtkTypes, int *pacmanTypes, int n)
 Convert an array of VTK cell-type IDs to PACMAN CellType values.
 
int pacman_vtk_cell_dim_c (int vtkCellType)
 Return the topological dimension for a VTK cell-type ID.
 

Detailed Description

Plain-C shim declarations for the Fortran ISO C bindings interface.

The implementation (fortran_interface.cpp) wraps PACMAN::rbf_interpolate and PACMAN::fe_interpolate using extern "C" linkage so that the Fortran module (pacman_fortran.f90) can bind to them with ISO_C_BINDING.

All integer arguments use plain int (32-bit on every supported platform) to match Fortran INTEGER(C_INT). Floating-point arguments use double to match REAL(C_DOUBLE). The selector arguments (execSpace, rbfFunction, method) accept the integer value of the corresponding PACMAN constant defined below.

Definition in file fortran_interface.h.

Enumeration Type Documentation

◆ PACMAN_ExecSpace

Execution space selectors, matching PACMAN::ExecSpaces.

Enumerator
PACMAN_SERIAL 
PACMAN_OPENMP 
PACMAN_THREADS 
PACMAN_CUDA 
PACMAN_HIP 
PACMAN_SYCL 

Definition at line 33 of file fortran_interface.h.

◆ PACMAN_FeMethod

FE method selectors, matching PACMAN::TransferMethods.

Enumerator
PACMAN_FE_NEAREST_NEAREST 
PACMAN_FE_INTERP_CLAMP 
PACMAN_FE_INTERP_NEAREST 
PACMAN_FE_INTERP_ZEROFILL 
PACMAN_FE_INTERP_EXTRAP 
PACMAN_MLS 

Definition at line 52 of file fortran_interface.h.

◆ PACMAN_RbfFunction

RBF basis-function selectors, matching PACMAN::RbfFunctions.

Enumerator
PACMAN_WENDLANDC0 
PACMAN_WENDLANDC2 
PACMAN_WENDLANDC4 
PACMAN_WENDLANDC6 
PACMAN_WENDLANDC8 

Definition at line 43 of file fortran_interface.h.

Function Documentation

◆ pacman_best_execspace_c()

int pacman_best_execspace_c ( void  )

Return the best execution space available in the current build.

Priority order: HIP > CUDA > SYCL > OpenMP > Threads > Serial. Returns -1 if no execution space is available (should not happen).

Definition at line 41 of file fortran_interface.cpp.

References PACMAN::ExecSpaces::CUDA, PACMAN::ExecSpaces::HIP, PACMAN::ExecSpaces::OPENMP, PACMAN::ExecSpaces::SERIAL, PACMAN::ExecSpaces::SYCL, and PACMAN::ExecSpaces::THREADS.

Referenced by pacman_mod::pacman_best_execspace().

◆ pacman_fe_interpolate_c()

int pacman_fe_interpolate_c ( int  spaceDimension,
int  execSpace,
int  method,
const double *  sourcePoints,
int  nSourcePoints,
const double *  sourceValues,
const int *  connVal,
int  connValSize,
const int *  connOff,
int  connOffSize,
const int *  cellTypes,
const double *  targetPoints,
int  nTargetPoints,
double *  targetValues,
int *  targetStatus 
)

C shim for PACMAN::fe_interpolate.

Connectivity arrays use CSR format (int32 values). For NEAREST_NEAREST, pass NULL for connVal, connOff, cellTypes and zero for the corresponding size arguments.

Parameters
spaceDimensionGeometric dimension (1, 2, or 3).
execSpaceExecution-space selector.
methodFE method selector (PACMAN_FeMethod).
sourcePointsRow-major source points [nSourcePoints × spaceDimension].
nSourcePointsNumber of source points.
sourceValuesSource scalar values, length nSourcePoints.
connValCSR connectivity values.
connValSizeNumber of entries in connVal.
connOffCSR connectivity offsets.
connOffSizeNumber of entries in connOff (= nElems + 1).
cellTypesPACMAN CellType per element, length connOffSize
  • 1.
targetPointsRow-major target points [nTargetPoints × spaceDimension].
nTargetPointsNumber of target points.
targetValuesCaller-allocated output, length nTargetPoints.
targetStatusCaller-allocated status output, length nTargetPoints.
Returns
0 on success, non-zero on error.

Definition at line 97 of file fortran_interface.cpp.

References PACMAN::fe_interpolate(), PACMAN::FeInterpolateResult::targetStatus, and PACMAN::FeInterpolateResult::targetValues.

Referenced by pacman_mod::pacman_fe_interpolate().

◆ pacman_kokkos_finalize_c()

void pacman_kokkos_finalize_c ( void  )

Finalize Kokkos.

Must be called after all interpolation calls are complete.

Definition at line 35 of file fortran_interface.cpp.

Referenced by pacman_mod::pacman_kokkos_finalize().

◆ pacman_kokkos_initialize_c()

void pacman_kokkos_initialize_c ( void  )

Initialize Kokkos with default settings.

Must be called before any interpolation function and only once.

Definition at line 29 of file fortran_interface.cpp.

Referenced by pacman_mod::pacman_kokkos_initialize().

◆ pacman_mls_interpolate_c()

int pacman_mls_interpolate_c ( int  spaceDimension,
int  execSpace,
const double *  sourcePoints,
int  nSourcePoints,
const double *  sourceValues,
const double *  targetPoints,
int  nTargetPoints,
double *  targetValues 
)

C shim for PACMAN::mls_interpolate.

Parameters
spaceDimensionGeometric dimension (1, 2, or 3).
execSpaceExecution-space selector (PACMAN_ExecSpace).
sourcePointsRow-major source points [nSourcePoints × spaceDimension].
nSourcePointsNumber of source points.
sourceValuesSource scalar values, length nSourcePoints.
targetPointsRow-major target points [nTargetPoints × spaceDimension].
nTargetPointsNumber of target points.
targetValuesCaller-allocated output, length nTargetPoints.
Returns
0 on success, non-zero on error.

Definition at line 138 of file fortran_interface.cpp.

References PACMAN::MLS_interpolate(), and PACMAN::MLSInterpolateResult::targetValues.

Referenced by pacman_mod::pacman_mls_interpolate().

◆ pacman_rbf_interpolate_c()

int pacman_rbf_interpolate_c ( int  spaceDimension,
int  execSpace,
int  rbfFunction,
const double *  sourcePoints,
int  nSourcePoints,
const double *  sourceValues,
const double *  targetPoints,
int  nTargetPoints,
double *  targetValues 
)

C shim for PACMAN::rbf_interpolate.

Point arrays are row-major: point i occupies elements [i*spaceDimension .. (i+1)*spaceDimension-1]. In Fortran, declare points as REAL(C_DOUBLE) :: pts(spaceDimension, n) (column-major storage = C row-major storage).

Parameters
spaceDimensionGeometric dimension (1, 2, or 3).
execSpaceExecution-space selector (PACMAN_ExecSpace).
rbfFunctionRBF basis-function selector (PACMAN_RbfFunction).
sourcePointsRow-major source points [nSourcePoints × spaceDimension].
nSourcePointsNumber of source points.
sourceValuesSource scalar values, length nSourcePoints.
targetPointsRow-major target points [nTargetPoints × spaceDimension].
nTargetPointsNumber of target points.
targetValuesCaller-allocated output, length nTargetPoints.
Returns
0 on success, non-zero on error.

Definition at line 63 of file fortran_interface.cpp.

References PACMAN::rbf_interpolate(), and PACMAN::RbfInterpolateResult::targetValues.

Referenced by pacman_mod::pacman_rbf_interpolate().

◆ pacman_vtk_cell_dim_c()

int pacman_vtk_cell_dim_c ( int  vtkCellType)

Return the topological dimension for a VTK cell-type ID.

Equivalent to PACMAN::vtk_cell_dim.

Parameters
vtkCellTypeVTK cell-type ID.
Returns
Topological dimension (0, 1, 2, or 3), or -1 on error.

Definition at line 188 of file fortran_interface.cpp.

References PACMAN::vtk_cell_dim().

Referenced by pacman_mod::pacman_vtk_cell_dim().

◆ pacman_vtk_to_pacman_cell_type_c()

int pacman_vtk_to_pacman_cell_type_c ( const int *  vtkTypes,
int *  pacmanTypes,
int  n 
)

Convert an array of VTK cell-type IDs to PACMAN CellType values.

Equivalent to PACMAN::vtk_to_pacman_cell_type.

Parameters
vtkTypesInput VTK cell-type IDs, length n.
pacmanTypesOutput PACMAN cell-type codes, length n.
nNumber of cell types to convert.
Returns
0 on success, non-zero if an unsupported VTK type is encountered.

Definition at line 171 of file fortran_interface.cpp.

References PACMAN::vtk_to_pacman_cell_type().

Referenced by pacman_mod::pacman_vtk_to_pacman_cell_type().