16 #ifndef __INTREPID2_ARRAYTOOLS_DEF_CLONESCALE_HPP__
17 #define __INTREPID2_ARRAYTOOLS_DEF_CLONESCALE_HPP__
21 namespace FunctorArrayTools {
26 template<
typename OutputViewType,
27 typename inputViewType,
30 OutputViewType _output;
31 const inputViewType _input;
33 KOKKOS_INLINE_FUNCTION
40 KOKKOS_INLINE_FUNCTION
42 operator()(
const ordinal_type cl,
43 const ordinal_type pt)
const {
46 _output.access(cl, pt) = _input.access(pt);
50 const ordinal_type iend = _output.extent(2);
51 for (ordinal_type i=0;i<iend;++i)
52 _output.access(cl, pt, i) = _input.access(pt, i);
57 iend = _output.extent(2),
58 jend = _output.extent(3);
59 for (ordinal_type i=0;i<iend;++i)
60 for (ordinal_type j=0;j<jend;++j)
61 _output.access(cl, pt, i, j) = _input.access(pt, i, j);
68 KOKKOS_INLINE_FUNCTION
70 operator()(
const ordinal_type cl,
71 const ordinal_type bf,
72 const ordinal_type pt)
const {
75 _output.access(cl, bf, pt) = _input.access(bf, pt);
79 const ordinal_type iend = _output.extent(3);
80 for (ordinal_type i=0;i<iend;++i)
81 _output.access(cl, bf, pt, i) = _input.access(bf, pt, i);
86 iend = _output.extent(3),
87 jend = _output.extent(4);
88 for (ordinal_type i=0;i<iend;++i)
89 for (ordinal_type j=0;j<jend;++j)
90 _output.access(cl, bf, pt, i, j) = _input.access(bf, pt, i, j);
98 template<
typename DeviceType>
99 template<
typename outputValueType,
class ...outputProperties,
100 typename inputValueType,
class ...inputProperties>
102 cloneFields( Kokkos::DynRankView<outputValueType,outputProperties...> output,
103 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
104 #ifdef HAVE_INTREPID2_DEBUG
106 INTREPID2_TEST_FOR_EXCEPTION( ( input.rank() < 2 || input.rank() > 4 ), std::invalid_argument,
107 ">>> ERROR (ArrayTools::clone): Input fields container must have rank 2, 3, or 4.");
108 INTREPID2_TEST_FOR_EXCEPTION( ( output.rank() != (input.rank()+1) ), std::invalid_argument,
109 ">>> ERROR (ArrayTools::clone): The rank of the input fields container must be one less than the rank of the output fields container.");
110 for (size_type i=0;i< input.rank();++i) {
111 INTREPID2_TEST_FOR_EXCEPTION( (input.extent(i) != output.extent(i+1)), std::invalid_argument,
112 ">>> ERROR (ArrayTools::clone): Dimensions of input and output fields containers do not match.");
117 typedef Kokkos::DynRankView<outputValueType,outputProperties...> OutputViewType;
118 typedef Kokkos::DynRankView<inputValueType, inputProperties...> inputViewType;
120 using range_policy_type = Kokkos::MDRangePolicy
121 < ExecSpaceType, Kokkos::Rank<3>, Kokkos::IndexType<ordinal_type> >;
123 range_policy_type policy( { 0, 0, 0 },
124 { output.extent(0), output.extent(1), output.extent(2) } );
125 const ordinal_type valRank = output.rank() - 3;
128 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,0> FunctorType;
129 Kokkos::parallel_for( policy, FunctorType(output, input) );
133 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,1> FunctorType;
134 Kokkos::parallel_for( policy, FunctorType(output, input) );
138 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,2> FunctorType;
139 Kokkos::parallel_for( policy, FunctorType(output, input) );
145 template<
typename DeviceType>
146 template<
typename outputValueType,
class ...outputProperties,
147 typename inputValueType,
class ...inputProperties>
149 cloneData( Kokkos::DynRankView<outputValueType,outputProperties...> output,
150 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
151 #ifdef HAVE_INTREPID2_DEBUG
153 INTREPID2_TEST_FOR_EXCEPTION( ( input.rank() < 1 || input.rank() > 3 ), std::invalid_argument,
154 ">>> ERROR (ArrayTools::clone): Input fields container must have rank 1, 2, or 3.");
155 INTREPID2_TEST_FOR_EXCEPTION( ( output.rank() != (input.rank()+1) ), std::invalid_argument,
156 ">>> ERROR (ArrayTools::clone): The rank of the input fields container must be one less than the rank of the output fields container.");
157 for (ordinal_type i=0;i<input.rank();++i) {
158 INTREPID2_TEST_FOR_EXCEPTION( (input.extent(i) != output.extent(i+1)), std::invalid_argument,
159 ">>> ERROR (ArrayTools::clone): Dimensions of input and output fields containers do not match.");
164 typedef Kokkos::DynRankView<outputValueType,outputProperties...> OutputViewType;
165 typedef Kokkos::DynRankView<inputValueType, inputProperties...> inputViewType;
167 using range_policy_type = Kokkos::MDRangePolicy
168 < ExecSpaceType, Kokkos::Rank<2>, Kokkos::IndexType<ordinal_type> >;
170 range_policy_type policy( { 0, 0 },
171 { output.extent(0), output.extent(1) } );
172 const ordinal_type valRank = output.rank() - 2;
175 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,0> FunctorType;
176 Kokkos::parallel_for( policy, FunctorType(output, input) );
180 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,1> FunctorType;
181 Kokkos::parallel_for( policy, FunctorType(output, input) );
185 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,2> FunctorType;
186 Kokkos::parallel_for( policy, FunctorType(output, input) );