SpatialOps
SpatialOps::MemoryWindow Class Reference

Provides tools to index into a sub-block of memory. More...

#include <MemoryWindow.h>

Public Member Functions

 MemoryWindow (const int npts[3], const int offset[3], const int extent[3])
 construct a MemoryWindow object More...
 
 MemoryWindow (const IntVec &npts, const IntVec &offset, const IntVec &extent)
 construct a MemoryWindow object More...
 
 MemoryWindow (const int npts[3])
 construct a MemoryWindow object where there is no "window" More...
 
 MemoryWindow (const IntVec &npts)
 construct a MemoryWindow object where there is no "window" More...
 
int flat_index (IntVec loc) const
 given the local ijk location (0-based on the local window), obtain the flat index in the global memory space.
 
IntVec ijk_index_from_global (const int loc) const
 given the local flat location (0-based on the global field), obtain the ijk index in the global memory space.
 
IntVec ijk_index_from_local (const int loc) const
 given the local flat location (0-based on the local window), obtain the ijk index in the global memory space.
 
size_t glob_npts () const
 obtain the global number of points in the field. Note that this is not necessarily contiguous memory
 
size_t local_npts () const
 obtain the local number of points in the field. Note that this is not necessarily contiguous memory
 
bool operator== (const MemoryWindow &w) const
 compare two MemoryWindows for equality
 
MemoryWindow reset_ghosts (GhostData const &oldGhosts, GhostData const &newGhosts) const
 return the current memory window with oldGhosts removed and newGhosts added More...
 
MemoryWindow remove_ghosts (GhostData const &ghosts) const
 return the current memory window with given ghosts removed More...
 
bool fits_in (MemoryWindow const &outer) const
 return if the current window fits in given window More...
 
bool fits_between (MemoryWindow const &inner, MemoryWindow const &outer) const
 return if current window fits between the two given windows More...
 
std::string print () const
 Writes the internals of MemoryWindow to a string. More...
 
bool sanity_check () const
 performs basic sanity checks to see if there is anything obviously wrong with this window.
 

Detailed Description

Provides tools to index into a sub-block of memory.

Author
James C. Sutherland
Date
September 2010

Given a block of memory, [Nx,Ny,Nz], assume that we want to deal with a sub-block of size [nx,ny,nz] that starts at [i,j,k] in the larger block. The MemoryWindow class provides basic tools to help with this.

Definition at line 63 of file MemoryWindow.h.

Constructor & Destructor Documentation

◆ MemoryWindow() [1/4]

SpatialOps::MemoryWindow::MemoryWindow ( const int  npts[3],
const int  offset[3],
const int  extent[3] 
)

construct a MemoryWindow object

Parameters
nptsthe total (global) number of points in each direction
offsetthe offset into the memory
extentthe size of the block that we are considering

Definition at line 34 of file MemoryWindow.cpp.

References sanity_check().

Referenced by SpatialOps::get_window_with_ghost(), and reset_ghosts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MemoryWindow() [2/4]

SpatialOps::MemoryWindow::MemoryWindow ( const IntVec npts,
const IntVec offset,
const IntVec extent 
)

construct a MemoryWindow object

Parameters
nptsthe total (global) number of points in each direction
offsetthe offset into the memory
extentthe size of the block that we are considering

Definition at line 46 of file MemoryWindow.cpp.

References sanity_check().

Here is the call graph for this function:

◆ MemoryWindow() [3/4]

SpatialOps::MemoryWindow::MemoryWindow ( const int  npts[3])

construct a MemoryWindow object where there is no "window"

Parameters
nptsthe total (global) number of points in each direction

Definition at line 58 of file MemoryWindow.cpp.

References sanity_check().

Here is the call graph for this function:

◆ MemoryWindow() [4/4]

SpatialOps::MemoryWindow::MemoryWindow ( const IntVec npts)

construct a MemoryWindow object where there is no "window"

Parameters
nptsthe total (global) number of points in each direction

Definition at line 66 of file MemoryWindow.cpp.

References sanity_check().

Here is the call graph for this function:

Member Function Documentation

◆ fits_between()

bool SpatialOps::MemoryWindow::fits_between ( MemoryWindow const &  inner,
MemoryWindow const &  outer 
) const
inline

return if current window fits between the two given windows

Parameters
innerwindow to fit in checked
outerwindow into which checked fits

If current, inner, and outer are equal, returns true.

If global dimensions are different, returns false.

Debug mode asserts that inner fits in outer.

Definition at line 247 of file MemoryWindow.h.

References fits_in().

Here is the call graph for this function:

◆ fits_in()

bool SpatialOps::MemoryWindow::fits_in ( MemoryWindow const &  outer) const
inline

return if the current window fits in given window

Parameters
outerwindow into which current window fits

If current and outer are equal, returns true.

If global dimensions are different, returns false.

Definition at line 227 of file MemoryWindow.h.

Referenced by fits_between().

Here is the caller graph for this function:

◆ print()

std::string SpatialOps::MemoryWindow::print ( ) const
inline

Writes the internals of MemoryWindow to a string.

Returns
a string value representing the internals of MemoryWindow.

Definition at line 258 of file MemoryWindow.h.

References sanity_check().

Here is the call graph for this function:

◆ remove_ghosts()

MemoryWindow SpatialOps::MemoryWindow::remove_ghosts ( GhostData const &  ghosts) const
inline

return the current memory window with given ghosts removed

Parameters
ghostsnumber of ghost cells to remove from window

Definition at line 214 of file MemoryWindow.h.

References reset_ghosts().

Referenced by SpatialOps::SpatialField< SpatialOps::SingleValue, T >::swap(), and SpatialOps::FieldInfo< T >::window_without_ghost().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_ghosts()

MemoryWindow SpatialOps::MemoryWindow::reset_ghosts ( GhostData const &  oldGhosts,
GhostData const &  newGhosts 
) const
inline

return the current memory window with oldGhosts removed and newGhosts added

Parameters
oldGhostsnumber of ghost cells to remove from window
newGhostsnumber of ghost cells to add to window

Definition at line 198 of file MemoryWindow.h.

References SpatialOps::GhostData::get_minus(), SpatialOps::GhostData::get_plus(), and MemoryWindow().

Referenced by remove_ghosts(), SpatialOps::FieldInfo< T >::reset_valid_ghosts(), SpatialOps::SpatialField< SpatialOps::SingleValue, T >::reset_valid_ghosts(), and SpatialOps::FieldInfo< T >::window_with_all_ghost().

Here is the call graph for this function:
Here is the caller graph for this function:

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