Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana_Utils.hpp
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2018-2022 by the Cabana authors *
3 * All rights reserved. *
4 * *
5 * This file is part of the Cabana library. Cabana is distributed under a *
6 * BSD 3-clause license. For the licensing terms see the LICENSE file in *
7 * the top-level directory. *
8 * *
9 * SPDX-License-Identifier: BSD-3-Clause *
10 ****************************************************************************/
11
16#ifndef CABANA_UTILS_HPP
17#define CABANA_UTILS_HPP
18
19#include <Cabana_Core_Config.hpp>
20
21#include <Kokkos_Core.hpp>
22
23#include <array>
24#include <type_traits>
25namespace Cabana
26{
27//---------------------------------------------------------------------------//
28// Array copies.
29//---------------------------------------------------------------------------//
31template <class Scalar, std::size_t Dim>
32auto copyArray( const std::array<Scalar, Dim> input )
33{
34 Kokkos::Array<Scalar, Dim> output;
35 for ( std::size_t d = 0; d < Dim; ++d )
36 output[d] = input[d];
37
38 return output;
39}
40
41template <class Scalar, std::size_t Dim>
42auto copyArray( const Kokkos::Array<Scalar, Dim> input )
43{
44 return input;
45}
46
47template <class Scalar, std::size_t Dim>
48auto copyArray( const Scalar input[Dim] )
49{
50 Kokkos::Array<Scalar, Dim> output;
51 for ( std::size_t d = 0; d < Dim; ++d )
52 output[d] = input[d];
53
54 return output;
55}
56
57namespace Impl
58{
60
61// Custom warning for use within static_assert.
62constexpr bool deprecated( std::false_type ) { return true; }
63
64[[deprecated( "Cabana deprecation." )]] constexpr bool
65deprecated( std::true_type )
66{
67 return true;
68}
69
70// Custom warning.
71#ifdef Cabana_DISABLE_DEPRECATION_WARNINGS
72#define CABANA_DEPRECATED
73#else
74#define CABANA_DEPRECATED [[deprecated( "Cabana deprecation." )]]
75#endif
76
78
79} // namespace Impl
80} // namespace Cabana
81
82#endif
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
auto copyArray(const std::array< Scalar, Dim > input)
Copy std::array into Kokkos::Array for potential device use.
Definition Cabana_Utils.hpp:32