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

C++ implementation of the plain-C shim for the Fortran bindings. More...

#include "fortran_interface.h"
#include "interface.hpp"
#include <Kokkos_Core.hpp>
#include <cstddef>
#include <iostream>
#include <stdexcept>

Go to the source code of this file.

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

C++ implementation of the plain-C shim for the Fortran bindings.

Each function catches all C++ exceptions and returns an integer error code so that Fortran callers receive a clean C ABI with no thrown exceptions crossing the language boundary.

Definition in file fortran_interface.cpp.

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().