Pointwise Plugin SDK
Public Member Functions | List of all members

The structured block class. More...

#include <CaeStrBlock.h>

+ Inheritance diagram for CaeStrBlock:
+ Collaboration diagram for CaeStrBlock:

Public Member Functions

 CaeStrBlock ()
 Default constructor. More...
 
 CaeStrBlock (const CaeBlock &src)
 CaeBlock constructor. More...
 
 CaeStrBlock (const CaeStrBlock &src)
 Copy constructor. More...
 
 CaeStrBlock (const CaeStrGridModel &model, PWP_UINT32 ndx=0)
 Model and block index constructor. More...
 
 CaeStrBlock (PWGM_HBLOCK block)
 Block handle constructor. More...
 
bool data (PWGM_BLOCKDATA &data) const
 Gets information about the block. More...
 
CaeStrGridModel model () const
 Gets the structured grid model of which this block is a member. More...
 
bool ndxVertData (PWGM_INDEX3 ndx3, PWGM_VERTDATA &data) const
 Get the block's vertex data at the given index location. More...
 
bool size (PWGM_STR_SIZE &size) const
 Gets the structured ijk size of the block's vertices. More...
 
virtual ~CaeStrBlock ()
 Destructor. More...
 
- Public Member Functions inherited from CaeBlock
bool condition (PWGM_CONDDATA &condData) const
 Gets the block's condition data. More...
 
bool data (PWGM_BLOCKDATA &data)
 Get the block data. More...
 
PWP_UINT32 index () const
 Get a block's index. More...
 
bool isValid () const
 Determines a block's validity. More...
 
CaeBlockmoveFirst (PWGM_HGRIDMODEL model)
 Rebinds an instance to the first block in a model. More...
 
CaeBlockmoveNext ()
 Rebinds an instance to the next block in a model. More...
 
CaeBlockmovePrev ()
 Rebinds an instance to the previous block in a model. More...
 
CaeBlockmoveTo (PWGM_HGRIDMODEL model, PWP_UINT32 ndx)
 Rebinds an instance to a specific model block. More...
 
 operator PWGM_HBLOCK () const
 The PWGM_HBLOCK cast operator. More...
 
CaeBlockoperator++ ()
 Prefix increment to the next block in a model. More...
 
CaeBlock operator++ (int)
 Postfix increment to the next block in a model. More...
 
CaeBlockoperator-- ()
 Prefix decrement to the previous block in a model. More...
 
CaeBlock operator-- (int)
 Postfix decrement to the previous block in a model. More...
 
CaeBlockoperator= (const CaeBlock &rhs)
 Assignment operator. More...
 
CaeBlockoperator= (PWGM_HBLOCK block)
 Assignment operator. More...
 
bool operator== (const CaeBlock &rhs) const
 Compares two CaeBlock instances for equality. More...
 
bool setExportName (const char *name)
 Set the name used to identify the block or group of blocks in the exported grid. More...
 
- Public Member Functions inherited from CaeStrConnectionGroup
PWP_UINT32 connectionCount () const
 Get the number of connections in the group. More...
 
PWGM_HCNXN enumConnections (PWP_UINT32 ndx) const
 Get an connection in the group. More...
 
PWGM_HCNXN firstConnection () const
 Get the first connection in the group. More...
 
virtual ~CaeStrConnectionGroup ()
 Destructor. More...
 
- Public Member Functions inherited from CaeStrBoundaryGroup
PWP_UINT32 boundaryCount () const
 Get the number of boundaries in the group. More...
 
PWGM_HBNDRY enumBoundaries (PWP_UINT32 ndx) const
 Get a boundary in the group. More...
 
PWGM_HBNDRY firstBoundary () const
 Get the first boundary in the group. More...
 
virtual ~CaeStrBoundaryGroup ()
 Destructor. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CaeBlock
 CaeBlock ()
 Default constructor. More...
 
 CaeBlock (const CaeBlock &src)
 Copy constructor. More...
 
 CaeBlock (PWGM_HBLOCK block)
 Block handle constructor. More...
 
 CaeBlock (PWGM_HGRIDMODEL model, PWP_UINT32 ndx=0)
 Model and block index constructor. More...
 
 ~CaeBlock ()
 Destructor. More...
 
- Protected Member Functions inherited from CaeStrConnectionGroup
virtual PWP_UINT32 connectionCountImpl () const =0
 Get the number of connections in the group. More...
 
virtual PWGM_HCNXN enumConnectionsImpl (PWP_UINT32 ndx) const =0
 Get a connection in the group. More...
 
- Protected Member Functions inherited from CaeStrBoundaryGroup
virtual PWP_UINT32 boundaryCountImpl () const =0
 Get the number of boundaries in the group. More...
 
virtual PWGM_HBNDRY enumBoundariesImpl (PWP_UINT32 ndx) const =0
 Get a boundary in the group. More...
 
- Protected Attributes inherited from CaeBlock
PWGM_HBLOCK block_
 The bound PWGM_HBLOCK. More...
 

Detailed Description

The structured block class.

The CaeStrBlock class represents a collection of structured ijk vertices, boundaries and connections. The grid model blocks are indexed from 0 to CaeGridModel::blockCount() - 1.

For 3D grid models, block elements are 3D hexahedrons. For 2D grid models, block elements are 2D (not necessarily planar) QUAD elements. The element connectivity is implicit in the ijk layout of the vertices.

A CaeStrBlock object is aware of its relative position in the grid model. As a result, a given block object can be moved (iterated) to its previous or next neighbor block. It can also be moved to the first block or to a block at a given index. After being moved, a CaeStrBlock object will return information about the grid block at its current position.

Sample Usage:

The following snippets are extracted from the structured XML sample plugin (CaeStrXMLCPP).

During the execution of the CaeStrXMLCPP::write() method, the CaeStrXMLCPP plugin writes the grid model blocks with a call to its CaeStrXMLCPP::writeBlocks() method. First, it writes an XML <blocks> tag. Then it moves through the blocks one by one and calls the CaeStrXMLCPP::writeBlock() method. Finally, a closing </blocks> tag is written.

void
CaeStrXMLCPP::writeBlocks()
{
PWP_UINT32 cnt = model_.blockCount();
if (progressBeginStep(cnt)) {
writeComment("**************** GRID BLOCKS ****************");
CaeStrBlock block(model_);
fprintf(fp(), "%s<blocks cnt='%lu'>\n", tabs(), (unsigned long)cnt);
++tabs_;
while (progressIncrement() && writeBlock(block)) {
++block;
}
--tabs_;
fprintf(fp(), "%s</blocks>\n", tabs());
}
progressEndStep();
}

CaeStrXMLCPP::writeBlock() writes an XML <block> tag. Next, the block's vertices, connections and boundaries are exported with calls to CaeStrXMLCPP::writeBlkVertices(), CaeStrXMLCPP::writeBlkConnections() and CaeStrXMLCPP::writeBlkBoundaries(). Finally, a closing </block> tag is written.

bool
CaeStrXMLCPP::writeBlock(const CaeStrBlock &block)
{
bool ret = false;
PWGM_BLOCKDATA blkData;
CaeCondition condData;
if (!aborted() && block.size(size) && block.data(blkData) &&
block.condition(condData)) {
if (0 == blkData.name) {
blkData.name = "";
}
if (isDimension3D()) {
fprintf(fp(),
"%s<block name='%s' id='%lu' ijkdim='%lu %lu %lu'>\n",
tabs(), blkData.name,
(unsigned long)block.index(), (unsigned long)size.i,
(unsigned long)size.j, (unsigned long)size.k);
}
else {
fprintf(fp(),
"%s<block name='%s' id='%lu' ijdim='%lu %lu'>\n", tabs(),
blkData.name, (unsigned long)block.index(),
(unsigned long)size.i, (unsigned long)size.j);
}
++tabs_;
writeConditionData(condData);
ret = !aborted() && writeBlkVertices(block) &&
!aborted() && writeBlkConnections(block) &&
!aborted() && writeBlkBoundaries(block);
--tabs_;
fprintf(fp(), "%s</block>\n", tabs());
}
return ret;
}

CaeStrXMLCPP::writeBlkVertices() gets the block's ijk size, and then loops through the vertices calling CaeStrXMLCPP::writeVertexData() for each ijk vertex.

bool
CaeStrXMLCPP::writeBlkVertices(const CaeStrBlock &block)
{
bool ret = (0 != block.size(size));
if (ret) {
fprintf(fp(), "%s<vertices cnt='%lu'>\n", tabs(),
(unsigned long)(size.i * size.j * size.k));
++tabs_;
for (ijk.i=0; ret && (ijk.i < size.i); ++ijk.i) {
for (ijk.j=0; ret && (ijk.j < size.j); ++ijk.j) {
for (ijk.k=0; ret && (ijk.k < size.k); ++ijk.k) {
ret = block.ndxVertData(ijk, data) && !aborted();
if (ret) {
writeVertexData(ijk, data);
}
}
}
}
--tabs_;
fprintf(fp(), "%s</vertices>\n", tabs());
}
return ret;
}

CaeStrXMLCPP::writeVertexData() writes a self-closed XML <vertex /> tag.

void
CaeStrXMLCPP::writeVertexData(const PWGM_INDEX3 &ijk, const PWGM_VERTDATA &data)
{
if (isDimension3D()) {
fprintf(fp(),
"%s<vertex xyz='%.5g %.5g %.5g' ijk='%lu %lu %lu' />\n",
tabs(), data.x, data.y, data.z, (unsigned long)ijk.i,
(unsigned long)ijk.j, (unsigned long)ijk.k);
}
else {
fprintf(fp(), "%s<vertex xy='%.5g %.5g' ij='%lu %lu' />\n",
tabs(), data.x, data.y, (unsigned long)ijk.i,
(unsigned long)ijk.j);
}
}

For CaeStrXMLCPP::writeBlkConnections() usage see CaeStrConnection.

For CaeStrXMLCPP::writeBlkBoundaries() usage see CaeStrBoundary.

Definition at line 71 of file CaeStrBlock.h.

Constructor & Destructor Documentation

◆ CaeStrBlock() [1/5]

CaeStrBlock::CaeStrBlock ( )
inline

Default constructor.

Constructs an invalid block.

Note
The block can be made valid using moveTo() or moveFirst().
See also
moveTo(), moveFirst(), moveNext(), movePrev()

Definition at line 81 of file CaeStrBlock.h.

◆ CaeStrBlock() [2/5]

CaeStrBlock::CaeStrBlock ( PWGM_HBLOCK  block)
inline

Block handle constructor.

Constructs a structured block object bound to the specified block.

Parameters
blockThe block handle to bind.

Definition at line 89 of file CaeStrBlock.h.

◆ CaeStrBlock() [3/5]

CaeStrBlock::CaeStrBlock ( const CaeStrBlock src)
inline

Copy constructor.

Binds this block to the same block as src.

Parameters
srcA block instance.

Definition at line 97 of file CaeStrBlock.h.

◆ CaeStrBlock() [4/5]

CaeStrBlock::CaeStrBlock ( const CaeBlock src)
inline

CaeBlock constructor.

Binds this block to the same block as src.

Parameters
srcA base block instance.

Definition at line 105 of file CaeStrBlock.h.

◆ CaeStrBlock() [5/5]

CaeStrBlock::CaeStrBlock ( const CaeStrGridModel model,
PWP_UINT32  ndx = 0 
)
inline

Model and block index constructor.

Constructs a structured block object bound to the block at the specified index.

Parameters
modelThe structured grid model.
ndxThe block's index.

Definition at line 115 of file CaeStrBlock.h.

◆ ~CaeStrBlock()

virtual CaeStrBlock::~CaeStrBlock ( )
inlinevirtual

Destructor.

Definition at line 120 of file CaeStrBlock.h.

Member Function Documentation

◆ data()

bool CaeStrBlock::data ( PWGM_BLOCKDATA data) const
inline

Gets information about the block.

Parameters
dataThe block information data buffer.
Returns
true if successful.
Sample usage:
// see CaeStrXMLCPP::writeBlock() above
if (block.data(blkData)) {
// use block data
}

Definition at line 141 of file CaeStrBlock.h.

References CaeBlock::block_, and PwBlock().

Referenced by ndxVertData().

◆ model()

CaeStrGridModel CaeStrBlock::model ( ) const
inline

Gets the structured grid model of which this block is a member.

Definition at line 124 of file CaeStrBlock.h.

References CaeBlock::block_, and PWGM_HBLOCK_MODEL.

◆ ndxVertData()

bool CaeStrBlock::ndxVertData ( PWGM_INDEX3  ndx3,
PWGM_VERTDATA data 
) const
inline

Get the block's vertex data at the given index location.

Parameters
ndx3The ijk index.
dataThe vertex data buffer.
Returns
true if successful.
Sample usage:
// see CaeStrXMLCPP::writeBlkVertices() above
PWGM_INDEX3 ijk = {0, 12, 5};
if (block.ndxVertData(ijk, data)) {
// use vertex data
}

Definition at line 177 of file CaeStrBlock.h.

References CaeBlock::block_, data(), and PwBlkNdxVertData().

◆ size()

bool CaeStrBlock::size ( PWGM_STR_SIZE size) const
inline

Gets the structured ijk size of the block's vertices.

Parameters
sizeThe block vertex size.
Returns
true if successful.
Sample usage:
// see CaeStrXMLCPP::writeBlock() above
if (block.size(size)) {
// use block size
}

Definition at line 158 of file CaeStrBlock.h.

References CaeBlock::block_, and PwBlkSize().


The documentation for this class was generated from the following file:
PWGM_INDEX3::j
PWP_INT32 j
j-coordinate used for 3D and 2D grids
Definition: apiGridModel.h:890
CaeStrBlock::ndxVertData
bool ndxVertData(PWGM_INDEX3 ndx3, PWGM_VERTDATA &data) const
Get the block's vertex data at the given index location.
Definition: CaeStrBlock.h:177
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
PWGM_BLOCKDATA::name
const char * name
name
Definition: apiGridModel.h:1006
CaeStrBlock::data
bool data(PWGM_BLOCKDATA &data) const
Gets information about the block.
Definition: CaeStrBlock.h:141
PWGM_INDEX3::i
PWP_INT32 i
i-coordinate used for 3D and 2D grids
Definition: apiGridModel.h:889
PWGM_INDEX3
Structured grid ijk index data type.
Definition: apiGridModel.h:888
CaeStrBlock
The structured block class.
Definition: CaeStrBlock.h:72
PWGM_VERTDATA
Vertex descriptor data type.
Definition: apiGridModel.h:607
PWGM_BLOCKDATA
Block data type.
Definition: apiGridModel.h:1005
PWGM_INDEX3::k
PWP_INT32 k
k-coordinate used for 3D grids only
Definition: apiGridModel.h:891
PWGM_STR_SIZE
PWGM_INDEX3 PW_DLL_IMPEXP PWGM_STR_SIZE
Structured grid ijk size data type.
Definition: apiGridModel.h:904
CaeBlock::index
PWP_UINT32 index() const
Get a block's index.
Definition: CaeGridModel.h:197
CaeCondition
The volume and boundary condition data class.
Definition: CaeGridModel.h:450
CaeStrBlock::size
bool size(PWGM_STR_SIZE &size) const
Gets the structured ijk size of the block's vertices.
Definition: CaeStrBlock.h:158
CaeBlock::condition
bool condition(PWGM_CONDDATA &condData) const
Gets the block's condition data.
Definition: CaeGridModel.h:215