TransportTagArrayInOut.h 2.46 KB
Newer Older
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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10
11
12
//  Copyright 2015 UT-Battelle, LLC.
//  Copyright 2015 Los Alamos National Security.
//
Kenneth Moreland's avatar
Kenneth Moreland committed
13
//  Under the terms of Contract DE-NA0003525 with NTESS,
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_TransportTagArrayInOut_h
#define vtk_m_cont_arg_TransportTagArrayInOut_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
{
35
36
37
38
39
40
41

/// \brief \c Transport tag for in-place arrays.
///
/// \c TransportTagArrayInOut is a tag used with the \c Transport class to
/// transport \c ArrayHandle objects for data that is both input and output
/// (that is, in place modification of array data).
///
42
43
44
struct TransportTagArrayInOut
{
};
45

46
template <typename ContObjectType, typename Device>
47
48
49
50
51
52
struct Transport<vtkm::cont::arg::TransportTagArrayInOut, ContObjectType, Device>
{
  // If you get a compile error here, it means you tried to use an object that
  // is not an array handle as an argument that is expected to be one.
  VTKM_IS_ARRAY_HANDLE(ContObjectType);

53
  using ExecObjectType = decltype(std::declval<ContObjectType>().PrepareForInPlace(Device()));
54

55
56
57
  template <typename InputDomainType>
  VTKM_CONT ExecObjectType operator()(ContObjectType object,
                                      const InputDomainType& vtkmNotUsed(inputDomain),
58
59
                                      vtkm::Id vtkmNotUsed(inputRange),
                                      vtkm::Id outputRange) const
60
  {
61
    if (object.GetNumberOfValues() != outputRange)
62
    {
63
      throw vtkm::cont::ErrorBadValue("Input/output array to worklet invocation the wrong size.");
64
65
66
67
68
69
70
71
72
73
    }

    return object.PrepareForInPlace(Device());
  }
};
}
}
} // namespace vtkm::cont::arg

#endif //vtk_m_cont_arg_TransportTagArrayInOut_h