OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
halo_pattern.hpp File Reference

Halo exchange pattern creation from Decomposition. More...

Include dependency graph for halo_pattern.hpp:

Go to the source code of this file.

Typedefs

using pfc::halo::Int3 = pfc::types::Int3
 

Enumerations

enum class  pfc::halo::Connectivity { Faces , Edges , All }
 Connectivity pattern for halo exchange.
 

Functions

template<typename BackendTag = backend::CpuTag>
core::SparseVector< BackendTag, size_tpfc::halo::create_send_halo (const decomposition::Decomposition &decomp, int rank, const Int3 &direction, int halo_width)
 
template<typename BackendTag = backend::CpuTag>
core::SparseVector< BackendTag, size_tpfc::halo::create_recv_halo (const decomposition::Decomposition &decomp, int rank, const Int3 &direction, int halo_width)
 Create SparseVector representing receive halo region.
 
template<typename BackendTag = backend::CpuTag>
std::map< Int3, std::pair< core::SparseVector< BackendTag, size_t >, core::SparseVector< BackendTag, size_t > > > pfc::halo::create_halo_patterns (const decomposition::Decomposition &decomp, int rank, Connectivity connectivity, int halo_width)
 Create all halo patterns for a rank.
 

Detailed Description

Halo exchange pattern creation from Decomposition.

Provides functions to create SparseVector objects representing halo regions for exchange between neighbors in a decomposed domain. Handles:

  • Automatic index calculation from Decomposition
  • Global to local index conversion
  • Different connectivity patterns (faces, edges, corners)
  • Periodic boundary conditions
  • Multiple halo widths
auto decomp = decomposition::create(world, {2, 2, 2});
int rank = 0;
int halo_width = 1;
// Create halo pattern for +X face (1 row)
auto send_halo = halo::create_send_halo(decomp, rank, {1, 0, 0}, halo_width);
auto recv_halo = halo::create_recv_halo(decomp, rank, {1, 0, 0}, halo_width);
// Exchange indices once (setup)
int neighbor = decomposition::get_neighbor_rank(decomp, rank, {1, 0, 0});
exchange::send(send_halo, rank, neighbor, MPI_COMM_WORLD);
exchange::receive(recv_halo, neighbor, rank, MPI_COMM_WORLD);
// Then exchange data repeatedly
exchange::send_data(send_halo, rank, neighbor, MPI_COMM_WORLD);
exchange::receive_data(recv_halo, neighbor, rank, MPI_COMM_WORLD);
See also
core/decomposition.hpp for Decomposition class
core/decomposition_neighbors.hpp for neighbor finding
core/sparse_vector.hpp for SparseVector
core/exchange.hpp for exchange operations
Author
OpenPFC Development Team
Date
2025

Function Documentation

◆ create_halo_patterns()

template<typename BackendTag = backend::CpuTag>
std::map< Int3, std::pair< core::SparseVector< BackendTag, size_t >, core::SparseVector< BackendTag, size_t > > > pfc::halo::create_halo_patterns ( const decomposition::Decomposition decomp,
int  rank,
Connectivity  connectivity,
int  halo_width 
)

Create all halo patterns for a rank.

Creates send and receive SparseVectors for all neighbors based on connectivity pattern. Returns a map from direction to {send_halo, recv_halo}.

Parameters
decompDecomposition object
rankCurrent rank
connectivityConnectivity pattern (Faces, Edges, or All)
halo_widthNumber of halo rows
Returns
Map from direction Int3 to pair of {send_halo, recv_halo} SparseVectors
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/core/halo_pattern.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_recv_halo()

template<typename BackendTag = backend::CpuTag>
core::SparseVector< BackendTag, size_t > pfc::halo::create_recv_halo ( const decomposition::Decomposition decomp,
int  rank,
const Int3 &  direction,
int  halo_width 
)

Create SparseVector representing receive halo region.

Extracts indices for the halo region where data should be received from a neighbor. Indices are in local coordinate space (0-based into the local field array, including halo zones).

Parameters
decompDecomposition object
rankCurrent rank
directionDirection from neighbor, e.g., {1,0,0} means receiving from +X neighbor
halo_widthNumber of halo rows/layers
Returns
SparseVector with local indices of receive halo region
Note
For periodic boundaries, this will wrap around to the opposite side
These indices point into the halo zone of the local field (which should be allocated with extra space for halos)
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/core/halo_pattern.hpp.
Here is the call graph for this function:
Here is the caller graph for this function: