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 SpT>
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;
152 typedef typename ExecSpace< typename inputViewType::execution_space , SpT >::ExecSpaceType ExecSpaceType;
154 using range_policy_type = Kokkos::Experimental::MDRangePolicy
155 < ExecSpaceType, Kokkos::Experimental::Rank<3>, Kokkos::IndexType<ordinal_type> >;
158 C = output.extent(0),
159 F = output.extent(1),
160 P = output.extent(2);
162 range_policy_type policy( { 0, 0, 0 },
164 const ordinal_type valRank = output.rank() - 3;
167 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,0> FunctorType;
168 Kokkos::parallel_for( policy, FunctorType(output, input) );
172 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,1> FunctorType;
173 Kokkos::parallel_for( policy, FunctorType(output, input) );
177 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,2> FunctorType;
178 Kokkos::parallel_for( policy, FunctorType(output, input) );
184 template<
typename SpT>
185 template<
typename outputValueType,
class ...outputProperties,
186 typename inputValueType,
class ...inputProperties>
188 cloneData( Kokkos::DynRankView<outputValueType,outputProperties...> output,
189 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
190 #ifdef HAVE_INTREPID2_DEBUG 192 INTREPID2_TEST_FOR_EXCEPTION( ( input.rank() < 1 || input.rank() > 3 ), std::invalid_argument,
193 ">>> ERROR (ArrayTools::clone): Input fields container must have rank 1, 2, or 3.");
194 INTREPID2_TEST_FOR_EXCEPTION( ( output.rank() != (input.rank()+1) ), std::invalid_argument,
195 ">>> ERROR (ArrayTools::clone): The rank of the input fields container must be one less than the rank of the output fields container.");
196 for (ordinal_type i=0;i<input.rank();++i) {
197 INTREPID2_TEST_FOR_EXCEPTION( (input.extent(i) != output.extent(i+1)), std::invalid_argument,
198 ">>> ERROR (ArrayTools::clone): Dimensions of input and output fields containers do not match.");
203 typedef Kokkos::DynRankView<outputValueType,outputProperties...> outputViewType;
204 typedef Kokkos::DynRankView<inputValueType, inputProperties...> inputViewType;
205 typedef typename ExecSpace< typename inputViewType::execution_space , SpT >::ExecSpaceType ExecSpaceType;
207 using range_policy_type = Kokkos::Experimental::MDRangePolicy
208 < ExecSpaceType, Kokkos::Experimental::Rank<2>, Kokkos::IndexType<ordinal_type> >;
211 C = output.extent(0),
212 P = output.extent(1);
214 range_policy_type policy( { 0, 0 },
216 const ordinal_type valRank = output.rank() - 2;
219 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,0> FunctorType;
220 Kokkos::parallel_for( policy, FunctorType(output, input) );
224 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,1> FunctorType;
225 Kokkos::parallel_for( policy, FunctorType(output, input) );
229 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,2> FunctorType;
230 Kokkos::parallel_for( policy, FunctorType(output, input) );