Pointwise Plugin SDK
Public Member Functions | List of all members

The unstructured grid model face stream handler class. More...

#include <CaeUnsGridModel.h>

Public Member Functions

virtual PWP_UINT32 streamBegin (const PWGM_BEGINSTREAM_DATA &data)
 Virtual begin stream implementation. More...
 
virtual PWP_UINT32 streamEnd (const PWGM_ENDSTREAM_DATA &data)
 Virtual end stream implementation. More...
 
virtual PWP_UINT32 streamFace (const PWGM_FACESTREAM_DATA &data)=0
 Pure virtual face stream handler method. More...
 
virtual ~CaeFaceStreamHandler ()
 Destructor. More...
 

Detailed Description

The unstructured grid model face stream handler class.

Handler objects passed to CaeUnsGridModel::streamFaces() must inherit the CaeFaceStreamHandler class and implement the streamFace() pure virtual method. Optionally, the subclass can also reimplement the streamBegin() and streamEnd() virtual methods as needed.

Sample Usage:

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

The CaeUnsXMLCPP plugin sets the desired face and element type ordering in its CaeUnsXMLCPP::beginExport() method. The face order is obtained from the published faceOrder attribute. The element type order is hard-coded to TRI, QUAD, other.

bool
CaeUnsXMLCPP::beginExport()
{
model_.getAttribute("faceOrder", ord);
faceOrder_ = (PWGM_ENUM_FACEORDER)ord;
sendInfoMsg(model_.faceOrderStr(faceOrder_));
setProgressMajorSteps((writeInfo_.conditionsOnly ? 0 : 3)
+ model_.blockCount() + model_.patchCount());
model_.appendEnumElementOrder(PWGM_ELEMORDER_TRI);
model_.appendEnumElementOrder(PWGM_ELEMORDER_QUAD);
return true;
}

During the execution of the CaeUnsXMLCPP::write() method, the CaeUnsXMLCPP plugin starts streaming faces with a call to its CaeUnsXMLCPP::writeFaces() method. Since CaeUnsXMLCPP inherits from CaeFaceStreamHandler, it uses itself, *this, as the stream handler. Faces will only be steamed if the export has not been aborted and if CaePlugin::conditionsOnly() returns false.

void
CaeUnsXMLCPP::writeFaces()
{
if (aborted()) {
// do nothing
}
else if (conditionsOnly()) {
progressEndStep();
}
else {
model_.streamFaces(faceOrder_, *this);
}
}

The CaeUnsXMLCPP plugin implements the stream handler methods. CaeUnsXMLCPP::streamBegin() writes an XML <faces> tag followed by the element count details. CaeUnsXMLCPP::streamFace() calls CaeUnsXMLCPP::writeFaceData() for each streamed face. CaeUnsXMLCPP::streamEnd() writes an XML </faces> tag. In all cases, the handler functions return the value from a progress method. These methods only return false if the export has been aborted.

CaeUnsXMLCPP::streamBegin(const PWGM_BEGINSTREAM_DATA &data)
{
writeComment(
"\n**************************************************************\n"
"\tGRID FACES\n"
"**************************************************************\n"
);
fprintf(fp(), "%s<faces count='%lu' bcount='%lu' icount='%lu'>\n", tabs(),
(unsigned long)data.totalNumFaces,
(unsigned long)data.numBoundaryFaces,
(unsigned long)data.numInteriorFaces);
++tabs_;
writeElemCounts(data.counts);
return progressBeginStep(data.totalNumFaces);
}
CaeUnsXMLCPP::streamFace(const PWGM_FACESTREAM_DATA &data)
{
writeFaceData(data);
return progressIncrement();
}
CaeUnsXMLCPP::streamEnd(const PWGM_ENDSTREAM_DATA &data)
{
(void)data.ok; // silence unused param warning
--tabs_;
fprintf(fp(), "%s</faces>\n", tabs());
return progressEndStep();
}

CaeUnsXMLCPP::writeFaceData() writes an XML <face> tag. Depending on the face's data.type, different tag attributes are written. If a boundary face, the condition data is written with a call to CaeUnsXMLCPP::writeCondData(). For all faces, the element connectivity is written with a call to CaeUnsXMLCPP::writeElemData(). Finally, a closing </face> tag is written.

void
CaeUnsXMLCPP::writeFaceData(const PWGM_FACESTREAM_DATA &data)
{
fprintf(fp(), "%s<face type='%s' id='%lu' ownerCell='%lu'>\n", tabs(),
faceType2Str(data.type), (unsigned long)data.face,
(unsigned long)data.owner.cellIndex);
++tabs_;
if (CaeUnsPatch(data.owner.domain).condition(cData)) {
writeCondData(cData);
}
}
else {
fprintf(fp(), "%s<face type='%s' id='%lu' ownerCell='%lu' "
"neighborCell='%lu'>\n", tabs(), faceType2Str(data.type),
(unsigned long)data.face, (unsigned long)data.owner.cellIndex,
(unsigned long)data.neighborCellIndex);
++tabs_;
}
writeElemData(data.elemData);
--tabs_;
fprintf(fp(), "%s</face>\n", tabs());
}

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 72 of file CaeUnsGridModel.h.

Constructor & Destructor Documentation

◆ ~CaeFaceStreamHandler()

virtual CaeFaceStreamHandler::~CaeFaceStreamHandler ( )
inlinevirtual

Destructor.

Definition at line 76 of file CaeUnsGridModel.h.

Member Function Documentation

◆ streamBegin()

virtual PWP_UINT32 CaeFaceStreamHandler::streamBegin ( const PWGM_BEGINSTREAM_DATA data)
inlinevirtual

Virtual begin stream implementation.

This method is called only once by CaeUnsGridModel::streamFaces() just before faces are streamed.

Subclasses are not required to implement this virtual method. The default implementation does nothing and returns 1.

Parameters
dataThe begin stream data.
Returns
non-zero to indicate success.
See also
streamFace(), streamEnd()
Note
See CaeFaceStreamHandler for sample usage.

Definition at line 93 of file CaeUnsGridModel.h.

References PWGM_BEGINSTREAM_DATA::userData.

Referenced by beginCB().

◆ streamEnd()

virtual PWP_UINT32 CaeFaceStreamHandler::streamEnd ( const PWGM_ENDSTREAM_DATA data)
inlinevirtual

Virtual end stream implementation.

This method is called only once by CaeUnsGridModel::streamFaces() after all faces have been streamed.

Subclasses are not required to implement this virtual method. The default implementation does nothing and returns 1.

Parameters
dataThe end stream data.
Returns
non-zero to indicate success.
See also
streamBegin(), streamFace()
Note
See CaeFaceStreamHandler() for sample usage.

Definition at line 126 of file CaeUnsGridModel.h.

References PWGM_ENDSTREAM_DATA::userData.

Referenced by endCB().

◆ streamFace()

virtual PWP_UINT32 CaeFaceStreamHandler::streamFace ( const PWGM_FACESTREAM_DATA data)
pure virtual

Pure virtual face stream handler method.

This method is called once by CaeUnsGridModel::streamFaces() for each face in the grid model.

Subclasses are required to implement this virtual method.

Parameters
dataThe face data.
Returns
non-zero to indicate success.
See also
streamBegin(), streamEnd()
Note
See CaeFaceStreamHandler() for sample usage.

Referenced by faceCB().


The documentation for this class was generated from the following file:
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_FACEREF_DATA::cellIndex
PWP_UINT32 cellIndex
The cell's index in the model's index space (0..totalNumCells-1)
Definition: apiGridModel.h:1106
PWGM_FACESTREAM_DATA::owner
PWGM_FACEREF_DATA owner
Information about the block element that owns face.
Definition: apiGridModel.h:1154
CaeUnsPatch
The unstructured patch class.
Definition: CaeUnsPatch.h:69
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
PWGM_FACEREF_DATA::domain
PWGM_HDOMAIN domain
The handle of the boundary domain that contains this cell's side of the face.
Definition: apiGridModel.h:1124
PWGM_FACESTREAM_DATA::type
PWGM_ENUM_FACETYPE type
One of the PWGM_FACETYPE_XXX types.
Definition: apiGridModel.h:1150
PWGM_ELEMORDER_QUAD
@ PWGM_ELEMORDER_QUAD
Order by 2D, 4-sided grid element.
Definition: apiGridModel.h:703
PWGM_FACESTREAM_DATA::elemData
PWGM_ELEMDATA elemData
The face's element data.
Definition: apiGridModel.h:1145
PWGM_FACESTREAM_DATA::neighborCellIndex
PWP_UINT32 neighborCellIndex
The cell index for the block element on the other side of the face.
Definition: apiGridModel.h:1142
PWGM_ELEMORDER_TRI
@ PWGM_ELEMORDER_TRI
Order by 2D, 3-sided grid element.
Definition: apiGridModel.h:705
PWGM_BEGINSTREAM_DATA::counts
PWGM_ELEMCOUNTS counts
The model's total element counts.
Definition: apiGridModel.h:1089
PWGM_BEGINSTREAM_DATA::totalNumFaces
PWP_UINT32 totalNumFaces
The total number of faces in the entire model (= numBoundaryFaces + numInteriorFaces).
Definition: apiGridModel.h:1086
PWGM_BEGINSTREAM_DATA
Data passed to a PWGM_BEGINSTREAMCB callback function.
Definition: apiGridModel.h:1084
PWGM_BEGINSTREAM_DATA::numInteriorFaces
PWP_UINT32 numInteriorFaces
How many faces in totalNumFaces that are interior to the model.
Definition: apiGridModel.h:1088
PWGM_ENDSTREAM_DATA::ok
PWP_BOOL ok
PWP_TRUE if streaming completed successfully.
Definition: apiGridModel.h:1172
PWGM_CONDDATA
Condition descriptor data type.
Definition: apiGridModel.h:644
PWGM_ENDSTREAM_DATA
Data passed to a PWGM_ENDSTREAMCB callback function.
Definition: apiGridModel.h:1170
PWGM_FACESTREAM_DATA
Data passed to a PWGM_FACESTREAMCB callback function.
Definition: apiGridModel.h:1133
PWGM_FACETYPE_BOUNDARY
@ PWGM_FACETYPE_BOUNDARY
The cell face is on the grid's boundary.
Definition: apiGridModel.h:1036
CaeUnsPatch::condition
bool condition(PWGM_CONDDATA &data) const
Get the patch's condition data.
Definition: CaeUnsPatch.h:140
PWGM_BEGINSTREAM_DATA::numBoundaryFaces
PWP_UINT32 numBoundaryFaces
How many faces in totalNumFaces lie on the model's boundary.
Definition: apiGridModel.h:1087
PWGM_ENUM_FACEORDER
PWGM_ENUM_FACEORDER
The orderings supported by face streaming.
Definition: apiGridModel.h:1059
PWGM_FACESTREAM_DATA::face
PWP_UINT32 face
The face's index in the model's index space.
Definition: apiGridModel.h:1138