OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::Box3D Class Reference

Represents a 3D integer box in grid index space. More...

#include <box3d.hpp>

Public Types

using Int3 = std::array< int, 3 >
 Type aliases for clarity.
 

Public Member Functions

 Box3D (const Int3 &lower, const Int3 &upper)
 Constructs a Box3D with given lower and upper corners.
 
const Int3lower () const noexcept
 Returns the lower corner indices.
 
const Int3upper () const noexcept
 Returns the upper corner indices.
 
Int3 size () const noexcept
 Returns the size (number of elements) in each dimension.
 
int total_size () const noexcept
 Computes the total number of grid points in the box.
 
bool contains (const Int3 &index) const noexcept
 Check if a given index {i,j,k} is inside this box.
 
bool operator== (const Box3D &other) const noexcept
 Equality operator.
 
bool operator!= (const Box3D &other) const noexcept
 Inequality operator.
 

Friends

std::ostream & operator<< (std::ostream &os, const Box3D &box) noexcept
 Output stream operator for Box3D objects.
 

Detailed Description

Represents a 3D integer box in grid index space.

The Box3D class describes a discrete 3D rectangular region using integer lower and upper corner indices.

It is designed to represent local computational domains in the simulation, distinct from the continuous physical domain described by World.

Box3D is purely an index-space concept: it does not know about physical coordinates, spacing, or origin.

Example usage:

#include <iostream>
int main() {
pfc::Box3D box({0, 0, 0}, {9, 9, 9});
std::cout << "Box size: {"
<< box.size()[0] << ", "
<< box.size()[1] << ", "
<< box.size()[2] << "}" << std::endl;
}
3D integer bounding box for grid index space
Represents a 3D integer box in grid index space.
Definition box3d.hpp:74
Represents the global simulation domain (the "world").
Definition world.hpp:91

Design Responsibilities:

  • Define a 3D discrete region.
  • Support size calculation and basic box queries.
  • Serve as a basis for parallel decomposition and FFT layouts.

This class follows the Single Responsibility Principle (SRP).

Constructor & Destructor Documentation

◆ Box3D()

pfc::Box3D::Box3D ( const Int3 lower,
const Int3 upper 
)

Constructs a Box3D with given lower and upper corners.

Parameters
lowerLower corner indices {i_min, j_min, k_min}.
upperUpper corner indices {i_max, j_max, k_max}.
Exceptions
std::invalid_argumentif lower > upper in any dimension.

Member Function Documentation

◆ contains()

bool pfc::Box3D::contains ( const Int3 index) const
noexcept

Check if a given index {i,j,k} is inside this box.

Parameters
indexA grid index {i, j, k}.
Returns
true if the index is inside the box, false otherwise.

◆ lower()

const Int3 & pfc::Box3D::lower ( ) const
noexcept

Returns the lower corner indices.

Returns
const Int3& Lower corner {i_min, j_min, k_min}.

◆ operator!=()

bool pfc::Box3D::operator!= ( const Box3D other) const
noexcept

Inequality operator.

Parameters
otherAnother box to compare.
Returns
true if either lower or upper corners differ.

◆ operator==()

bool pfc::Box3D::operator== ( const Box3D other) const
noexcept

Equality operator.

Parameters
otherAnother box to compare.
Returns
true if both lower and upper corners are identical.

◆ size()

Int3 pfc::Box3D::size ( ) const
noexcept

Returns the size (number of elements) in each dimension.

Size is computed as (upper - lower + 1) per dimension.

Returns
Int3 Size {Nx, Ny, Nz}.

◆ total_size()

int pfc::Box3D::total_size ( ) const
noexcept

Computes the total number of grid points in the box.

Equivalent to size()[0] * size()[1] * size()[2].

Returns
int Total number of grid points.

◆ upper()

const Int3 & pfc::Box3D::upper ( ) const
noexcept

Returns the upper corner indices.

Returns
const Int3& Upper corner {i_max, j_max, k_max}.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Box3D box 
)
friend

Output stream operator for Box3D objects.

Allows easy printing of Box3D state for debugging and logging.

Parameters
osThe output stream.
boxThe Box3D object.
Returns
The updated output stream.

The documentation for this class was generated from the following file: