cee::ug::DataPartScalar
-
class DataPartScalar : public RefCountedObject
Scalar result values for a part.
A scalar result value is a numerical value. DataPartScalar contains an array of scalar values which can be set with single precision (float) or double precision (double). Internal storage is in double precision.
A DataPartScalar object contains the scalar result values corresponding to a DataPart. This means that the number of result values in each scalar part must match the number of nodes/elements in the corresponding 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.
DataPartScalar is a child of a DataResultScalar in the same way as a DataPart is a child of a DataGeometry. The DataResultScalar must have the same number of child parts as the DataGeometry.
Values are inserted using setValue(), setValues() or setValuesFloat(). Get the number of values with count() and query a specific value using value() with an index.
Note! The class is reference counted and can be shared between multiple results. 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 DataResultScalar object with a unique id and node based result mapping.
int scalarResultId = 1; cee::PtrRef<cee::ug::DataResultScalar> scalarResult = new cee::ug::DataResultScalar(scalarResultId, cee::ug::PER_NODE);
The result array must have one value for each node in the triangle. Resize the array before inserting the results.
cee::PtrRef<cee::ug::DataPartScalar> scalarPart = new cee::ug::DataPartScalar(); 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 scalar.
The number of result values in each part scalar must match the number of nodes/elements in the part (depending on mapping type). Here the result is a single triangle with node based mapping, so the scalar part must contains three values.
scalarResult->addPart(scalarPart.get());
Add the result scalar to the state (DataState) for the corresponding geometry (DataGeometry) geo
state->results(geo.get())->addScalar(scalarResult.get());
See the complete source code at: UnstructGrid: A simple model with results
Tutorials UnstructGrid: A simple model with results
See also
Public Functions
-
DataPartScalar()
Constructs an empty object.
-
size_t count() const
Returns the number of result values for this data part scalar.
-
double value(size_t index) const
Returns the result value at the given index.
The interpretation of the index depends on the result mapping in the parent DataResultScalar
-
const double *rawValuePointer() const
Returns a raw pointer to the value array.
-
double *rawValuePointer()
Returns a modifiable raw pointer to the value array.
-
void resize(size_t count)
Sets the number of scalar values in the data part.
The current values in the object will be kept up to the given count (if shrinking).
-
void setValue(size_t index, double value)
Sets the scalar value for the given index.
See also
Warning
The specified index must be a valid index. Either call one of the setValues() methods or call resize() prior to calling this method.
-
void setValues(const std::vector<double> &values)
Sets the scalar values from a std::vector of doubles.
-
void setValues(const double values[], size_t count)
Sets the scalar values from an array of doubles.
-
void setValuesFloat(const float values[], size_t count)
Sets the scalar values from an array of floats.
Note that this function is only provided for convenience, and that the values will be stored as double internally
-
bool valueRange(double *min, double *max) const
Gets minimum and maximum scalar values.
-
bool hasNodeAverageValues() const
Returns true if the part has node averaged results.
-
double nodeAverageValue(size_t nodeIndex) const
Returns the node averaged result value at the given node index.
Returns cee::UNDEFINED_DOUBLE if no node averaged values exists
-
void updateMinMax()
Recomputes the minimum and maximum values.
-
DataPartScalar()