VTK-m  2.0
CopyIntoCombinedArrayWorklet.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 // Copyright 2014 UT-Battelle, LLC.
11 // Copyright 2014 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-NA0003525 with NTESS,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20 // Copyright (c) 2018, The Regents of the University of California, through
21 // Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
22 // from the U.S. Dept. of Energy). All rights reserved.
23 //
24 // Redistribution and use in source and binary forms, with or without modification,
25 // are permitted provided that the following conditions are met:
26 //
27 // (1) Redistributions of source code must retain the above copyright notice, this
28 // list of conditions and the following disclaimer.
29 //
30 // (2) Redistributions in binary form must reproduce the above copyright notice,
31 // this list of conditions and the following disclaimer in the documentation
32 // and/or other materials provided with the distribution.
33 //
34 // (3) Neither the name of the University of California, Lawrence Berkeley National
35 // Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
36 // used to endorse or promote products derived from this software without
37 // specific prior written permission.
38 //
39 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
40 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
41 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
43 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
47 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 // OF THE POSSIBILITY OF SUCH DAMAGE.
49 //
50 //=============================================================================
51 //
52 // This code is an extension of the algorithm presented in the paper:
53 // Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
54 // Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
55 // Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
56 // (LDAV), October 2016, Baltimore, Maryland.
57 //
58 // The PPP2 algorithm and software were jointly developed by
59 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
60 // Oliver Ruebel (LBNL)
61 //==============================================================================
62 
63 #ifndef vtk_m_worklet_contourtree_augmented_contourtree_mesh_inc_copy_into_combined_array_worklet_h
64 #define vtk_m_worklet_contourtree_augmented_contourtree_mesh_inc_copy_into_combined_array_worklet_h
65 
66 #include <vtkm/LowerBound.h>
67 #include <vtkm/UpperBound.h>
70 
71 namespace vtkm
72 {
73 namespace worklet
74 {
75 namespace contourtree_augmented
76 {
77 namespace mesh_dem_contourtree_mesh_inc
78 {
79 
80 template <bool useLowerBound>
82 {
83 public:
84  typedef void ControlSignature(FieldIn thisArray,
85  WholeArrayIn otherArray,
86  ExecObject comparisonFunctor,
87  WholeArrayOut resultArray);
88  typedef void ExecutionSignature(_1, InputIndex, _2, _3, _4);
89  typedef _1 InputDomain;
90 
91  template <typename InputType,
92  typename InputArrayPortalType,
93  typename ComparisonFunctorType,
94  typename OutputArrayPortalType>
95  VTKM_EXEC void operator()(const InputType& value,
96  vtkm::Id idx,
97  const InputArrayPortalType& otherArrayPortal,
98  const ComparisonFunctorType& comparisonFunctor,
99  OutputArrayPortalType& resultArrayPortal) const
100  {
101  // Find position of value in other array. Note: We use lower and upper bounds for
102  // the two different arrays (passed as template bool parameter so that the test
103  // occurs at compile time). If the same value occurs in both arrays, this approach
104  // "shifts" the position upwards for one of the arrays/elements, resulting in a
105  // uniuqe positioj in the result array. (Without this distinction, both values would
106  // end up at the same location in the result array, leaving and "empty"/uninitialized
107  // position.
108  vtkm::Id posInOther = useLowerBound
109  ? vtkm::LowerBound(otherArrayPortal, value, comparisonFunctor)
110  : vtkm::UpperBound(otherArrayPortal, value, comparisonFunctor);
111 
112  // The position of the current elemnt is its index in our array plus its
113  // position in the ohter array.
114  resultArrayPortal.Set(idx + posInOther, value);
115  }
116 }; // CopyIntoCombinedArrayWorklet
117 
118 
119 } // namespace mesh_dem_contourtree_mesh_inc
120 } // namespace contourtree_augmented
121 } // namespace worklet
122 } // namespace vtkm
123 
124 #endif
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CopyIntoCombinedArrayWorklet::ControlSignature
void ControlSignature(FieldIn thisArray, WholeArrayIn otherArray, ExecObject comparisonFunctor, WholeArrayOut resultArray)
Definition: CopyIntoCombinedArrayWorklet.h:84
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::UpperBound
VTKM_EXEC_CONT IterT UpperBound(IterT first, IterT last, const T &val, Comp comp)
Implementation of std::upper_bound that is appropriate for both control and execution environments.
Definition: UpperBound.h:30
WorkletMapField.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CopyIntoCombinedArrayWorklet
Definition: CopyIntoCombinedArrayWorklet.h:81
LowerBound.h
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CopyIntoCombinedArrayWorklet::ExecutionSignature
void ExecutionSignature(_1, InputIndex, _2, _3, _4)
Definition: CopyIntoCombinedArrayWorklet.h:88
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CopyIntoCombinedArrayWorklet::InputDomain
_1 InputDomain
Definition: CopyIntoCombinedArrayWorklet.h:89
Types.h
vtkm::worklet::contourtree_augmented::mesh_dem_contourtree_mesh_inc::CopyIntoCombinedArrayWorklet::operator()
VTKM_EXEC void operator()(const InputType &value, vtkm::Id idx, const InputArrayPortalType &otherArrayPortal, const ComparisonFunctorType &comparisonFunctor, OutputArrayPortalType &resultArrayPortal) const
Definition: CopyIntoCombinedArrayWorklet.h:95
vtkm::LowerBound
VTKM_EXEC_CONT IterT LowerBound(IterT first, IterT last, const T &val, Comp comp)
Implementation of std::lower_bound that is appropriate for both control and execution environments.
Definition: LowerBound.h:30
UpperBound.h
vtkm::exec::arg::InputIndex
The ExecutionSignature tag to use to get the input index.
Definition: InputIndex.h:42
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38