49 #ifndef __INTREPID2_ARRAYTOOLS_DEF_CLONESCALE_HPP__
50 #define __INTREPID2_ARRAYTOOLS_DEF_CLONESCALE_HPP__
54 namespace FunctorArrayTools {
59 template<
typename OutputViewType,
60 typename inputViewType,
63 OutputViewType _output;
64 const inputViewType _input;
66 KOKKOS_INLINE_FUNCTION
73 KOKKOS_INLINE_FUNCTION
75 operator()(
const ordinal_type cl,
76 const ordinal_type pt)
const {
79 _output.access(cl, pt) = _input.access(pt);
83 const ordinal_type iend = _output.extent(2);
84 for (ordinal_type i=0;i<iend;++i)
85 _output.access(cl, pt, i) = _input.access(pt, i);
90 iend = _output.extent(2),
91 jend = _output.extent(3);
92 for (ordinal_type i=0;i<iend;++i)
93 for (ordinal_type j=0;j<jend;++j)
94 _output.access(cl, pt, i, j) = _input.access(pt, i, j);
101 KOKKOS_INLINE_FUNCTION
103 operator()(
const ordinal_type cl,
104 const ordinal_type bf,
105 const ordinal_type pt)
const {
108 _output.access(cl, bf, pt) = _input.access(bf, pt);
112 const ordinal_type iend = _output.extent(3);
113 for (ordinal_type i=0;i<iend;++i)
114 _output.access(cl, bf, pt, i) = _input.access(bf, pt, i);
119 iend = _output.extent(3),
120 jend = _output.extent(4);
121 for (ordinal_type i=0;i<iend;++i)
122 for (ordinal_type j=0;j<jend;++j)
123 _output.access(cl, bf, pt, i, j) = _input.access(bf, pt, i, j);
131 template<
typename DeviceType>
132 template<
typename outputValueType,
class ...outputProperties,
133 typename inputValueType,
class ...inputProperties>
135 cloneFields( Kokkos::DynRankView<outputValueType,outputProperties...> output,
136 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
137 #ifdef HAVE_INTREPID2_DEBUG
139 INTREPID2_TEST_FOR_EXCEPTION( ( input.rank() < 2 || input.rank() > 4 ), std::invalid_argument,
140 ">>> ERROR (ArrayTools::clone): Input fields container must have rank 2, 3, or 4.");
141 INTREPID2_TEST_FOR_EXCEPTION( ( output.rank() != (input.rank()+1) ), std::invalid_argument,
142 ">>> ERROR (ArrayTools::clone): The rank of the input fields container must be one less than the rank of the output fields container.");
143 for (size_type i=0;i< input.rank();++i) {
144 INTREPID2_TEST_FOR_EXCEPTION( (input.extent(i) != output.extent(i+1)), std::invalid_argument,
145 ">>> ERROR (ArrayTools::clone): Dimensions of input and output fields containers do not match.");
150 typedef Kokkos::DynRankView<outputValueType,outputProperties...> OutputViewType;
151 typedef Kokkos::DynRankView<inputValueType, inputProperties...> inputViewType;
153 using range_policy_type = Kokkos::MDRangePolicy
154 < ExecSpaceType, Kokkos::Rank<3>, Kokkos::IndexType<ordinal_type> >;
156 range_policy_type policy( { 0, 0, 0 },
157 { output.extent(0), output.extent(1), output.extent(2) } );
158 const ordinal_type valRank = output.rank() - 3;
161 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,0> FunctorType;
162 Kokkos::parallel_for( policy, FunctorType(output, input) );
166 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,1> FunctorType;
167 Kokkos::parallel_for( policy, FunctorType(output, input) );
171 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,2> FunctorType;
172 Kokkos::parallel_for( policy, FunctorType(output, input) );
178 template<
typename DeviceType>
179 template<
typename outputValueType,
class ...outputProperties,
180 typename inputValueType,
class ...inputProperties>
182 cloneData( Kokkos::DynRankView<outputValueType,outputProperties...> output,
183 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
184 #ifdef HAVE_INTREPID2_DEBUG
186 INTREPID2_TEST_FOR_EXCEPTION( ( input.rank() < 1 || input.rank() > 3 ), std::invalid_argument,
187 ">>> ERROR (ArrayTools::clone): Input fields container must have rank 1, 2, or 3.");
188 INTREPID2_TEST_FOR_EXCEPTION( ( output.rank() != (input.rank()+1) ), std::invalid_argument,
189 ">>> ERROR (ArrayTools::clone): The rank of the input fields container must be one less than the rank of the output fields container.");
190 for (ordinal_type i=0;i<input.rank();++i) {
191 INTREPID2_TEST_FOR_EXCEPTION( (input.extent(i) != output.extent(i+1)), std::invalid_argument,
192 ">>> ERROR (ArrayTools::clone): Dimensions of input and output fields containers do not match.");
197 typedef Kokkos::DynRankView<outputValueType,outputProperties...> OutputViewType;
198 typedef Kokkos::DynRankView<inputValueType, inputProperties...> inputViewType;
200 using range_policy_type = Kokkos::MDRangePolicy
201 < ExecSpaceType, Kokkos::Rank<2>, Kokkos::IndexType<ordinal_type> >;
203 range_policy_type policy( { 0, 0 },
204 { output.extent(0), output.extent(1) } );
205 const ordinal_type valRank = output.rank() - 2;
208 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,0> FunctorType;
209 Kokkos::parallel_for( policy, FunctorType(output, input) );
213 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,1> FunctorType;
214 Kokkos::parallel_for( policy, FunctorType(output, input) );
218 typedef FunctorArrayTools::F_clone<OutputViewType,inputViewType,2> FunctorType;
219 Kokkos::parallel_for( policy, FunctorType(output, input) );