cee::ug::DataState

class DataState : public RefCountedObject

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

../_images/uml_datastate.png

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.

cee::PtrRef<cee::ug::UnstructGridModel> ugModel = new cee::ug::UnstructGridModel();
cee::PtrRef<cee::ug::DataSourceMemory> dataSource = new cee::ug::DataSourceMemory(1, 1);
ugModel->setDataSource(dataSource.get());

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

int stateId = 1;
cee::PtrRef<cee::ug::DataState> state = new cee::ug::DataState(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;
cee::PtrRef<cee::ug::DataGeometry> geo = new cee::ug::DataGeometry();
state->setGeometry(geometryIndex, geo.get());

See the complete source code at: UnstructGrid: Simple Model with Two Triangles

Tutorials

Public Functions

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.

int id() const

Returns the id of the state.

size_t geometryCount() const

Returns number of geometries.

const DataGeometry *geometry(size_t globalGeometryIndex) const

Returns the geometry at the requested index.

DataGeometry *geometry(size_t globalGeometryIndex)

Returns the geometry at the requested index.

const DataGeometry *firstGeometry() const

Returns the first geometry.

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

DataGeometry *firstGeometry()

Returns the first geometry.

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

void 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!

const DataResultGroup *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 *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 *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 *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.

const DataPart *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 *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.