cee::ug::DataResultScalar Class Reference

Scalar result for all parts in the geometry. More...

Public Member Functions

 DataResultScalar (int resultId, ResultMapping mappingType)
 Constructs an empty object. More...
 
int resultId () const
 Returns the result id. More...
 
size_t partCount () const
 Returns number of scalar parts in this scalar result. More...
 
const DataPartScalarpart (size_t partIndex) const
 Returns the part at the given index. More...
 
DataPartScalarpart (size_t partIndex)
 Returns the part at the given index. More...
 
ResultMapping resultMapping () const
 Returns the result mapping for this result. More...
 
void addPart (DataPartScalar *part)
 Adds a scalar part to the result scalar. More...
 
void removeAllParts ()
 Removes all scalar parts. More...
 
void computeNodeAverage (const DataGeometry *geometry)
 Computes node average values of the scalar result. More...
 
- Public Member Functions inherited from cee::RefCountedObject
void addRef () const
 Increments the reference count for this object. More...
 
void release () const
 Decrements the reference count for this object. More...
 
int refCount () const
 Returns the reference count for this object. More...
 
void setRefCountZero () const
 Sets the ref count to zero, but DOES NOT delete the object. More...
 
Inheritance diagram for cee::ug::DataResultScalar:
cee::RefCountedObject

Detailed Description

Scalar result for all parts in the geometry.

The DataResultScalar holds a collection of DataPartScalar objects, each containing an array of scalar values for the belonging part. The DataResultScalar has a result mapping type(per node, per element, per element node or per element surface) which applies to all its scalar parts.

Each DataResultScalar has a unique id.

The number of parts in the result scalar and in the geometry must be the same. And the number of result values in each scalar part must match the number of nodes/elements in the part (depending on mapping type). For instance, a node mapped result will need the same number of result values in the scalar part as there are nodes in the part.

The id and result mapping is set upon construction of the object and cannot be changed afterwards. The selected id and result mapping can be found by calling resultId() and resultMapping().

DataPartScalar objects can be added using addPart(). Get the number of parts in the scalar with partCount() and accessed individual parts by calling part() with the requested index. All parts can be removed using removeAllParts().

Scalar result values can be visualized as fringes. Set which scalar results to show using UnstructGridModel::modelSpec().

To configure the setting for a scalar result, use ScalarSettings. Get the scalar settings by calling UnstructGridModel::scalarSettings() with the requested result id.

cee::ug::ScalarSettings* settings = ugModel->scalarSettings(42);
Note
The class is reference counted and can be shared between multiple result groups. Remember that since this object is reference counted it should never be created on the stack.
Example

Example of how to add a node based scalar result to a geometry consisting of only one triangle.

Create the scalar result object with a unique id and node based result mapping.

int scalarResultId = 1;

The result array must have one value for each node in the triangle. Resize the array before inserting the results.

scalarPart->resize(3);
scalarPart->setValue(0, 1.0);
scalarPart->setValue(1, 2.0);
scalarPart->setValue(2, 3.0);

Add the scalar part to the result. The result must contain the same number of parts as the corresponding geometry.

scalarResult->addPart(scalarPart.get());

For each geometry there is a result group binding the geometry and results. Add the result scalar to the state (DataState) for the corresponding geometry (DataGeometry) geo

state->results(geo.get())->addScalar(scalarResult.get());

The result is now created and added to the model.

To tell the model to use this result, you must set the current scalar result in the model's model specification.

ugModel->modelSpec().setFringesResultId(scalarResultId);

To visualize the scalar result, you have to toggle the visibility of fringes in the part settings for each part.

ugModel->partSettings(geometryIndex, partId)->setFringesVisible(true);

See the complete source code at: UnstructGrid: A simple model with results

See also
DataPartScalar
ModelSpec
UnstructGridModel
ScalarSettings
Tutorials
UnstructGrid: A simple model with results

Constructor & Destructor Documentation

cee::ug::DataResultScalar::DataResultScalar ( int  resultId,
ResultMapping  mappingType 
)

Constructs an empty object.

A unique id and the mapping type are decided upon construction.

See also
ResultMapping

Member Function Documentation

void cee::ug::DataResultScalar::addPart ( DataPartScalar part)

Adds a scalar part to the result scalar.

Number of parts must match the number of parts in the corresponding geometry.

Warning
The added object is reference counted and should never be created on the stack or deleted!
void cee::ug::DataResultScalar::computeNodeAverage ( const DataGeometry geometry)

Computes node average values of the scalar result.

This method will compute a nodal result with the average scalar value for each node in the geometry.

const DataPartScalar * cee::ug::DataResultScalar::part ( size_t  partIndex) const

Returns the part at the given index.

DataPartScalar * cee::ug::DataResultScalar::part ( size_t  partIndex)

Returns the part at the given index.

size_t cee::ug::DataResultScalar::partCount ( ) const

Returns number of scalar parts in this scalar result.

void cee::ug::DataResultScalar::removeAllParts ( )

Removes all scalar parts.

int cee::ug::DataResultScalar::resultId ( ) const

Returns the result id.

ResultMapping cee::ug::DataResultScalar::resultMapping ( ) const

Returns the result mapping for this result.

See also
ResultMapping