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

Apply 3D function f(x,y,z) to all field points.

Apply 3D function f(x,y,z) to all field pointsEvaluates the function at each grid point's physical coordinates and assigns the result to that point. This is the most common way to initialize fields with analytical functions.

Template Parameters
Function3DFunction type callable with (double, double, double)
Parameters
funcFunction to apply, must return type convertible to T

mathematical functions

pfc::DiscreteField<double, 3> field({64,64,64}, {0,0,0},
{0.0,0.0,0.0}, {1.0,1.0,1.0});
// Sine wave in x, constant in y,z
field.apply([](double x, double y, double z) {
return std::sin(pfc::two_pi * x / 64.0);
});
// Radial Gaussian
field.apply([](double x, double y, double z) {
double r2 = (x-32)*(x-32) + (y-32)*(y-32) + (z-32)*(z-32);
return std::exp(-r2 / 100.0);
});
Represents the global simulation domain (the "world").
Definition world.hpp:91