Go to the documentation of this file.
11 #ifndef vtk_m_worklet_StreamLineUniformGrid_h
12 #define vtk_m_worklet_StreamLineUniformGrid_h
45 template <
typename FieldType,
typename PortalType>
50 const PortalType& vecdata)
57 if (pos[d] >
static_cast<FieldType
>(vdims[d] - 1))
58 pos[d] =
static_cast<FieldType
>(vdims[d] - 1);
62 vtkm::Id3 idx000, idx001, idx010, idx011, idx100, idx101, idx110, idx111;
63 idx000[0] =
static_cast<vtkm::Id>(floor(pos[0]));
64 idx000[1] =
static_cast<vtkm::Id>(floor(pos[1]));
65 idx000[2] =
static_cast<vtkm::Id>(floor(pos[2]));
68 idx001[0] = (idx001[0] + 1) <= vdims[0] - 1 ? idx001[0] + 1 : vdims[0] - 1;
70 idx010[1] = (idx010[1] + 1) <= vdims[1] - 1 ? idx010[1] + 1 : vdims[1] - 1;
72 idx011[0] = (idx011[0] + 1) <= vdims[0] - 1 ? idx011[0] + 1 : vdims[0] - 1;
74 idx100[2] = (idx100[2] + 1) <= vdims[2] - 1 ? idx100[2] + 1 : vdims[2] - 1;
76 idx101[0] = (idx101[0] + 1) <= vdims[0] - 1 ? idx101[0] + 1 : vdims[0] - 1;
78 idx110[1] = (idx110[1] + 1) <= vdims[1] - 1 ? idx110[1] + 1 : vdims[1] - 1;
80 idx111[0] = (idx111[0] + 1) <= vdims[0] - 1 ? idx111[0] + 1 : vdims[0] - 1;
84 v000 = vecdata.Get(idx000[2] * planesize + idx000[1] * rowsize + idx000[0]);
85 v001 = vecdata.Get(idx001[2] * planesize + idx001[1] * rowsize + idx001[0]);
86 v010 = vecdata.Get(idx010[2] * planesize + idx010[1] * rowsize + idx010[0]);
87 v011 = vecdata.Get(idx011[2] * planesize + idx011[1] * rowsize + idx011[0]);
88 v100 = vecdata.Get(idx100[2] * planesize + idx100[1] * rowsize + idx100[0]);
89 v101 = vecdata.Get(idx101[2] * planesize + idx101[1] * rowsize + idx101[0]);
90 v110 = vecdata.Get(idx110[2] * planesize + idx110[1] * rowsize + idx110[0]);
91 v111 = vecdata.Get(idx111[2] * planesize + idx111[1] * rowsize + idx111[0]);
95 FieldType a = pos[0] -
static_cast<FieldType
>(floor(pos[0]));
96 v00[0] = (1.0f - a) * v000[0] + a * v001[0];
97 v00[1] = (1.0f - a) * v000[1] + a * v001[1];
98 v00[2] = (1.0f - a) * v000[2] + a * v001[2];
100 v01[0] = (1.0f - a) * v010[0] + a * v011[0];
101 v01[1] = (1.0f - a) * v010[1] + a * v011[1];
102 v01[2] = (1.0f - a) * v010[2] + a * v011[2];
104 v10[0] = (1.0f - a) * v100[0] + a * v101[0];
105 v10[1] = (1.0f - a) * v100[1] + a * v101[1];
106 v10[2] = (1.0f - a) * v100[2] + a * v101[2];
108 v11[0] = (1.0f - a) * v110[0] + a * v111[0];
109 v11[1] = (1.0f - a) * v110[1] + a * v111[1];
110 v11[2] = (1.0f - a) * v110[2] + a * v111[2];
114 a = pos[1] -
static_cast<FieldType
>(floor(pos[1]));
115 v0[0] = (1.0f - a) * v00[0] + a * v01[0];
116 v0[1] = (1.0f - a) * v00[1] + a * v01[1];
117 v0[2] = (1.0f - a) * v00[2] + a * v01[2];
119 v1[0] = (1.0f - a) * v10[0] + a * v11[0];
120 v1[1] = (1.0f - a) * v10[1] + a * v11[1];
121 v1[2] = (1.0f - a) * v10[2] + a * v11[2];
125 a = pos[2] -
static_cast<FieldType
>(floor(pos[2]));
126 v[0] = (1.0f - a) * v0[0] + v1[0];
127 v[1] = (1.0f - a) * v0[1] + v1[1];
128 v[2] = (1.0f - a) * v0[2] + v1[2];
134 template <
typename T>
141 template <
typename FieldType>
148 WholeArrayOut numIndices,
149 WholeArrayOut validPoint,
150 WholeArrayOut streamLines);
152 using InputDomain = _2;
180 template <
typename FieldPortalType,
typename IdComponentPortalType,
typename FieldVec3PortalType>
184 IdComponentPortalType& numIndices,
185 IdComponentPortalType& validPoint,
186 FieldVec3PortalType& slLists,
199 validPoint.Set(index, 1);
200 slLists.Set(index++, pos);
202 while (done !=
true && step <
maxsteps)
209 pos[d] += adata[d] / 2.0f;
216 pos[d] += bdata[d] / 2.0f;
223 pos[d] += cdata[d] / 2.0f;
230 pos[d] += (adata[d] + (2.0f * bdata[d]) + (2.0f * cdata[d]) + ddata[d]) / 6.0f;
233 if (pos[0] < 0.0f || pos[0] >
static_cast<FieldType
>(
vdims[0]) || pos[1] < 0.0f ||
234 pos[1] >
static_cast<FieldType
>(
vdims[1]) || pos[2] < 0.0f ||
235 pos[2] >
static_cast<FieldType
>(
vdims[2]))
242 validPoint.Set(index, 1);
243 slLists.Set(index++, pos);
257 validPoint.Set(index, 1);
258 slLists.Set(index++, pos);
260 while (done !=
true && step <
maxsteps)
266 adata[d] =
timestep * (0.0f - vdata[d]);
267 pos[d] += adata[d] / 2.0f;
273 bdata[d] =
timestep * (0.0f - vdata[d]);
274 pos[d] += bdata[d] / 2.0f;
280 cdata[d] =
timestep * (0.0f - vdata[d]);
281 pos[d] += cdata[d] / 2.0f;
287 ddata[d] =
timestep * (0.0f - vdata[d]);
288 pos[d] += (adata[d] + (2.0f * bdata[d]) + (2.0f * cdata[d]) + ddata[d]) / 6.0f;
291 if (pos[0] < 0.0f || pos[0] >
static_cast<FieldType
>(
vdims[0]) || pos[1] < 0.0f ||
292 pos[1] >
static_cast<FieldType
>(
vdims[1]) || pos[2] < 0.0f ||
293 pos[2] >
static_cast<FieldType
>(
vdims[2]))
300 validPoint.Set(index, 1);
301 slLists.Set(index++, pos);
315 template <
typename FieldType>
342 for (
vtkm::Id i = 0; i < numSeeds; i++)
345 seed[0] =
static_cast<FieldType
>(rand() % vdims[0]);
346 seed[1] =
static_cast<FieldType
>(rand() % vdims[1]);
347 seed[2] =
static_cast<FieldType
>(rand() % vdims[2]);
348 seedPosPortal.Set(i, seed);
355 vtkm::Id maxConnectivityLen = numCells * maxSteps;
359 streamArray.
Allocate(maxConnectivityLen);
370 Algorithm::Copy(polyLineShape, cellTypes);
375 validPoint.
Allocate(maxConnectivityLen);
376 Algorithm::Copy(zeros, validPoint);
382 makeStreamLines, fieldArray, seedIdArray, seedPosArray, numIndices, validPoint, streamArray);
391 Algorithm::Copy(connCount, connectivity);
411 #endif // vtk_m_worklet_StreamLineUniformGrid_h
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
const vtkm::cont::UnknownCellSet & GetCellSet() const
Definition: DataSet.h:403
Manages an array-worth of data.
Definition: ArrayHandle.h:300
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
@ BACKWARD
Definition: StreamLineUniformGrid.h:40
MakeStreamLines()
Definition: StreamLineUniformGrid.h:164
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
Definition: StreamLineUniformGrid.h:132
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:32
void operator()(const FieldPortalType &field, vtkm::Id &seedId, vtkm::Vec< FieldType, 3 > &seedPos, IdComponentPortalType &numIndices, IdComponentPortalType &validPoint, FieldVec3PortalType &slLists, vtkm::IdComponent visitIndex) const
Definition: StreamLineUniformGrid.h:181
const FieldType timestep
Definition: StreamLineUniformGrid.h:158
const vtkm::cont::Field & GetField(vtkm::Id index) const
Retrieves a field by index.
Definition: DataSet.h:108
void SetCellSet(const CellSetType &cellSet)
Definition: DataSet.h:396
Contains and manages the geometric data structures that VTK-m operates on.
Definition: DataSet.h:57
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
const vtkm::Id streammode
Definition: StreamLineUniformGrid.h:161
void AsArrayHandle(vtkm::cont::ArrayHandle< T, S > &array) const
Returns this array cast appropriately and stored in the given ArrayHandle type.
Definition: UnknownArrayHandle.h:657
void(WholeArrayIn field, FieldIn seedId, FieldIn position, WholeArrayOut numIndices, WholeArrayOut validPoint, WholeArrayOut streamLines) ControlSignature
Definition: StreamLineUniformGrid.h:150
void AsCellSet(CellSetType &cellSet) const
Get the cell set as a known type.
Definition: UnknownCellSet.h:178
void Fill(vtkm::Id numPoints, const vtkm::cont::ArrayHandle< vtkm::UInt8, ShapesStorageTag > &cellTypes, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity, const vtkm::cont::ArrayHandle< vtkm::Id, OffsetsStorageTag > &offsets)
Set all the cells of the mesh.
const vtkm::cont::UnknownArrayHandle & GetData() const
Get the array of the data for the field.
void(_1, _2, _3, _4, _5, _6, VisitIndex) ExecutionSignature
Definition: StreamLineUniformGrid.h:151
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:30
const vtkm::Id rowsize
Definition: StreamLineUniformGrid.h:160
void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle &numComponentsArray, vtkm::cont::ArrayHandle< vtkm::Id > &offsetsArray, vtkm::Id &componentsArraySize, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e.
const vtkm::UInt8 CELL_SHAPE_POLY_LINE
Definition: StreamLineUniformGrid.h:35
A control signature tag for input fields.
Definition: WorkletMapField.h:60
vtkm::Vec< FieldType, 3 > VecDataAtPos(vtkm::Vec< FieldType, 3 > pos, const vtkm::Id3 &vdims, const vtkm::Id &planesize, const vtkm::Id &rowsize, const PortalType &vecdata)
Definition: StreamLineUniformGrid.h:46
ArrayHandleCounting is a specialization of ArrayHandle.
Definition: ArrayHandleCounting.h:130
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
SchedulingRangeType GetSchedulingRange(TopologyElement) const
Definition: CellSetStructured.h:131
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
An array handle with a constant value.
Definition: ArrayHandleConstant.h:70
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
MakeStreamLines(const FieldType tStep, const vtkm::Id sMode, const vtkm::Id nSteps, const vtkm::Id3 dims)
Definition: StreamLineUniformGrid.h:167
vtkm::IdComponent AddCoordinateSystem(const vtkm::cont::CoordinateSystem &cs)
Adds the given CoordinateSystem to the DataSet.
@ FORWARD
Definition: StreamLineUniformGrid.h:39
Definition: Algorithm.h:386
A short fixed-length array.
Definition: Types.h:357
const vtkm::Id planesize
Definition: StreamLineUniformGrid.h:159
StreamLineMode
Definition: StreamLineUniformGrid.h:37
const vtkm::Id maxsteps
Definition: StreamLineUniformGrid.h:157
Defines an irregular collection of cells.
Definition: CastAndCall.h:36
A scatter that maps input directly to output.
Definition: ScatterIdentity.h:30
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
const vtkm::Id3 vdims
Definition: StreamLineUniformGrid.h:156
Definition: StreamLineUniformGrid.h:142
The ExecutionSignature tag to use to get the visit index.
Definition: VisitIndex.h:46
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:454
@ BOTH
Definition: StreamLineUniformGrid.h:41
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:55
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:39
bool operator()(const T &x) const
Definition: StreamLineUniformGrid.h:135