OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
Basic

Interpolate field value at physical coordinates (nearest-neighbor)

Interpolate field value at physical coordinates (nearest-neighbor)Returns the field value at the grid point nearest to the given physical coordinates. This uses simple rounding (not linear or higher-order). This is the preferred way to interpolate - free function instead of member.

Design Philosophy: Free functions enable extension via ADL and align with OpenPFC's "laboratory, not fortress" philosophy. Users can provide custom interpolation schemes without modifying DiscreteField.

Template Parameters
TField value type (double, complex, etc.)
DDimensionality (1, 2, or 3)
Parameters
fieldThe discrete field to interpolate
coordinatesPhysical coordinates [x, y, z] to interpolate at
Returns
Reference to the field value at the nearest grid point (mutable)

usage

pfc::DiscreteField<double, 3> field({64,64,64}, {0,0,0},
{0.0,0.0,0.0}, {1.0,1.0,1.0});
field.apply([](double x, double y, double z) { return x + y + z; });
// Interpolate at arbitrary coordinate (free function - preferred)
double& value = pfc::interpolate(field, {5.7, 10.2, 20.8});
value = 42.0; // Can modify through reference
Represents the global simulation domain (the "world").
Definition world.hpp:91