Skip to content

Boundary Conditions

The BoundaryConditions module owns the treatment of all external faces of the simulation domain for every Storage3D field in the library. During each time step, solver classes hand their fields to the appropriate BoundaryConditions::Set* method, which refreshes the boundary (halo) cells according to the user-selected condition on each face. Six condition types are supported and can be set independently on each of the six domain faces (0X, NX, 0Y, NY, 0Z, NZ). In MPI-parallel builds the module also handles neighbour-block halo exchange.

Key Classes and Concepts

  • BoundaryConditionTypes: enum class listing the six condition types. See the Condition types table below.
  • BoundaryConditions: the main class. It stores one condition per face (BC0X, BCNX, BC0Y, BCNY, BC0Z, BCNZ), reads those from the input file, and exposes Set* templates that operate on any Storage3D<T, Num> passed in. In MPI builds it additionally owns the cartesian-topology setup (Setup_MPI, Setup_MPIX/Y/Z) and the Communicate* halo-exchange helpers.

Condition types

ValueBehaviour
PeriodicWraps the field at the opposite face.
NoFluxZero first-order derivative at the boundary (adiabatic).
FreeContinuous gradient across the boundary (free surface).
FixedDirichlet / Neumann value pinned externally.
MirrorLike NoFlux but places the boundary on the edge grid point.
MPIcommHalo exchange between adjacent MPI sub-domains. Set automatically in MPI builds; not a user-facing input value.

The user-facing input strings accepted by TranslateBoundaryConditions are exactly Periodic, NoFlux, Free, Fixed, and Mirror.

Usage

Input

Defined in the @BoundaryConditions block of the input file. One entry per face; the default for every face is Periodic.

text
@BoundaryConditions

$BC0X   X axis beginning boundary condition         : Periodic
$BCNX   X axis far end boundary condition           : Periodic

$BC0Y   Y axis beginning boundary condition         : NoFlux
$BCNY   Y axis far end boundary condition           : NoFlux

$BC0Z   Z axis beginning boundary condition         : Free
$BCNZ   Z axis far end boundary condition           : Free

Output

The module does not write any dedicated output file. It mutates the storages passed to Set* in place.

Example

cpp
#include "Settings.h"
#include "BoundaryConditions.h"
#include "PhaseField.h"
#include "InterfaceProperties.h"

using namespace openphase;

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

    Settings            OPSettings;
    OPSettings.ReadInput(InputFile);

    BoundaryConditions  BC(OPSettings, InputFile);
    PhaseField          Phi(OPSettings, InputFile);
    InterfaceProperties IP(OPSettings, InputFile);

    // Example: fields that carry halo cells are updated via BC inside
    // their owner classes (e.g. Phi.NormalizeIncrements(BC, dt) applies
    // boundary conditions along with the increment update).
}

Dependencies

  • Settings — supplies grid size and phase count at initialization.
  • Storage3D and its variants — the templates Set, SetX, SetY, SetZ, SetXVector, SetXFlags, … operate on these container types.
  • Every solver class receives BoundaryConditions& in the methods that advance a field (see PhaseField, InterfaceProperties).

Released under the GNU GPLv3 License.