TransportTagArrayIn.h 2.21 KB
Newer Older
Kenneth Moreland's avatar
Kenneth Moreland committed
1
2
3
4
5
6
7
8
//============================================================================
//  Copyright (c) Kitware, Inc.
//  All rights reserved.
//  See LICENSE.txt for details.
//  This software is distributed WITHOUT ANY WARRANTY; without even
//  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//  PURPOSE.  See the above copyright notice for more information.
//
Kenneth Moreland's avatar
Kenneth Moreland committed
9
//  Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Kenneth Moreland's avatar
Kenneth Moreland committed
10
//  Copyright 2014 UT-Battelle, LLC.
11
//  Copyright 2014 Los Alamos National Security.
Kenneth Moreland's avatar
Kenneth Moreland committed
12
//
Kenneth Moreland's avatar
Kenneth Moreland committed
13
//  Under the terms of Contract DE-NA0003525 with NTESS,
Kenneth Moreland's avatar
Kenneth Moreland committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//  the U.S. Government retains certain rights in this software.
//
//  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
//  Laboratory (LANL), the U.S. Government retains certain rights in
//  this software.
//============================================================================
#ifndef vtk_m_cont_arg_TransportTagArrayIn_h
#define vtk_m_cont_arg_TransportTagArrayIn_h

#include <vtkm/Types.h>

#include <vtkm/cont/ArrayHandle.h>

#include <vtkm/cont/arg/Transport.h>

29
30
31
32
33
34
namespace vtkm
{
namespace cont
{
namespace arg
{
Kenneth Moreland's avatar
Kenneth Moreland committed
35
36
37
38
39
40

/// \brief \c Transport tag for input arrays.
///
/// \c TransportTagArrayIn is a tag used with the \c Transport class to
/// transport \c ArrayHandle objects for input data.
///
41
42
43
struct TransportTagArrayIn
{
};
Kenneth Moreland's avatar
Kenneth Moreland committed
44

45
template <typename ContObjectType, typename Device>
Kenneth Moreland's avatar
Kenneth Moreland committed
46
47
struct Transport<vtkm::cont::arg::TransportTagArrayIn, ContObjectType, Device>
{
48
  VTKM_IS_ARRAY_HANDLE(ContObjectType);
Kenneth Moreland's avatar
Kenneth Moreland committed
49

50
  using ExecObjectType = decltype(std::declval<ContObjectType>().PrepareForInput(Device()));
Kenneth Moreland's avatar
Kenneth Moreland committed
51

52
53
54
  template <typename InputDomainType>
  VTKM_CONT ExecObjectType operator()(const ContObjectType& object,
                                      const InputDomainType& vtkmNotUsed(inputDomain),
55
56
                                      vtkm::Id inputRange,
                                      vtkm::Id vtkmNotUsed(outputRange)) const
Kenneth Moreland's avatar
Kenneth Moreland committed
57
  {
58
    if (object.GetNumberOfValues() != inputRange)
59
    {
60
      throw vtkm::cont::ErrorBadValue("Input array to worklet invocation the wrong size.");
61
    }
62

Kenneth Moreland's avatar
Kenneth Moreland committed
63
64
65
66
67
68
69
70
    return object.PrepareForInput(Device());
  }
};
}
}
} // namespace vtkm::cont::arg

#endif //vtk_m_cont_arg_TransportTagArrayIn_h