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

JSON deserialization functions for OpenPFC types. More...

Include dependency graph for from_json.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T >
pfc::ui::from_json (const json &settings)
 
template<>
fft::Backend pfc::ui::from_json< fft::Backend > (const json &j)
 Converts a JSON string to fft::Backend enum.
 
template<>
heffte::plan_options pfc::ui::from_json< heffte::plan_options > (const json &j)
 Converts a JSON object to heffte::plan_options.
 
template<>
World pfc::ui::from_json< World > (const json &j)
 
template<>
Time pfc::ui::from_json< Time > (const json &settings)
 
void pfc::ui::from_json (const json &j, Constant &ic)
 
void pfc::ui::from_json (const json &j, SingleSeed &seed)
 
void pfc::ui::from_json (const json &j, RandomSeeds &ic)
 
void pfc::ui::from_json (const json &j, SeedGrid &ic)
 
void pfc::ui::from_json (const json &j, FileReader &ic)
 
void pfc::ui::from_json (const json &j, FixedBC &bc)
 
void pfc::ui::from_json (const json &j, MovingBC &bc)
 
void pfc::ui::from_json (const json &, Model &)
 

Detailed Description

JSON deserialization functions for OpenPFC types.

This header provides template specializations and overloads for converting JSON objects into OpenPFC types. It handles:

  • World configuration (domain size, spacing, origin)
  • Time stepping parameters
  • Initial conditions (constant, seeds, file input)
  • Boundary conditions (fixed, moving)
  • FFT backend options
  • Model parameters
Author
OpenPFC Development Team
Date
2025

Function Documentation

◆ from_json< fft::Backend >()

template<>
fft::Backend pfc::ui::from_json< fft::Backend > ( const json &  j)
inline

Converts a JSON string to fft::Backend enum.

Parses backend selection from configuration. Supported values:

  • "fftw" or "FFTW": CPU-based FFT (always available)
  • "cuda" or "CUDA": GPU-based FFT using cuFFT (requires OpenPFC_ENABLE_CUDA)
Parameters
jThe JSON object to parse (looks for "backend" field)
Returns
The fft::Backend enum value
Exceptions
std::runtime_errorif backend is not supported or not compiled in

◆ from_json< heffte::plan_options >()

template<>
heffte::plan_options pfc::ui::from_json< heffte::plan_options > ( const json &  j)
inline

Converts a JSON object to heffte::plan_options.

This function parses the provided JSON object and constructs a heffte::plan_options object based on the values found in the JSON. The function prints debug information to the console regarding the options being parsed.

Parameters
jThe JSON object to parse.
Returns
The heffte::plan_options object constructed from the JSON.
Here is the call graph for this function:

◆ from_json< World >()

template<>
World pfc::ui::from_json< World > ( const json &  j)
inline

Creates a World object from a JSON input.

Parameters
jA JSON object containing the following fields:
  • Lx (int): The number of grid points in the x direction.
  • Ly (int): The number of grid points in the y direction.
  • Lz (int): The number of grid points in the z direction.
  • dx (float): The grid spacing in the x direction.
  • dy (float): The grid spacing in the y direction.
  • dz (float): The grid spacing in the z direction.
  • origin (string): The origin of the coordinate system. Must be one of "center" or "corner".
Returns
A World object.
Exceptions
std::invalid_argumentif any of the required fields are missing or have an invalid value.
Here is the call graph for this function: