VTK-m  2.0
MIR.h
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // Copyright (c) Kitware, Inc.
4 // All rights reserved.
5 // See LICENSE.txt for details.
6 //
7 // This software is distributed WITHOUT ANY WARRANTY; without even
8 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9 // PURPOSE. See the above copyright notice for more information.
10 //
11 //=============================================================================
12 
13 #ifndef vtk_m_worklet_MIR_h
14 #define vtk_m_worklet_MIR_h
15 
16 #include <vtkm/CellShape.h>
17 #include <vtkm/Types.h>
18 #include <vtkm/VectorAnalysis.h>
19 
20 #include <vtkm/cont/Algorithm.h>
21 #include <vtkm/cont/ArrayCopy.h>
22 #include <vtkm/cont/ArrayHandle.h>
31 #include <vtkm/cont/Timer.h>
32 
33 #include <vtkm/exec/FunctorBase.h>
34 
38 #include <vtkm/worklet/Keys.h>
43 
46 
47 namespace vtkm
48 {
49 namespace worklet
50 {
51 
52 struct MIRStats
53 {
57 
58  //VTKM New point stats
63 
64  struct SumOp
65  {
67  MIRStats operator()(const MIRStats& stat1, const MIRStats& stat2) const
68  {
69  MIRStats sum = stat1;
70  sum.NumberOfCells += stat2.NumberOfCells;
71  sum.NumberOfIndices += stat2.NumberOfIndices;
77  return sum;
78  }
79  };
80 };
81 struct EdgeInterpolation
82 {
83  vtkm::Id Vertex1 = -1;
84  vtkm::Id Vertex2 = -1;
86 
87  struct LessThanOp
88  {
89  VTKM_EXEC
90  bool operator()(const EdgeInterpolation& v1, const EdgeInterpolation& v2) const
91  {
92  return (v1.Vertex1 < v2.Vertex1) || (v1.Vertex1 == v2.Vertex1 && v1.Vertex2 < v2.Vertex2);
93  }
94  };
95 
96  struct EqualToOp
97  {
98  VTKM_EXEC
99  bool operator()(const EdgeInterpolation& v1, const EdgeInterpolation& v2) const
100  {
101  return v1.Vertex1 == v2.Vertex1 && v1.Vertex2 == v2.Vertex2;
102  }
103  };
104 };
105 namespace MIRinternal
106 {
107 template <typename T>
108 VTKM_EXEC_CONT T Scale(const T& val, vtkm::Float64 scale)
109 {
110  return static_cast<T>(scale * static_cast<vtkm::Float64>(val));
111 }
112 
113 template <typename T, vtkm::IdComponent NumComponents>
115  vtkm::Float64 scale)
116 {
117  return val * scale;
118 }
119 }
120 
122 {
123 private:
127 
128 public:
129  VTKM_CONT
130  ExecutionConnectivityExplicit() = default;
131 
132  VTKM_CONT
137  MIRStats stats,
139  vtkm::cont::Token& token)
140  : Shapes(shapes.PrepareForOutput(stats.NumberOfCells, device, token))
141  , NumberOfIndices(numberOfIndices.PrepareForOutput(stats.NumberOfCells, device, token))
142  , Connectivity(connectivity.PrepareForOutput(stats.NumberOfIndices, device, token))
143  , Offsets(offsets.PrepareForOutput(stats.NumberOfCells, device, token))
144  {
145  }
146 
147  VTKM_EXEC
148  void SetCellShape(vtkm::Id cellIndex, vtkm::UInt8 shape) { this->Shapes.Set(cellIndex, shape); }
149 
150  VTKM_EXEC
151  void SetNumberOfIndices(vtkm::Id cellIndex, vtkm::IdComponent numIndices)
152  {
153  this->NumberOfIndices.Set(cellIndex, numIndices);
154  }
155 
156  VTKM_EXEC
157  void SetIndexOffset(vtkm::Id cellIndex, vtkm::Id indexOffset)
158  {
159  this->Offsets.Set(cellIndex, indexOffset);
160  }
161 
162  VTKM_EXEC
163  void SetConnectivity(vtkm::Id connectivityIndex, vtkm::Id pointIndex)
164  {
165  this->Connectivity.Set(connectivityIndex, pointIndex);
166  }
167 
168 private:
173 };
174 
176 {
177 public:
178  VTKM_CONT
179  ConnectivityExplicit() = default;
180 
181  VTKM_CONT
183  const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numberOfIndices,
184  const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
185  const vtkm::cont::ArrayHandle<vtkm::Id>& offsets,
186  const MIRStats& stats)
187  : Shapes(shapes)
188  , NumberOfIndices(numberOfIndices)
189  , Connectivity(connectivity)
190  , Offsets(offsets)
191  , Stats(stats)
192  {
193  }
194 
196  vtkm::cont::Token& token) const
197  {
198  ExecutionConnectivityExplicit execConnectivity(this->Shapes,
199  this->NumberOfIndices,
200  this->Connectivity,
201  this->Offsets,
202  this->Stats,
203  device,
204  token);
205  return execConnectivity;
206  }
207 
208 private:
214 };
215 
217 {
218 public:
221  : targ(target)
222  {
223  }
224  VTKM_CONT ComputeStats() = default;
225  using ControlSignature = void(CellSetIn,
226  WholeArrayIn curVals,
227  WholeArrayIn prevVals,
228  FieldInCell offsets,
229  ExecObject mirTables,
230  FieldInCell parentObj,
231  FieldInCell prevCol,
232  FieldOutCell stats,
233  FieldOutCell caseID);
234  using ExecutionSignature = void(CellShape, PointCount, _3, _2, _4, _5, _6, _7, _8, _9);
235  using InputDomain = _1;
236 
237  template <typename CellShapeTag,
238  typename ScalarFieldVec,
239  typename ScalarFieldVec1,
240  typename DeviceAdapter,
241  typename ScalarPos,
242  typename ParentObj,
243  typename PreCol>
245  const CellShapeTag shape,
246  const vtkm::IdComponent pointCount,
247  const ScalarFieldVec& prevVals,
248  const ScalarFieldVec1& newVals,
249  const ScalarPos& valPositionStart,
251  const ParentObj&,
252  const PreCol& prevCol,
253  MIRStats& MIRStat,
254  vtkm::Id& MIRDataIndex) const
255  {
256  (void)shape;
257  vtkm::Id caseId = 0;
258  if (prevCol == vtkm::Id(-1))
259  {
260  // In case of this being the first material for the cell, automatically set it to the furthest case (that is, same shape, color 1)
261  for (vtkm::IdComponent iter = pointCount - 1; iter >= 0; iter--)
262  {
263  caseId++;
264  if (iter > 0)
265  {
266  caseId *= 2;
267  }
268  }
269  }
270  else
271  {
272  for (vtkm::IdComponent iter = pointCount - 1; iter >= 0; iter--)
273  {
274  if (static_cast<vtkm::Float64>(prevVals.Get(valPositionStart + iter)) <=
275  static_cast<vtkm::Float64>(newVals.Get(valPositionStart + iter)))
276  {
277  caseId++;
278  }
279  if (iter > 0)
280  {
281  caseId *= 2;
282  }
283  }
284  }
285  // Reinitialize all struct values to 0, experienced weird memory bug otherwise, might be an issue with development environment
286  MIRStat.NumberOfCells = 0;
287  MIRStat.NumberOfEdgeIndices = 0;
288  MIRStat.NumberOfInCellEdgeIndices = 0;
289  MIRStat.NumberOfInCellIndices = 0;
290  MIRStat.NumberOfInCellInterpPoints = 0;
291  MIRStat.NumberOfInCellPoints = 0;
292  MIRStat.NumberOfIndices = 0;
293  vtkm::Id index = MIRData.GetCaseIndex(shape.Id, caseId, pointCount);
294  MIRDataIndex = vtkm::Id(caseId);
295  vtkm::Id numberOfCells = MIRData.GetNumberOfShapes(shape.Id, caseId, pointCount);
296  if (numberOfCells == -1)
297  {
298  this->RaiseError("Getting a size index of a polygon with more points than 8 or less points "
299  "than 3. Bad case.");
300  return;
301  }
302  MIRStat.NumberOfCells = numberOfCells;
303 
304  for (vtkm::IdComponent shapes = 0; shapes < numberOfCells; shapes++)
305  {
306  vtkm::UInt8 cellType = MIRData.ValueAt(index++);
307  // SH_PNT is a specification that a center point is to be used
308  // Note: It is only possible to support 1 midpoint with the current code format
309  if (cellType == MIRCases::SH_PNT)
310  {
311  MIRStat.NumberOfCells = numberOfCells - 1;
312  vtkm::UInt8 numberOfIndices = MIRData.ValueAt(index + 2);
313  index += 3;
314  MIRStat.NumberOfInCellPoints = 1;
315  MIRStat.NumberOfInCellInterpPoints = numberOfIndices;
316  for (vtkm::IdComponent points = 0; points < numberOfIndices; points++)
317  {
318  vtkm::Id elem = MIRData.ValueAt(index);
319  // If the midpoint needs to reference an edge point, record it.
320  MIRStat.NumberOfInCellEdgeIndices += (elem >= MIRCases::EA) ? 1 : 0;
321  index++;
322  }
323  }
324  else
325  {
326  vtkm::Id numberOfIndices = MIRData.GetNumberOfIndices(cellType);
327  index++;
328  MIRStat.NumberOfIndices += numberOfIndices;
329  for (vtkm::IdComponent points = 0; points < numberOfIndices; points++, index++)
330  {
331  vtkm::IdComponent element = MIRData.ValueAt(index);
332  if (element >= MIRCases::EA && element <= MIRCases::EL)
333  {
334  MIRStat.NumberOfEdgeIndices++;
335  }
336  else if (element == MIRCases::N0)
337  {
338  // N0 stands for the midpoint. Technically it could be N0->N3, but with the current
339  // setup, only N0 is supported/present in the MIRCases tables.
340  MIRStat.NumberOfInCellIndices++;
341  }
342  }
343  }
344  }
345  }
346 };
348 {
349 public:
350  VTKM_CONT MIRParentObject() = default;
356  : newCellColors(newCellCol)
357  , newCellLookback(newcellLook)
358  , numberOfInd(numCells)
359  , cellLookback(celllook)
360  , cellColors(cellCol){};
361 
363  {
364  public:
365  VTKM_EXEC void SetNewCellLookback(vtkm::Id index, vtkm::Id originalIndex)
366  {
367  this->NewCellLookback.Set(index, originalIndex);
368  }
370  {
371  this->NewCellColors.Set(index, col);
372  }
373  VTKM_EXEC vtkm::Id GetParentCellIndex(vtkm::Id index) { return this->CellLookback.Get(index); }
374  VTKM_EXEC vtkm::Id GetParentCellColor(vtkm::Id index) { return this->CellColors.Get(index); }
375 
376  private:
381  friend class MIRParentObject;
382  };
383 
385  vtkm::cont::Token& token)
386  {
387  MIRParentPortal dev;
388  dev.CellLookback = this->cellLookback.PrepareForInput(device, token);
389  dev.CellColors = this->cellColors.PrepareForInput(device, token);
390  dev.NewCellColors = this->newCellColors.PrepareForOutput(this->numberOfInd, device, token);
391  dev.NewCellLookback = this->newCellLookback.PrepareForOutput(this->numberOfInd, device, token);
392  return dev;
393  }
396 
397 private:
401 };
403 {
404 public:
407  : target(tar)
408  {
409  }
410 
411  using ControlSignature = void(CellSetIn,
412  WholeArrayIn prevVals,
413  WholeArrayIn newVals,
414  FieldInCell vf_pos,
415  FieldInCell mirTableIndices,
416  FieldInCell mirStats,
417  ExecObject mirTables,
418  ExecObject connectivityObject,
419  WholeArrayOut edgePointReverseConnectivity,
420  WholeArrayOut edgePointInterpolation,
421  WholeArrayOut inCellReverseConnectivity,
422  WholeArrayOut inCellEdgeReverseConnectivity,
423  WholeArrayOut inCellEdgeInterpolation,
424  WholeArrayOut inCellInterpolationKeys,
425  WholeArrayOut inCellInterpolationInfo,
426  ExecObject cellLookbackObj,
427  WholeArrayOut simpleLookback);
428 
429  using ExecutionSignature = void(CellShape,
430  InputIndex,
431  PointCount,
432  PointIndices,
433  _2,
434  _3,
435  _4,
436  _5,
437  _6,
438  _7,
439  _8,
440  _9,
441  _10,
442  _11,
443  _12,
444  _13,
445  _14,
446  _15,
447  _16,
448  _17); // 20! NO MORE ROOM!
449 
450  template <typename CellShapeTag,
451  typename PointVecType,
452  typename ScalarVecType1,
453  typename ScalarVecType2,
454  typename ConnectivityObject,
455  typename IdArrayType,
456  typename EdgeInterpolationPortalType,
457  typename DeviceAdapter,
458  typename ScalarPos,
459  typename CellLookbackArr>
461  const CellShapeTag shape,
462  const vtkm::Id workIndex,
463  const vtkm::IdComponent pointcount,
464  const PointVecType points,
465  const ScalarVecType1& curScalars, // Previous VF
466  const ScalarVecType2& newScalars, // New VF
467  const ScalarPos& valPositionStart, // Offsets into the ^ arrays for indexing
468  const vtkm::Id& clipDataIndex,
469  const MIRStats mirStats,
471  ConnectivityObject& connectivityObject,
472  IdArrayType& edgePointReverseConnectivity,
473  EdgeInterpolationPortalType& edgePointInterpolation,
474  IdArrayType& inCellReverseConnectivity,
475  IdArrayType& inCellEdgeReverseConnectivity,
476  EdgeInterpolationPortalType& inCellEdgeInterpolation,
477  IdArrayType& inCellInterpolationKeys,
478  IdArrayType& inCellInterpolationInfo,
480  CellLookbackArr& cellLookbackArray) const
481  {
482 
483  (void)shape;
484  vtkm::Id clipIndex = MIRData.GetCaseIndex(shape.Id, clipDataIndex, pointcount);
485 
486  // Start index for the cells of this case.
487  vtkm::Id cellIndex = mirStats.NumberOfCells;
488  // Start index to store connevtivity of this case.
489  vtkm::Id connectivityIndex = mirStats.NumberOfIndices;
490  // Start indices for reverse mapping into connectivity for this case.
491  vtkm::Id edgeIndex = mirStats.NumberOfEdgeIndices;
492  vtkm::Id inCellIndex = mirStats.NumberOfInCellIndices;
493  vtkm::Id inCellPoints = mirStats.NumberOfInCellPoints;
494  // Start Indices to keep track of interpolation points for new cell.
495  vtkm::Id inCellInterpPointIndex = mirStats.NumberOfInCellInterpPoints;
496  vtkm::Id inCellEdgeInterpIndex = mirStats.NumberOfInCellEdgeIndices;
497 
498  // Iterate over the shapes for the current cell and begin to fill connectivity.
499  vtkm::Id numberOfCells = MIRData.GetNumberOfShapes(shape.Id, clipDataIndex, pointcount);
500 
501  for (vtkm::Id cell = 0; cell < numberOfCells; ++cell)
502  {
503  vtkm::UInt8 cellShape = MIRData.ValueAt(clipIndex++);
504  if (cellShape == MIRCases::SH_PNT)
505  {
506  clipIndex += 2;
507  vtkm::IdComponent numberOfPoints = MIRData.ValueAt(clipIndex);
508  clipIndex++;
509  // Case for a new cell point
510 
511  // 1. Output the input cell id for which we need to generate new point.
512  // 2. Output number of points used for interpolation.
513  // 3. If vertex
514  // - Add vertex to connectivity interpolation information.
515  // 4. If edge
516  // - Add edge interpolation information for new points.
517  // - Reverse connectivity map for new points.
518  // Make an array which has all the elements that need to be used
519  // for interpolation.
520  for (vtkm::IdComponent point = 0; point < numberOfPoints;
521  point++, inCellInterpPointIndex++, clipIndex++)
522  {
523  vtkm::IdComponent entry = static_cast<vtkm::IdComponent>(MIRData.ValueAt(clipIndex));
524  inCellInterpolationKeys.Set(inCellInterpPointIndex, workIndex);
525  if (entry <= MIRCases::P7)
526  {
527  inCellInterpolationInfo.Set(inCellInterpPointIndex, points[entry]);
528  }
529  else
530  {
532  MIRData.GetEdge(shape.Id, entry - MIRCases::EA, pointcount);
533  if (edge[0] == 255 || edge[1] == 255)
534  {
535  this->RaiseError("Edge vertices are assigned incorrect values.");
536  return;
537  }
538 
540  ei.Vertex1 = points[edge[0]];
541  ei.Vertex2 = points[edge[1]];
542  // For consistency purposes keep the points ordered.
543  if (ei.Vertex1 > ei.Vertex2)
544  {
545  this->swap(ei.Vertex1, ei.Vertex2);
546  this->swap(edge[0], edge[1]);
547  }
548  // need to swap the weight of the point to be A-C / ((D-C) - (B-A)),
549  // where A and C are edge0 mats 1 and 2, and B and D are edge1 mats 1 and 2.
550  ei.Weight = vtkm::Float64(1) +
551  ((static_cast<vtkm::Float64>(curScalars.Get(valPositionStart + edge[0]) -
552  newScalars.Get(valPositionStart + edge[0]))) /
553  static_cast<vtkm::Float64>(curScalars.Get(valPositionStart + edge[1]) -
554  curScalars.Get(valPositionStart + edge[0]) +
555  newScalars.Get(valPositionStart + edge[0]) -
556  newScalars.Get(valPositionStart + edge[1])));
557 
558  inCellEdgeReverseConnectivity.Set(inCellEdgeInterpIndex, inCellInterpPointIndex);
559  inCellEdgeInterpolation.Set(inCellEdgeInterpIndex, ei);
560  inCellEdgeInterpIndex++;
561  }
562  }
563  }
564  else
565  {
566  vtkm::IdComponent numberOfPoints =
567  static_cast<vtkm::IdComponent>(MIRData.GetNumberOfIndices(cellShape));
568  vtkm::IdComponent colorQ = static_cast<vtkm::IdComponent>(MIRData.ValueAt(clipIndex++));
569  vtkm::Id color = colorQ == vtkm::IdComponent(MIRCases::COLOR0)
570  ? parentObj.GetParentCellColor(workIndex)
571  : target;
572  parentObj.SetNewCellColor(cellIndex, color);
573  parentObj.SetNewCellLookback(cellIndex, parentObj.GetParentCellIndex(workIndex));
574  connectivityObject.SetCellShape(cellIndex, cellShape);
575  connectivityObject.SetNumberOfIndices(cellIndex, numberOfPoints);
576  connectivityObject.SetIndexOffset(cellIndex, connectivityIndex);
577 
578  for (vtkm::IdComponent point = 0; point < numberOfPoints; point++, clipIndex++)
579  {
580  vtkm::IdComponent entry = static_cast<vtkm::IdComponent>(MIRData.ValueAt(clipIndex));
581  if (entry == MIRCases::N0) // case of cell point interpolation
582  {
583  // Add index of the corresponding cell point.
584  inCellReverseConnectivity.Set(inCellIndex++, connectivityIndex);
585  connectivityObject.SetConnectivity(connectivityIndex, inCellPoints);
586  connectivityIndex++;
587  }
588  else if (entry <= MIRCases::P7) // existing vertex
589  {
590  connectivityObject.SetConnectivity(connectivityIndex, points[entry]);
591  connectivityIndex++;
592  }
593  else // case of a new edge point
594  {
596  MIRData.GetEdge(shape.Id, entry - MIRCases::EA, pointcount);
597  if (edge[0] == 255 || edge[1] == 255)
598  {
599  this->RaiseError("Edge vertices are assigned incorrect values.");
600  return;
601  }
603  ei.Vertex1 = points[edge[0]];
604  ei.Vertex2 = points[edge[1]];
605  // For consistency purposes keep the points ordered.
606  if (ei.Vertex1 > ei.Vertex2)
607  {
608  this->swap(ei.Vertex1, ei.Vertex2);
609  this->swap(edge[0], edge[1]);
610  }
611 
612  ei.Weight = vtkm::Float64(1) +
613  ((static_cast<vtkm::Float64>(curScalars.Get(valPositionStart + edge[0]) -
614  newScalars.Get(valPositionStart + edge[0]))) /
615  static_cast<vtkm::Float64>(curScalars.Get(valPositionStart + edge[1]) -
616  curScalars.Get(valPositionStart + edge[0]) +
617  newScalars.Get(valPositionStart + edge[0]) -
618  newScalars.Get(valPositionStart + edge[1])));
619  //Add to set of new edge points
620  //Add reverse connectivity;
621  edgePointReverseConnectivity.Set(edgeIndex, connectivityIndex++);
622  edgePointInterpolation.Set(edgeIndex, ei);
623  edgeIndex++;
624  }
625  }
626  // Set cell matID...
627  cellLookbackArray.Set(cellIndex, workIndex);
628  ++cellIndex;
629  }
630  }
631  }
632 
633  template <typename T>
634  VTKM_EXEC void swap(T& v1, T& v2) const
635  {
636  T temp = v1;
637  v1 = v2;
638  v2 = temp;
639  }
640 
641 private:
643 };
645 {
646 public:
647  VTKM_CONT
649  : EdgePointOffset(edgePointOffset)
650  {
651  }
652 
653  using ControlSignature = void(FieldIn sourceValue,
654  FieldIn destinationIndices,
655  WholeArrayOut destinationData);
656 
657  using ExecutionSignature = void(_1, _2, _3);
658 
659  using InputDomain = _1;
660 
661  template <typename ConnectivityDataType>
662  VTKM_EXEC void operator()(const vtkm::Id sourceValue,
663  const vtkm::Id destinationIndex,
664  ConnectivityDataType& destinationData) const
665  {
666  destinationData.Set(destinationIndex, (sourceValue + EdgePointOffset));
667  }
668 
669 private:
671 };
673 {
674 public:
675  VTKM_CONT
677  : InCellPointOffset(inCellPointOffset)
678  {
679  }
680 
681  using ControlSignature = void(FieldIn destinationIndices, WholeArrayOut destinationData);
682 
683  using ExecutionSignature = void(_1, _2);
684 
685  using InputDomain = _1;
686 
687  template <typename ConnectivityDataType>
688  VTKM_EXEC void operator()(const vtkm::Id destinationIndex,
689  ConnectivityDataType& destinationData) const
690  {
691  auto sourceValue = destinationData.Get(destinationIndex);
692  destinationData.Set(destinationIndex, (sourceValue + InCellPointOffset));
693  }
694 
695 private:
697 };
698 class MIR
699 {
700 public:
701  MIR()
707  , EdgePointsOffset()
709  {
710  }
711  template <typename VFList1, typename VFList2, typename CellSet, typename VFLocs, typename IDList>
712  vtkm::cont::CellSetExplicit<> Run(const CellSet& cellSet,
713  const VFList1& prevValues,
714  const VFList2& curValues,
715  const VFLocs& offsets,
716  const IDList& prevIDs,
717  const vtkm::Id& newID,
718  const IDList& prevLookback,
719  IDList& newIDs,
720  IDList& newLookback)
721  {
722  // First compute the stats for the MIR algorithm & build the offsets
723  //{
724  ComputeStats statWorklet(newID);
725  vtkm::worklet::DispatcherMapTopology<ComputeStats> statsDispatch(statWorklet);
726 
727  // Output variables
730 
731  statsDispatch.Invoke(cellSet,
732  curValues,
733  prevValues,
734  offsets,
735  this->MIRTablesInstance,
736  prevLookback,
737  prevIDs,
738  mirStats,
739  mirInd);
740  // Sum all stats to form an offset array (for indexing in the MIR algorithm)
741  MIRStats zero;
743  MIRStats total =
744  vtkm::cont::Algorithm::ScanExclusive(mirStats, cellSetStats, MIRStats::SumOp(), zero);
745  mirStats.ReleaseResources();
746  //}
747  // Secondly, build the sets.
748  //{
749  // CellSetExplicit sets
754  ConnectivityExplicit connectivityObject(shapes, numberOfIndices, connectivity, offset, total);
755  // Connectivity related sets
756  vtkm::cont::ArrayHandle<vtkm::Id> edgePointReverseConnectivity;
757  edgePointReverseConnectivity.Allocate(total.NumberOfEdgeIndices);
759  edgeInterpolation.Allocate(total.NumberOfEdgeIndices);
760  vtkm::cont::ArrayHandle<vtkm::Id> cellPointReverseConnectivity;
761  cellPointReverseConnectivity.Allocate(total.NumberOfInCellIndices);
762  vtkm::cont::ArrayHandle<vtkm::Id> cellPointEdgeReverseConnectivity;
763  cellPointEdgeReverseConnectivity.Allocate(total.NumberOfInCellEdgeIndices);
764  vtkm::cont::ArrayHandle<EdgeInterpolation> cellPointEdgeInterpolation;
765  cellPointEdgeInterpolation.Allocate(total.NumberOfInCellEdgeIndices);
769 
770 
771  //}
772  // Thirdly, call the MIR generator
773  //{
774  GenerateCellSet cellSetWorklet(newID);
775  vtkm::worklet::DispatcherMapTopology<GenerateCellSet> cellSetDispatcher(cellSetWorklet);
776  // Output arrays storing information about cell lookbacks and cell material IDs
777  vtkm::cont::ArrayHandle<vtkm::Id> nextID, nextLookback;
778  nextID.Allocate(total.NumberOfCells);
779  nextLookback.Allocate(total.NumberOfCells);
780  MIRParentObject po(total.NumberOfCells, prevLookback, prevIDs, nextID, nextLookback);
781 
782 
783  // Perform the MIR step
784  cellSetDispatcher.Invoke(cellSet,
785  prevValues,
786  curValues,
787  offsets,
788  mirInd,
789  cellSetStats,
790  this->MIRTablesInstance,
791  connectivityObject,
792  edgePointReverseConnectivity,
793  edgeInterpolation,
794  cellPointReverseConnectivity,
795  cellPointEdgeReverseConnectivity,
796  cellPointEdgeInterpolation,
799  po,
800  this->CellMapOutputToInput);
801 
802  //}
803  // Forthly, create the output set and clean up connectivity objects.
804  //{
805  // Get unique keys for all shared edges
807  edgeInterpolation, edgePointReverseConnectivity, EdgeInterpolation::LessThanOp());
808  vtkm::cont::Algorithm::Copy(edgeInterpolation, this->EdgePointsInterpolation);
810  vtkm::cont::ArrayHandle<vtkm::Id> edgeInterpolationIndexToUnique;
812  edgeInterpolation,
813  edgeInterpolationIndexToUnique,
815 
816  vtkm::cont::ArrayHandle<vtkm::Id> cellInterpolationIndexToUnique;
818  cellPointEdgeInterpolation,
819  cellInterpolationIndexToUnique,
821  this->EdgePointsOffset = cellSet.GetNumberOfPoints();
822  this->InCellPointsOffset =
823  this->EdgePointsOffset + this->EdgePointsInterpolation.GetNumberOfValues();
824 
825  ScatterEdgeConnectivity scatterEdgePointConnectivity(this->EdgePointsOffset);
827  scatterEdgePointConnectivity);
828  scatterEdgeDispatcher.Invoke(
829  edgeInterpolationIndexToUnique, edgePointReverseConnectivity, connectivity);
830  scatterEdgeDispatcher.Invoke(cellInterpolationIndexToUnique,
831  cellPointEdgeReverseConnectivity,
833  // Add offset in connectivity of all new in-cell points.
834  ScatterInCellConnectivity scatterInCellPointConnectivity(this->InCellPointsOffset);
836  scatterInCellPointConnectivity);
837  scatterInCellDispatcher.Invoke(cellPointReverseConnectivity, connectivity);
838 
840  vtkm::Id numberOfPoints = cellSet.GetNumberOfPoints() +
841  this->EdgePointsInterpolation.GetNumberOfValues() + total.NumberOfInCellPoints;
842 
843  vtkm::cont::ConvertNumComponentsToOffsets(numberOfIndices, offset);
844  // Create explicit cell set output
845  output.Fill(numberOfPoints, shapes, connectivity, offset);
846  //}
848  vtkm::cont::ArrayCopy(po.newCellLookback, newLookback);
849 
850  return output;
851  }
852 
853  template <typename ArrayHandleType>
855  {
856  public:
857  using ValueType = typename ArrayHandleType::ValueType;
859 
861  vtkm::cont::ArrayHandle<vtkm::Id> inCellInterpolationKeys,
862  vtkm::cont::ArrayHandle<vtkm::Id> inCellInterpolationInfo,
863  vtkm::Id edgePointsOffset,
864  vtkm::Id inCellPointsOffset,
865  ArrayHandleType* output)
866  : EdgeInterpolationArray(edgeInterpolationArray)
867  , InCellInterpolationKeys(inCellInterpolationKeys)
868  , InCellInterpolationInfo(inCellInterpolationInfo)
869  , EdgePointsOffset(edgePointsOffset)
870  , InCellPointsOffset(inCellPointsOffset)
871  , Output(output)
872  {
873  }
874 
876  {
877  public:
879  : EdgePointsOffset(edgePointsOffset)
880  {
881  }
882 
883  using ControlSignature = void(FieldIn edgeInterpolations, WholeArrayInOut outputField);
884 
885  using ExecutionSignature = void(_1, _2, WorkIndex);
886 
887  template <typename EdgeInterp, typename OutputFieldPortal>
888  VTKM_EXEC void operator()(const EdgeInterp& ei,
889  OutputFieldPortal& field,
890  const vtkm::Id workIndex) const
891  {
892  using T = typename OutputFieldPortal::ValueType;
893  T v1 = field.Get(ei.Vertex1);
894  T v2 = field.Get(ei.Vertex2);
895  field.Set(this->EdgePointsOffset + workIndex,
896  static_cast<T>(MIRinternal::Scale(T(v1 - v2), ei.Weight) + v2));
897  if (ei.Weight > vtkm::Float64(1) || ei.Weight < vtkm::Float64(0))
898  {
899  this->RaiseError("Error in edge weight, assigned value not it interval [0,1].");
900  }
901  }
902 
903  private:
905  };
906 
908  {
909  public:
910  using ControlSignature = void(KeysIn keys, ValuesIn toReduce, ReducedValuesOut centroid);
911 
912  using ExecutionSignature = void(_2, _3);
913 
914  template <typename MappedValueVecType, typename MappedValueType>
915  VTKM_EXEC void operator()(const MappedValueVecType& toReduce, MappedValueType& centroid) const
916  {
917  vtkm::IdComponent numValues = toReduce.GetNumberOfComponents();
918  MappedValueType sum = toReduce[0];
919  for (vtkm::IdComponent i = 1; i < numValues; i++)
920  {
921  MappedValueType value = toReduce[i];
922  // static_cast is for when MappedValueType is a small int that gets promoted to int32.
923  sum = static_cast<MappedValueType>(sum + value);
924  }
925  centroid = MIRinternal::Scale(sum, 1. / static_cast<vtkm::Float64>(numValues));
926  }
927  };
928 
929  template <typename Storage>
931  {
933 
934  vtkm::Id numberOfOriginalValues = field.GetNumberOfValues();
935  vtkm::Id numberOfEdgePoints = EdgeInterpolationArray.GetNumberOfValues();
936  vtkm::Id numberOfInCellPoints = interpolationKeys.GetUniqueKeys().GetNumberOfValues();
937 
938  ArrayHandleType result;
939  result.Allocate(numberOfOriginalValues + numberOfEdgePoints + numberOfInCellPoints);
940  vtkm::cont::Algorithm::CopySubRange(field, 0, numberOfOriginalValues, result);
941 
942  PerformEdgeInterpolations edgeInterpWorklet(numberOfOriginalValues);
944  edgeInterpWorklet);
945  edgeInterpDispatcher.Invoke(this->EdgeInterpolationArray, result);
946 
947  // Perform a gather on output to get all required values for calculation of
948  // centroids using the interpolation info array.
949  using IdHandle = vtkm::cont::ArrayHandle<vtkm::Id>;
950  using ValueHandle = vtkm::cont::ArrayHandle<ValueType>;
952  InCellInterpolationInfo, result);
953 
956  inCellInterpolationDispatcher;
957  inCellInterpolationDispatcher.Invoke(interpolationKeys, toReduceValues, reducedValues);
958  vtkm::Id inCellPointsOffset = numberOfOriginalValues + numberOfEdgePoints;
960  reducedValues, 0, reducedValues.GetNumberOfValues(), result, inCellPointsOffset);
961  *(this->Output) = result;
962  }
963 
964  private:
970  ArrayHandleType* Output;
971  };
972 
973  template <typename IDLen, typename IDPos, typename IDList, typename VFList>
975  {
976  public:
978  vtkm::cont::ArrayHandle<vtkm::Id> inCellInterpolationKeys,
979  vtkm::cont::ArrayHandle<vtkm::Id> inCellInterpolationInfo,
980  vtkm::Id edgePointsOffset,
981  vtkm::Id inCellPointsOffset,
982  IDLen* output1,
983  IDPos* output2,
984  IDList* output3,
985  VFList* output4)
986  : EdgeInterpolationArray(edgeInterpolationArray)
987  , InCellInterpolationKeys(inCellInterpolationKeys)
988  , InCellInterpolationInfo(inCellInterpolationInfo)
989  , EdgePointsOffset(edgePointsOffset)
990  , InCellPointsOffset(inCellPointsOffset)
991  , LenOut(output1)
992  , PosOut(output2)
993  , IDOut(output3)
994  , VFOut(output4)
995  {
996  }
997 
999  {
1000  public:
1002  : EdgePointsOffset(edgePointsOffset)
1003  {
1004  }
1005 
1006  using ControlSignature = void(FieldIn edgeInterpolations,
1007  WholeArrayIn lengths,
1008  WholeArrayIn positions,
1009  WholeArrayInOut ids,
1010  WholeArrayInOut vfs);
1011 
1012  using ExecutionSignature = void(_1, _2, _3, _4, _5, WorkIndex);
1013 
1014  template <typename EdgeInterp, typename IDL, typename IDO, typename IdsVec, typename VfsVec>
1015  VTKM_EXEC void operator()(const EdgeInterp& ei,
1016  const IDL& lengths,
1017  const IDO& positions,
1018  IdsVec& ids,
1019  VfsVec& vfs,
1020  const vtkm::Id workIndex) const
1021  {
1022  vtkm::Vec<vtkm::Id, 2> idOff;
1023  vtkm::Vec<vtkm::Id, 2> idLen;
1024  vtkm::Vec<vtkm::Id, 2> idInd;
1025  vtkm::Vec<vtkm::Float64, 2> multiplier;
1026  multiplier[1] = vtkm::Float64(1.0) - ei.Weight;
1027  multiplier[0] = ei.Weight;
1028  vtkm::Id uniqueMats = vtkm::Id(0);
1029 
1030  idOff[0] = vtkm::Id(0);
1031  idOff[1] = idOff[0];
1032  idInd[0] = positions.Get(ei.Vertex1);
1033  idInd[1] = positions.Get(ei.Vertex2);
1034  idLen[0] = lengths.Get(ei.Vertex1);
1035  idLen[1] = lengths.Get(ei.Vertex2);
1036  vtkm::IdComponent numberOfPoints = 2;
1037  vtkm::UInt8 hasWork = vtkm::UInt8(1);
1038  while (hasWork != vtkm::UInt8(0))
1039  {
1040  hasWork = vtkm::UInt8(0);
1041  vtkm::Id lowest = vtkm::Id(-1);
1042  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1043  {
1044  if (idOff[i] < idLen[i])
1045  {
1046  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1047  if (lowest == vtkm::Id(-1) || tmp < lowest)
1048  {
1049  lowest = tmp;
1050  hasWork = vtkm::UInt8(1);
1051  }
1052  }
1053  }
1054  if (hasWork != vtkm::UInt8(0))
1055  {
1056  vtkm::Float64 vfVal = vtkm::Float64(0);
1057  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1058  {
1059  if (idOff[i] < idLen[i])
1060  {
1061  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1062  if (lowest == tmp)
1063  {
1064  vfVal += multiplier[i] * vfs.Get(idInd[i] + idOff[i]);
1065  idOff[i]++;
1066  }
1067  }
1068  }
1069  ids.Set(positions.Get(this->EdgePointsOffset + workIndex) + uniqueMats, lowest);
1070  vfs.Set(positions.Get(this->EdgePointsOffset + workIndex) + uniqueMats, vfVal);
1071  uniqueMats++;
1072  }
1073  }
1074  }
1075 
1076  private:
1078  };
1080  {
1081  private:
1083 
1084  public:
1086  : EdgePointsOffset(edgePointsOffset)
1087  {
1088  }
1089  using ControlSignature = void(FieldIn edgeInterpolations,
1090  WholeArrayInOut IDLengths,
1091  WholeArrayIn IDOffsets,
1092  WholeArrayIn IDs,
1093  FieldOut edgeLength);
1094  using ExecutionSignature = void(_1, _2, _3, _4, WorkIndex, _5);
1095  template <typename EdgeInterp, typename IDL, typename IDO, typename IdsVec, typename ELL>
1096  VTKM_EXEC void operator()(const EdgeInterp& ei,
1097  IDL& lengths,
1098  const IDO& positions,
1099  const IdsVec& ids,
1100  const vtkm::Id workIndex,
1101  ELL& edgelength) const
1102  {
1103  vtkm::Vec<vtkm::Id, 2> idOff;
1104  vtkm::Vec<vtkm::Id, 2> idLen;
1105  vtkm::Vec<vtkm::Id, 2> idInd;
1106  vtkm::Id uniqueMats = vtkm::Id(0);
1107 
1108  idOff[0] = vtkm::Id(0);
1109  idOff[1] = idOff[0];
1110  idInd[0] = positions.Get(ei.Vertex1);
1111  idInd[1] = positions.Get(ei.Vertex2);
1112  idLen[0] = lengths.Get(ei.Vertex1);
1113  idLen[1] = lengths.Get(ei.Vertex2);
1114  vtkm::IdComponent numberOfPoints = 2;
1115  vtkm::UInt8 hasWork = vtkm::UInt8(1);
1116  while (hasWork != vtkm::UInt8(0))
1117  {
1118  hasWork = vtkm::UInt8(0);
1119  vtkm::Id lowest = vtkm::Id(-1);
1120  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1121  {
1122  if (idOff[i] < idLen[i])
1123  {
1124  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1125  if (lowest == vtkm::Id(-1) || tmp < lowest)
1126  {
1127  lowest = tmp;
1128  hasWork = vtkm::UInt8(1);
1129  }
1130  }
1131  }
1132  if (hasWork != vtkm::UInt8(0))
1133  {
1134  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1135  {
1136  if (idOff[i] < idLen[i])
1137  {
1138  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1139  if (lowest == tmp)
1140  {
1141  idOff[i]++;
1142  }
1143  }
1144  }
1145  uniqueMats++;
1146  }
1147  }
1148  lengths.Set(this->EdgePointsOffset + workIndex, uniqueMats);
1149  edgelength = uniqueMats;
1150  }
1151  };
1152 
1154  {
1155  public:
1156  using ControlSignature = void(KeysIn keys,
1157  ValuesIn toReduce,
1158  WholeArrayIn IDLengths,
1159  WholeArrayIn IDOffsets,
1160  WholeArrayIn IDs,
1161  ReducedValuesOut centroid);
1162 
1163  using ExecutionSignature = void(_2, _3, _4, _5, _6);
1164 
1165  template <typename MappedValueVecType,
1166  typename MappedValueType,
1167  typename IDArr,
1168  typename IDOff,
1169  typename IdsVec>
1170  VTKM_EXEC void operator()(const MappedValueVecType& toReduce,
1171  const IDArr& lengths,
1172  const IDOff& positions,
1173  const IdsVec& ids,
1174  MappedValueType& numIdNeeded) const
1175  {
1176  vtkm::IdComponent numberOfPoints = toReduce.GetNumberOfComponents();
1177  // ToReduce is simply the indexArray, giving us point information (since this is reduce by key)
1178  // numIdNeeded is the output length of this key
1179  using IdVec = vtkm::Vec<vtkm::Id, 8>;
1183  vtkm::Id uniqueMats = vtkm::Id(0);
1184 
1185  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1186  {
1187  idOff[i] = 0;
1188  idLen[i] = lengths.Get(toReduce[i]);
1189  idInd[i] = positions.Get(toReduce[i]);
1190  }
1191 
1192  vtkm::UInt8 hasWork = vtkm::UInt8(1);
1193  while (hasWork != vtkm::UInt8(0))
1194  {
1195  hasWork = vtkm::UInt8(0);
1196  vtkm::Id lowest = vtkm::Id(-1);
1197  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1198  {
1199  if (idOff[i] < idLen[i])
1200  {
1201  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1202  if (lowest == vtkm::Id(-1) || tmp < lowest)
1203  {
1204  lowest = tmp;
1205  hasWork = vtkm::UInt8(1);
1206  }
1207  }
1208  }
1209  if (hasWork != vtkm::UInt8(0))
1210  {
1211  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1212  {
1213  if (idOff[i] < idLen[i])
1214  {
1215  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1216  if (lowest == tmp)
1217  {
1218  idOff[i]++;
1219  }
1220  }
1221  }
1222  uniqueMats++;
1223  }
1224  }
1225  numIdNeeded = uniqueMats;
1226  }
1227  };
1228 
1230  {
1231  private:
1233 
1234  public:
1235  PerformInCellInterpolations(vtkm::Id outputOffsetForBookkeeping)
1236  : offset(outputOffsetForBookkeeping)
1237  {
1238  }
1239  using ControlSignature = void(KeysIn keys,
1240  ValuesIn toReduce,
1241  WholeArrayIn IDLengths,
1242  WholeArrayIn IDOffsets,
1243  WholeArrayIn IDs,
1244  WholeArrayIn VFs,
1245  ReducedValuesIn indexOff,
1246  ReducedValuesOut reindexedOut,
1247  WholeArrayOut outputIDs,
1248  WholeArrayOut outputVFs);
1249 
1250  using ExecutionSignature = void(_2, _3, _4, _5, _6, _7, _8, _9, _10);
1251 
1252  template <typename MappedValueVecType,
1253  typename IDArr,
1254  typename IDOff,
1255  typename IdsVec,
1256  typename VfsVec,
1257  typename IndexIn,
1258  typename IndexOut,
1259  typename OutID,
1260  typename OutVF>
1261  VTKM_EXEC void operator()(const MappedValueVecType& toReduce,
1262  const IDArr& lengths,
1263  const IDOff& positions,
1264  const IdsVec& ids,
1265  const VfsVec& vfs,
1266  const IndexIn& localOffset,
1267  IndexOut& globalOffset,
1268  OutID& outIDs,
1269  OutVF& outVFs) const
1270  {
1271 
1272  globalOffset = localOffset + this->offset;
1273  vtkm::IdComponent numberOfPoints = toReduce.GetNumberOfComponents();
1274  // ToReduce is simply the indexArray, giving us point information (since this is reduce by key)
1275 
1276  // numIdNeeded is the output length of this key
1277  using IdVec = vtkm::Vec<vtkm::Id, 8>;
1281  vtkm::Id uniqueMats = vtkm::Id(0);
1282 
1283  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1284  {
1285  idOff[i] = 0;
1286  idLen[i] = lengths.Get(toReduce[i]);
1287  idInd[i] = positions.Get(toReduce[i]);
1288  }
1289 
1290  vtkm::UInt8 hasWork = vtkm::UInt8(1);
1291  while (hasWork != vtkm::UInt8(0))
1292  {
1293  hasWork = vtkm::UInt8(0);
1294  vtkm::Id lowest = vtkm::Id(-1);
1295  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1296  {
1297  if (idOff[i] < idLen[i])
1298  {
1299  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1300  if (lowest == vtkm::Id(-1) || tmp < lowest)
1301  {
1302  lowest = tmp;
1303  hasWork = vtkm::UInt8(1);
1304  }
1305  }
1306  }
1307  if (hasWork != vtkm::UInt8(0))
1308  {
1309  vtkm::Float64 val = vtkm::Float64(0);
1310  for (vtkm::IdComponent i = 0; i < numberOfPoints; i++)
1311  {
1312  if (idOff[i] < idLen[i])
1313  {
1314  vtkm::Id tmp = ids.Get(idInd[i] + idOff[i]);
1315  if (lowest == tmp)
1316  {
1317  val += vfs.Get(idInd[i] + idOff[i]);
1318  idOff[i]++;
1319  }
1320  }
1321  }
1322  outVFs.Set(localOffset + uniqueMats, val / vtkm::Float64(numberOfPoints));
1323  outIDs.Set(localOffset + uniqueMats, lowest);
1324  uniqueMats++;
1325  }
1326  }
1327  }
1328  };
1329 
1335  {
1337  vtkm::Id numberOfOriginalPos = originalLen.GetNumberOfValues();
1338  vtkm::Id numberOfEdgePoints = EdgeInterpolationArray.GetNumberOfValues();
1339 
1344  lengthArr.Allocate(numberOfOriginalPos + numberOfEdgePoints);
1345  posArr.Allocate(numberOfOriginalPos + numberOfEdgePoints);
1346  vtkm::cont::Algorithm::CopySubRange(originalLen, 0, numberOfOriginalPos, lengthArr);
1347  vtkm::cont::Algorithm::CopySubRange(originalPos, 0, numberOfOriginalPos, posArr);
1348 
1350  PerformEdgeInterpolations_C edgeCountWorklet(numberOfOriginalPos);
1352  edgeCountWorklet);
1353  edgeInterpDispatcher_C.Invoke(
1354  this->EdgeInterpolationArray, lengthArr, posArr, originalIDs, edgeLengths);
1355 
1356  vtkm::Id idLengthFromJustEdges = vtkm::cont::Algorithm::Reduce(edgeLengths, vtkm::Id(0));
1357 
1358  idArr.Allocate(originalIDs.GetNumberOfValues() + idLengthFromJustEdges);
1359  vfArr.Allocate(originalIDs.GetNumberOfValues() + idLengthFromJustEdges);
1360  vtkm::cont::Algorithm::CopySubRange(originalIDs, 0, originalIDs.GetNumberOfValues(), idArr);
1361  vtkm::cont::Algorithm::CopySubRange(originalVFs, 0, originalIDs.GetNumberOfValues(), vfArr);
1362  vtkm::cont::Algorithm::ScanExclusive(lengthArr, posArr);
1363 
1364  // Accept that you will have to copy data :| Maybe can speed this up with some special logic...
1365  PerformEdgeInterpolations edgeInterpWorklet(numberOfOriginalPos);
1367  edgeInterpWorklet);
1368  edgeInterpDispatcher.Invoke(this->EdgeInterpolationArray, lengthArr, posArr, idArr, vfArr);
1369 
1370  // Need to run actual edgeInterpDispatcher, we then reduce the values
1371 
1372 
1373  vtkm::cont::ArrayHandleIndex pointArr(numberOfOriginalPos + numberOfEdgePoints);
1375  vtkm::cont::ArrayCopy(pointArr, pointArrCp);
1376  using IdHandle = vtkm::cont::ArrayHandle<vtkm::Id>;
1377  using ValueHandle = vtkm::cont::ArrayHandle<vtkm::Id>;
1379  InCellInterpolationInfo, pointArrCp);
1380 
1381  PerformInCellInterpolations_C incellCountWorklet;
1382  vtkm::cont::ArrayHandle<vtkm::Id> reducedIDCounts;
1384  incellCountWorklet);
1385  cellCountDispatcher.Invoke(
1386  interpolationKeys, toReduceValues, lengthArr, posArr, idArr, reducedIDCounts);
1387 
1388  vtkm::cont::ArrayHandle<vtkm::Id> reducedIDOffsets;
1389  vtkm::Id totalIDLen = vtkm::cont::Algorithm::ScanExclusive(reducedIDCounts, reducedIDOffsets);
1390 
1391  PerformInCellInterpolations incellWorklet(originalIDs.GetNumberOfValues() +
1392  idLengthFromJustEdges);
1393  vtkm::cont::ArrayHandle<vtkm::Id> cellids, cellOffsets;
1395 
1396  cellids.Allocate(totalIDLen);
1397  cellvfs.Allocate(totalIDLen);
1399  incellWorklet);
1400  cellInterpDispatcher.Invoke(interpolationKeys,
1401  toReduceValues,
1402  lengthArr,
1403  posArr,
1404  idArr,
1405  vfArr,
1406  reducedIDOffsets,
1407  cellOffsets,
1408  cellids,
1409  cellvfs);
1410 
1411  vtkm::Id inCellVFOffset = originalIDs.GetNumberOfValues() + idLengthFromJustEdges;
1412  vtkm::cont::Algorithm::CopySubRange(cellids, 0, totalIDLen, idArr, inCellVFOffset);
1413  vtkm::cont::Algorithm::CopySubRange(cellvfs, 0, totalIDLen, vfArr, inCellVFOffset);
1414  vtkm::cont::Algorithm::CopySubRange(reducedIDCounts,
1415  0,
1416  reducedIDCounts.GetNumberOfValues(),
1417  lengthArr,
1418  numberOfOriginalPos + numberOfEdgePoints);
1420  0,
1421  cellOffsets.GetNumberOfValues(),
1422  posArr,
1423  numberOfOriginalPos + numberOfEdgePoints);
1424 
1425  *(this->LenOut) = lengthArr;
1426  *(this->PosOut) = posArr;
1427  *(this->IDOut) = idArr;
1428  *(this->VFOut) = vfArr;
1429  }
1430 
1431  private:
1437  IDLen* LenOut;
1438  IDPos* PosOut;
1439  IDList* IDOut;
1440  VFList* VFOut;
1441  };
1442 
1443  template <typename LookbackArr, typename WeightArr>
1445  {
1446  public:
1448  vtkm::cont::ArrayHandle<vtkm::Id> inCellInterpolationKeys,
1449  vtkm::cont::ArrayHandle<vtkm::Id> inCellInterpolationInfo,
1450  vtkm::Id edgePointsOffset,
1451  vtkm::Id inCellPointsOffset,
1452  LookbackArr* output,
1453  WeightArr* output2)
1454  : EdgeInterpolationArray(edgeInterpolationArray)
1455  , InCellInterpolationKeys(inCellInterpolationKeys)
1456  , InCellInterpolationInfo(inCellInterpolationInfo)
1457  , EdgePointsOffset(edgePointsOffset)
1458  , InCellPointsOffset(inCellPointsOffset)
1459  , Output(output)
1460  , Output2(output2)
1461  {
1462  }
1464  {
1465  public:
1467  : EdgePointsOffset(edgePointsOffset)
1468  {
1469  }
1470 
1471  using ControlSignature = void(FieldIn edgeInterpolations,
1472  WholeArrayInOut inoutID,
1473  WholeArrayInOut inoutWeights);
1474 
1475  using ExecutionSignature = void(_1, _2, _3, WorkIndex);
1476 
1477  template <typename EdgeInterp, typename InOutId, typename InOutWeight>
1478  VTKM_EXEC void operator()(const EdgeInterp& ei,
1479  InOutId& field,
1480  InOutWeight& field1,
1481  const vtkm::Id workIndex) const
1482  {
1483 
1486  vtkm::Vec<vtkm::Id, 8> centroid;
1490  keys[0] = field.Get(ei.Vertex1);
1491  keys[1] = field.Get(ei.Vertex2);
1492  weights[0] = field1.Get(ei.Vertex1);
1493  weights[1] = field1.Get(ei.Vertex2);
1494  for (vtkm::IdComponent i = 0; i < 8; i++)
1495  {
1496  weight[i] = 0;
1497  centroid[i] = -1;
1498  }
1499  curOff[0] = 0;
1500  curOff[1] = 0;
1501  mult[0] = ei.Weight;
1502  mult[1] = vtkm::Float64(1.0) - ei.Weight;
1503  for (vtkm::IdComponent j = 0; j < 8; j++)
1504  {
1505  vtkm::Id lowestID = vtkm::Id(-1);
1506  for (vtkm::IdComponent i = 0; i < 2; i++)
1507  {
1508  if (curOff[i] < 8 &&
1509  (lowestID == vtkm::Id(-1) ||
1510  ((keys[i])[curOff[i]] != vtkm::Id(-1) && (keys[i])[curOff[i]] < lowestID)))
1511  {
1512  lowestID = (keys[i])[curOff[i]];
1513  }
1514  if (curOff[i] < 8 && (keys[i])[curOff[i]] == vtkm::Id(-1))
1515  {
1516  curOff[i] = 8;
1517  }
1518  }
1519  if (lowestID == vtkm::Id(-1))
1520  {
1521  break;
1522  }
1523  centroid[j] = lowestID;
1524  for (vtkm::IdComponent i = 0; i < 2; i++)
1525  {
1526  if (curOff[i] < 8 && lowestID == (keys[i])[curOff[i]])
1527  {
1528  weight[j] += mult[i] * weights[i][curOff[i]];
1529  curOff[i]++;
1530  }
1531  }
1532  }
1533 
1534  field.Set(this->EdgePointsOffset + workIndex, centroid);
1535  field1.Set(this->EdgePointsOffset + workIndex, weight);
1536  }
1537 
1538  private:
1540  };
1541 
1543  {
1544  public:
1545  using ControlSignature = void(KeysIn keys,
1546  ValuesIn toReduceID,
1547  WholeArrayIn Keys,
1548  WholeArrayIn weights,
1549  ReducedValuesOut id,
1551 
1552  using ExecutionSignature = void(_2, _3, _4, _5, _6);
1553 
1554  template <typename IDs,
1555  typename VecOfVecIDs,
1556  typename VecOfVecWeights,
1557  typename VecId,
1558  typename VecWeight>
1559  VTKM_EXEC void operator()(const IDs& ids,
1560  const VecOfVecIDs& keysIn,
1561  const VecOfVecWeights& weightsIn,
1562  VecId& centroid,
1563  VecWeight& weight) const
1564  {
1565  vtkm::IdComponent numValues = ids.GetNumberOfComponents();
1569  for (vtkm::IdComponent i = 0; i < 8; i++)
1570  {
1571  weight[i] = 0;
1572  centroid[i] = -1;
1573  curOff[i] = 0;
1574  }
1575  for (vtkm::IdComponent i = 0; i < numValues; i++)
1576  {
1577  keys[i] = keysIn.Get(ids[i]);
1578  weights[i] = weightsIn.Get(ids[i]);
1579  }
1580  for (vtkm::IdComponent i = numValues; i < 8; i++)
1581  {
1582  curOff[i] = 8;
1583  }
1584  for (vtkm::IdComponent j = 0; j < 8; j++)
1585  {
1586  vtkm::Id lowestID = vtkm::Id(-1);
1587  for (vtkm::IdComponent i = 0; i < numValues; i++)
1588  {
1589  auto tmp = keys[i];
1590  if (curOff[i] < 8 &&
1591  (lowestID == vtkm::Id(-1) ||
1592  (tmp[curOff[i]] != vtkm::Id(-1) && tmp[curOff[i]] < lowestID)))
1593  {
1594  lowestID = tmp[curOff[i]];
1595  }
1596 
1597  if (curOff[i] < 8 && tmp[curOff[i]] == vtkm::Id(-1))
1598  {
1599  curOff[i] = 8;
1600  }
1601  }
1602  if (lowestID == vtkm::Id(-1))
1603  {
1604  break;
1605  }
1606  centroid[j] = lowestID;
1607  for (vtkm::IdComponent i = 0; i < numValues; i++)
1608  {
1609  auto tmp = keys[i];
1610  if (curOff[i] < 8 && lowestID == tmp[curOff[i]])
1611  {
1612  auto w = weights[i];
1613  weight[j] += w[curOff[i]];
1614  curOff[i]++;
1615  }
1616  }
1617  }
1618  for (vtkm::IdComponent j = 0; j < 8; j++)
1619  {
1620  weight[j] *= 1. / static_cast<vtkm::Float64>(numValues);
1621  VTKM_ASSERT(curOff[j] == 8);
1622  }
1623  }
1624  };
1625 
1626  template <typename ValueType, typename ValueType1, typename Storage, typename Storage2>
1629  const vtkm::cont::ArrayHandle<ValueType1, Storage2>& weightsField) const
1630  {
1632 
1633  vtkm::Id numberOfOriginalValues = fieldID.GetNumberOfValues();
1634  vtkm::Id numberOfEdgePoints = EdgeInterpolationArray.GetNumberOfValues();
1635  vtkm::Id numberOfInCellPoints = interpolationKeys.GetUniqueKeys().GetNumberOfValues();
1636  LookbackArr result;
1637  result.Allocate(numberOfOriginalValues + numberOfEdgePoints + numberOfInCellPoints);
1638  vtkm::cont::Algorithm::CopySubRange(fieldID, 0, numberOfOriginalValues, result);
1639  WeightArr result2;
1640  result2.Allocate(numberOfOriginalValues + numberOfEdgePoints + numberOfInCellPoints);
1641  vtkm::cont::Algorithm::CopySubRange(weightsField, 0, numberOfOriginalValues, result2);
1642 
1643  PerformEdgeInterpolations edgeInterpWorklet(numberOfOriginalValues);
1645  edgeInterpWorklet);
1646  edgeInterpDispatcher.Invoke(this->EdgeInterpolationArray, result, result2);
1647 
1648  // Perform a gather on output to get all required values for calculation of
1649  // centroids using the interpolation info array.oi
1650  vtkm::cont::ArrayHandleIndex nout(numberOfOriginalValues + numberOfEdgePoints);
1651  auto toReduceValues = make_ArrayHandlePermutation(InCellInterpolationInfo, nout);
1652 
1653  vtkm::cont::ArrayHandle<ValueType> reducedValues;
1654  vtkm::cont::ArrayHandle<ValueType1> reducedWeights;
1656  inCellInterpolationDispatcher;
1657  inCellInterpolationDispatcher.Invoke(
1658  interpolationKeys, toReduceValues, result, result2, reducedValues, reducedWeights);
1659  vtkm::Id inCellPointsOffset = numberOfOriginalValues + numberOfEdgePoints;
1661  reducedValues, 0, reducedValues.GetNumberOfValues(), result, inCellPointsOffset);
1663  reducedWeights, 0, reducedWeights.GetNumberOfValues(), result2, inCellPointsOffset);
1664  *(this->Output) = result;
1665  *(this->Output2) = result2;
1666  }
1667 
1668  private:
1674  LookbackArr* Output;
1675  WeightArr* Output2;
1676  };
1680  orWeights,
1683  const
1684  {
1690  this->EdgePointsOffset,
1691  this->InCellPointsOffset,
1692  &newLookback,
1693  &newweights);
1694  worker(orLookback, orWeights);
1695  }
1705  {
1706  auto worker =
1714  this->EdgePointsOffset,
1715  this->InCellPointsOffset,
1716  &newLen,
1717  &newPos,
1718  &newIDs,
1719  &newVFs);
1720  worker(orLen, orPos, orIDs, orVFs);
1721  }
1722 
1723  template <typename ValueType, typename StorageType>
1725  const vtkm::cont::ArrayHandle<ValueType, StorageType>& fieldData) const
1726  {
1728  using Worker = InterpolateField<ResultType>;
1729  ResultType output;
1730  Worker worker = Worker(this->EdgePointsInterpolation,
1733  this->EdgePointsOffset,
1734  this->InCellPointsOffset,
1735  &output);
1736  worker(fieldData);
1737  return output;
1738  }
1739 
1740 private:
1748 };
1749 
1750 }
1751 }
1752 
1753 namespace vtkm
1754 {
1755 namespace worklet
1756 {
1757 template <typename IDType, typename FloatType>
1759 {
1760 public:
1762  {
1763  public:
1764  VTKM_EXEC FloatType GetVFForPoint(IDType point, IDType matID, IDType) const
1765  {
1766  IDType low = this->PPos.Get(point);
1767  IDType high = this->PPos.Get(point) + this->PLens.Get(point) - 1;
1768  IDType matIdAt = -1;
1769  while (low <= high)
1770  {
1771  IDType mid = (low + high) / 2;
1772  IDType midMatId = this->PIDs.Get(mid);
1773  if (matID == midMatId)
1774  {
1775  matIdAt = mid;
1776  break;
1777  }
1778  else if (matID > midMatId)
1779  {
1780  low = mid + 1;
1781  }
1782  else if (matID < midMatId)
1783  {
1784  high = mid - 1;
1785  }
1786  }
1787  if (matIdAt >= 0)
1788  {
1789  return this->PVFs.Get(matIdAt);
1790  }
1791  else
1792  return FloatType(0);
1793  }
1794 
1795  private:
1800  friend struct MIRObject;
1801  };
1802 
1807 
1808  // Do we need to copy these arrays?
1809  template <typename IDInput, typename FloatInput>
1810  MIRObject(const IDInput& len, const IDInput& pos, const IDInput& ids, const FloatInput& floats)
1811  : pointLen(len)
1812  , pointPos(pos)
1813  , pointIDs(ids)
1814  , pointVFs(floats)
1815  {
1816  }
1817 
1819  {
1820  MIRObjectPortal portal;
1821  portal.PLens = this->pointLen.PrepareForInput(device, token);
1822  portal.PPos = this->pointPos.PrepareForInput(device, token);
1823  portal.PIDs = this->pointIDs.PrepareForInput(device, token);
1824  portal.PVFs = this->pointVFs.PrepareForInput(device, token);
1825  return portal;
1826  }
1827 
1828 private:
1831 };
1832 
1834 {
1835 public:
1836  using ControlSignature = void(CellSetIn cellSet,
1837  FieldInCell lens,
1838  FieldInCell pos,
1839  WholeArrayIn ids,
1840  FieldOutPoint idcount);
1841  using ExecutionSignature = void(CellCount, _2, _3, _4, _5);
1842  using InputDomain = _1;
1843 
1844  template <typename LenVec, typename PosVec, typename IdsVec, typename OutVec>
1846  const LenVec& len,
1847  const PosVec& pos,
1848  const IdsVec& ids,
1849  OutVec& outlength) const
1850  {
1851 
1852  // This is for the number of VFs in the surrounding cells...
1853  // We assume that the ids are sorted.
1854  outlength = vtkm::Id(0);
1855 
1856  vtkm::Id uniqueMats = vtkm::Id(0);
1857 
1858  using ida = vtkm::Id;
1859 
1860  ida lowest = ids.Get(pos[0]);
1861  ida prevLowest = ida(-1);
1862  ida largest = ida(-1);
1863 
1864  for (vtkm::IdComponent ci = 0; ci < numCells; ci++)
1865  {
1866  vtkm::IdComponent l = vtkm::IdComponent(pos[ci] + len[ci]);
1867  for (vtkm::IdComponent idi = vtkm::IdComponent(pos[ci]); idi < l; idi++)
1868  {
1869  ida tmp = ids.Get(idi);
1870  largest = vtkm::Maximum()(tmp, largest);
1871  }
1872  }
1873 
1874  while (prevLowest != lowest)
1875  {
1876  for (vtkm::IdComponent ci = 0; ci < numCells; ci++)
1877  {
1878  vtkm::IdComponent l = vtkm::IdComponent(pos[ci] + len[ci]);
1879  for (vtkm::IdComponent idi = vtkm::IdComponent(pos[ci]); idi < l; idi++)
1880  {
1881  ida tmp = ids.Get(idi);
1882  if (tmp < lowest && tmp > prevLowest)
1883  {
1884  lowest = tmp;
1885  }
1886  }
1887  }
1888  uniqueMats++;
1889  prevLowest = ida(lowest);
1890  lowest = ida(largest);
1891  }
1892  outlength = uniqueMats;
1893  }
1894 };
1895 
1897 {
1898 public:
1899  using ControlSignature = void(CellSetIn cellSet,
1900  FieldInCell lens,
1901  FieldInCell pos,
1902  WholeArrayIn ids,
1903  WholeArrayIn vfs,
1904  FieldInPoint actpos,
1905  WholeArrayOut idx,
1906  WholeArrayOut vfx);
1907  using ExecutionSignature = void(CellCount, _2, _3, _4, _5, _6, _7, _8);
1908  using InputDomain = _1;
1909  template <typename LenVec,
1910  typename PosVec,
1911  typename IdsVec,
1912  typename VfsVec,
1913  typename PosVec2,
1914  typename OutVec,
1915  typename OutVec2>
1917  const LenVec& len,
1918  const PosVec& pos,
1919  const IdsVec& ids,
1920  const VfsVec& vfs,
1921  const PosVec2& posit,
1922  OutVec& outid,
1923  OutVec2& outvf) const
1924  {
1925 
1926  // This is for the number of VFs in the surrounding cells...
1927  // We assume that the ids are sorted.
1928 
1929 
1930  vtkm::Id uniqueMats = vtkm::Id(0);
1931 
1932  using ida = vtkm::Id;
1933 
1934  ida lowest = ids.Get(pos[0]);
1935  ida prevLowest = ida(-1);
1936  ida largest = ida(-1);
1937 
1938  for (vtkm::IdComponent ci = 0; ci < numCells; ci++)
1939  {
1940  vtkm::IdComponent l = vtkm::IdComponent(pos[ci] + len[ci]);
1941  for (vtkm::IdComponent idi = vtkm::IdComponent(pos[ci]); idi < l; idi++)
1942  {
1943  ida tmp = ids.Get(idi);
1944  largest = vtkm::Maximum()(tmp, largest);
1945  }
1946  }
1947 
1948  while (prevLowest != lowest)
1949  {
1950  for (vtkm::IdComponent ci = 0; ci < numCells; ci++)
1951  {
1952  vtkm::IdComponent l = vtkm::IdComponent(pos[ci] + len[ci]);
1953  for (vtkm::IdComponent idi = vtkm::IdComponent(pos[ci]); idi < l; idi++)
1954  {
1955  ida tmp = ids.Get(idi);
1956  if (tmp < lowest && tmp > prevLowest)
1957  {
1958  lowest = tmp;
1959  }
1960  }
1961  }
1962  outid.Set(posit + uniqueMats, lowest);
1963  vtkm::Float64 avg = vtkm::Float64(0);
1964  for (vtkm::IdComponent ci = 0; ci < numCells; ci++)
1965  {
1966  vtkm::IdComponent l = vtkm::IdComponent(pos[ci] + len[ci]);
1967  for (vtkm::IdComponent idi = vtkm::IdComponent(pos[ci]); idi < l; idi++)
1968  {
1969  ida tmp = ids.Get(idi);
1970  if (tmp == lowest)
1971  {
1972  avg += vfs.Get(idi);
1973  }
1974  }
1975  }
1976  outvf.Set(posit + uniqueMats, avg / vtkm::Float64(numCells));
1977  uniqueMats++;
1978  prevLowest = ida(lowest);
1979  lowest = ida(largest);
1980  }
1981  }
1982 };
1983 
1985 {
1986 public:
1987  using ControlSignature = void(CellSetIn cellSet, FieldOutCell numPointsCount);
1988  using ExecutionSignature = void(PointCount, _2);
1989  using InputDomain = _1;
1990  template <typename OutVec>
1991  VTKM_EXEC void operator()(vtkm::IdComponent numPoints, OutVec& outlength) const
1992  {
1993  outlength = numPoints;
1994  }
1995 };
1996 
1998 {
1999 public:
2000  using ControlSignature = void(CellSetIn cellSet,
2001  ExecObject mir_obj,
2002  FieldInCell previousMatID,
2003  FieldOutCell curvfVals,
2004  FieldOutCell prevvfVals);
2005 
2006  using ExecutionSignature = void(PointCount, VisitIndex, PointIndices, _2, _3, _4, _5);
2007  using InputDomain = _1;
2009  template <typename CountArrayType>
2010  VTKM_CONT static ScatterType MakeScatter(const CountArrayType& countArray)
2011  {
2012  VTKM_IS_ARRAY_HANDLE(CountArrayType);
2013  return ScatterType(countArray);
2014  }
2015  template <typename DA, typename prevID, typename OutVec, typename OutVec2, typename pointVec>
2017  vtkm::IdComponent index,
2018  pointVec& pointIDs,
2019  const DA& mirobj,
2020  const prevID& previousID,
2021  OutVec& outVF,
2022  OutVec2& prevOutVF) const
2023  {
2024  (void)numPoints;
2025  outVF = OutVec(0);
2026  prevOutVF = OutVec2(0);
2027  outVF = mirobj.GetVFForPoint(pointIDs[index], this->target, 0);
2028  if (previousID == 0)
2029  {
2030  prevOutVF = 0;
2031  }
2032  else
2033  {
2034  prevOutVF = mirobj.GetVFForPoint(pointIDs[index], previousID, 0);
2035  }
2036  }
2038  : target(targetMat)
2039  {
2040  }
2041 
2042 private:
2044 };
2045 
2047 {
2048 public:
2049  using ControlSignature = void(CellSetIn cellSet,
2050  ExecObject mirTables,
2051  FieldInPoint verts,
2053  using ExecutionSignature = void(PointCount, CellShape, _2, _3, _4);
2054  template <typename Arrout, typename PointListIn, typename Dev, typename CellShape>
2055  VTKM_EXEC void operator()(const vtkm::IdComponent pointCount,
2056  const CellShape& cellShape,
2057  const Dev& mirTable,
2058  const PointListIn& vertPos,
2059  Arrout& volumeOut) const
2060  {
2061  vtkm::IdComponent numFaces = mirTable.GetNumberOfFaces(static_cast<vtkm::Id>(cellShape.Id));
2062 
2063  vtkm::Float64 totVol = vtkm::Float64(0);
2064  vtkm::IdComponent offset = mirTable.GetFaceOffset(static_cast<vtkm::Id>(cellShape.Id));
2065 
2066  auto av1 = vertPos[0];
2067  for (vtkm::IdComponent i = 1; i < pointCount; i++)
2068  {
2069  av1 += vertPos[i];
2070  }
2071  auto av = av1 * (vtkm::Float64(1.0) / vtkm::Float64(pointCount));
2072 
2073  for (vtkm::IdComponent i = 0; i < numFaces; i++)
2074  {
2075  vtkm::UInt8 p1 = mirTable.GetPoint(offset++);
2076  vtkm::UInt8 p2 = mirTable.GetPoint(offset++);
2077  vtkm::UInt8 p3 = mirTable.GetPoint(offset++);
2078  auto v1 = vertPos[p1];
2079  auto v2 = vertPos[p2];
2080  auto v3 = vertPos[p3];
2081 
2082  auto v4 = v1 - av;
2083  auto v5 = v2 - av;
2084  auto v6 = v3 - av;
2085  totVol += vtkm::Abs(vtkm::Dot(v4, vtkm::Cross(v5, v6))) / 6;
2086  }
2087  volumeOut = totVol;
2088  }
2089 };
2090 
2092 {
2093 public:
2094  using ControlSignature = void(KeysIn cellID,
2095  ValuesIn cellColors,
2096  WholeArrayIn origLen,
2097  WholeArrayIn origPos,
2098  WholeArrayIn origIDs,
2099  WholeArrayOut newlengthsOut);
2100  using ExecutionSignature = void(ValueCount, _1, _2, _3, _4, _5, _6);
2101  using InputDomain = _1;
2102  template <typename Colors, typename ORL, typename ORP, typename ORID, typename NLO>
2104  const vtkm::Id cellID,
2105  const Colors& cellCol,
2106  const ORL& orgLen,
2107  const ORP& orgPos,
2108  const ORID& orgID,
2109  NLO& outputLen) const
2110  {
2111  // Although I don't doubt for a minute that keys is sorted and hence the output would be too,
2112  // but this ensures I don't deal with a headache if they change that.
2113  // The orgLen and orgPos are the true, original cell IDs and VFs
2114  // Luckily indexing into cellID should be quick compared to orgLen...
2115  vtkm::Id lowest = orgID.Get(orgPos.Get(0));
2116  vtkm::Id originalInd = 0;
2117  vtkm::Id orgLen1 = orgLen.Get(cellID);
2118  vtkm::Id orgPos1 = orgPos.Get(cellID);
2119  vtkm::Id uniqueMats = 0;
2120  vtkm::Id largest = orgID.Get(orgLen1 + orgPos1 - 1);
2121  for (vtkm::IdComponent i = 0; i < numCells; i++)
2122  {
2123  vtkm::Id tmp = cellCol[i];
2124  largest = vtkm::Maximum()(tmp, largest);
2125  }
2126  vtkm::Id prevLowest = vtkm::Id(-1);
2127  lowest = vtkm::Id(0);
2128  while (prevLowest != largest)
2129  {
2130  if (originalInd < orgLen1)
2131  {
2132  lowest = orgID.Get(orgPos1 + originalInd);
2133  }
2134  for (vtkm::IdComponent i = 0; i < numCells; i++)
2135  {
2136  vtkm::Id tmp = cellCol[i];
2137  if (tmp > prevLowest)
2138  {
2139  lowest = vtkm::Minimum()(tmp, lowest);
2140  }
2141  }
2142  if (originalInd < orgLen1)
2143  {
2144  if (orgID.Get(orgPos1 + originalInd) == lowest)
2145  {
2146  originalInd++;
2147  }
2148  }
2149  uniqueMats++;
2150 
2151  prevLowest = lowest;
2152  lowest = largest;
2153  }
2154  outputLen.Set(cellID, uniqueMats);
2155  }
2156 };
2157 
2159 {
2160 private:
2162 
2163 public:
2165  : lerping(errorLerp)
2166  {
2167  }
2168  using ControlSignature = void(KeysIn cellID,
2169  ValuesIn cellColors,
2170  ValuesIn cellVols,
2171  WholeArrayIn origLen,
2172  WholeArrayIn origPos,
2173  WholeArrayIn origIDs,
2174  WholeArrayIn origVFs,
2175  WholeArrayIn curLen,
2176  WholeArrayIn curPos,
2177  WholeArrayIn curID,
2178  WholeArrayIn curVF,
2179  WholeArrayIn newLength,
2180  WholeArrayIn newposition,
2181  WholeArrayOut newIDs,
2182  WholeArrayOut newVFs,
2183  WholeArrayIn origVols,
2184  ReducedValuesOut totalErr);
2185  using ExecutionSignature =
2186  void(ValueCount, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17);
2187  using InputDomain = _1;
2188  template <typename Colors,
2189  typename ORL,
2190  typename ORP,
2191  typename ORID,
2192  typename NLO,
2193  typename ORVF,
2194  typename NID,
2195  typename NVF,
2196  typename Vols,
2197  typename TEO,
2198  typename CPos,
2199  typename CLen,
2200  typename CID,
2201  typename CVF,
2202  typename NLen,
2203  typename OVols>
2205  const vtkm::Id cellID,
2206  const Colors& cellCol,
2207  const Vols& cellVolumes,
2208  const ORL& orgLen,
2209  const ORP& orgPos,
2210  const ORID& orgID,
2211  const ORVF& orgVF,
2212  const CLen& curLen,
2213  const CPos& curPos,
2214  const CID& curID,
2215  const CVF& curVF,
2216  const NLen&,
2217  const NLO& inputPos,
2218  NID& inputIDs,
2219  NVF& inputVFs,
2220  const OVols& orgVols,
2221  TEO& totalErrorOut) const
2222  {
2223  // Although I don't doubt for a minute that keys is sorted and hence the output would be too,
2224  // but this ensures I don't deal with a headache if they change that.
2225  // The orgLen and orgPos are the true, original cell IDs and VFs
2226  // Luckily indexing into cellID should be quick compared to orgLen...
2227  //{
2228  vtkm::Id lowest = orgID.Get(orgPos.Get(0));
2229  vtkm::Id originalInd = 0;
2230  vtkm::Id orgLen1 = orgLen.Get(cellID);
2231  vtkm::Id orgPos1 = orgPos.Get(cellID);
2232  vtkm::Id uniqueMats = 0;
2233  vtkm::Id largest = orgID.Get(orgLen1 + orgPos1 - 1);
2234 
2235  //vtkm::Id canConnect = vtkm::Id(0);
2236  for (vtkm::IdComponent i = 0; i < numCells; i++)
2237  {
2238  vtkm::Id tmp = cellCol[i];
2239  largest = vtkm::Maximum()(tmp, largest);
2240  }
2241  vtkm::Id prevLowest = vtkm::Id(-1);
2242 
2243  vtkm::Id currentIndex = curPos.Get(cellID);
2244  vtkm::Id currentLens = curLen.Get(cellID) + currentIndex;
2245  //}
2246 
2247  vtkm::Float64 totalError = vtkm::Float64(0);
2248  while (prevLowest != largest)
2249  {
2250  if (originalInd < orgLen1)
2251  {
2252  lowest = orgID.Get(orgPos1 + originalInd);
2253  }
2254  for (vtkm::IdComponent i = 0; i < numCells; i++)
2255  {
2256  vtkm::Id tmp = cellCol[i];
2257  if (tmp > prevLowest)
2258  {
2259  lowest = vtkm::Minimum()(tmp, lowest);
2260  }
2261  }
2262  vtkm::Float64 totalVolForColor = vtkm::Float64(0);
2263  for (vtkm::IdComponent i = 0; i < numCells; i++)
2264  {
2265  vtkm::Id tmp = cellCol[i];
2266  if (tmp == lowest)
2267  {
2268  totalVolForColor += cellVolumes[i];
2269  }
2270  }
2271  if (originalInd < orgLen1)
2272  {
2273  if (orgID.Get(orgPos1 + originalInd) == lowest)
2274  {
2275  totalVolForColor -= orgVF.Get(orgPos1 + originalInd) * orgVols.Get(cellID);
2276  originalInd++;
2277  }
2278  }
2279 
2280  vtkm::Float64 prevTarget = vtkm::Float64(0);
2281  if (currentIndex < currentLens)
2282  {
2283 
2284  if (curID.Get(currentIndex) == lowest)
2285  {
2286  prevTarget = curVF.Get(currentIndex);
2287  currentIndex++;
2288  }
2289  }
2290  //vtkm::Float64 tmp = prevTarget;
2291  prevTarget += this->lerping * (-totalVolForColor) / orgVols.Get(cellID);
2292  totalError += vtkm::Abs(totalVolForColor);
2293  //VTKM_LOG_S(vtkm::cont::LogLevel::Warn, "Lerping " << tmp << " -> " << prevTarget << " :| " << totalVolForColor);
2294  //VTKM_LOG_S(vtkm::cont::LogLevel::Info, cellID << ": " << uniqueMats << " PT: " << tmp << " AVPTR "
2295  // << totalVolForColor << " L: " << this->lerping << " and " << prevTarget << " / " << totalError
2296  // << "\n" << inputPos.Get(cellID));
2297  inputIDs.Set(inputPos.Get(cellID) + uniqueMats, lowest);
2298  inputVFs.Set(inputPos.Get(cellID) + uniqueMats, vtkm::FloatDefault(prevTarget));
2299  uniqueMats++;
2300 
2301  prevLowest = lowest;
2302  lowest = largest;
2303  }
2304  totalErrorOut = TEO(totalError);
2305  }
2306 };
2308 {
2309  using ControlSignature = void(CellSetIn,
2310  FieldOutCell is2D,
2311  FieldOutCell is3D,
2312  FieldOutCell isOther);
2313  using ExecutionSignature = void(CellShape, _2, _3, _4);
2314  using InputDomain = _1;
2315  template <typename OO, typename OP, typename OQ, typename SHAPE>
2316  VTKM_EXEC void operator()(const SHAPE shape, OO& is2D, OP& is3D, OQ& isOther) const
2317  {
2318  is2D = vtkm::Id(0);
2319  is3D = vtkm::Id(0);
2320 
2324  shape.Id == vtkm::Id(6) // Tri strip?
2325  || shape.Id == vtkm::Id(8) /* Pixel? */)
2326  {
2327  is2D = vtkm::Id(1);
2328  }
2329  else if (shape.Id == vtkm::Id(0) /*Empty*/
2333  shape.Id == vtkm::Id(2) /* Poly Vertex? */)
2334  {
2335  isOther = vtkm::Id(1);
2336  }
2337  else if (shape.Id == vtkm::CellShapeIdToTag<vtkm::CELL_SHAPE_TETRA>::Tag().Id ||
2341  shape.Id == vtkm::Id(11) /* Voxel? */)
2342  {
2343  is3D = vtkm::Id(1);
2344  }
2345  else
2346  {
2347  // Truly is other
2348  isOther = vtkm::Id(1);
2349  }
2350  }
2351 };
2352 
2354 {
2355  using ControlSignature = void(FieldIn pointIDs, FieldOut VecLookback, FieldOut VecWeights);
2356  using ExecutionSignature = void(InputIndex, _2, _3);
2357  using InputDomain = _1;
2358  template <typename VO1, typename VO2>
2359  VTKM_EXEC void operator()(vtkm::Id& in, VO1& lookback, VO2& weights) const
2360  {
2361  for (vtkm::IdComponent i = 0; i < 8; i++)
2362  {
2363  lookback[i] = vtkm::Id(-1);
2364  weights[i] = vtkm::Float64(0);
2365  }
2366  lookback[0] = in;
2367  weights[0] = vtkm::Float64(1);
2368  }
2369 };
2370 
2372 {
2373  using ControlSignature = void(FieldIn pointIDs,
2374  FieldIn pointWeights,
2375  WholeArrayIn originalVals,
2376  FieldOut newVals);
2377  using ExecutionSignature = void(_1, _2, _3, _4);
2378  using InputDomain = _1;
2379  template <typename PID, typename PW, typename OV, typename NV>
2380  VTKM_EXEC void operator()(const PID& pids, const PW& pws, const OV& ov, NV& newVals) const
2381  {
2382  VTKM_ASSERT(pids[0] != -1);
2383  newVals = static_cast<NV>(ov.Get(pids[0]) * pws[0]);
2384  for (vtkm::IdComponent i = 1; i < 8; i++)
2385  {
2386  if (pids[i] == vtkm::Id(-1))
2387  {
2388  break;
2389  }
2390  else
2391  {
2392  newVals += static_cast<NV>(ov.Get(pids[i]) * pws[i]);
2393  }
2394  }
2395  }
2396 };
2397 
2398 }
2399 
2400 }
2401 
2402 #endif
vtkm::worklet::DestructPointWeightList::InputDomain
_1 InputDomain
Definition: MIR.h:2378
vtkm::worklet::MIRObject
Definition: MIR.h:1758
vtkm::worklet::MIR::InterpolateField::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:968
vtkm::worklet::CalcError_C
Definition: MIR.h:2091
vtkm::worklet::MIR
Definition: MIR.h:698
vtkm::worklet::MIR::InterpolateMIRFields::LenOut
IDLen * LenOut
Definition: MIR.h:1437
vtkm::worklet::MIRObject::getPointLenArr
VTKM_CONT vtkm::cont::ArrayHandle< IDType > getPointLenArr()
Definition: MIR.h:1803
vtkm::worklet::MIR::InCellInterpolationKeys
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationKeys
Definition: MIR.h:1743
vtkm::worklet::MIRObject::MIRObjectPortal::PLens
vtkm::cont::ArrayHandle< IDType, vtkm::cont::StorageTagBasic >::ReadPortalType PLens
Definition: MIR.h:1796
vtkm::cont::ArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::worklet::DestructPointWeightList
Definition: MIR.h:2371
vtkm::cont::Algorithm::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: Algorithm.h:993
vtkm::worklet::DestructPointWeightList::ControlSignature
void(FieldIn pointIDs, FieldIn pointWeights, WholeArrayIn originalVals, FieldOut newVals) ControlSignature
Definition: MIR.h:2376
vtkm::worklet::GenerateCellSet::operator()
VTKM_EXEC void operator()(const CellShapeTag shape, const vtkm::Id workIndex, const vtkm::IdComponent pointcount, const PointVecType points, const ScalarVecType1 &curScalars, const ScalarVecType2 &newScalars, const ScalarPos &valPositionStart, const vtkm::Id &clipDataIndex, const MIRStats mirStats, const worklet::MIRCases::MIRTables::MIRDevicePortal< DeviceAdapter > &MIRData, ConnectivityObject &connectivityObject, IdArrayType &edgePointReverseConnectivity, EdgeInterpolationPortalType &edgePointInterpolation, IdArrayType &inCellReverseConnectivity, IdArrayType &inCellEdgeReverseConnectivity, EdgeInterpolationPortalType &inCellEdgeInterpolation, IdArrayType &inCellInterpolationKeys, IdArrayType &inCellInterpolationInfo, worklet::MIRParentObject::MIRParentPortal &parentObj, CellLookbackArr &cellLookbackArray) const
Definition: MIR.h:460
vtkm::worklet::ConnectivityExplicit::ConnectivityExplicit
VTKM_CONT ConnectivityExplicit()=default
vtkm::worklet::ExtractVFsForMIR::ExtractVFsForMIR
ExtractVFsForMIR(vtkm::Id targetMat)
Definition: MIR.h:2037
vtkm::worklet::ScatterInCellConnectivity::operator()
VTKM_EXEC void operator()(const vtkm::Id destinationIndex, ConnectivityDataType &destinationData) const
Definition: MIR.h:688
vtkm::worklet::MIR::InterpolateField::PerformInCellInterpolations::operator()
VTKM_EXEC void operator()(const MappedValueVecType &toReduce, MappedValueType &centroid) const
Definition: MIR.h:915
vtkm::cont::ArrayHandle< vtkm::UInt8 >
ArrayHandle.h
vtkm::worklet::ExtractVFsForMIR::target
vtkm::Id target
Definition: MIR.h:2043
vtkm::worklet::CombineVFsForPoints_C::ControlSignature
void(CellSetIn cellSet, FieldInCell lens, FieldInCell pos, WholeArrayIn ids, FieldOutPoint idcount) ControlSignature
Definition: MIR.h:1840
vtkm::worklet::MIRStats::NumberOfInCellPoints
vtkm::Id NumberOfInCellPoints
Definition: MIR.h:59
vtkm::worklet::ExtractVFsForMIR_C::InputDomain
_1 InputDomain
Definition: MIR.h:1989
vtkm::worklet::MIR::InterpolateMIRFields::InCellInterpolationKeys
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationKeys
Definition: MIR.h:1433
vtkm::worklet::MIR::InterpolateLookbackField::EdgeInterpolationArray
vtkm::cont::ArrayHandle< EdgeInterpolation > EdgeInterpolationArray
Definition: MIR.h:1669
MIRTables.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm::worklet::MIRObject::getPointIDArr
VTKM_CONT vtkm::cont::ArrayHandle< IDType > getPointIDArr()
Definition: MIR.h:1805
vtkm::worklet::MIRObject::PrepareForExecution
MIRObjectPortal PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: MIR.h:1818
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::CalcVol
Definition: MIR.h:2046
vtkm::worklet::MIR::InterpolateLookbackField::PerformEdgeInterpolations::ControlSignature
void(FieldIn edgeInterpolations, WholeArrayInOut inoutID, WholeArrayInOut inoutWeights) ControlSignature
Definition: MIR.h:1473
vtkm::worklet::MIRObject::getPointVFArr
VTKM_CONT vtkm::cont::ArrayHandle< FloatType > getPointVFArr()
Definition: MIR.h:1806
vtkm::worklet::CheckFor2D
Definition: MIR.h:2307
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations::ControlSignature
void(KeysIn keys, ValuesIn toReduce, WholeArrayIn IDLengths, WholeArrayIn IDOffsets, WholeArrayIn IDs, WholeArrayIn VFs, ReducedValuesIn indexOff, ReducedValuesOut reindexedOut, WholeArrayOut outputIDs, WholeArrayOut outputVFs) ControlSignature
Definition: MIR.h:1248
vtkm::worklet::MIRObject::MIRObjectPortal::PPos
vtkm::cont::ArrayHandle< IDType, vtkm::cont::StorageTagBasic >::ReadPortalType PPos
Definition: MIR.h:1797
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations::offset
vtkm::Id offset
Definition: MIR.h:1232
Types.h
vtkm::worklet::ConnectivityExplicit::Shapes
vtkm::cont::ArrayHandle< vtkm::UInt8 > Shapes
Definition: MIR.h:209
vtkm::worklet::ExecutionConnectivityExplicit
Definition: MIR.h:121
vtkm::worklet::CombineVFsForPoints_C
Definition: MIR.h:1833
vtkm::worklet::MIR::InterpolateLookbackField::PerformEdgeInterpolations
Definition: MIR.h:1463
vtkm::worklet::ComputeStats::ExecutionSignature
void(CellShape, PointCount, _3, _2, _4, _5, _6, _7, _8, _9) ExecutionSignature
Definition: MIR.h:234
vtkm::worklet::MIR::InterpolateMIRFields::VFOut
VFList * VFOut
Definition: MIR.h:1440
vtkm::worklet::CalcError::ExecutionSignature
void(ValueCount, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) ExecutionSignature
Definition: MIR.h:2186
WorkletMapField.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
CellSetExplicit.h
vtkm::worklet::ExecutionConnectivityExplicit::Offsets
IdPortal Offsets
Definition: MIR.h:172
vtkm::worklet::CheckFor2D::ControlSignature
void(CellSetIn, FieldOutCell is2D, FieldOutCell is3D, FieldOutCell isOther) ControlSignature
Definition: MIR.h:2312
vtkm::worklet::CombineVFsForPoints_C::operator()
VTKM_EXEC void operator()(vtkm::IdComponent numCells, const LenVec &len, const PosVec &pos, const IdsVec &ids, OutVec &outlength) const
Definition: MIR.h:1845
vtkm::worklet::MIR::InterpolateLookbackField::Output2
WeightArr * Output2
Definition: MIR.h:1675
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT 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:465
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations::operator()
VTKM_EXEC void operator()(const MappedValueVecType &toReduce, const IDArr &lengths, const IDOff &positions, const IdsVec &ids, const VfsVec &vfs, const IndexIn &localOffset, IndexOut &globalOffset, OutID &outIDs, OutVF &outVFs) const
Definition: MIR.h:1261
vtkm::worklet::WorkletVisitPointsWithCells::FieldInCell
FieldInIncident FieldInCell
Definition: WorkletMapTopology.h:278
vtkm::cont::ArrayHandle::PrepareForInput
VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:574
vtkm::worklet::WorkletVisitCellsWithPoints::PointCount
IncidentElementCount PointCount
Definition: WorkletMapTopology.h:267
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::worklet::WorkletReduceByKey::ValuesIn
A control signature tag for input values.
Definition: WorkletReduceByKey.h:70
vtkm::worklet::EdgeInterpolation
Definition: Clip.h:82
vtkm::worklet::ComputeStats::InputDomain
_1 InputDomain
Definition: MIR.h:235
vtkm::worklet::MIR::InterpolateLookbackField::PerformInCellInterpolations::operator()
VTKM_EXEC void operator()(const IDs &ids, const VecOfVecIDs &keysIn, const VecOfVecWeights &weightsIn, VecId &centroid, VecWeight &weight) const
Definition: MIR.h:1559
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations_C::ExecutionSignature
void(_1, _2, _3, _4, WorkIndex, _5) ExecutionSignature
Definition: MIR.h:1094
vtkm::worklet::ExecutionConnectivityExplicit::SetCellShape
VTKM_EXEC void SetCellShape(vtkm::Id cellIndex, vtkm::UInt8 shape)
Definition: MIR.h:148
vtkm::worklet::GenerateCellSet::target
vtkm::Id target
Definition: MIR.h:642
vtkm::worklet::GenerateCellSet::swap
VTKM_EXEC void swap(T &v1, T &v2) const
Definition: MIR.h:634
vtkm::worklet::GenerateCellSet::ExecutionSignature
void(CellShape, InputIndex, PointCount, PointIndices, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) ExecutionSignature
Definition: MIR.h:448
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations_C::ControlSignature
void(KeysIn keys, ValuesIn toReduce, WholeArrayIn IDLengths, WholeArrayIn IDOffsets, WholeArrayIn IDs, ReducedValuesOut centroid) ControlSignature
Definition: MIR.h:1161
vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal
Definition: MIRTables.h:11210
vtkm::worklet::CombineVFsForPoints
Definition: MIR.h:1896
vtkm::worklet::MIR::EdgePointsInterpolation
vtkm::cont::ArrayHandle< EdgeInterpolation > EdgePointsInterpolation
Definition: MIR.h:1742
vtkm::worklet::ComputeStats::operator()
VTKM_EXEC void operator()(const CellShapeTag shape, const vtkm::IdComponent pointCount, const ScalarFieldVec &prevVals, const ScalarFieldVec1 &newVals, const ScalarPos &valPositionStart, const vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal< DeviceAdapter > &MIRData, const ParentObj &, const PreCol &prevCol, MIRStats &MIRStat, vtkm::Id &MIRDataIndex) const
Definition: MIR.h:244
vtkm::worklet::MIR::InterpolateLookbackField::InCellPointsOffset
vtkm::Id InCellPointsOffset
Definition: MIR.h:1673
vtkm::worklet::MIR::InterpolateMIRFields::operator()
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > &originalLen, const vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > &originalPos, const vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > &originalIDs, const vtkm::cont::ArrayHandle< vtkm::Float64, vtkm::cont::StorageTagBasic > &originalVFs) const
Definition: MIR.h:1330
vtkm::worklet::CombineVFsForPoints::ExecutionSignature
void(CellCount, _2, _3, _4, _5, _6, _7, _8) ExecutionSignature
Definition: MIR.h:1907
vtkm::worklet::ExtractVFsForMIR::ExecutionSignature
void(PointCount, VisitIndex, PointIndices, _2, _3, _4, _5) ExecutionSignature
Definition: MIR.h:2006
vtkm::worklet::ExtractVFsForMIR_C
Definition: MIR.h:1984
vtkm::cont::Algorithm::LowerBounds
static VTKM_CONT void LowerBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Definition: Algorithm.h:604
vtkm::worklet::ScatterEdgeConnectivity::ScatterEdgeConnectivity
VTKM_CONT ScatterEdgeConnectivity(vtkm::Id edgePointOffset)
Definition: MIR.h:648
vtkm::worklet::MIR::InterpolateLookbackField::PerformEdgeInterpolations::PerformEdgeInterpolations
PerformEdgeInterpolations(vtkm::Id edgePointsOffset)
Definition: MIR.h:1466
vtkm::worklet::MIR::InterpolateField::PerformEdgeInterpolations::PerformEdgeInterpolations
PerformEdgeInterpolations(vtkm::Id edgePointsOffset)
Definition: MIR.h:878
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations
Definition: MIR.h:998
vtkm::worklet::ComputeStats::ComputeStats
VTKM_CONT ComputeStats(vtkm::Id target)
Definition: MIR.h:220
Keys.h
vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal::GetCaseIndex
VTKM_EXEC vtkm::Id GetCaseIndex(vtkm::Id shape, vtkm::Id caseId, vtkm::IdComponent numPoints) const
Definition: MIRTables.h:11237
vtkm::worklet::ExecutionConnectivityExplicit::Shapes
UInt8Portal Shapes
Definition: MIR.h:169
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations::PerformEdgeInterpolations
PerformEdgeInterpolations(vtkm::Id edgePointsOffset)
Definition: MIR.h:1001
vtkm::worklet::CheckFor2D::InputDomain
_1 InputDomain
Definition: MIR.h:2314
vtkm::worklet::MIRParentObject
Definition: MIR.h:347
vtkm::worklet::MIR::InterpolateField
Definition: MIR.h:854
vtkm::cont::Algorithm::CopySubRange
static VTKM_CONT bool CopySubRange(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::Id inputStartIndex, vtkm::Id numberOfElementsToCopy, vtkm::cont::ArrayHandle< U, COut > &output, vtkm::Id outputIndex=0)
Definition: Algorithm.h:472
vtkm::worklet::ExtractVFsForMIR::operator()
VTKM_EXEC void operator()(vtkm::IdComponent numPoints, vtkm::IdComponent index, pointVec &pointIDs, const DA &mirobj, const prevID &previousID, OutVec &outVF, OutVec2 &prevOutVF) const
Definition: MIR.h:2016
vtkm::worklet::DestructPointWeightList::ExecutionSignature
void(_1, _2, _3, _4) ExecutionSignature
Definition: MIR.h:2377
vtkm::worklet::CombineVFsForPoints_C::InputDomain
_1 InputDomain
Definition: MIR.h:1842
vtkm::worklet::MIR::InterpolateLookbackField::InCellInterpolationKeys
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationKeys
Definition: MIR.h:1670
vtkm::worklet::MIRParentObject::MIRParentPortal::CellColors
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType CellColors
Definition: MIR.h:378
vtkm::worklet::MIR::InterpolateField::PerformInCellInterpolations
Definition: MIR.h:907
vtkm::worklet::WorkletReduceByKey::ValueCount
The ExecutionSignature tag to get the number of values.
Definition: WorkletReduceByKey.h:164
vtkm::worklet::MIR::InterpolateField::EdgeInterpolationArray
vtkm::cont::ArrayHandle< EdgeInterpolation > EdgeInterpolationArray
Definition: MIR.h:965
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations_C::ControlSignature
void(FieldIn edgeInterpolations, WholeArrayInOut IDLengths, WholeArrayIn IDOffsets, WholeArrayIn IDs, FieldOut edgeLength) ControlSignature
Definition: MIR.h:1093
vtkm::worklet::ScatterInCellConnectivity::ScatterInCellConnectivity
VTKM_CONT ScatterInCellConnectivity(vtkm::Id inCellPointOffset)
Definition: MIR.h:676
vtkm::Maximum
Binary Predicate that takes two arguments argument x, and y and returns the x if x > y otherwise retu...
Definition: BinaryOperators.h:85
vtkm::worklet::ExtractVFsForMIR::ControlSignature
void(CellSetIn cellSet, ExecObject mir_obj, FieldInCell previousMatID, FieldOutCell curvfVals, FieldOutCell prevvfVals) ControlSignature
Definition: MIR.h:2004
vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal::ValueAt
VTKM_EXEC vtkm::UInt8 ValueAt(vtkm::Id idx) const
Definition: MIRTables.h:11294
vtkm::worklet::ExecutionConnectivityExplicit::SetConnectivity
VTKM_EXEC void SetConnectivity(vtkm::Id connectivityIndex, vtkm::Id pointIndex)
Definition: MIR.h:163
vtkm::worklet::ScatterEdgeConnectivity::EdgePointOffset
vtkm::Id EdgePointOffset
Definition: MIR.h:670
vtkm::CellShapeIdToTag
A traits-like class to get an CellShapeId known at compile time to a tag.
Definition: CellShape.h:89
vtkm::worklet::cellmetrics::FloatType
vtkm::FloatDefault FloatType
Definition: CellAspectFrobeniusMetric.h:50
vtkm::worklet::CalcError_C::ControlSignature
void(KeysIn cellID, ValuesIn cellColors, WholeArrayIn origLen, WholeArrayIn origPos, WholeArrayIn origIDs, WholeArrayOut newlengthsOut) ControlSignature
Definition: MIR.h:2099
vtkm::cont::Algorithm::Copy
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
vtkm::worklet::ExtractVFsForMIR_C::ExecutionSignature
void(PointCount, _2) ExecutionSignature
Definition: MIR.h:1988
vtkm::worklet::CalcError
Definition: MIR.h:2158
vtkm::worklet::MIRParentObject::MIRParentPortal::NewCellColors
vtkm::cont::ArrayHandle< vtkm::Id >::WritePortalType NewCellColors
Definition: MIR.h:379
vtkm::worklet::WorkletReduceByKey::ReducedValuesOut
A control signature tag for reduced output values.
Definition: WorkletReduceByKey.h:150
vtkm::worklet::ScatterInCellConnectivity::ControlSignature
void(FieldIn destinationIndices, WholeArrayOut destinationData) ControlSignature
Definition: MIR.h:681
vtkm::worklet::MIR::InCellInterpolationInfo
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationInfo
Definition: MIR.h:1744
ErrorFilterExecution.h
CellShape.h
vtkm::worklet::ScatterEdgeConnectivity
Definition: MIR.h:644
vtkm::worklet::MIR::InterpolateLookbackField::PerformEdgeInterpolations::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:1539
vtkm::worklet::MIR::InterpolateField::PerformEdgeInterpolations::operator()
VTKM_EXEC void operator()(const EdgeInterp &ei, OutputFieldPortal &field, const vtkm::Id workIndex) const
Definition: MIR.h:888
ArrayHandleView.h
CoordinateSystem.h
vtkm::worklet::MIRStats::NumberOfCells
vtkm::Id NumberOfCells
Definition: MIR.h:54
vtkm::worklet::WorkletVisitCellsWithPoints::PointIndices
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::worklet::MIRParentObject::cellLookback
vtkm::cont::ArrayHandle< vtkm::Id > cellLookback
Definition: MIR.h:399
vtkm::cont::ArrayHandle::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
vtkm::worklet::MIR::InterpolateField::InCellInterpolationKeys
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationKeys
Definition: MIR.h:966
vtkm::worklet::ScatterEdgeConnectivity::ControlSignature
void(FieldIn sourceValue, FieldIn destinationIndices, WholeArrayOut destinationData) ControlSignature
Definition: MIR.h:655
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::MIR::InterpolateField::InCellPointsOffset
vtkm::Id InCellPointsOffset
Definition: MIR.h:969
vtkm::worklet::MIR::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:1746
ArrayCopy.h
vtkm::worklet::EdgeInterpolation::Vertex2
vtkm::Id Vertex2
Definition: Clip.h:85
vtkm::worklet::CombineVFsForPoints::InputDomain
_1 InputDomain
Definition: MIR.h:1908
vtkm::worklet::MIR::InterpolateLookbackField::InterpolateLookbackField
InterpolateLookbackField(vtkm::cont::ArrayHandle< EdgeInterpolation > edgeInterpolationArray, vtkm::cont::ArrayHandle< vtkm::Id > inCellInterpolationKeys, vtkm::cont::ArrayHandle< vtkm::Id > inCellInterpolationInfo, vtkm::Id edgePointsOffset, vtkm::Id inCellPointsOffset, LookbackArr *output, WeightArr *output2)
Definition: MIR.h:1447
DispatcherMapField.h
vtkm::worklet::CalcError::ControlSignature
void(KeysIn cellID, ValuesIn cellColors, ValuesIn cellVols, WholeArrayIn origLen, WholeArrayIn origPos, WholeArrayIn origIDs, WholeArrayIn origVFs, WholeArrayIn curLen, WholeArrayIn curPos, WholeArrayIn curID, WholeArrayIn curVF, WholeArrayIn newLength, WholeArrayIn newposition, WholeArrayOut newIDs, WholeArrayOut newVFs, WholeArrayIn origVols, ReducedValuesOut totalErr) ControlSignature
Definition: MIR.h:2184
vtkm::worklet::ExecutionConnectivityExplicit::SetIndexOffset
VTKM_EXEC void SetIndexOffset(vtkm::Id cellIndex, vtkm::Id indexOffset)
Definition: MIR.h:157
vtkm::worklet::MIRParentObject::newCellLookback
vtkm::cont::ArrayHandle< vtkm::Id > newCellLookback
Definition: MIR.h:395
ScatterCounting.h
vtkm::cont::ExecutionAndControlObjectBase
Base ExecutionAndControlObjectBase class.
Definition: ExecutionAndControlObjectBase.h:28
vtkm::worklet::MIR::InterpolateLookbackField::Output
LookbackArr * Output
Definition: MIR.h:1674
vtkm::worklet::MIRStats::SumOp
Definition: MIR.h:64
vtkm::worklet::MIRStats::NumberOfEdgeIndices
vtkm::Id NumberOfEdgeIndices
Definition: MIR.h:56
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations::ControlSignature
void(FieldIn edgeInterpolations, WholeArrayIn lengths, WholeArrayIn positions, WholeArrayInOut ids, WholeArrayInOut vfs) ControlSignature
Definition: MIR.h:1010
vtkm::worklet::ScatterEdgeConnectivity::operator()
VTKM_EXEC void operator()(const vtkm::Id sourceValue, const vtkm::Id destinationIndex, ConnectivityDataType &destinationData) const
Definition: MIR.h:662
VectorAnalysis.h
vtkm::worklet::ExecutionConnectivityExplicit::UInt8Portal
typename vtkm::cont::ArrayHandle< vtkm::UInt8 >::WritePortalType UInt8Portal
Definition: MIR.h:124
vtkm::worklet::ScatterInCellConnectivity
Definition: MIR.h:672
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::ExtractVFsForMIR::ScatterType
vtkm::worklet::ScatterCounting ScatterType
Definition: MIR.h:2008
vtkm::worklet::CheckFor2D::ExecutionSignature
void(CellShape, _2, _3, _4) ExecutionSignature
Definition: MIR.h:2313
vtkm::worklet::MIRParentObject::MIRParentPortal::SetNewCellColor
VTKM_EXEC void SetNewCellColor(vtkm::Id index, vtkm::Id col)
Definition: MIR.h:369
vtkm::worklet::ScatterCounting
A scatter that maps input to some numbers of output.
Definition: ScatterCounting.h:44
vtkm::worklet::MIRObject::MIRObjectPortal::PVFs
vtkm::cont::ArrayHandle< FloatType, vtkm::cont::StorageTagBasic >::ReadPortalType PVFs
Definition: MIR.h:1799
vtkm::worklet::CalcError_C::operator()
VTKM_EXEC void operator()(const vtkm::IdComponent numCells, const vtkm::Id cellID, const Colors &cellCol, const ORL &orgLen, const ORP &orgPos, const ORID &orgID, NLO &outputLen) const
Definition: MIR.h:2103
vtkm::worklet::MIR::InterpolateField::PerformInCellInterpolations::ControlSignature
void(KeysIn keys, ValuesIn toReduce, ReducedValuesOut centroid) ControlSignature
Definition: MIR.h:910
vtkm::worklet::MIRObject::MIRObjectPortal
Definition: MIR.h:1761
vtkm::worklet::EdgeInterpolation::EqualToOp::operator()
VTKM_EXEC bool operator()(const EdgeInterpolation &v1, const EdgeInterpolation &v2) const
Definition: MIR.h:99
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations_C::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:1082
vtkm::cont::Algorithm::Unique
static VTKM_CONT void Unique(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:1063
vtkm::worklet::WorkletVisitPointsWithCells::CellCount
IncidentElementCount CellCount
Definition: WorkletMapTopology.h:286
vtkm::worklet::MIR::InterpolateField::PerformEdgeInterpolations::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:904
vtkm::worklet::ComputeStats::targ
vtkm::Id targ
Definition: MIR.h:219
vtkm::worklet::ExtractVFsForMIR_C::operator()
VTKM_EXEC void operator()(vtkm::IdComponent numPoints, OutVec &outlength) const
Definition: MIR.h:1991
vtkm::worklet::MIRParentObject::MIRParentPortal::GetParentCellIndex
VTKM_EXEC vtkm::Id GetParentCellIndex(vtkm::Id index)
Definition: MIR.h:373
vtkm::worklet::DispatcherMapField
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
WorkletReduceByKey.h
vtkm::worklet::CombineVFsForPoints::ControlSignature
void(CellSetIn cellSet, FieldInCell lens, FieldInCell pos, WholeArrayIn ids, WholeArrayIn vfs, FieldInPoint actpos, WholeArrayOut idx, WholeArrayOut vfx) ControlSignature
Definition: MIR.h:1906
vtkm::worklet::WorkletVisitPointsWithCells
Base class for worklets that map from Cells to Points.
Definition: WorkletMapTopology.h:274
ArrayHandlePermutation.h
vtkm::worklet::ExtractVFsForMIR::MakeScatter
static VTKM_CONT ScatterType MakeScatter(const CountArrayType &countArray)
Definition: MIR.h:2010
Timer.h
Algorithm.h
vtkm::worklet::ExtractVFsForMIR::InputDomain
_1 InputDomain
Definition: MIR.h:2007
vtkm::worklet::MIRParentObject::cellColors
vtkm::cont::ArrayHandle< vtkm::Id > cellColors
Definition: MIR.h:400
vtkm::worklet::DestructPointWeightList::operator()
VTKM_EXEC void operator()(const PID &pids, const PW &pws, const OV &ov, NV &newVals) const
Definition: MIR.h:2380
vtkm::worklet::MIR::InterpolateMIRFields
Definition: MIR.h:974
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations::PerformInCellInterpolations
PerformInCellInterpolations(vtkm::Id outputOffsetForBookkeeping)
Definition: MIR.h:1235
vtkm::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::worklet::MIRStats::NumberOfIndices
vtkm::Id NumberOfIndices
Definition: MIR.h:55
vtkm::worklet::ConstructCellWeightList::ControlSignature
void(FieldIn pointIDs, FieldOut VecLookback, FieldOut VecWeights) ControlSignature
Definition: MIR.h:2355
vtkm::worklet::ExecutionConnectivityExplicit::NumberOfIndices
IdComponentPortal NumberOfIndices
Definition: MIR.h:170
VTKM_IS_ARRAY_HANDLE
#define VTKM_IS_ARRAY_HANDLE(T)
Definition: ArrayHandle.h:132
vtkm::worklet::WorkletReduceByKey
Definition: WorkletReduceByKey.h:42
FunctorBase.h
vtkm::worklet::ExtractVFsForMIR
Definition: MIR.h:1997
vtkm::cont::Algorithm::ScanExclusive
static VTKM_CONT T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:816
vtkm::worklet::ConstructCellWeightList
Definition: MIR.h:2353
vtkm::cont::ArrayHandlePermutation
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:227
vtkm::worklet::MIRParentObject::newCellColors
vtkm::cont::ArrayHandle< vtkm::Id > newCellColors
Definition: MIR.h:394
vtkm::worklet::MIR::MIR
MIR()
Definition: MIR.h:701
vtkm::worklet::EdgeInterpolation::EqualToOp
Definition: Clip.h:97
vtkm::worklet::MIRObject::MIRObject
MIRObject(const IDInput &len, const IDInput &pos, const IDInput &ids, const FloatInput &floats)
Definition: MIR.h:1810
vtkm::Cross
VTKM_EXEC_CONT vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > Cross(const vtkm::Vec< T, 3 > &x, const vtkm::Vec< T, 3 > &y)
Find the cross product of two vectors.
Definition: VectorAnalysis.h:177
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations::ExecutionSignature
void(_1, _2, _3, _4, _5, WorkIndex) ExecutionSignature
Definition: MIR.h:1012
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
vtkm::worklet::MIRParentObject::MIRParentPortal::SetNewCellLookback
VTKM_EXEC void SetNewCellLookback(vtkm::Id index, vtkm::Id originalIndex)
Definition: MIR.h:365
vtkm::worklet::MIR::InterpolateLookbackField::PerformEdgeInterpolations::operator()
VTKM_EXEC void operator()(const EdgeInterp &ei, InOutId &field, InOutWeight &field1, const vtkm::Id workIndex) const
Definition: MIR.h:1478
vtkm::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::worklet::contourtree_augmented::IdArrayType
vtkm::cont::ArrayHandle< vtkm::Id > IdArrayType
Definition: filter/scalar_topology/worklet/contourtree_augmented/Types.h:90
vtkm::worklet::MIR::ProcessPointField
vtkm::cont::ArrayHandle< ValueType > ProcessPointField(const vtkm::cont::ArrayHandle< ValueType, StorageType > &fieldData) const
Definition: MIR.h:1724
vtkm::worklet::MIR::InterpolateLookbackField::PerformEdgeInterpolations::ExecutionSignature
void(_1, _2, _3, WorkIndex) ExecutionSignature
Definition: MIR.h:1475
vtkm::worklet::ConnectivityExplicit::Offsets
vtkm::cont::ArrayHandle< vtkm::Id > Offsets
Definition: MIR.h:212
vtkm::worklet::ExecutionConnectivityExplicit::IdComponentPortal
typename vtkm::cont::ArrayHandle< vtkm::IdComponent >::WritePortalType IdComponentPortal
Definition: MIR.h:125
vtkm::worklet::CombineVFsForPoints_C::ExecutionSignature
void(CellCount, _2, _3, _4, _5) ExecutionSignature
Definition: MIR.h:1841
vtkm::worklet::MIR::InterpolateField::PerformEdgeInterpolations
Definition: MIR.h:875
vtkm::worklet::MIRObject::pointPos
vtkm::cont::ArrayHandle< IDType > pointPos
Definition: MIR.h:1829
vtkm::worklet::MIR::InterpolateLookbackField
Definition: MIR.h:1444
vtkm::worklet::GenerateCellSet::GenerateCellSet
VTKM_EXEC_CONT GenerateCellSet(vtkm::Id tar)
Definition: MIR.h:406
vtkm::worklet::MIR::InterpolateLookbackField::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:1672
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInPoint
FieldInIncident FieldInPoint
Definition: WorkletMapTopology.h:259
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::ConnectivityExplicit::NumberOfIndices
vtkm::cont::ArrayHandle< vtkm::IdComponent > NumberOfIndices
Definition: MIR.h:210
vtkm::worklet::WorkletReduceByKey::KeysIn
A control signature tag for input keys.
Definition: WorkletReduceByKey.h:56
vtkm::worklet::MIR::Run
vtkm::cont::CellSetExplicit Run(const CellSet &cellSet, const VFList1 &prevValues, const VFList2 &curValues, const VFLocs &offsets, const IDList &prevIDs, const vtkm::Id &newID, const IDList &prevLookback, IDList &newIDs, IDList &newLookback)
Definition: MIR.h:712
vtkm::worklet::MIR::InterpolateField::InterpolateField
InterpolateField(vtkm::cont::ArrayHandle< EdgeInterpolation > edgeInterpolationArray, vtkm::cont::ArrayHandle< vtkm::Id > inCellInterpolationKeys, vtkm::cont::ArrayHandle< vtkm::Id > inCellInterpolationInfo, vtkm::Id edgePointsOffset, vtkm::Id inCellPointsOffset, ArrayHandleType *output)
Definition: MIR.h:860
vtkm::worklet::ConstructCellWeightList::InputDomain
_1 InputDomain
Definition: MIR.h:2357
vtkm::cont::CellSetExplicit::Fill
VTKM_CONT 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)
Second method to add cells – all at once.
vtkm::cont::ArrayHandle::WritePortalType
typename StorageType::WritePortalType WritePortalType
Definition: ArrayHandle.h:295
vtkm::worklet::ExecutionConnectivityExplicit::IdPortal
typename vtkm::cont::ArrayHandle< vtkm::Id >::WritePortalType IdPortal
Definition: MIR.h:126
vtkm::worklet::Keys::GetUniqueKeys
VTKM_CONT KeyArrayHandleType GetUniqueKeys() const
Definition: Keys.h:175
vtkm::worklet::MIR::InterpolateField::operator()
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle< ValueType, Storage > &field) const
Definition: MIR.h:930
vtkm::worklet::MIRObject::getPointPosArr
VTKM_CONT vtkm::cont::ArrayHandle< IDType > getPointPosArr()
Definition: MIR.h:1804
vtkm::worklet::MIR::InterpolateMIRFields::EdgeInterpolationArray
vtkm::cont::ArrayHandle< EdgeInterpolation > EdgeInterpolationArray
Definition: MIR.h:1432
vtkm::worklet::MIR::InterpolateField::PerformInCellInterpolations::ExecutionSignature
void(_2, _3) ExecutionSignature
Definition: MIR.h:912
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::worklet::CheckFor2D::operator()
VTKM_EXEC void operator()(const SHAPE shape, OO &is2D, OP &is3D, OQ &isOther) const
Definition: MIR.h:2316
vtkm::worklet::MIRParentObject::MIRParentPortal::CellLookback
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType CellLookback
Definition: MIR.h:377
vtkm::worklet::MIR::InterpolateField::Output
ArrayHandleType * Output
Definition: MIR.h:970
vtkm::worklet::GenerateCellSet::ControlSignature
void(CellSetIn, WholeArrayIn prevVals, WholeArrayIn newVals, FieldInCell vf_pos, FieldInCell mirTableIndices, FieldInCell mirStats, ExecObject mirTables, ExecObject connectivityObject, WholeArrayOut edgePointReverseConnectivity, WholeArrayOut edgePointInterpolation, WholeArrayOut inCellReverseConnectivity, WholeArrayOut inCellEdgeReverseConnectivity, WholeArrayOut inCellEdgeInterpolation, WholeArrayOut inCellInterpolationKeys, WholeArrayOut inCellInterpolationInfo, ExecObject cellLookbackObj, WholeArrayOut simpleLookback) ControlSignature
Definition: MIR.h:427
vtkm::worklet::MIRParentObject::MIRParentObject
VTKM_CONT MIRParentObject()=default
vtkm::worklet::ComputeStats::ComputeStats
VTKM_CONT ComputeStats()=default
vtkm::worklet::MIR::InterpolateLookbackField::InCellInterpolationInfo
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationInfo
Definition: MIR.h:1671
vtkm::worklet::MIRParentObject::MIRParentObject
VTKM_CONT MIRParentObject(vtkm::Id numCells, vtkm::cont::ArrayHandle< vtkm::Id > celllook, vtkm::cont::ArrayHandle< vtkm::Id > cellCol, vtkm::cont::ArrayHandle< vtkm::Id > newCellCol, vtkm::cont::ArrayHandle< vtkm::Id > newcellLook)
Definition: MIR.h:351
CellSetPermutation.h
DispatcherReduceByKey.h
vtkm::worklet::ExecutionConnectivityExplicit::ExecutionConnectivityExplicit
VTKM_CONT ExecutionConnectivityExplicit()=default
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations::operator()
VTKM_EXEC void operator()(const EdgeInterp &ei, const IDL &lengths, const IDO &positions, IdsVec &ids, VfsVec &vfs, const vtkm::Id workIndex) const
Definition: MIR.h:1015
vtkm::worklet::ConstructCellWeightList::operator()
VTKM_EXEC void operator()(vtkm::Id &in, VO1 &lookback, VO2 &weights) const
Definition: MIR.h:2359
vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal::GetNumberOfShapes
VTKM_EXEC vtkm::Id GetNumberOfShapes(vtkm::Id shape, vtkm::Id caseId, vtkm::IdComponent numPoints) const
Definition: MIRTables.h:11296
vtkm::worklet::MIRParentObject::MIRParentPortal
Definition: MIR.h:362
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations_C::operator()
VTKM_EXEC void operator()(const MappedValueVecType &toReduce, const IDArr &lengths, const IDOff &positions, const IdsVec &ids, MappedValueType &numIdNeeded) const
Definition: MIR.h:1170
vtkm::worklet::MIRStats::NumberOfInCellInterpPoints
vtkm::Id NumberOfInCellInterpPoints
Definition: MIR.h:61
vtkm::worklet::MIRObject::pointLen
vtkm::cont::ArrayHandle< IDType > pointLen
Definition: MIR.h:1829
vtkm::worklet::ScatterInCellConnectivity::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: MIR.h:683
vtkm::worklet::WorkletVisitPointsWithCells::FieldInPoint
FieldInVisit FieldInPoint
Definition: WorkletMapTopology.h:280
vtkm::cont::make_ArrayHandlePermutation
VTKM_CONT vtkm::cont::ArrayHandlePermutation< IndexArrayHandleType, ValueArrayHandleType > make_ArrayHandlePermutation(IndexArrayHandleType indexArray, ValueArrayHandleType valueArray)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandlePermutation.h:279
vtkm::worklet::ExecutionConnectivityExplicit::Connectivity
IdPortal Connectivity
Definition: MIR.h:171
vtkm::cont::ExecutionObjectBase
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::worklet::MIR::InterpolateMIRFields::InCellInterpolationInfo
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationInfo
Definition: MIR.h:1434
vtkm::cont::CellSetExplicit::GetNumberOfPoints
VTKM_CONT vtkm::Id GetNumberOfPoints() const override
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::cont::ConvertNumComponentsToOffsets
VTKM_CONT_EXPORT void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle &numComponentsArray, vtkm::cont::ArrayHandle< vtkm::Id > &offsetsArray, vtkm::Id &componentsArraySize, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
vtkm::worklet::MIR::InterpolateLookbackField::operator()
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle< ValueType, Storage > &fieldID, const vtkm::cont::ArrayHandle< ValueType1, Storage2 > &weightsField) const
Definition: MIR.h:1627
vtkm::worklet::ConnectivityExplicit::ConnectivityExplicit
VTKM_CONT ConnectivityExplicit(const vtkm::cont::ArrayHandle< vtkm::UInt8 > &shapes, const vtkm::cont::ArrayHandle< vtkm::IdComponent > &numberOfIndices, const vtkm::cont::ArrayHandle< vtkm::Id > &connectivity, const vtkm::cont::ArrayHandle< vtkm::Id > &offsets, const MIRStats &stats)
Definition: MIR.h:182
vtkm::worklet::MIR::InterpolateMIRFields::IDOut
IDList * IDOut
Definition: MIR.h:1439
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::worklet::ExtractVFsForMIR_C::ControlSignature
void(CellSetIn cellSet, FieldOutCell numPointsCount) ControlSignature
Definition: MIR.h:1987
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations_C::ExecutionSignature
void(_2, _3, _4, _5, _6) ExecutionSignature
Definition: MIR.h:1163
vtkm::worklet::ConstructCellWeightList::ExecutionSignature
void(InputIndex, _2, _3) ExecutionSignature
Definition: MIR.h:2356
vtkm::worklet::ConnectivityExplicit::Stats
vtkm::worklet::MIRStats Stats
Definition: MIR.h:213
vtkm::worklet::MIRStats
Definition: MIR.h:52
vtkm::worklet::MIR::InterpolateLookbackField::PerformInCellInterpolations
Definition: MIR.h:1542
vtkm::worklet::MIR::InterpolateField::InCellInterpolationInfo
vtkm::cont::ArrayHandle< vtkm::Id > InCellInterpolationInfo
Definition: MIR.h:967
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations
Definition: MIR.h:1229
ConvertNumComponentsToOffsets.h
vtkm::worklet::DispatcherReduceByKey
Dispatcher for worklets that inherit from WorkletReduceByKey.
Definition: DispatcherReduceByKey.h:27
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:1077
vtkm::worklet::MIR::InterpolateField::PerformEdgeInterpolations::ControlSignature
void(FieldIn edgeInterpolations, WholeArrayInOut outputField) ControlSignature
Definition: MIR.h:883
vtkm::cont::Algorithm::Reduce
static VTKM_CONT U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:656
vtkm::worklet::WorkletVisitPointsWithCells::FieldOutPoint
FieldOut FieldOutPoint
Definition: WorkletMapTopology.h:282
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations::ExecutionSignature
void(_2, _3, _4, _5, _6, _7, _8, _9, _10) ExecutionSignature
Definition: MIR.h:1250
vtkm::worklet::MIRinternal::Scale
VTKM_EXEC_CONT T Scale(const T &val, vtkm::Float64 scale)
Definition: MIR.h:108
vtkm::cont::ArrayHandle::PrepareForOutput
VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:613
vtkm::worklet::MIR::InterpolateMIRFields::PosOut
IDPos * PosOut
Definition: MIR.h:1438
vtkm::worklet::MIRObject::pointVFs
vtkm::cont::ArrayHandle< FloatType > pointVFs
Definition: MIR.h:1830
vtkm::worklet::CalcError::operator()
VTKM_EXEC void operator()(const vtkm::IdComponent numCells, const vtkm::Id cellID, const Colors &cellCol, const Vols &cellVolumes, const ORL &orgLen, const ORP &orgPos, const ORID &orgID, const ORVF &orgVF, const CLen &curLen, const CPos &curPos, const CID &curID, const CVF &curVF, const NLen &, const NLO &inputPos, NID &inputIDs, NVF &inputVFs, const OVols &orgVols, TEO &totalErrorOut) const
Definition: MIR.h:2204
vtkm::cont::CellSetExplicit
Definition: CastAndCall.h:36
vtkm::worklet::MIRObject::MIRObjectPortal::GetVFForPoint
VTKM_EXEC FloatType GetVFForPoint(IDType point, IDType matID, IDType) const
Definition: MIR.h:1764
vtkm::worklet::ScatterInCellConnectivity::InputDomain
_1 InputDomain
Definition: MIR.h:685
vtkm::worklet::Keys< vtkm::Id >
vtkm::worklet::MIR::ProcessSimpleMIRField
void ProcessSimpleMIRField(const vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::Id, 8 >, vtkm::cont::StorageTagBasic > &orLookback, const vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::Float64, 8 >, vtkm::cont::StorageTagBasic > &orWeights, vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::Id, 8 >, vtkm::cont::StorageTagBasic > &newLookback, vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::Float64, 8 >, vtkm::cont::StorageTagBasic > &newweights) const
Definition: MIR.h:1677
vtkm::worklet::CalcVol::ControlSignature
void(CellSetIn cellSet, ExecObject mirTables, FieldInPoint verts, FieldOutCell vol) ControlSignature
Definition: MIR.h:2052
vtkm::worklet::EdgeInterpolation::Vertex1
vtkm::Id Vertex1
Definition: Clip.h:84
vtkm::List
Definition: List.h:34
vtkm::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:45
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::worklet::MIRStats::NumberOfInCellEdgeIndices
vtkm::Id NumberOfInCellEdgeIndices
Definition: MIR.h:62
vtkm::worklet::CalcError_C::InputDomain
_1 InputDomain
Definition: MIR.h:2101
vtkm::worklet::ScatterEdgeConnectivity::InputDomain
_1 InputDomain
Definition: MIR.h:659
vtkm::worklet::ComputeStats::ControlSignature
void(CellSetIn, WholeArrayIn curVals, WholeArrayIn prevVals, FieldInCell offsets, ExecObject mirTables, FieldInCell parentObj, FieldInCell prevCol, FieldOutCell stats, FieldOutCell caseID) ControlSignature
Definition: MIR.h:233
vtkm::worklet::MIRParentObject::MIRParentPortal::NewCellLookback
vtkm::cont::ArrayHandle< vtkm::Id >::WritePortalType NewCellLookback
Definition: MIR.h:380
vtkm::worklet::MIRStats::SumOp::operator()
VTKM_EXEC_CONT MIRStats operator()(const MIRStats &stat1, const MIRStats &stat2) const
Definition: MIR.h:67
vtkm::worklet::ExecutionConnectivityExplicit::ExecutionConnectivityExplicit
VTKM_CONT ExecutionConnectivityExplicit(vtkm::cont::ArrayHandle< vtkm::UInt8 > shapes, vtkm::cont::ArrayHandle< vtkm::IdComponent > numberOfIndices, vtkm::cont::ArrayHandle< vtkm::Id > connectivity, vtkm::cont::ArrayHandle< vtkm::Id > offsets, MIRStats stats, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: MIR.h:133
vtkm::worklet::ConnectivityExplicit::Connectivity
vtkm::cont::ArrayHandle< vtkm::Id > Connectivity
Definition: MIR.h:211
vtkm::worklet::CalcError::CalcError
CalcError(vtkm::Float64 errorLerp)
Definition: MIR.h:2164
vtkm::worklet::MIR::InCellPointsOffset
vtkm::Id InCellPointsOffset
Definition: MIR.h:1747
vtkm::worklet::MIR::InterpolateLookbackField::PerformInCellInterpolations::ControlSignature
void(KeysIn keys, ValuesIn toReduceID, WholeArrayIn Keys, WholeArrayIn weights, ReducedValuesOut id, ReducedValuesOut weight) ControlSignature
Definition: MIR.h:1550
vtkm::worklet::ScatterInCellConnectivity::InCellPointOffset
vtkm::Id InCellPointOffset
Definition: MIR.h:696
vtkm::worklet::MIR::CellMapOutputToInput
vtkm::cont::ArrayHandle< vtkm::Id > CellMapOutputToInput
Definition: MIR.h:1745
vtkm::worklet::ExecutionConnectivityExplicit::SetNumberOfIndices
VTKM_EXEC void SetNumberOfIndices(vtkm::Id cellIndex, vtkm::IdComponent numIndices)
Definition: MIR.h:151
vtkm::worklet::CalcVol::ExecutionSignature
void(PointCount, CellShape, _2, _3, _4) ExecutionSignature
Definition: MIR.h:2053
vtkm::worklet::MIR::InterpolateField::PerformEdgeInterpolations::ExecutionSignature
void(_1, _2, WorkIndex) ExecutionSignature
Definition: MIR.h:885
vtkm::worklet::MIRObject::pointIDs
vtkm::cont::ArrayHandle< IDType > pointIDs
Definition: MIR.h:1829
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations_C
Definition: MIR.h:1079
vtkm::worklet::MIR::InterpolateMIRFields::InterpolateMIRFields
InterpolateMIRFields(vtkm::cont::ArrayHandle< EdgeInterpolation > edgeInterpolationArray, vtkm::cont::ArrayHandle< vtkm::Id > inCellInterpolationKeys, vtkm::cont::ArrayHandle< vtkm::Id > inCellInterpolationInfo, vtkm::Id edgePointsOffset, vtkm::Id inCellPointsOffset, IDLen *output1, IDPos *output2, IDList *output3, VFList *output4)
Definition: MIR.h:977
vtkm::exec::arg::VisitIndex
The ExecutionSignature tag to use to get the visit index.
Definition: VisitIndex.h:43
vtkm::worklet::MIR::MIRTablesInstance
MIRCases::MIRTables MIRTablesInstance
Definition: MIR.h:1741
vtkm::worklet::MIRObject::MIRObjectPortal::PIDs
vtkm::cont::ArrayHandle< IDType, vtkm::cont::StorageTagBasic >::ReadPortalType PIDs
Definition: MIR.h:1798
DispatcherMapTopology.h
WorkletMapTopology.h
vtkm::worklet::MIRParentObject::numberOfInd
vtkm::Id numberOfInd
Definition: MIR.h:398
vtkm::worklet::MIR::InterpolateLookbackField::PerformInCellInterpolations::ExecutionSignature
void(_2, _3, _4, _5, _6) ExecutionSignature
Definition: MIR.h:1552
vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal::GetEdge
VTKM_EXEC EdgeVec GetEdge(vtkm::Id shape, vtkm::Id edgeId, vtkm::IdComponent numPoints) const
Definition: MIRTables.h:11353
vtkm::worklet::EdgeInterpolation::Weight
vtkm::Float64 Weight
Definition: Clip.h:86
vtkm::worklet::MIR::InterpolateMIRFields::PerformInCellInterpolations_C
Definition: MIR.h:1153
vtkm::worklet::ConnectivityExplicit::PrepareForExecution
VTKM_CONT ExecutionConnectivityExplicit PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Definition: MIR.h:195
vtkm::worklet::MIR::InterpolateField::ValueType
typename ArrayHandleType::ValueType ValueType
Definition: MIR.h:857
ClipTables.h
vtkm::worklet::MIRStats::NumberOfInCellIndices
vtkm::Id NumberOfInCellIndices
Definition: MIR.h:60
vtkm::worklet::MIRParentObject::MIRParentPortal::GetParentCellColor
VTKM_EXEC vtkm::Id GetParentCellColor(vtkm::Id index)
Definition: MIR.h:374
vtkm::worklet::CalcError::InputDomain
_1 InputDomain
Definition: MIR.h:2187
ExecutionObjectBase.h
vtkm::exec::arg::InputIndex
The ExecutionSignature tag to use to get the input index.
Definition: InputIndex.h:42
vtkm::worklet::CalcVol::operator()
VTKM_EXEC void operator()(const vtkm::IdComponent pointCount, const CellShape &cellShape, const Dev &mirTable, const PointListIn &vertPos, Arrout &volumeOut) const
Definition: MIR.h:2055
vtkm::cont::ArrayHandle::ReleaseResources
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
vtkm::worklet::MIR::ProcessMIRField
void ProcessMIRField(const vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > orLen, const vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > orPos, const vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > orIDs, const vtkm::cont::ArrayHandle< vtkm::Float64, vtkm::cont::StorageTagBasic > orVFs, vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > &newLen, vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > &newPos, vtkm::cont::ArrayHandle< vtkm::Id, vtkm::cont::StorageTagBasic > &newIDs, vtkm::cont::ArrayHandle< vtkm::Float64, vtkm::cont::StorageTagBasic > &newVFs) const
Definition: MIR.h:1696
vtkm::worklet::ComputeStats
Definition: MIR.h:216
vtkm::TypeTraits::ZeroInitialization
static VTKM_EXEC_CONT T ZeroInitialization()
Definition: TypeTraits.h:75
vtkm::worklet::CalcError::lerping
vtkm::Float64 lerping
Definition: MIR.h:2161
vtkm::worklet::MIRCases::MIRTables
Definition: MIRTables.h:11205
vtkm::worklet::MIRCases::MIRTables::MIRDevicePortal::GetNumberOfIndices
VTKM_EXEC vtkm::Id GetNumberOfIndices(vtkm::Id shape) const
Definition: MIRTables.h:11213
vtkm::worklet::CalcError_C::ExecutionSignature
void(ValueCount, _1, _2, _3, _4, _5, _6) ExecutionSignature
Definition: MIR.h:2100
vtkm::worklet::EdgeInterpolation::LessThanOp::operator()
VTKM_EXEC bool operator()(const EdgeInterpolation &v1, const EdgeInterpolation &v2) const
Definition: MIR.h:90
vtkm::worklet::WorkletVisitCellsWithPoints::FieldInCell
FieldInVisit FieldInCell
Definition: WorkletMapTopology.h:261
vtkm::worklet::CombineVFsForPoints::operator()
VTKM_EXEC void operator()(vtkm::IdComponent numCells, const LenVec &len, const PosVec &pos, const IdsVec &ids, const VfsVec &vfs, const PosVec2 &posit, OutVec &outid, OutVec2 &outvf) const
Definition: MIR.h:1916
vtkm::worklet::MIR::InterpolateMIRFields::EdgePointsOffset
vtkm::Id EdgePointsOffset
Definition: MIR.h:1435
vtkm::exec::FunctorBase::RaiseError
VTKM_EXEC void RaiseError(const char *message) const
Definition: FunctorBase.h:40
vtkm::worklet::GenerateCellSet
Definition: MIR.h:402
vtkm::worklet::ScatterEdgeConnectivity::ExecutionSignature
void(_1, _2, _3) ExecutionSignature
Definition: MIR.h:657
vtkm::cont::ArrayHandleIndex
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations_C::operator()
VTKM_EXEC void operator()(const EdgeInterp &ei, IDL &lengths, const IDO &positions, const IdsVec &ids, const vtkm::Id workIndex, ELL &edgelength) const
Definition: MIR.h:1096
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::EdgeInterpolation::LessThanOp
Definition: Clip.h:88
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOutCell
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
vtkm::Minimum
Binary Predicate that takes two arguments argument x, and y and returns the x if x < y otherwise retu...
Definition: BinaryOperators.h:99
vtkm::exec::arg::WorkIndex
The ExecutionSignature tag to use to get the work index.
Definition: WorkIndex.h:39
vtkm::worklet::MIR::InterpolateMIRFields::PerformEdgeInterpolations_C::PerformEdgeInterpolations_C
PerformEdgeInterpolations_C(vtkm::Id edgePointsOffset)
Definition: MIR.h:1085
vtkm::worklet::MIR::InterpolateMIRFields::InCellPointsOffset
vtkm::Id InCellPointsOffset
Definition: MIR.h:1436
vtkm::worklet::ConnectivityExplicit
Definition: MIR.h:175
vtkm::worklet::MIRParentObject::PrepareForExecution
VTKM_CONT MIRParentPortal PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: MIR.h:384