Go to the documentation of this file.
19 #ifndef viskores_worklet_StreamLineUniformGrid_h
20 #define viskores_worklet_StreamLineUniformGrid_h
53 template <
typename FieldType,
typename PortalType>
58 const PortalType& vecdata)
65 if (pos[d] >
static_cast<FieldType
>(vdims[d] - 1))
66 pos[d] =
static_cast<FieldType
>(vdims[d] - 1);
70 viskores::Id3 idx000, idx001, idx010, idx011, idx100, idx101, idx110, idx111;
76 idx001[0] = (idx001[0] + 1) <= vdims[0] - 1 ? idx001[0] + 1 : vdims[0] - 1;
78 idx010[1] = (idx010[1] + 1) <= vdims[1] - 1 ? idx010[1] + 1 : vdims[1] - 1;
80 idx011[0] = (idx011[0] + 1) <= vdims[0] - 1 ? idx011[0] + 1 : vdims[0] - 1;
82 idx100[2] = (idx100[2] + 1) <= vdims[2] - 1 ? idx100[2] + 1 : vdims[2] - 1;
84 idx101[0] = (idx101[0] + 1) <= vdims[0] - 1 ? idx101[0] + 1 : vdims[0] - 1;
86 idx110[1] = (idx110[1] + 1) <= vdims[1] - 1 ? idx110[1] + 1 : vdims[1] - 1;
88 idx111[0] = (idx111[0] + 1) <= vdims[0] - 1 ? idx111[0] + 1 : vdims[0] - 1;
92 v000 = vecdata.Get(idx000[2] * planesize + idx000[1] * rowsize + idx000[0]);
93 v001 = vecdata.Get(idx001[2] * planesize + idx001[1] * rowsize + idx001[0]);
94 v010 = vecdata.Get(idx010[2] * planesize + idx010[1] * rowsize + idx010[0]);
95 v011 = vecdata.Get(idx011[2] * planesize + idx011[1] * rowsize + idx011[0]);
96 v100 = vecdata.Get(idx100[2] * planesize + idx100[1] * rowsize + idx100[0]);
97 v101 = vecdata.Get(idx101[2] * planesize + idx101[1] * rowsize + idx101[0]);
98 v110 = vecdata.Get(idx110[2] * planesize + idx110[1] * rowsize + idx110[0]);
99 v111 = vecdata.Get(idx111[2] * planesize + idx111[1] * rowsize + idx111[0]);
103 FieldType a = pos[0] -
static_cast<FieldType
>(floor(pos[0]));
104 v00[0] = (1.0f - a) * v000[0] + a * v001[0];
105 v00[1] = (1.0f - a) * v000[1] + a * v001[1];
106 v00[2] = (1.0f - a) * v000[2] + a * v001[2];
108 v01[0] = (1.0f - a) * v010[0] + a * v011[0];
109 v01[1] = (1.0f - a) * v010[1] + a * v011[1];
110 v01[2] = (1.0f - a) * v010[2] + a * v011[2];
112 v10[0] = (1.0f - a) * v100[0] + a * v101[0];
113 v10[1] = (1.0f - a) * v100[1] + a * v101[1];
114 v10[2] = (1.0f - a) * v100[2] + a * v101[2];
116 v11[0] = (1.0f - a) * v110[0] + a * v111[0];
117 v11[1] = (1.0f - a) * v110[1] + a * v111[1];
118 v11[2] = (1.0f - a) * v110[2] + a * v111[2];
122 a = pos[1] -
static_cast<FieldType
>(floor(pos[1]));
123 v0[0] = (1.0f - a) * v00[0] + a * v01[0];
124 v0[1] = (1.0f - a) * v00[1] + a * v01[1];
125 v0[2] = (1.0f - a) * v00[2] + a * v01[2];
127 v1[0] = (1.0f - a) * v10[0] + a * v11[0];
128 v1[1] = (1.0f - a) * v10[1] + a * v11[1];
129 v1[2] = (1.0f - a) * v10[2] + a * v11[2];
133 a = pos[2] -
static_cast<FieldType
>(floor(pos[2]));
134 v[0] = (1.0f - a) * v0[0] + v1[0];
135 v[1] = (1.0f - a) * v0[1] + v1[1];
136 v[2] = (1.0f - a) * v0[2] + v1[2];
142 template <
typename T>
149 template <
typename FieldType>
156 WholeArrayOut numIndices,
157 WholeArrayOut validPoint,
158 WholeArrayOut streamLines);
160 using InputDomain = _2;
188 template <
typename FieldPortalType,
typename IdComponentPortalType,
typename FieldVec3PortalType>
192 IdComponentPortalType& numIndices,
193 IdComponentPortalType& validPoint,
194 FieldVec3PortalType& slLists,
207 validPoint.Set(index, 1);
208 slLists.Set(index++, pos);
210 while (done !=
true && step <
maxsteps)
217 pos[d] += adata[d] / 2.0f;
224 pos[d] += bdata[d] / 2.0f;
231 pos[d] += cdata[d] / 2.0f;
238 pos[d] += (adata[d] + (2.0f * bdata[d]) + (2.0f * cdata[d]) + ddata[d]) / 6.0f;
241 if (pos[0] < 0.0f || pos[0] >
static_cast<FieldType
>(
vdims[0]) || pos[1] < 0.0f ||
242 pos[1] >
static_cast<FieldType
>(
vdims[1]) || pos[2] < 0.0f ||
243 pos[2] >
static_cast<FieldType
>(
vdims[2]))
250 validPoint.Set(index, 1);
251 slLists.Set(index++, pos);
265 validPoint.Set(index, 1);
266 slLists.Set(index++, pos);
268 while (done !=
true && step <
maxsteps)
274 adata[d] =
timestep * (0.0f - vdata[d]);
275 pos[d] += adata[d] / 2.0f;
281 bdata[d] =
timestep * (0.0f - vdata[d]);
282 pos[d] += bdata[d] / 2.0f;
288 cdata[d] =
timestep * (0.0f - vdata[d]);
289 pos[d] += cdata[d] / 2.0f;
295 ddata[d] =
timestep * (0.0f - vdata[d]);
296 pos[d] += (adata[d] + (2.0f * bdata[d]) + (2.0f * cdata[d]) + ddata[d]) / 6.0f;
299 if (pos[0] < 0.0f || pos[0] >
static_cast<FieldType
>(
vdims[0]) || pos[1] < 0.0f ||
300 pos[1] >
static_cast<FieldType
>(
vdims[1]) || pos[2] < 0.0f ||
301 pos[2] >
static_cast<FieldType
>(
vdims[2]))
308 validPoint.Set(index, 1);
309 slLists.Set(index++, pos);
323 template <
typename FieldType>
353 seed[0] =
static_cast<FieldType
>(rand() % vdims[0]);
354 seed[1] =
static_cast<FieldType
>(rand() % vdims[1]);
355 seed[2] =
static_cast<FieldType
>(rand() % vdims[2]);
356 seedPosPortal.Set(i, seed);
367 streamArray.
Allocate(maxConnectivityLen);
378 Algorithm::Copy(polyLineShape, cellTypes);
383 validPoint.
Allocate(maxConnectivityLen);
384 Algorithm::Copy(zeros, validPoint);
390 makeStreamLines, fieldArray, seedIdArray, seedPosArray, numIndices, validPoint, streamArray);
399 Algorithm::Copy(connCount, connectivity);
419 #endif // viskores_worklet_StreamLineUniformGrid_h
Contains and manages the geometric data structures that Viskores operates on.
Definition: DataSet.h:66
const viskores::Id3 vdims
Definition: StreamLineUniformGrid.h:164
viskores::Vec< FieldType, 3 > VecDataAtPos(viskores::Vec< FieldType, 3 > pos, const viskores::Id3 &vdims, const viskores::Id &planesize, const viskores::Id &rowsize, const PortalType &vecdata)
Definition: StreamLineUniformGrid.h:54
A control signature tag for input fields.
Definition: WorkletMapField.h:68
bool operator()(const T &x) const
Definition: StreamLineUniformGrid.h:143
Definition: Algorithm.h:397
const viskores::cont::UnknownArrayHandle & GetData() const
Get the array of the data for the field.
Manages an array-worth of data.
Definition: ArrayHandle.h:313
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:38
const viskores::cont::Field & GetField(viskores::Id index) const
Retrieves a field by index.
Definition: DataSet.h:117
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
SchedulingRangeType GetSchedulingRange(TopologyElement) const
Definition: CellSetStructured.h:140
void operator()(const FieldPortalType &field, viskores::Id &seedId, viskores::Vec< FieldType, 3 > &seedPos, IdComponentPortalType &numIndices, IdComponentPortalType &validPoint, FieldVec3PortalType &slLists, viskores::IdComponent visitIndex) const
Definition: StreamLineUniformGrid.h:189
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:42
viskores::IdComponent AddCoordinateSystem(const viskores::cont::CoordinateSystem &cs)
Adds the given CoordinateSystem to the DataSet.
Definition: StreamLineUniformGrid.h:140
The ExecutionSignature tag to use to get the visit index.
Definition: VisitIndex.h:54
@ BACKWARD
Definition: StreamLineUniformGrid.h:48
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
MakeStreamLines(const FieldType tStep, const viskores::Id sMode, const viskores::Id nSteps, const viskores::Id3 dims)
Definition: StreamLineUniformGrid.h:175
const viskores::UInt8 CELL_SHAPE_POLY_LINE
Definition: StreamLineUniformGrid.h:43
An array handle with a constant value.
Definition: ArrayHandleConstant.h:78
A scatter that maps input directly to output.
Definition: ScatterIdentity.h:38
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
Defines an irregular collection of cells.
Definition: CastAndCall.h:44
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
ArrayHandleCounting is a specialization of ArrayHandle.
Definition: ArrayHandleCounting.h:140
Definition: StreamLineUniformGrid.h:150
void AsArrayHandle(viskores::cont::ArrayHandle< T, S > &array) const
Returns this array cast appropriately and stored in the given ArrayHandle type.
Definition: UnknownArrayHandle.h:679
@ FORWARD
Definition: StreamLineUniformGrid.h:47
void Fill(viskores::Id numPoints, const viskores::cont::ArrayHandle< viskores::UInt8, ShapesStorageTag > &cellTypes, const viskores::cont::ArrayHandle< viskores::Id, ConnectivityStorageTag > &connectivity, const viskores::cont::ArrayHandle< viskores::Id, OffsetsStorageTag > &offsets)
Set all the cells of the mesh.
void ConvertNumComponentsToOffsets(const viskores::cont::UnknownArrayHandle &numComponentsArray, viskores::cont::ArrayHandle< viskores::Id > &offsetsArray, viskores::Id &componentsArraySize, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e.
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
MakeStreamLines()
Definition: StreamLineUniformGrid.h:172
void(WholeArrayIn field, FieldIn seedId, FieldIn position, WholeArrayOut numIndices, WholeArrayOut validPoint, WholeArrayOut streamLines) ControlSignature
Definition: StreamLineUniformGrid.h:158
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:40
const viskores::cont::UnknownCellSet & GetCellSet() const
Definition: DataSet.h:422
StreamLineMode
Definition: StreamLineUniformGrid.h:45
const viskores::Id streammode
Definition: StreamLineUniformGrid.h:169
const viskores::Id planesize
Definition: StreamLineUniformGrid.h:167
@ BOTH
Definition: StreamLineUniformGrid.h:49
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:49
const viskores::Id maxsteps
Definition: StreamLineUniformGrid.h:165
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:47
A short fixed-length array.
Definition: Types.h:365
void AsCellSet(CellSetType &cellSet) const
Get the cell set as a known type.
Definition: UnknownCellSet.h:189
#define VISKORES_EXEC
Definition: ExportMacros.h:59
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:64
const viskores::Id rowsize
Definition: StreamLineUniformGrid.h:168
const FieldType timestep
Definition: StreamLineUniformGrid.h:166
void(_1, _2, _3, _4, _5, _6, VisitIndex) ExecutionSignature
Definition: StreamLineUniformGrid.h:159
void SetCellSet(const CellSetType &cellSet)
Definition: DataSet.h:415