Pointwise Plugin SDK
Public Member Functions | List of all members

The unstructured block class. More...

#include <CaeUnsBlock.h>

+ Inheritance diagram for CaeUnsBlock:
+ Collaboration diagram for CaeUnsBlock:

Public Member Functions

 CaeUnsBlock ()
 Default constructor. More...
 
 CaeUnsBlock (const CaeBlock &src)
 CaeBlock constructor. More...
 
 CaeUnsBlock (const CaeUnsBlock &src)
 Copy constructor. More...
 
 CaeUnsBlock (const CaeUnsGridModel &model, PWP_UINT32 ndx=0)
 Model and block index constructor. More...
 
 CaeUnsBlock (PWGM_HBLOCK block)
 Block handle constructor. More...
 
CaeUnsGridModel model () const
 Gets the unstructured grid model of which this block is a member. More...
 
virtual ~CaeUnsBlock ()
 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 CaeUnsElementGroup
PWP_UINT32 elementCount (PWGM_ELEMCOUNTS *pDetails=0) const
 Get the number of elements in the group. More...
 
PWGM_HELEMENT enumElements (PWP_UINT32 ndx) const
 Get an element in the group. More...
 
PWGM_HELEMENT firstElement () const
 Get the first element in the group. More...
 
virtual ~CaeUnsElementGroup ()
 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 CaeUnsElementGroup
virtual PWP_UINT32 elementCountImpl (PWGM_ELEMCOUNTS *pDetails) const =0
 Get the number of elements in the group. More...
 
virtual PWGM_HELEMENT enumElementsImpl (PWP_UINT32 ndx) const =0
 Get an element in the group. More...
 
- Protected Attributes inherited from CaeBlock
PWGM_HBLOCK block_
 The bound PWGM_HBLOCK. More...
 

Detailed Description

The unstructured block class.

The CaeUnsBlock class represents a collection of unstructured grid model elements sharing a common volume condition. The grid model blocks are indexed from 0 to CaeGridModel::blockCount() - 1.

For 3D grid models, block elements are 3D polyhedrons. Currently, only 8-point HEX, 6-point WEDGE (PRISM), 5-point PYRAMID and 4-point TET elements are supported. See Cell Connectivity.

For 2D grid models, block elements are 2D (not necessarily planar) polygons. Currently, only 3-point TRI and 4-point QUAD elements are supported.

A CaeUnsBlock 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 CaeUnsBlock object will return information about the grid block at its current position.

Sample Usage:

The following snippets are extracted from the unstructured XML sample plugin (CaeUnsXMLCPP).

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

void
CaeUnsXMLCPP::writeBlocks()
{
if (!aborted()) {
writeComment("**************** GRID BLOCKS ****************");
PWP_UINT32 cnt = model_.blockCount();
fprintf(fp(), "%s<blocks count='%lu'>\n", tabs(), (unsigned long)cnt);
++tabs_;
CaeUnsBlock block(model_);
while (writeBlock(block)) {
++block; // could also use block.moveNext()
}
--tabs_;
fprintf(fp(), "%s</blocks>\n", tabs());
}
}

CaeUnsXMLCPP::writeBlock() writes an XML <block> tag. Next, the block condition data is written with a call to CaeUnsXMLCPP::writeCondData(). If only boundary conditions are being exported, the progress is incremented. Otherwise, the block's element data is exported. Finally, a closing </block> tag is written.

bool
CaeUnsXMLCPP::writeBlock(const CaeUnsBlock &block)
{
bool ret = block.isValid() && !aborted();
if (ret) {
PWP_UINT32 eCnt = block.elementCount(&eCnts);
if (progressBeginStep(conditionsOnly() ? 1 : eCnt)) {
fprintf(fp(), "%s<block id='%lu' count='%lu'>\n", tabs(),
(unsigned long)block.index(), (unsigned long)eCnt);
++tabs_;
if (block.condition(cData)) {
writeCondData(cData);
}
if (conditionsOnly()) {
progressIncrement();
}
else {
writeElemCounts(eCnts);
CaeUnsElement element(block);
while (element.data(eData) && progressIncrement()) {
writeElemData(eData);
++element; // could also use element.moveNext()
}
}
--tabs_;
fprintf(fp(), "%s</block>\n", tabs());
}
}
return progressEndStep() && ret;
}

CaeUnsXMLCPP::writeElemData() writes a self-closed XML <element /> tag.

void
CaeUnsXMLCPP::writeElemData(const PWGM_ELEMDATA &elemData)
{
char indices[256] = { '\0' }; // zero fill
char *p = indices;
for (PWP_UINT32 ii = 0; ii < elemData.vertCnt; ++ii) {
p += sprintf(p, " %lu", (unsigned long)elemData.index[ii]);
}
// indices + 1 skips leading space
fprintf(fp(), "%s<element type='%s' count='%lu' indices='%s' />\n", tabs(),
elemType2Str(elemData.type), (unsigned long)elemData.vertCnt,
indices + 1);
}

Definition at line 68 of file CaeUnsBlock.h.

Constructor & Destructor Documentation

◆ CaeUnsBlock() [1/5]

CaeUnsBlock::CaeUnsBlock ( )
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 77 of file CaeUnsBlock.h.

◆ CaeUnsBlock() [2/5]

CaeUnsBlock::CaeUnsBlock ( PWGM_HBLOCK  block)
inline

Block handle constructor.

Constructs an unstructured block object bound to the specified block.

Parameters
blockThe block handle to bind.

Definition at line 85 of file CaeUnsBlock.h.

◆ CaeUnsBlock() [3/5]

CaeUnsBlock::CaeUnsBlock ( const CaeUnsBlock src)
inline

Copy constructor.

Binds this block to the same block as src.

Parameters
srcA block instance.

Definition at line 93 of file CaeUnsBlock.h.

◆ CaeUnsBlock() [4/5]

CaeUnsBlock::CaeUnsBlock ( const CaeBlock src)
inline

CaeBlock constructor.

Binds this block to the same block as src.

Parameters
srcA base block instance.

Definition at line 101 of file CaeUnsBlock.h.

◆ CaeUnsBlock() [5/5]

CaeUnsBlock::CaeUnsBlock ( const CaeUnsGridModel model,
PWP_UINT32  ndx = 0 
)
inline

Model and block index constructor.

Constructs an unstructured block object bound to the block at the specified index.

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

Definition at line 111 of file CaeUnsBlock.h.

◆ ~CaeUnsBlock()

virtual CaeUnsBlock::~CaeUnsBlock ( )
inlinevirtual

Destructor.

Definition at line 116 of file CaeUnsBlock.h.

Member Function Documentation

◆ model()

CaeUnsGridModel CaeUnsBlock::model ( ) const
inline

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

Definition at line 120 of file CaeUnsBlock.h.

References CaeBlock::block_, and PWGM_HBLOCK_MODEL.


The documentation for this class was generated from the following file:
CaeUnsBlock
The unstructured block class.
Definition: CaeUnsBlock.h:68
CaeUnsElementGroup::elementCount
PWP_UINT32 elementCount(PWGM_ELEMCOUNTS *pDetails=0) const
Get the number of elements in the group.
Definition: CaeUnsElementGroup.h:59
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
PWGM_ELEMDATA::vertCnt
PWP_UINT32 vertCnt
Number of vertices in the face.
Definition: apiGridModel.h:739
PWGM_ELEMDATA::index
PWP_UINT32 index[8]
The vertex indices.
Definition: apiGridModel.h:741
PWGM_ELEMDATA::type
PWGM_ENUM_ELEMTYPE type
One of the PWGM_ELEMTYPE_XXX values.
Definition: apiGridModel.h:738
PWGM_ELEMDATA
Element descriptor data type.
Definition: apiGridModel.h:737
CaeUnsElement
The unstructured element class.
Definition: CaeUnsElement.h:544
CaeBlock::isValid
bool isValid() const
Determines a block's validity.
Definition: CaeGridModel.h:242
PWGM_ELEMCOUNTS
Element count information.
Definition: apiGridModel.h:774
PWGM_CONDDATA
Condition descriptor data type.
Definition: apiGridModel.h:644
CaeBlock::index
PWP_UINT32 index() const
Get a block's index.
Definition: CaeGridModel.h:197
CaeBlock::condition
bool condition(PWGM_CONDDATA &condData) const
Gets the block's condition data.
Definition: CaeGridModel.h:215