OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
olb::BlockStructure2D Class Reference

#include <blockStructure2D.h>

+ Inheritance diagram for olb::BlockStructure2D:
+ Collaboration diagram for olb::BlockStructure2D:

Public Member Functions

 BlockStructure2D (int nx, int ny)
 
 BlockStructure2D (int nx, int ny, int overlap)
 
 BlockStructure2D ()
 
int getNx () const
 Read only access to block width.
 
int getNy () const
 Read only access to block height.
 
std::size_t getNcells () const
 Get number of cells.
 
std::size_t getCellId (int iX, int iY) const
 Get 1D cell ID.
 
std::ptrdiff_t getNeighborDistance (int iX, int iY) const
 Get 1D neighbor distance.
 
std::ptrdiff_t getNeighborDistance (Vector< int, 2 > c) const
 Get 1D neighbor distance.
 
bool isInside (int iX, int iY) const
 Return whether location is valid.
 

Protected Attributes

int _nx
 Block width.
 
int _ny
 Block height.
 

Detailed Description

Definition at line 47 of file blockStructure2D.h.

Constructor & Destructor Documentation

◆ BlockStructure2D() [1/3]

olb::BlockStructure2D::BlockStructure2D ( int nx,
int ny )
inline

Definition at line 54 of file blockStructure2D.h.

54: _nx(nx), _ny(ny) {};

◆ BlockStructure2D() [2/3]

olb::BlockStructure2D::BlockStructure2D ( int nx,
int ny,
int overlap )
inline

Definition at line 55 of file blockStructure2D.h.

55 :
56 _nx(nx+2*overlap), _ny(ny+2*overlap) { };

◆ BlockStructure2D() [3/3]

olb::BlockStructure2D::BlockStructure2D ( )
inline

Definition at line 57 of file blockStructure2D.h.

Member Function Documentation

◆ getCellId()

std::size_t olb::BlockStructure2D::getCellId ( int iX,
int iY ) const
inline

Get 1D cell ID.

Definition at line 79 of file blockStructure2D.h.

80 {
81
82
83 if(!(iX >= 0 && iX < this->_nx && iY >= 0 && iY < this->_ny)){
84 throw std::runtime_error{"Bad access at: " + std::to_string(iX) + " " + std::to_string(iY) + " " + std::to_string(foo_x) + " " + std::to_string(foo_y) + " "+ std::to_string(_nx) + " " + std::to_string(_ny)};
85
86 }
87
88 foo_x = iX;
89 foo_y = iY;
90
91 OLB_PRECONDITION(iX >= 0 && iX < this->_nx);
92 OLB_PRECONDITION(iY >= 0 && iY < this->_ny);
93 return iX*_ny + iY;
94 }
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46

References _nx, _ny, and OLB_PRECONDITION.

◆ getNcells()

std::size_t olb::BlockStructure2D::getNcells ( ) const
inline

Get number of cells.

Definition at line 69 of file blockStructure2D.h.

70 {
71 // The conversions to std::size_t ensure 64-bit compatibility. Note that
72 // Nx and Ny are of type int, which might be 32-bit types, even on
73 // 64-bit platforms. Therefore, Nx*Ny may lead to a type overflow.
74 return static_cast<std::size_t>(getNx())
75 * static_cast<std::size_t>(getNy());
76 }
int getNx() const
Read only access to block width.
int getNy() const
Read only access to block height.

References getNx(), and getNy().

+ Here is the call graph for this function:

◆ getNeighborDistance() [1/2]

std::ptrdiff_t olb::BlockStructure2D::getNeighborDistance ( int iX,
int iY ) const
inline

Get 1D neighbor distance.

Definition at line 96 of file blockStructure2D.h.

97 {
98 return iX*_ny + iY;
99 }

References _ny.

+ Here is the caller graph for this function:

◆ getNeighborDistance() [2/2]

std::ptrdiff_t olb::BlockStructure2D::getNeighborDistance ( Vector< int, 2 > c) const
inline

Get 1D neighbor distance.

Definition at line 101 of file blockStructure2D.h.

102 {
103 return getNeighborDistance(c[0], c[1]);
104 }
std::ptrdiff_t getNeighborDistance(int iX, int iY) const
Get 1D neighbor distance.

References getNeighborDistance().

+ Here is the call graph for this function:

◆ getNx()

int olb::BlockStructure2D::getNx ( ) const
inline

Read only access to block width.

Definition at line 59 of file blockStructure2D.h.

60 {
61 return _nx;
62 };

References _nx.

+ Here is the caller graph for this function:

◆ getNy()

int olb::BlockStructure2D::getNy ( ) const
inline

Read only access to block height.

Definition at line 64 of file blockStructure2D.h.

65 {
66 return _ny;
67 };

References _ny.

+ Here is the caller graph for this function:

◆ isInside()

bool olb::BlockStructure2D::isInside ( int iX,
int iY ) const
inline

Return whether location is valid.

Definition at line 106 of file blockStructure2D.h.

107 {
108 return 0 <= iX && iX < getNx() &&
109 0 <= iY && iY < getNy();
110 };

References getNx(), and getNy().

+ Here is the call graph for this function:

Member Data Documentation

◆ _nx

int olb::BlockStructure2D::_nx
protected

Block width.

Definition at line 50 of file blockStructure2D.h.

◆ _ny

int olb::BlockStructure2D::_ny
protected

Block height.

Definition at line 52 of file blockStructure2D.h.


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