A custom built data source for an unstructured grid model. More...
Public Member Functions | |
DataSourceMemory (int dataSourceId, size_t geometryCountPerState) | |
Constructs a memory data source. More... | |
size_t | geometryCountPerState () const |
Returns number of geometries per state. More... | |
bool | updateDerivedResult (ResultType resultType, int id) |
Updates the derived result. More... | |
bool | updateAllDerivedResults () |
Updates all derived results. More... | |
void | addState (DataState *state) |
Adds a new state to the data source. More... | |
void | removeAllStates () |
Removes all states in the data source. More... | |
void | updateDirectoryFromStates () |
Populates the directory with dummy data. More... | |
![]() | |
int | id () const |
Returns the id of the data source. More... | |
size_t | stateCount () const |
Returns number of states for the data source. More... | |
size_t | stateIndex (int stateId) const |
Returns the index of the state with id stateId. More... | |
size_t | geometryCountPerState () const |
Returns the number of geometries (per state) in the Datasource. More... | |
const DataState * | state (size_t stateIndex) const |
Returns the state at the given state index. More... | |
DataState * | state (size_t stateIndex) |
Returns the state at the given state index. More... | |
const DataState * | currentState (const UnstructGridModel *model) const |
Returns the current state (the state in the current frame) in the given model. More... | |
DataState * | currentState (const UnstructGridModel *model) |
Returns the current state (the state in the current frame) in the given model. More... | |
const DataSourceDirectory * | directory () const |
Returns the data directory of the data source. More... | |
DataSourceDirectory * | directory () |
Returns the data directory of the data source. More... | |
const DataElementSet * | elementSet (size_t setIndex) const |
Returns a const ptr to the element set at the given index. More... | |
DataElementSet * | elementSet (size_t setIndex) |
Returns the element set at the given index. More... | |
size_t | elementSetCount () const |
Returns the number of DataElementSets in this data source. More... | |
size_t | elementSetIndex (int setId) const |
Returns the index of the element set with the given id. More... | |
void | addElementSet (DataElementSet *elementSet) |
Adds an element set to this data source. More... | |
void | removeElementSet (const DataElementSet *elementSet) |
Removes an element set from this data source. More... | |
void | removeAllElementSets () |
Removes all element sets from the data source. More... | |
bool | isDataSourceValid (Str *failReason) const |
Validates that the data source contents matches the metadata. More... | |
int | defaultDispacementResultId () const |
Returns the current state (the state in the current frame) in the given model. More... | |
bool | computeCustomResults (int stateId, const DataStateSpec &stateSpec) |
Computes custom results. More... | |
![]() | |
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... | |
A custom built data source for an unstructured grid model.
The data source contains a collection of all states for one analysis. Each state groups together geometries and results for one time step, load case, frequency etc. The memory data source class provides a way for the user to manually create the model "by hand".
Each unstructured grid model owns one data source. A data source must have a minimum of one state. Each state must have at least one geometry and may contain a selection of results (scalars, vectors, displacements and/or transformations).
When creating the memory data source, a unique id and a predefined number of geometries per state must be set in the constructor. The number of geometries per state cannot be changed after creation. Add states using addState() and query existing states with state() with the requested state index. All states can be removed with removeAllStates().
The data source directory describes the metadata for this data source and is accessed through directory(). All states, parts and results (scalars, vectors, displacements and transformations) added to the data source MUST have a corresponding info object in the directory.
Adding a data state and update the directory with the state metadata:
See DataSourceDirectory.
Example on building your data source and geometry.
Create a model and a memory data source. The constructor of the data source takes a unique id and the number of geometries (here 1). Set the data source in the created model.
Create the state. Set number of geometries to 1 in the constructor.
Set the newly created state to current in the model specification.
Create the geometry and add it to the state at index 0.
Build a geometry containing the necessary parts, nodes and elements. Optionally, add results.
When finished, update the metadata in the data source directory with all new content.
See the complete source code at: UnstructGrid: Simple model with two triangles
cee::ug::DataSourceMemory::DataSourceMemory | ( | int | dataSourceId, |
size_t | geometryCountPerState | ||
) |
Constructs a memory data source.
Set a unique id and number of geometries per state upon construction. These values cannot be changed afterwards.
void cee::ug::DataSourceMemory::addState | ( | DataState * | state | ) |
Adds a new state to the data source.
An added state MUST have the same number of geometries as the data source!
size_t cee::ug::DataSourceMemory::geometryCountPerState | ( | ) | const |
Returns number of geometries per state.
Number of geometries per state is set upon construction of the data source object and cannot be changed afterwards.
void cee::ug::DataSourceMemory::removeAllStates | ( | ) |
Removes all states in the data source.
bool cee::ug::DataSourceMemory::updateAllDerivedResults | ( | ) |
Updates all derived results.
bool cee::ug::DataSourceMemory::updateDerivedResult | ( | ResultType | resultType, |
int | id | ||
) |
Updates the derived result.
void cee::ug::DataSourceMemory::updateDirectoryFromStates | ( | ) |
Populates the directory with dummy data.
Provided for convenience. The directory should be populated manually to increase performance and providing more descriptive names and values.
Note that all existing items will be removed.