Skip to content

Settings

Settings is the first object constructed in every OpenPhase simulation. It owns the global simulation parameters — the active phase list, the component list, the grid parameters, and the output directory paths — and must be initialized before any other module. Nearly every subsequent class receives a reference to Settings in its constructor and queries it for the number of phases, the component names, and the output directories when allocating its own storages.

Key Classes and Concepts

  • Settings: configuration container and primary input-file reader. It transparently owns a GridParameters block read from the same input file ($Nx, $Ny, $Nz, $dx, $IWidth), so users do not need to instantiate GridParameters directly.
  • AggregateStates: enum tag attached to every active phase. The supported values are Solid, Liquid, and Gas.

Usage

Input

The configuration lives in the @Settings block (plus the @GridParameters block it owns). The phase list is discovered by incrementing the zero-based index until the corresponding $Phase_<n> key is absent.

text
@GridParameters

$Nx       System Size in X Direction                : 101
$Ny       System Size in Y Direction                : 101
$Nz       System Size in Z Direction                : 101
$dx       Grid Spacing                              : 1e-6
$IWidth   Interface Width (in grid points)          : 5.0

@Settings

$Phase_0  Name of phase 0                           : Austenite
$State_0  State of phase 0 (SOLID / LIQUID / GAS)   : SOLID

$Phase_1  Name of phase 1                           : Liquid
$State_1  State of phase 1                          : LIQUID

$VTKDir   VTK output directory                      : VTK/
$RAWDir   Raw binary output directory               : RawData/
$DATADir  Text output directory                     : TextData/

Accepted values for $State_<n> are SOLID, LIQUID, and GAS. The default, used when the key is omitted, is SOLID. Any other value causes the module to abort.

Output

Settings does not produce time-dependent output. On initialization it records the simulation configuration in the console log so that runs can be traced from their output.

Example

cpp
#include "Settings.h"

using namespace openphase;

int main(int argc, char *argv[])
{
    std::string InputFile = (argc > 1) ? argv[1] : "ProjectInput.opi";

    Settings OPSettings;
    OPSettings.ReadInput(InputFile);
    // OPSettings is now safe to pass to every other module's constructor.
}

The same pattern appears in every example under OpenPhase-main/examples/, which construct further modules by passing OPSettings and InputFile into each constructor.

Dependencies

  • GridParameters — read through the same input file.
  • FileInterface — parsing helpers for both the .opi text format and the JSON-format input.
  • Consumed by every other module in the library (BoundaryConditions, PhaseField, InterfaceProperties, …).

Released under the GNU GPLv3 License.