Pointwise Plugin SDK
Public Member Functions | Protected Attributes | List of all members

The unstructured patch class. More...

#include <CaeUnsPatch.h>

+ Inheritance diagram for CaeUnsPatch:
+ Collaboration diagram for CaeUnsPatch:

Public Member Functions

 CaeUnsPatch ()
 Default constructor. More...
 
 CaeUnsPatch (const CaeUnsGridModel &model, PWP_UINT32 ndx=0)
 Model and patch index constructor. More...
 
 CaeUnsPatch (const CaeUnsPatch &src)
 Copy constructor. More...
 
 CaeUnsPatch (PWGM_HDOMAIN domain)
 Domain handle constructor. More...
 
bool condition (PWGM_CONDDATA &data) const
 Get the patch's condition data. More...
 
PWP_UINT32 index () const
 Get the patch's index. More...
 
bool isValid () const
 Determines a patch's validity. More...
 
CaeUnsGridModel model () const
 Gets the unstructured grid model of which this patch is a member. More...
 
CaeUnsPatchmoveFirst (const CaeUnsGridModel &model)
 Rebinds an instance to the first patch in a model. More...
 
CaeUnsPatchmoveNext ()
 Rebinds an instance to the next patch in a model. More...
 
CaeUnsPatchmovePrev ()
 Rebinds an instance to the previous patch in a model. More...
 
CaeUnsPatchmoveTo (const CaeUnsGridModel &model, PWP_UINT32 ndx)
 Rebinds an instance to a specific model patch. More...
 
 operator PWGM_HDOMAIN () const
 The PWGM_HDOMAIN cast operator. More...
 
CaeUnsPatchoperator++ ()
 Prefix increment to the next patch in a model. More...
 
CaeUnsPatch operator++ (int)
 Postfix increment to the next patch in a model. More...
 
CaeUnsPatchoperator-- ()
 Prefix decrement to the previous patch in a model. More...
 
CaeUnsPatch operator-- (int)
 Postfix decrement to the previous patch in a model. More...
 
CaeUnsPatchoperator= (const CaeUnsPatch &rhs)
 Assignment operator. More...
 
CaeUnsPatchoperator= (PWGM_HDOMAIN domain)
 Assignment operator. More...
 
virtual ~CaeUnsPatch ()
 Destructor. 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...
 

Protected Attributes

PWGM_HDOMAIN h_
 The bound PWGM_HDOMAIN. More...
 

Additional Inherited Members

- 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...
 

Detailed Description

The unstructured patch class.

The CaeUnsPatch class represents a collection of unstructured grid model elements sharing a common boundary condition. The grid model patches are indexed from 0 to CaeUnsGridModel::patchCount() - 1.

For 3D grid models, patch elements are 2D (not necessarily planar) polygons. Currently, only 3-point TRI and 4-point QUAD elements are supported. However, if the grid model contains hex blocks with collapsed faces, it is possible that 2-point BAR elements will be encountered. Typically, BAR elements can be skipped during export.

For 2D grid models, patch elements are 1D bars (2 points). However, if the grid model contains quad blocks with collapsed edges, it is possible that 1-point POINT elements will be encountered. Typically, POINT elements can be skipped during export.

A CaeUnsPatch object is aware of its relative position in the grid model. As a result, a given patch object can be moved (iterated) to its previous or next neighbor patch. It can also be moved to the first patch or to a patch at a given index. After being moved, a patch will return information about the patch 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 patches with a call to its CaeUnsXMLCPP::writePatches() method. First, it writes an XML <patches> tag. Then it moves through the patches one by one and calls the CaeUnsXMLCPP::writePatch() method. Finally, a closing </patches> tag is written.

void
CaeUnsXMLCPP::writePatches()
{
if (!aborted()) {
PWP_UINT32 cnt = model_.patchCount();
writeComment("**************** GRID PATCHES ***************");
fprintf(fp(), "%s<patches count='%lu'>\n", tabs(), (unsigned long)cnt);
++tabs_;
CaeUnsPatch patch(model_);
while (writePatch(patch)) {
++patch; // could also use patch.moveNext()
}
--tabs_;
fprintf(fp(), "%s</patches>\n", tabs());
}
}

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

bool
CaeUnsXMLCPP::writePatch(const CaeUnsPatch &patch)
{
bool ret = patch.isValid() && !aborted();
if (ret) {
PWP_UINT32 eCnt = patch.elementCount(&eCnts);
if (progressBeginStep(conditionsOnly() ? 1 : eCnt)) {
fprintf(fp(), "%s<patch id='%lu' count='%lu'>\n", tabs(),
(unsigned long)patch.index(), (unsigned long)eCnt);
++tabs_;
if (patch.condition(cData)) {
writeCondData(cData);
}
if (conditionsOnly()) {
progressIncrement();
}
else {
writeElemCounts(eCnts);
CaeUnsElement element(patch);
while (element.data(eData) && progressIncrement()) {
writeElemData(eData);
++element; // could also use element.moveNext()
}
}
--tabs_;
fprintf(fp(), "%s</patch>\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 69 of file CaeUnsPatch.h.

Constructor & Destructor Documentation

◆ CaeUnsPatch() [1/4]

CaeUnsPatch::CaeUnsPatch ( )
inline

Default constructor.

Constructs an invalid patch.

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

Definition at line 78 of file CaeUnsPatch.h.

References h_.

◆ CaeUnsPatch() [2/4]

CaeUnsPatch::CaeUnsPatch ( PWGM_HDOMAIN  domain)
inline

Domain handle constructor.

Constructs an unstructured patch object bound to the specified domain.

Parameters
domainThe domain handle to bind.

Definition at line 87 of file CaeUnsPatch.h.

◆ CaeUnsPatch() [3/4]

CaeUnsPatch::CaeUnsPatch ( const CaeUnsPatch src)
inline

Copy constructor.

Binds this patch to the same patch as src.

Parameters
srcA patch instance.

Definition at line 95 of file CaeUnsPatch.h.

References h_.

◆ CaeUnsPatch() [4/4]

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

Model and patch index constructor.

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

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

Definition at line 106 of file CaeUnsPatch.h.

References model(), and moveTo().

◆ ~CaeUnsPatch()

virtual CaeUnsPatch::~CaeUnsPatch ( )
inlinevirtual

Destructor.

Definition at line 111 of file CaeUnsPatch.h.

Member Function Documentation

◆ condition()

bool CaeUnsPatch::condition ( PWGM_CONDDATA data) const
inline

Get the patch's condition data.

Returns
true if successful.
Sample usage:
// see CaeUnsXMLCPP::writePatch() above
if (patch.condition(cData)) {
writeCondData(cData);
}
void
CaeUnsXMLCPP::writeCondData(const PWGM_CONDDATA &condData)
{
fprintf(fp(), "%s<condition name='%s' id='%ld' type='%s' typeid='%ld' />\n",
tabs(), condData.name, (long)condData.id, condData.type,
(long)condData.tid);
}

Definition at line 140 of file CaeUnsPatch.h.

References h_, and PwDomCondition().

◆ index()

PWP_UINT32 CaeUnsPatch::index ( ) const
inline

Get the patch's index.

Returns
The patch's grid model index.

Definition at line 123 of file CaeUnsPatch.h.

References h_, and PWGM_HDOMAIN_ID.

Referenced by moveNext(), and movePrev().

◆ isValid()

bool CaeUnsPatch::isValid ( ) const
inline

Determines a patch's validity.

Returns
true if the patch is valid.

Definition at line 146 of file CaeUnsPatch.h.

References h_, and PWGM_HDOMAIN_ISVALID.

Referenced by CaeUnsGridModel::patchElementCount().

◆ model()

CaeUnsGridModel CaeUnsPatch::model ( ) const
inline

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

Definition at line 115 of file CaeUnsPatch.h.

References h_, and PWGM_HDOMAIN_H.

Referenced by CaeUnsPatch(), moveFirst(), and moveTo().

◆ moveFirst()

CaeUnsPatch& CaeUnsPatch::moveFirst ( const CaeUnsGridModel model)
inline

Rebinds an instance to the first patch in a model.

Parameters
modelThe unstructured grid model.
Returns
A self reference.
Note
Equivalent to calling moveTo(model, 0).
See also
moveTo(), movePrev(), moveNext()

Definition at line 192 of file CaeUnsPatch.h.

References model(), and moveTo().

◆ moveNext()

CaeUnsPatch& CaeUnsPatch::moveNext ( )
inline

Rebinds an instance to the next patch in a model.

Returns
A self reference.
Note
If already on the last patch, the patch will become invalid.
See also
moveTo(), moveFirst(), movePrev(), isValid()

Definition at line 202 of file CaeUnsPatch.h.

References h_, index(), moveTo(), and PWGM_HDOMAIN_H.

Referenced by operator++().

◆ movePrev()

CaeUnsPatch& CaeUnsPatch::movePrev ( )
inline

Rebinds an instance to the previous patch in a model.

Returns
A self reference.
Note
If already on the first patch, the patch will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 236 of file CaeUnsPatch.h.

References h_, index(), moveTo(), and PWGM_HDOMAIN_H.

Referenced by operator--().

◆ moveTo()

CaeUnsPatch& CaeUnsPatch::moveTo ( const CaeUnsGridModel model,
PWP_UINT32  ndx 
)
inline

Rebinds an instance to a specific model patch.

Parameters
modelThe unstructured grid model.
ndxThe patch's index.
Returns
A self reference.
Note
If ndx is not a valid index, the patch will become invalid.
See also
moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 180 of file CaeUnsPatch.h.

References h_, model(), and PwModEnumDomains().

Referenced by CaeUnsPatch(), moveFirst(), moveNext(), and movePrev().

◆ operator PWGM_HDOMAIN()

CaeUnsPatch::operator PWGM_HDOMAIN ( ) const
inline

The PWGM_HDOMAIN cast operator.

Definition at line 265 of file CaeUnsPatch.h.

References h_.

◆ operator++() [1/2]

CaeUnsPatch& CaeUnsPatch::operator++ ( )
inline

Prefix increment to the next patch in a model.

Returns
A self reference.
Note
Equivalent to calling moveNext().
If already on the last patch, the patch will become invalid.
See also
moveTo(), moveFirst(), movePrev(), isValid()

Definition at line 214 of file CaeUnsPatch.h.

References moveNext().

Referenced by operator++().

◆ operator++() [2/2]

CaeUnsPatch CaeUnsPatch::operator++ ( int  )
inline

Postfix increment to the next patch in a model.

Returns
A copy of the patch before it was moved.
Note
If already on the last patch, the patch will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 224 of file CaeUnsPatch.h.

References operator++().

◆ operator--() [1/2]

CaeUnsPatch& CaeUnsPatch::operator-- ( )
inline

Prefix decrement to the previous patch in a model.

Returns
A self reference.
Note
Equivalent to calling movePrev().
If already on the first patch, the patch will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 248 of file CaeUnsPatch.h.

References movePrev().

Referenced by operator--().

◆ operator--() [2/2]

CaeUnsPatch CaeUnsPatch::operator-- ( int  )
inline

Postfix decrement to the previous patch in a model.

Returns
A copy of the patch before it was moved.
Note
If already on the first patch, the patch will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 258 of file CaeUnsPatch.h.

References operator--().

◆ operator=() [1/2]

CaeUnsPatch& CaeUnsPatch::operator= ( const CaeUnsPatch rhs)
inline

Assignment operator.

Rebind this instance to the same patch as rhs.

Parameters
rhsA patch instance.
Returns
A self reference.

Definition at line 156 of file CaeUnsPatch.h.

References h_.

◆ operator=() [2/2]

CaeUnsPatch& CaeUnsPatch::operator= ( PWGM_HDOMAIN  domain)
inline

Assignment operator.

Rebind this instance to the specified domain handle.

Parameters
domainThe domain handle.
Returns
A self reference.

Definition at line 167 of file CaeUnsPatch.h.

References h_.

Member Data Documentation

◆ h_

PWGM_HDOMAIN CaeUnsPatch::h_
protected

The documentation for this class was generated from the following file:
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_CONDDATA::id
PWP_UINT32 id
grid-defined condition id
Definition: apiGridModel.h:646
PWGM_CONDDATA::tid
PWP_UINT32 tid
cae-defined condition id
Definition: apiGridModel.h:648
PWGM_CONDDATA::name
const char * name
grid-defined condition name
Definition: apiGridModel.h:645
CaeUnsPatch::isValid
bool isValid() const
Determines a patch's validity.
Definition: CaeUnsPatch.h:146
CaeUnsPatch::index
PWP_UINT32 index() const
Get the patch's index.
Definition: CaeUnsPatch.h:123
PWGM_CONDDATA::type
const char * type
cae-defined condition physical type name
Definition: apiGridModel.h:647
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
CaeUnsElement
The unstructured element class.
Definition: CaeUnsElement.h:544
PWGM_ELEMCOUNTS
Element count information.
Definition: apiGridModel.h:774
PWGM_CONDDATA
Condition descriptor data type.
Definition: apiGridModel.h:644
CaeUnsPatch::condition
bool condition(PWGM_CONDDATA &data) const
Get the patch's condition data.
Definition: CaeUnsPatch.h:140