1 #ifndef INTREPID_ARRAYTOOLSDEFSCALAR_KOKKOS_HPP
2 #define INTREPID_ARRAYTOOLSDEFSCALAR_KOKKOS_HPP
4 #ifdef INTREPID_OLD_KOKKOS_CODE
14 template<
class ViewType,
class ViewType1,
class ViewType2>
15 struct PFor__Recip_Not_Const2_2 {
17 typename ViewType1::const_type inputDataLeft;
18 typename ViewType2::const_type inputDataRight;
19 PFor__Recip_Not_Const2_2(ViewType outputData_, ViewType1 inputDataLeft_,
20 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
22 KOKKOS_INLINE_FUNCTION
23 void operator() (
int i)
const {
24 for(
int j = 0; j < outputData.dimension_1(); j++){
25 outputData(i,j) = inputDataRight(i,j)/inputDataLeft(i,j);
29 template<
class ViewType,
class ViewType1,
class ViewType2>
30 struct PFor_Not_Recip_Not_Const2_2 {
32 typename ViewType1::const_type inputDataLeft;
33 typename ViewType2::const_type inputDataRight;
34 PFor_Not_Recip_Not_Const2_2(ViewType outputData_, ViewType1 inputDataLeft_,
35 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
37 KOKKOS_INLINE_FUNCTION
38 void operator() (
int i)
const {
39 for(
int j = 0; j < outputData.dimension_1(); j++){
40 outputData(i,j) = inputDataRight(i,j)*inputDataLeft(i,j);
44 template<
class ViewType,
class ViewType1,
class ViewType2>
45 struct PFor__Recip__Const2_2 {
47 typename ViewType1::const_type inputDataLeft;
48 typename ViewType2::const_type inputDataRight;
49 PFor__Recip__Const2_2(ViewType outputData_, ViewType1 inputDataLeft_,
50 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
52 KOKKOS_INLINE_FUNCTION
53 void operator() (
int i)
const {
54 for(
int j = 0; j < outputData.dimension_1(); j++){
55 outputData(i,j) = inputDataRight(i,j)/inputDataLeft(i,0);
59 template<
class ViewType,
class ViewType1,
class ViewType2>
60 struct PFor_Not_Recip__Const2_2 {
62 typename ViewType1::const_type inputDataLeft;
63 typename ViewType2::const_type inputDataRight;
64 PFor_Not_Recip__Const2_2(ViewType outputData_, ViewType1 inputDataLeft_,
65 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
67 KOKKOS_INLINE_FUNCTION
68 void operator() (
int i)
const {
69 for(
int j = 0; j < outputData.dimension_1(); j++){
70 outputData(i,j) = inputDataRight(i,j)*inputDataLeft(i,0);
78 template<
class ArrayOutData,
class ArrayInDataLeft,
class ArrayInDataRight,
class Layout,
class MemorySpace>
79 struct ArrayTools::scalarMultiplyDataData2Kokkos<ArrayOutData, ArrayInDataLeft, ArrayInDataRight, Layout, MemorySpace,2,2>{
80 scalarMultiplyDataData2Kokkos(ArrayOutData & outputData,
81 ArrayInDataLeft & inputDataLeft,
82 ArrayInDataRight & inputDataRight,
83 const bool reciprocal){
85 #ifdef HAVE_INTREPID_DEBUG
86 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.rank() != 2), std::invalid_argument,
87 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Left input data container must have rank 2.");
88 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.rank() != 2)), std::invalid_argument,
89 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input data container must have rank 2.");
90 TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != inputDataRight.rank()), std::invalid_argument,
91 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input and output data containers must have the same rank.");
92 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(0) != inputDataLeft.dimension(0) ), std::invalid_argument,
93 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimensions (number of integration domains) of the left and right data input containers must agree!");
94 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(1) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
95 ">>> ERROR (ArrayTools::scalarMultiplyDataData): First dimensions of the left and right data input containers (number of integration points) must agree or first dimension of the left data input container must be 1!");
96 for (
int i=0; i<inputDataRight.rank(); i++) {
97 std::string errmsg =
">>> ERROR (ArrayTools::scalarMultiplyDataData): Dimension ";
98 errmsg += (char)(48+i);
99 errmsg +=
" of the right input and output data containers must agree!";
100 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i)), std::invalid_argument, errmsg );
108 int numCells = outputData.dimension(0);
109 int numDataPoints = inputDataLeft.dimension(1);
111 if (numDataPoints != 1) {
113 Kokkos::parallel_for(numCells,PFor__Recip_Not_Const2_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
118 Kokkos::parallel_for(numCells,PFor_Not_Recip_Not_Const2_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
124 Kokkos::parallel_for(numCells,PFor__Recip__Const2_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
128 Kokkos::parallel_for(numCells,PFor_Not_Recip__Const2_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
138 #define VECTOR_LENGTH 32
139 typedef Kokkos::TeamVectorPolicy<8> team_policy;
140 typedef team_policy::member_type team_member ;
143 template<
class ViewType,
class ViewType1,
class ViewType2>
144 struct PFor__Recip_Not_Const3_3 {
146 typename ViewType1::const_type inputDataLeft;
147 typename ViewType2::const_type inputDataRight;
148 PFor__Recip_Not_Const3_3(ViewType outputData_, ViewType1 inputDataLeft_,
149 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
151 KOKKOS_INLINE_FUNCTION
152 void operator() (
const team_member & thread)
const {
153 int i = thread.league_rank();
154 thread.team_par_for(outputData.dimension_1(),[&] (
const int& j){
155 thread.vector_par_for(outputData.dimension_2(),[&] (
const int& k){
156 outputData(i,j,k) = inputDataRight(i,j,k)/inputDataLeft(i,j);
188 template<
class ViewType,
class ViewType1,
class ViewType2>
189 struct PFor_Not_Recip_Not_Const3_3 {
191 typename ViewType1::const_type inputDataLeft;
192 typename ViewType2::const_type inputDataRight;
193 PFor_Not_Recip_Not_Const3_3(ViewType outputData_, ViewType1 inputDataLeft_,
194 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
196 KOKKOS_INLINE_FUNCTION
197 void operator() (
int i)
const {
198 for(
int j = 0; j < outputData.dimension_1(); j++){
199 for(
int k = 0; k < outputData.dimension_2(); k++){
200 outputData(i,j,k) = inputDataRight(i,j,k)*inputDataLeft(i,j);
205 template<
class ViewType,
class ViewType1,
class ViewType2>
206 struct PFor__Recip__Const3_3 {
208 typename ViewType1::const_type inputDataLeft;
209 typename ViewType2::const_type inputDataRight;
210 PFor__Recip__Const3_3(ViewType outputData_, ViewType1 inputDataLeft_,
211 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
213 KOKKOS_INLINE_FUNCTION
214 void operator() (
int i)
const {
215 for(
int j = 0; j < outputData.dimension_1(); j++){
216 for(
int k = 0; k < outputData.dimension_2(); k++){
217 outputData(i,j,k) = inputDataRight(i,j,k)/inputDataLeft(i,0);
223 template<
class ViewType,
class ViewType1,
class ViewType2>
224 struct PFor_Not_Recip__Const3_3 {
226 typename ViewType1::const_type inputDataLeft;
227 typename ViewType2::const_type inputDataRight;
228 PFor_Not_Recip__Const3_3(ViewType outputData_, ViewType1 inputDataLeft_,
229 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
231 KOKKOS_INLINE_FUNCTION
232 void operator() (
int i)
const {
233 for(
int j = 0; j < outputData.dimension_1(); j++){
234 for(
int k = 0; k < outputData.dimension_2(); k++){
235 outputData(i,j,k) = inputDataRight(i,j,k)*inputDataLeft(i,0);
244 template<
class ArrayOutData,
class ArrayInDataLeft,
class ArrayInDataRight,
class Layout,
class MemorySpace>
245 struct ArrayTools::scalarMultiplyDataData2Kokkos<ArrayOutData, ArrayInDataLeft, ArrayInDataRight, Layout, MemorySpace,3,3>{
246 scalarMultiplyDataData2Kokkos(ArrayOutData & outputData,
247 ArrayInDataLeft & inputDataLeft,
248 ArrayInDataRight & inputDataRight,
249 const bool reciprocal){
250 #ifdef HAVE_INTREPID_DEBUG
251 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.rank() != 2), std::invalid_argument,
252 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Left input data container must have rank 2.");
253 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.rank() != 3)), std::invalid_argument,
254 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input data container must have rank 3.");
255 TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != inputDataRight.rank()), std::invalid_argument,
256 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input and output data containers must have the same rank of 3.");
257 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(0) != inputDataLeft.dimension(0) ), std::invalid_argument,
258 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimensions (number of integration domains) of the left and right data input containers must agree!");
259 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(1) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
260 ">>> ERROR (ArrayTools::scalarMultiplyDataData): First dimensions of the left and right data input containers (number of integration points) must agree or first dimension of the left data input container must be 1!");
261 for (
int i=0; i<inputDataRight.rank(); i++) {
262 std::string errmsg =
">>> ERROR (ArrayTools::scalarMultiplyDataData): Dimension ";
263 errmsg += (char)(48+i);
264 errmsg +=
" of the right input and output data containers must agree!";
265 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i)), std::invalid_argument, errmsg );
273 int numCells = outputData.dimension(0);
274 int numDataPoints = inputDataLeft.dimension(1);
276 if (numDataPoints != 1) {
279 const team_policy policy( numCells , 2 );
280 Kokkos::parallel_for(policy,PFor__Recip_Not_Const3_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft, inputDataRight));
284 Kokkos::parallel_for(numCells,PFor_Not_Recip_Not_Const3_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
292 Kokkos::parallel_for(numCells,PFor__Recip__Const3_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight >(outputData, inputDataLeft,
297 Kokkos::parallel_for(numCells,PFor_Not_Recip__Const3_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight >(outputData, inputDataLeft,
306 template<
class ViewType,
class ViewType1,
class ViewType2>
307 struct PFor__Recip_Not_Const4_4 {
309 typename ViewType1::const_type inputDataLeft;
310 typename ViewType2::const_type inputDataRight;
311 PFor__Recip_Not_Const4_4(ViewType outputData_, ViewType1 inputDataLeft_,
312 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
314 KOKKOS_INLINE_FUNCTION
315 void operator() (
int i)
const {
316 for(
int j = 0; j < outputData.dimension_1(); j++){
317 for(
int k = 0; k < outputData.dimension_2(); k++){
318 for(
int l = 0; l < outputData.dimension_3(); l++){
319 outputData(i,j,k,l) = inputDataRight(i,j,k,l)/inputDataLeft(i,j);
325 template<
class ViewType,
class ViewType1,
class ViewType2>
326 struct PFor_Not_Recip_Not_Const4_4 {
328 typename ViewType1::const_type inputDataLeft;
329 typename ViewType2::const_type inputDataRight;
330 PFor_Not_Recip_Not_Const4_4(ViewType outputData_, ViewType1 inputDataLeft_,
331 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
333 KOKKOS_INLINE_FUNCTION
334 void operator() (
int i)
const {
335 for(
int j = 0; j < outputData.dimension_1(); j++){
336 for(
int k = 0; k < outputData.dimension_2(); k++){
337 for(
int l = 0; l < outputData.dimension_3(); l++){
338 outputData(i,j,k,l) = inputDataRight(i,j,k,l)*inputDataLeft(i,j);
344 template<
class ViewType,
class ViewType1,
class ViewType2>
345 struct PFor__Recip__Const4_4 {
347 typename ViewType1::const_type inputDataLeft;
348 typename ViewType2::const_type inputDataRight;
349 PFor__Recip__Const4_4(ViewType outputData_, ViewType1 inputDataLeft_,
350 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
352 KOKKOS_INLINE_FUNCTION
353 void operator() (
int i)
const {
354 for(
int j = 0; j < outputData.dimension_1(); j++){
355 for(
int k = 0; k < outputData.dimension_2(); k++){
356 for(
int l = 0; l < outputData.dimension_3(); l++){
357 outputData(i,j,k,l) = inputDataRight(i,j,k,l)/inputDataLeft(i,0);
363 template<
class ViewType,
class ViewType1,
class ViewType2>
364 struct PFor_Not_Recip__Const4_4 {
366 typename ViewType1::const_type inputDataLeft;
367 typename ViewType2::const_type inputDataRight;
368 PFor_Not_Recip__Const4_4(ViewType outputData_, ViewType1 inputDataLeft_,
369 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
371 KOKKOS_INLINE_FUNCTION
372 void operator() (
int i)
const {
373 for(
int j = 0; j < outputData.dimension_1(); j++){
374 for(
int k = 0; k < outputData.dimension_2(); k++){
375 for(
int l = 0; l < outputData.dimension_3(); l++){
376 outputData(i,j,k,l) = inputDataRight(i,j,k,l)/inputDataLeft(i,0);
387 template<
class ArrayOutData,
class ArrayInDataLeft,
class ArrayInDataRight,
class Layout,
class MemorySpace>
388 struct ArrayTools::scalarMultiplyDataData2Kokkos<ArrayOutData, ArrayInDataLeft, ArrayInDataRight, Layout, MemorySpace,4,4>{
389 scalarMultiplyDataData2Kokkos(ArrayOutData& outputData,
390 ArrayInDataLeft& inputDataLeft,
391 ArrayInDataRight& inputDataRight,
392 const bool reciprocal){
393 #ifdef HAVE_INTREPID_DEBUG
394 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.rank() != 2), std::invalid_argument,
395 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Left input data container must have rank 2.");
396 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.rank() != 4)), std::invalid_argument,
397 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input data container must have rank 4.");
398 TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != inputDataRight.rank()), std::invalid_argument,
399 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input and output data containers must have the same rank of 4.");
400 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(0) != inputDataLeft.dimension(0) ), std::invalid_argument,
401 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimensions (number of integration domains) of the left and right data input containers must agree!");
402 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(1) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
403 ">>> ERROR (ArrayTools::scalarMultiplyDataData): First dimensions of the left and right data input containers (number of integration points) must agree or first dimension of the left data input container must be 1!");
404 for (
int i=0; i<inputDataRight.rank(); i++) {
405 std::string errmsg =
">>> ERROR (ArrayTools::scalarMultiplyDataData): Dimension ";
406 errmsg += (char)(48+i);
407 errmsg +=
" of the right input and output data containers must agree!";
408 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i)), std::invalid_argument, errmsg );
415 int numCells = outputData.dimension(0);
416 int numDataPoints = inputDataLeft.dimension(1);
418 if (numDataPoints != 1) {
420 Kokkos::parallel_for(numCells,PFor__Recip_Not_Const4_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
424 Kokkos::parallel_for(numCells,PFor_Not_Recip_Not_Const4_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight >(outputData, inputDataLeft,
432 Kokkos::parallel_for(numCells,PFor__Recip__Const4_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
436 Kokkos::parallel_for(numCells,PFor_Not_Recip__Const4_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight >(outputData, inputDataLeft,
446 template<
class ViewType,
class ViewType1,
class ViewType2>
447 struct PFor__Recip_Not_Const1_2 {
449 typename ViewType1::const_type inputDataLeft;
450 typename ViewType2::const_type inputDataRight;
451 PFor__Recip_Not_Const1_2(ViewType outputData_, ViewType1 inputDataLeft_,
452 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
454 KOKKOS_INLINE_FUNCTION
455 void operator() (
int i)
const {
456 for(
int j = 0; j < outputData.dimension_1(); j++){
457 outputData(i,j) = inputDataRight(j)/inputDataLeft(i,j);
461 template<
class ViewType,
class ViewType1,
class ViewType2>
462 struct PFor_Not_Recip_Not_Const1_2 {
464 typename ViewType1::const_type inputDataLeft;
465 typename ViewType2::const_type inputDataRight;
466 PFor_Not_Recip_Not_Const1_2(ViewType outputData_, ViewType1 inputDataLeft_,
467 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
469 KOKKOS_INLINE_FUNCTION
470 void operator() (
int i)
const {
471 for(
int j = 0; j < outputData.dimension_1(); j++){
472 outputData(i,j) = inputDataRight(j)*inputDataLeft(i,j);
476 template<
class ViewType,
class ViewType1,
class ViewType2>
477 struct PFor__Recip__Const1_2 {
479 typename ViewType1::const_type inputDataLeft;
480 typename ViewType2::const_type inputDataRight;
481 PFor__Recip__Const1_2(ViewType outputData_, ViewType1 inputDataLeft_,
482 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
484 KOKKOS_INLINE_FUNCTION
485 void operator() (
int i)
const {
486 for(
int j = 0; j < outputData.dimension_1(); j++){
487 outputData(i,j) = inputDataRight(j)/inputDataLeft(i,0);
491 template<
class ViewType,
class ViewType1,
class ViewType2>
492 struct PFor_Not_Recip__Const1_2 {
494 typename ViewType1::const_type inputDataLeft;
495 typename ViewType2::const_type inputDataRight;
496 PFor_Not_Recip__Const1_2(ViewType outputData_, ViewType1 inputDataLeft_,
497 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
499 KOKKOS_INLINE_FUNCTION
500 void operator() (
int i)
const {
501 for(
int j = 0; j < outputData.dimension_1(); j++){
502 outputData(i,j) = inputDataRight(j)*inputDataLeft(i,0);
510 template<
class ArrayOutData,
class ArrayInDataLeft,
class ArrayInDataRight,
class Layout,
class MemorySpace>
511 struct ArrayTools::scalarMultiplyDataData2Kokkos<ArrayOutData, ArrayInDataLeft, ArrayInDataRight, Layout, MemorySpace,1,2>{
512 scalarMultiplyDataData2Kokkos(ArrayOutData& outputData,
513 ArrayInDataLeft& inputDataLeft,
514 ArrayInDataRight& inputDataRight,
515 const bool reciprocal){
516 #ifdef HAVE_INTREPID_DEBUG
517 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.rank() != 2), std::invalid_argument,
518 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Left input data container must have rank 2.");
519 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.rank() != 1) ), std::invalid_argument,
520 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input data container must have rank 1.");
521 TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != inputDataRight.rank()+1), std::invalid_argument,
522 ">>> ERROR (ArrayTools::scalarMultiplyDataData): The rank of the right input data container must be one less than the rank of the output data container.");
523 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(0) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
524 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimension of the right input data container and first dimension of the left data input container (number of integration points) must agree or first dimension of the left data input container must be 1!");
525 TEUCHOS_TEST_FOR_EXCEPTION( ( inputDataLeft.dimension(0) != outputData.dimension(0) ), std::invalid_argument,
526 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimensions of data output and left data input containers (number of integration domains) must agree!");
527 for (
int i=0; i<inputDataRight.rank(); i++) {
528 std::string errmsg =
">>> ERROR (ArrayTools::scalarMultiplyDataData): Dimensions ";
529 errmsg += (char)(48+i);
531 errmsg += (char)(48+i+1);
532 errmsg +=
" of the right input and output data containers must agree!";
533 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i+1)), std::invalid_argument, errmsg );
538 int numCells = outputData.dimension(0);
539 int numDataPoints = inputDataLeft.dimension(1);
541 if (numDataPoints != 1) {
543 Kokkos::parallel_for(numCells,PFor__Recip_Not_Const1_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight >(outputData, inputDataLeft,
547 Kokkos::parallel_for(numCells,PFor_Not_Recip_Not_Const1_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
553 Kokkos::parallel_for(numCells,PFor__Recip__Const1_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
557 Kokkos::parallel_for(numCells,PFor_Not_Recip__Const1_2<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
565 template<
class ViewType,
class ViewType1,
class ViewType2>
566 struct PFor__Recip_Not_Const2_3 {
568 typename ViewType1::const_type inputDataLeft;
569 typename ViewType2::const_type inputDataRight;
570 PFor__Recip_Not_Const2_3(ViewType outputData_, ViewType1 inputDataLeft_,
571 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
573 KOKKOS_INLINE_FUNCTION
574 void operator() (
int i)
const {
576 for(
int j = 0; j < outputData.dimension_1(); j++){
577 for(
int k = 0; k < outputData.dimension_2(); k++){
578 outputData(i,j,k) = inputDataRight(j,k)/inputDataLeft(i,j);
583 template<
class ViewType,
class ViewType1,
class ViewType2>
584 struct PFor_Not_Recip_Not_Const2_3 {
586 typename ViewType1::const_type inputDataLeft;
587 typename ViewType2::const_type inputDataRight;
588 PFor_Not_Recip_Not_Const2_3(ViewType outputData_, ViewType1 inputDataLeft_,
589 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
591 KOKKOS_INLINE_FUNCTION
592 void operator() (
int i)
const {
593 for(
int j = 0; j < outputData.dimension_1(); j++){
594 for(
int k = 0; k < outputData.dimension_2(); k++){
595 outputData(i,j,k) = inputDataRight(j,k)*inputDataLeft(i,j);
600 template<
class ViewType,
class ViewType1,
class ViewType2>
601 struct PFor__Recip__Const2_3 {
603 typename ViewType1::const_type inputDataLeft;
604 typename ViewType2::const_type inputDataRight;
605 PFor__Recip__Const2_3(ViewType outputData_, ViewType1 inputDataLeft_,
606 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
608 KOKKOS_INLINE_FUNCTION
609 void operator() (
int i)
const {
610 for(
int j = 0; j < outputData.dimension_1(); j++){
611 for(
int k = 0; k < outputData.dimension_2(); k++){
612 outputData(i,j,k) = inputDataRight(j,k)/inputDataLeft(i,0);
617 template<
class ViewType,
class ViewType1,
class ViewType2>
618 struct PFor_Not_Recip__Const2_3 {
620 typename ViewType1::const_type inputDataLeft;
621 typename ViewType2::const_type inputDataRight;
622 PFor_Not_Recip__Const2_3(ViewType outputData_, ViewType1 inputDataLeft_,
623 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
625 KOKKOS_INLINE_FUNCTION
626 void operator() (
int i)
const {
627 for(
int j = 0; j < outputData.dimension_1(); j++){
628 for(
int k = 0; k < outputData.dimension_2(); k++){
629 outputData(i,j,k) = inputDataRight(j,k)*inputDataLeft(i,0);
638 template<
class ArrayOutData,
class ArrayInDataLeft,
class ArrayInDataRight,
class Layout,
class MemorySpace>
639 struct ArrayTools::scalarMultiplyDataData2Kokkos<ArrayOutData, ArrayInDataLeft, ArrayInDataRight, Layout, MemorySpace,2,3>{
640 scalarMultiplyDataData2Kokkos(ArrayOutData& outputData,
641 ArrayInDataLeft& inputDataLeft,
642 ArrayInDataRight& inputDataRight,
643 const bool reciprocal){
645 #ifdef HAVE_INTREPID_DEBUG
646 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.rank() != 2), std::invalid_argument,
647 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Left input data container must have rank 2.");
648 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.rank() != 2) ), std::invalid_argument,
649 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input data container must have rank 2.");
650 TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != inputDataRight.rank()+1), std::invalid_argument,
651 ">>> ERROR (ArrayTools::scalarMultiplyDataData): The rank of the right input data container must be one less than the rank of the output data container.");
652 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(0) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
653 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimension of the right input data container and first dimension of the left data input container (number of integration points) must agree or first dimension of the left data input container must be 1!");
654 TEUCHOS_TEST_FOR_EXCEPTION( ( inputDataLeft.dimension(0) != outputData.dimension(0) ), std::invalid_argument,
655 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimensions of data output and left data input containers (number of integration domains) must agree!");
656 for (
int i=0; i<inputDataRight.rank(); i++) {
657 std::string errmsg =
">>> ERROR (ArrayTools::scalarMultiplyDataData): Dimensions ";
658 errmsg += (char)(48+i);
660 errmsg += (char)(48+i+1);
661 errmsg +=
" of the right input and output data containers must agree!";
662 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i+1)), std::invalid_argument, errmsg );
666 int numCells = outputData.dimension(0);
667 int numDataPoints = inputDataLeft.dimension(1);
668 if (numDataPoints != 1) {
670 Kokkos::parallel_for(numCells,PFor__Recip_Not_Const2_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
674 Kokkos::parallel_for(numCells,PFor_Not_Recip_Not_Const2_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
680 Kokkos::parallel_for(numCells,PFor__Recip__Const2_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
684 Kokkos::parallel_for(numCells,PFor_Not_Recip__Const2_3<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
693 template<
class ViewType,
class ViewType1,
class ViewType2>
694 struct PFor__Recip_Not_Const3_4 {
696 typename ViewType1::const_type inputDataLeft;
697 typename ViewType2::const_type inputDataRight;
698 PFor__Recip_Not_Const3_4(ViewType outputData_, ViewType1 inputDataLeft_,
699 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
701 KOKKOS_INLINE_FUNCTION
702 void operator() (
int i)
const {
703 for(
int j = 0; j < outputData.dimension_1(); j++){
704 for(
int k = 0; k < outputData.dimension_2(); k++){
705 for(
int l = 0; l < outputData.dimension_3(); l++){
706 outputData(i,j,k,l) = inputDataRight(j,k,l)/inputDataLeft(i,j);
712 template<
class ViewType,
class ViewType1,
class ViewType2>
713 struct PFor_Not_Recip_Not_Const3_4 {
715 typename ViewType1::const_type inputDataLeft;
716 typename ViewType2::const_type inputDataRight;
717 PFor_Not_Recip_Not_Const3_4(ViewType outputData_, ViewType1 inputDataLeft_,
718 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
720 KOKKOS_INLINE_FUNCTION
721 void operator() (
int i)
const {
722 for(
int j = 0; j < outputData.dimension_1(); j++){
723 for(
int k = 0; k < outputData.dimension_2(); k++){
724 for(
int l = 0; l < outputData.dimension_3(); l++){
725 outputData(i,j,k,l) = inputDataRight(j,k,l)*inputDataLeft(i,j);
731 template<
class ViewType,
class ViewType1,
class ViewType2>
732 struct PFor__Recip__Const3_4 {
734 typename ViewType1::const_type inputDataLeft;
735 typename ViewType2::const_type inputDataRight;
736 PFor__Recip__Const3_4(ViewType outputData_, ViewType1 inputDataLeft_,
737 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
739 KOKKOS_INLINE_FUNCTION
740 void operator() (
int i)
const {
741 for(
int j = 0; j < outputData.dimension_1(); j++){
742 for(
int k = 0; k < outputData.dimension_2(); k++){
743 for(
int l = 0; l < outputData.dimension_3(); l++){
744 outputData(i,j,k,l) = inputDataRight(j,k,l)/inputDataLeft(i,0);
750 template<
class ViewType,
class ViewType1,
class ViewType2>
751 struct PFor_Not_Recip__Const3_4 {
753 typename ViewType1::const_type inputDataLeft;
754 typename ViewType2::const_type inputDataRight;
755 PFor_Not_Recip__Const3_4(ViewType outputData_, ViewType1 inputDataLeft_,
756 ViewType2 inputDataRight_):outputData(outputData_),inputDataLeft(inputDataLeft_),inputDataRight(inputDataRight_) {}
758 KOKKOS_INLINE_FUNCTION
759 void operator() (
int i)
const {
760 for(
int j = 0; j < outputData.dimension_1(); j++){
761 for(
int k = 0; k < outputData.dimension_2(); k++){
762 for(
int l = 0; l < outputData.dimension_3(); l++){
763 outputData(i,j,k,l) = inputDataRight(j,k,l)/inputDataLeft(i,0);
773 template<
class ArrayOutData,
class ArrayInDataLeft,
class ArrayInDataRight,
class Layout,
class MemorySpace>
774 struct ArrayTools::scalarMultiplyDataData2Kokkos<ArrayOutData, ArrayInDataLeft, ArrayInDataRight, Layout, MemorySpace,3,4>{
775 scalarMultiplyDataData2Kokkos(ArrayOutData& outputData,
776 ArrayInDataLeft& inputDataLeft,
777 ArrayInDataRight& inputDataRight,
778 const bool reciprocal){
779 #ifdef HAVE_INTREPID_DEBUG
780 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.rank() != 2), std::invalid_argument,
781 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Left input data container must have rank 2.");
782 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.rank() != 3) ), std::invalid_argument,
783 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Right input data container must have rank 3.");
784 TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != inputDataRight.rank()+1), std::invalid_argument,
785 ">>> ERROR (ArrayTools::scalarMultiplyDataData): The rank of the right input data container must be one less than the rank of the output data container.");
786 TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(0) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
787 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimension of the right input data container and first dimension of the left data input container (number of integration points) must agree or first dimension of the left data input container must be 1!");
788 TEUCHOS_TEST_FOR_EXCEPTION( ( inputDataLeft.dimension(0) != outputData.dimension(0) ), std::invalid_argument,
789 ">>> ERROR (ArrayTools::scalarMultiplyDataData): Zeroth dimensions of data output and left data input containers (number of integration domains) must agree!");
790 for (
int i=0; i<inputDataRight.rank(); i++) {
791 std::string errmsg =
">>> ERROR (ArrayTools::scalarMultiplyDataData): Dimensions ";
792 errmsg += (char)(48+i);
794 errmsg += (char)(48+i+1);
795 errmsg +=
" of the right input and output data containers must agree!";
796 TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i+1)), std::invalid_argument, errmsg );
801 int numCells = outputData.dimension(0);
802 int numDataPoints = inputDataLeft.dimension(1);
806 if (numDataPoints != 1) {
808 Kokkos::parallel_for(numCells,PFor__Recip_Not_Const3_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
812 Kokkos::parallel_for(numCells,PFor_Not_Recip_Not_Const3_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight >(outputData, inputDataLeft,
818 Kokkos::parallel_for(numCells,PFor__Recip__Const3_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,
822 Kokkos::parallel_for(numCells,PFor_Not_Recip__Const3_4<ArrayOutData,ArrayInDataLeft,ArrayInDataRight>(outputData, inputDataLeft,