cee::ug::DataState Class Reference

A state contains all data available for one time step, load case or frequency. More...

Public Member Functions

 DataState (int id, size_t geometryCount)
 Constructs an empty state. More...
 
int id () const
 Returns the id of the state. More...
 
size_t geometryCount () const
 Returns number of geometries. More...
 
const DataGeometrygeometry (size_t globalGeometryIndex) const
 Returns the geometry at the requested index. More...
 
DataGeometrygeometry (size_t globalGeometryIndex)
 Returns the geometry at the requested index. More...
 
const DataGeometryfirstGeometry () const
 Returns the first geometry. More...
 
DataGeometryfirstGeometry ()
 Returns the first geometry. More...
 
void setGeometry (size_t globalGeometryIndex, DataGeometry *geometry)
 Adds a geometry to the state and given index. More...
 
const DataResultGroupresults (const DataGeometry *geometry) const
 Returns the result group for the given geometry. More...
 
DataResultGroupresults (const DataGeometry *geometry)
 Returns the result group for the given geometry. More...
 
const DataResultGroupresultsFirstGeometry () const
 Returns the result group for the first geometry. More...
 
DataResultGroupresultsFirstGeometry ()
 Returns the result group for the first geometry. More...
 
const DataPartfindPart (size_t globalGeometryIndex, int partId) const
 Returns the part specified by a geometry index and a part id. More...
 
DataPartfindPart (size_t globalGeometryIndex, int partId)
 Returns the part specified by a geometry index and a part id. 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::DataState:
cee::RefCountedObject

Detailed Description

A state contains all data available for one time step, load case or frequency.

The state owns one or more geometries and corresponding results. For each geometry there is a result group binding the geometry and results. A data source must contain one or more states. Which state is current is set in the model specification (ModelSpec).

A unique id and the number of geometries for a state is set upon construction of the state and cannot be changes afterwards. To query number of geometries for a state, call geometryCount() and use id() to get the id for the current state.

Geometries are added to the state using setGeometry() with an index that must be within the number of geometries given when constructing the object. To get a pointer to a DataGeometry object in a state, call geometry() with the requested index. For convenience, the function firstGeometry() will always return the geometry and index 0.

A DataResultGroup is a binding between a geometry and it's results. Find the correct result group calling results() and passing the corresponding geometry as a parameter. The function resultsFirstGeometry() is implemented for convenience and will return the result group for the first geometry in the state. resultsFirstGeometry() equals results(firstGeometry()).

Note
Remember that since this object is reference counted it should never be created on the stack.
Example - Creating a new state

Example on building your data source and geometry.

Create a model and a data source.

Create the state. Set number of geometries to 1 in the constructor.

int stateId = 1;
dataSource->addState(state.get());

Set the newly created state to current in the model specification.

ugModel->modelSpec().setStateId(stateId);

Create the geometry and add it to the state at index 0.

int geometryIndex = 0;
state->setGeometry(geometryIndex, geo.get());

See the complete source code at: UnstructGrid: Simple model with two triangles

See also
ModelSpec
DataSource
DataGeometry
DataResultGroup
Tutorials
UnstructGrid: Simple model with two triangles
UnstructGrid: A simple model with results

Constructor & Destructor Documentation

cee::ug::DataState::DataState ( int  id,
size_t  geometryCount 
)

Constructs an empty state.

Specify number of geometries (geometryCount) for the new state and give it a unique id.

Member Function Documentation

const DataPart * cee::ug::DataState::findPart ( size_t  globalGeometryIndex,
int  partId 
) const

Returns the part specified by a geometry index and a part id.

Returns NULL if no part was found.

DataPart * cee::ug::DataState::findPart ( size_t  globalGeometryIndex,
int  partId 
)

Returns the part specified by a geometry index and a part id.

Returns NULL if no part was found.

const DataGeometry * cee::ug::DataState::firstGeometry ( ) const

Returns the first geometry.

Equals geometry(0). Provided for convenience. Returns NULL if no geometries exists.

DataGeometry * cee::ug::DataState::firstGeometry ( )

Returns the first geometry.

Equals geometry(0). Provided for convenience. Returns NULL if no geometries exists.

const DataGeometry * cee::ug::DataState::geometry ( size_t  globalGeometryIndex) const

Returns the geometry at the requested index.

DataGeometry * cee::ug::DataState::geometry ( size_t  globalGeometryIndex)

Returns the geometry at the requested index.

size_t cee::ug::DataState::geometryCount ( ) const

Returns number of geometries.

int cee::ug::DataState::id ( ) const

Returns the id of the state.

const DataResultGroup * cee::ug::DataState::results ( const DataGeometry geometry) const

Returns the result group for the given geometry.

For each geometry there is a result group binding the geometry and results.

DataResultGroup * cee::ug::DataState::results ( const DataGeometry geometry)

Returns the result group for the given geometry.

For each geometry there is a result group binding the geometry and results.

const DataResultGroup * cee::ug::DataState::resultsFirstGeometry ( ) const

Returns the result group for the first geometry.

Equals results(firstGeometry()). Returns NULL if no geometries exists. For each geometry there is a result group binding the geometry and results.

DataResultGroup * cee::ug::DataState::resultsFirstGeometry ( )

Returns the result group for the first geometry.

Equals results(firstGeometry()). Returns NULL if no geometries exists. For each geometry there is a result group binding the geometry and results.

void cee::ug::DataState::setGeometry ( size_t  globalGeometryIndex,
DataGeometry geometry 
)

Adds a geometry to the state and given index.

The globalGeometryIndex must be within the number of geometries specified upon construction of the state.

Warning
The added object is reference counted and should never be created on the stack or deleted!