OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::decomposition::Decomposition Struct Reference

Describes a static, pure partitioning of the global simulation domain into local subdomains. More...

#include <decomposition.hpp>

Collaboration diagram for pfc::decomposition::Decomposition:

Public Member Functions

 Decomposition (const World &world, const Int3 grid)
 

Public Attributes

const pfc::Worldm_global_world
 The World object.
 
const std::array< int, 3 > m_grid
 The number of parts in each dimension.
 
const std::vector< pfc::Worldm_subworlds
 The sub-worlds for each part.
 

Friends

std::ostream & operator<< (std::ostream &os, const Decomposition &d)
 

Detailed Description

Describes a static, pure partitioning of the global simulation domain into local subdomains.

The Decomposition struct encapsulates how the global World domain is split across compute units, such as MPI processes, OpenMP threads, or GPU tiles. It represents the ownership layout, not how communication is performed.

Each Decomposition instance defines the local subdomain assigned to the current compute entity, including bounding box, size, and global offset. It provides a consistent, backend-independent view of how the World is subdivided.

Responsibilities

  • Partition the World into non-overlapping subdomains.
  • Store the local bounding box for the current process/thread/tile.
  • Provide basic global-to-local coordinate mappings.
  • Support communication planning and field allocation.

Design Principles

  • Immutable: All members are set at construction; no mutation after creation.
  • Pure: No behavior; only data. All logic is implemented via free functions in the pfc::decomposition namespace.
  • Backend-agnostic: The decomposition itself contains no knowledge of MPI, GPU, or FFT specifics.
  • Strategy-based construction: Backends (DifferentialOperators) define their requirements using a DecompositionRequest, and decomposition is created to satisfy that request.
  • Composable and inspectable: Designed to be shared and reused across modules.

Integration with Backends

Decomposition supports an inversion of control model where DifferentialOperator (or any backend) declares its layout requirements via a DecompositionRequest:

};
Represents the global simulation domain (the "world").
Definition world.hpp:91

This request is passed to the decomposition builder:

Decomposition decomp = pfc::decomposition::create(world, rank, size,
backend.decomposition_request());
Describes a static, pure partitioning of the global simulation domain into local subdomains.
Definition decomposition.hpp:182

This design allows:

  • Clean separation of concerns between numerical kernels and layout logic.
  • Support for specialized strategies (e.g., slab vs pencil, real vs complex).
  • Reuse of decompositions across multiple algorithmic backends.

Usage Context

  • Used during startup to allocate Fields with correct local shape.
  • Passed to communication planning logic to derive what needs to be exchanged.
  • Required by FFT, finite difference, or hybrid backends to define their working layout.

Extensibility

The decomposition system is extensible by:

  • Adding new strategy types (SplitStrategy) or request properties.
  • Supporting templated decomposition traits (e.g., GPU-aware or NUMA-aware partitions).
  • Implementing high-level abstractions over common layouts (e.g., block, slab, tile).

Limitations

  • Assumes a structured, rectangular global World domain.
  • Does not encode or perform communication (that's a separate layer).
  • Does not (yet) support dynamic repartitioning or adaptive remeshing.
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/fft.hpp, and 08_discrete_fields.cpp.

The documentation for this struct was generated from the following file: