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> >;
157 range_policy_type policy( { 0, 0, 0 },
158 { output.extent(0), output.extent(1), output.extent(2) } );
159 const ordinal_type valRank = output.rank() - 3;
162 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,0> FunctorType;
163 Kokkos::parallel_for( policy, FunctorType(output, input) );
167 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,1> FunctorType;
168 Kokkos::parallel_for( policy, FunctorType(output, input) );
172 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,2> FunctorType;
173 Kokkos::parallel_for( policy, FunctorType(output, input) );
179 template<
typename SpT>
180 template<
typename outputValueType,
class ...outputProperties,
181 typename inputValueType,
class ...inputProperties>
183 cloneData( Kokkos::DynRankView<outputValueType,outputProperties...> output,
184 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
185 #ifdef HAVE_INTREPID2_DEBUG
187 INTREPID2_TEST_FOR_EXCEPTION( ( input.rank() < 1 || input.rank() > 3 ), std::invalid_argument,
188 ">>> ERROR (ArrayTools::clone): Input fields container must have rank 1, 2, or 3.");
189 INTREPID2_TEST_FOR_EXCEPTION( ( output.rank() != (input.rank()+1) ), std::invalid_argument,
190 ">>> ERROR (ArrayTools::clone): The rank of the input fields container must be one less than the rank of the output fields container.");
191 for (ordinal_type i=0;i<input.rank();++i) {
192 INTREPID2_TEST_FOR_EXCEPTION( (input.extent(i) != output.extent(i+1)), std::invalid_argument,
193 ">>> ERROR (ArrayTools::clone): Dimensions of input and output fields containers do not match.");
198 typedef Kokkos::DynRankView<outputValueType,outputProperties...> outputViewType;
199 typedef Kokkos::DynRankView<inputValueType, inputProperties...> inputViewType;
200 typedef typename ExecSpace< typename inputViewType::execution_space , SpT >::ExecSpaceType ExecSpaceType;
202 using range_policy_type = Kokkos::Experimental::MDRangePolicy
203 < ExecSpaceType, Kokkos::Experimental::Rank<2>, Kokkos::IndexType<ordinal_type> >;
205 range_policy_type policy( { 0, 0 },
206 { output.extent(0), output.extent(1) } );
207 const ordinal_type valRank = output.rank() - 2;
210 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,0> FunctorType;
211 Kokkos::parallel_for( policy, FunctorType(output, input) );
215 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,1> FunctorType;
216 Kokkos::parallel_for( policy, FunctorType(output, input) );
220 typedef FunctorArrayTools::F_clone<outputViewType,inputViewType,2> FunctorType;
221 Kokkos::parallel_for( policy, FunctorType(output, input) );