52 #include "Teuchos_oblackholestream.hpp"
53 #include "Teuchos_RCP.hpp"
54 #include "Teuchos_ScalarTraits.hpp"
55 #include "Teuchos_GlobalMPISession.hpp"
56 #include <Kokkos_Core.hpp>
59 using namespace Intrepid;
61 #define INTREPID_TEST_COMMAND( S ) \
66 catch (std::logic_error err) { \
67 *outStream << "Expected Error ----------------------------------------------------------------\n"; \
68 *outStream << err.what() << '\n'; \
69 *outStream << "-------------------------------------------------------------------------------" << "\n\n"; \
74 int main(
int argc,
char *argv[]) {
76 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
80 int iprint = argc - 1;
81 Teuchos::RCP<std::ostream> outStream;
82 Teuchos::oblackholestream bhs;
84 outStream = Teuchos::rcp(&std::cout,
false);
86 outStream = Teuchos::rcp(&bhs,
false);
89 Teuchos::oblackholestream oldFormatState;
90 oldFormatState.copyfmt(std::cout);
93 <<
"===============================================================================\n" \
95 <<
"| Unit Test (ArrayTools) |\n" \
97 <<
"| 1) Array operations: contractions |\n" \
99 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov) or |\n" \
100 <<
"| Denis Ridzal (dridzal@sandia.gov). |\n" \
102 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
103 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
105 <<
"===============================================================================\n";
110 #ifdef HAVE_INTREPID_DEBUG
111 int beginThrowNumber = Teuchos::TestForException_getThrowNumber();
112 int endThrowNumber = beginThrowNumber + 81;
116 #ifdef HAVE_INTREPID_DEBUG
121 <<
"===============================================================================\n"\
122 <<
"| TEST 1: exceptions |\n"\
123 <<
"===============================================================================\n";
127 #ifdef HAVE_INTREPID_DEBUG
136 *outStream <<
"-> contractFieldFieldScalar:\n";
156 *outStream <<
"-> contractFieldFieldVector:\n";
166 INTREPID_TEST_COMMAND( atools.
contractFieldFieldVector<
double>(a_10_2_3, a_10_2_2_2, a_10_3_2_2, COMP_ENGINE_MAX) );
177 *outStream <<
"-> contractFieldFieldTensor:\n";
188 INTREPID_TEST_COMMAND( atools.
contractFieldFieldTensor<
double>(a_10_2_3, a_10_2_2_2_2, a_10_3_2_2_2, COMP_ENGINE_MAX) );
195 *outStream <<
"-> contractDataFieldScalar:\n";
211 *outStream <<
"-> contractDataFieldVector:\n";
220 INTREPID_TEST_COMMAND( atools.
contractDataFieldVector<
double>(a_10_2, a_10_2_2, a_10_2_2_2, COMP_ENGINE_MAX) );
227 *outStream <<
"-> contractDataFieldTensor:\n";
237 INTREPID_TEST_COMMAND( atools.
contractDataFieldTensor<
double>(a_10_2, a_10_2_2_2, a_10_2_2_2_2, COMP_ENGINE_MAX) );
245 *outStream <<
"-> contractDataDataScalar:\n";
256 *outStream <<
"-> contractDataDataVector:\n";
264 INTREPID_TEST_COMMAND( atools.
contractDataDataVector<
double>(a_10, a_10_2_2, a_10_2_2, COMP_ENGINE_MAX) );
268 *outStream <<
"-> contractDataDataTensor:\n";
277 INTREPID_TEST_COMMAND( atools.
contractDataDataTensor<
double>(a_10, a_10_2_2_2, a_10_2_2_2, COMP_ENGINE_MAX) );
284 catch (std::logic_error err) {
285 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
286 *outStream << err.what() <<
'\n';
287 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
291 #ifdef HAVE_INTREPID_DEBUG
292 if (Teuchos::TestForException_getThrowNumber() != endThrowNumber)
299 <<
"===============================================================================\n"\
300 <<
"| TEST 2: correctness of math operations |\n"\
301 <<
"===============================================================================\n";
303 outStream->precision(20);
307 *outStream <<
"\n************ Checking contractFieldFieldScalar ************\n";
309 int c=5, p=9, l=3, r=7;
311 Kokkos::View<double***> in_c_l_p(
"in_c_l_p",c, l, p);
312 Kokkos::View<double***> in_c_r_p(
"in_c_r_p",c, r, p);
313 Kokkos::View<double***> out1_c_l_r(
"out1_c_l_r",c, l, r);
314 Kokkos::View<double***> out2_c_l_r(
"out2_c_l_r",c, l, r);
315 double zero = INTREPID_TOL*10000.0;
318 for (
unsigned int i=0; i<in_c_l_p.dimension(0); i++)
319 for (
unsigned int j=0; j<in_c_l_p.dimension(1); j++)
320 for (
unsigned int k=0; k<in_c_l_p.dimension(2); k++)
321 in_c_l_p(i,j,k) = Teuchos::ScalarTraits<double>::random();
323 for (
unsigned int i=0; i<in_c_r_p.dimension(0); i++)
324 for (
unsigned int j=0; j<in_c_r_p.dimension(1); j++)
325 for (
unsigned int k=0; k<in_c_r_p.dimension(2); k++)
326 in_c_r_p(i,j,k) = Teuchos::ScalarTraits<double>::random();
329 art::contractFieldFieldScalar<double>(out1_c_l_r, in_c_l_p, in_c_r_p, COMP_CPP);
330 art::contractFieldFieldScalar<double>(out2_c_l_r, in_c_l_p, in_c_r_p, COMP_BLAS);
331 rst::subtract(out1_c_l_r, out2_c_l_r);
332 if (rst::vectorNorm(out1_c_l_r, NORM_ONE) > zero) {
333 *outStream <<
"\n\nINCORRECT contractFieldFieldScalar (1): check COMP_CPP vs. COMP_BLAS; "
334 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l_r, NORM_ONE) <<
"\n\n";
338 Kokkos::deep_copy(out1_c_l_r, 2.0);
339 Kokkos::deep_copy(out2_c_l_r, 2.0);
340 art::contractFieldFieldScalar<double>(out1_c_l_r, in_c_l_p, in_c_r_p, COMP_CPP,
true);
341 art::contractFieldFieldScalar<double>(out2_c_l_r, in_c_l_p, in_c_r_p, COMP_BLAS,
true);
342 rst::subtract(out1_c_l_r, out2_c_l_r);
343 if (rst::vectorNorm(out1_c_l_r, NORM_ONE) > zero) {
344 *outStream <<
"\n\nINCORRECT contractFieldFieldScalar (1): check COMP_CPP vs. COMP_BLAS; "
345 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l_r, NORM_ONE) <<
"\n\n";
351 *outStream <<
"\n************ Checking contractFieldFieldVector ************\n";
353 int c=5, p=9, l=3, r=7, d=13;
355 Kokkos::View<double****> in_c_l_p_d(
"in_c_l_p_d",c, l, p, d);
356 Kokkos::View<double****> in_c_r_p_d(
"in_c_r_p_d",c, r, p, d);
357 Kokkos::View<double***> out1_c_l_r(
"out1_c_l_r",c, l, r);
358 Kokkos::View<double***> out2_c_l_r(
"out2_c_l_r",c, l, r);
359 double zero = INTREPID_TOL*10000.0;
362 for (
unsigned int i=0; i<in_c_l_p_d.dimension(0); i++)
363 for (
unsigned int j=0; j<in_c_l_p_d.dimension(1); j++)
364 for (
unsigned int k=0; k<in_c_l_p_d.dimension(2); k++)
365 for (
unsigned int l=0; l<in_c_l_p_d.dimension(3); l++)
366 in_c_l_p_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
368 for (
unsigned int i=0; i<in_c_r_p_d.dimension(0); i++)
369 for (
unsigned int j=0; j<in_c_r_p_d.dimension(1); j++)
370 for (
unsigned int k=0; k<in_c_r_p_d.dimension(2); k++)
371 for (
unsigned int l=0; l<in_c_r_p_d.dimension(3); l++)
372 in_c_r_p_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
375 art::contractFieldFieldVector<double>(out1_c_l_r, in_c_l_p_d, in_c_r_p_d, COMP_CPP);
376 art::contractFieldFieldVector<double>(out2_c_l_r, in_c_l_p_d, in_c_r_p_d, COMP_BLAS);
378 rst::subtract(out1_c_l_r, out2_c_l_r);
379 if (rst::vectorNorm(out1_c_l_r, NORM_ONE) > zero) {
380 *outStream <<
"\n\nINCORRECT contractFieldFieldVector (1): check COMP_CPP vs. COMP_BLAS; "
381 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l_r, NORM_ONE) <<
"\n\n";
386 Kokkos::deep_copy(out1_c_l_r, 2.0);
387 Kokkos::deep_copy(out2_c_l_r, 2.0);
388 art::contractFieldFieldVector<double>(out1_c_l_r, in_c_l_p_d, in_c_r_p_d, COMP_CPP,
true);
389 art::contractFieldFieldVector<double>(out2_c_l_r, in_c_l_p_d, in_c_r_p_d, COMP_BLAS,
true);
391 rst::subtract(out1_c_l_r, out2_c_l_r);
392 if (rst::vectorNorm(out1_c_l_r, NORM_ONE) > zero) {
393 *outStream <<
"\n\nINCORRECT contractFieldFieldVector (1): check COMP_CPP vs. COMP_BLAS; "
394 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l_r, NORM_ONE) <<
"\n\n";
400 *outStream <<
"\n************ Checking contractFieldFieldTensor ************\n";
402 int c=5, p=9, l=3, r=7, d1=13, d2=5;
404 Kokkos::View<double*****> in_c_l_p_d_d(
"in_c_l_p_d_d", c, l, p, d1, d2);
405 Kokkos::View<double*****> in_c_r_p_d_d(
"in_c_r_p_d_d", c, r, p, d1, d2);
406 Kokkos::View<double***> out1_c_l_r(
"out1_c_l_r", c, l, r);
407 Kokkos::View<double***> out2_c_l_r(
"out2_c_l_r", c, l, r);
408 double zero = INTREPID_TOL*10000.0;
412 for (
unsigned int i=0; i<in_c_l_p_d_d.dimension(0); i++)
413 for (
unsigned int j=0; j<in_c_l_p_d_d.dimension(1); j++)
414 for (
unsigned int k=0; k<in_c_l_p_d_d.dimension(2); k++)
415 for (
unsigned int l=0; l<in_c_l_p_d_d.dimension(3); l++)
416 for (
unsigned int m=0; m<in_c_l_p_d_d.dimension(4); m++)
417 in_c_l_p_d_d(i,j,k,l,m) = Teuchos::ScalarTraits<double>::random();
419 for (
unsigned int i=0; i<in_c_r_p_d_d.dimension(0); i++)
420 for (
unsigned int j=0; j<in_c_r_p_d_d.dimension(1); j++)
421 for (
unsigned int k=0; k<in_c_r_p_d_d.dimension(2); k++)
422 for (
unsigned int l=0; l<in_c_r_p_d_d.dimension(3); l++)
423 for (
unsigned int m=0; m<in_c_r_p_d_d.dimension(4); m++)
424 in_c_r_p_d_d(i,j,k,l,m) = Teuchos::ScalarTraits<double>::random();
427 art::contractFieldFieldTensor<double>(out1_c_l_r, in_c_l_p_d_d, in_c_r_p_d_d, COMP_CPP);
428 art::contractFieldFieldTensor<double>(out2_c_l_r, in_c_l_p_d_d, in_c_r_p_d_d, COMP_BLAS);
430 rst::subtract(out1_c_l_r, out2_c_l_r);
431 if (rst::vectorNorm(out1_c_l_r, NORM_ONE) > zero) {
432 *outStream <<
"\n\nINCORRECT contractFieldFieldTensor (1): check COMP_CPP vs. COMP_BLAS; "
433 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l_r, NORM_ONE) <<
"\n\n";
438 Kokkos::deep_copy(out1_c_l_r, 2.0);
439 Kokkos::deep_copy(out2_c_l_r, 2.0);
441 art::contractFieldFieldTensor<double>(out1_c_l_r, in_c_l_p_d_d, in_c_r_p_d_d, COMP_CPP,
true);
442 art::contractFieldFieldTensor<double>(out2_c_l_r, in_c_l_p_d_d, in_c_r_p_d_d, COMP_BLAS,
true);
444 rst::subtract(out1_c_l_r, out2_c_l_r);
445 if (rst::vectorNorm(out1_c_l_r, NORM_ONE) > zero) {
446 *outStream <<
"\n\nINCORRECT contractFieldFieldTensor (1): check COMP_CPP vs. COMP_BLAS; "
447 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l_r, NORM_ONE) <<
"\n\n";
453 *outStream <<
"\n************ Checking contractDataFieldScalar ************\n";
457 Kokkos::View<double***> in_c_l_p(
"in_c_l_p", c, l, p);
458 Kokkos::View<double**> data_c_p(
"data_c_p", c, p);
459 Kokkos::View<double**> data_c_1(
"data_c_1", c, 1);
460 Kokkos::View<double**> out1_c_l(
"out1_c_l", c, l);
461 Kokkos::View<double**> out2_c_l(
"out2_c_l", c, l);
462 double zero = INTREPID_TOL*10000.0;
465 for (
unsigned int i=0; i<in_c_l_p.dimension(0); i++)
466 for (
unsigned int j=0; j<in_c_l_p.dimension(1); j++)
467 for (
unsigned int k=0; k<in_c_l_p.dimension(2); k++)
468 in_c_l_p(i,j,k) = Teuchos::ScalarTraits<double>::random();
470 for (
unsigned int i=0; i<data_c_p.dimension(0); i++)
471 for (
unsigned int j=0; j<data_c_p.dimension(1); j++)
472 data_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
474 for (
unsigned int i=0; i<data_c_1.dimension(0); i++)
475 for (
unsigned int j=0; j<data_c_1.dimension(1); j++)
476 data_c_1(i,j) = Teuchos::ScalarTraits<double>::random();
481 art::contractDataFieldScalar<double>(out1_c_l, data_c_p, in_c_l_p, COMP_CPP);
482 art::contractDataFieldScalar<double>(out2_c_l, data_c_p, in_c_l_p, COMP_BLAS);
483 rst::subtract(out1_c_l, out2_c_l);
484 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
485 *outStream <<
"\n\nINCORRECT contractDataFieldScalar (1): check COMP_CPP vs. COMP_BLAS; "
486 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
490 art::contractDataFieldScalar<double>(out1_c_l, data_c_1, in_c_l_p, COMP_CPP);
491 art::contractDataFieldScalar<double>(out2_c_l, data_c_1, in_c_l_p, COMP_BLAS);
492 rst::subtract(out1_c_l, out2_c_l);
493 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
494 *outStream <<
"\n\nINCORRECT contractDataFieldScalar (2): check COMP_CPP vs. COMP_BLAS; "
495 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
499 Kokkos::deep_copy(out1_c_l, 2.0);
500 Kokkos::deep_copy(out2_c_l, 2.0);
501 art::contractDataFieldScalar<double>(out1_c_l, data_c_p, in_c_l_p, COMP_CPP,
true);
502 art::contractDataFieldScalar<double>(out2_c_l, data_c_p, in_c_l_p, COMP_BLAS,
true);
503 rst::subtract(out1_c_l, out2_c_l);
504 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
505 *outStream <<
"\n\nINCORRECT contractDataFieldScalar (1): check COMP_CPP vs. COMP_BLAS; "
506 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
512 *outStream <<
"\n************ Checking contractDataFieldVector ************\n";
514 int c=5, p=9, l=7, d=3;
516 Kokkos::View<double****> in_c_l_p_d(
"in_c_l_p_d", c, l, p, d);
517 Kokkos::View<double***> data_c_p_d(
"data_c_p_d", c, p, d);
518 Kokkos::View<double***> data_c_1_d(
"data_c_1_d", c, 1, d);
519 Kokkos::View<double**> out1_c_l(
"out1_c_l", c, l);
520 Kokkos::View<double**> out2_c_l(
"out2_c_l", c, l);
521 double zero = INTREPID_TOL*10000.0;
524 for (
unsigned int i=0; i<in_c_l_p_d.dimension(0); i++)
525 for (
unsigned int j=0; j<in_c_l_p_d.dimension(1); j++)
526 for (
unsigned int k=0; k<in_c_l_p_d.dimension(2); k++)
527 for (
unsigned int l=0; l<in_c_l_p_d.dimension(3); l++)
528 in_c_l_p_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
530 for (
unsigned int i=0; i<data_c_p_d.dimension(0); i++)
531 for (
unsigned int j=0; j<data_c_p_d.dimension(1); j++)
532 for (
unsigned int k=0; k<data_c_p_d.dimension(2); k++)
533 data_c_p_d(i,j,k) = Teuchos::ScalarTraits<double>::random();
535 for (
unsigned int i=0; i<data_c_1_d.dimension(0); i++)
536 for (
unsigned int j=0; j<data_c_1_d.dimension(1); j++)
537 for (
unsigned int k=0; k<data_c_1_d.dimension(2); k++)
538 data_c_1_d(i,j,k) = Teuchos::ScalarTraits<double>::random();
542 art::contractDataFieldVector<double>(out1_c_l, data_c_p_d, in_c_l_p_d, COMP_CPP);
543 art::contractDataFieldVector<double>(out2_c_l, data_c_p_d, in_c_l_p_d, COMP_BLAS);
544 rst::subtract(out1_c_l, out2_c_l);
545 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
546 *outStream <<
"\n\nINCORRECT contractDataFieldVector (1): check COMP_CPP vs. COMP_BLAS; "
547 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
551 art::contractDataFieldVector<double>(out1_c_l, data_c_1_d, in_c_l_p_d, COMP_CPP);
552 art::contractDataFieldVector<double>(out2_c_l, data_c_1_d, in_c_l_p_d, COMP_BLAS);
553 rst::subtract(out1_c_l, out2_c_l);
554 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
555 *outStream <<
"\n\nINCORRECT contractDataFieldVector (2): check COMP_CPP vs. COMP_BLAS; "
556 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
560 Kokkos::deep_copy(out1_c_l, 2.0);
561 Kokkos::deep_copy(out2_c_l, 2.0);
562 art::contractDataFieldVector<double>(out1_c_l, data_c_p_d, in_c_l_p_d, COMP_CPP,
true);
563 art::contractDataFieldVector<double>(out2_c_l, data_c_p_d, in_c_l_p_d, COMP_BLAS,
true);
564 rst::subtract(out1_c_l, out2_c_l);
565 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
566 *outStream <<
"\n\nINCORRECT contractDataFieldVector (1): check COMP_CPP vs. COMP_BLAS; "
567 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
573 *outStream <<
"\n************ Checking contractDataFieldTensor ************\n";
575 int c=5, p=9, l=7, d1=3, d2=13;
577 Kokkos::View<double*****> in_c_l_p_d_d(
"in_c_l_p_d_d", c, l, p, d1, d2);
578 Kokkos::View<double****> data_c_p_d_d(
"data_c_p_d_d", c, p, d1, d2);
579 Kokkos::View<double****> data_c_1_d_d(
"data_c_1_d_d", c, 1, d1, d2);
580 Kokkos::View<double**> out1_c_l(
"out1_c_l", c, l);
581 Kokkos::View<double**> out2_c_l(
"out2_c_l", c, l);
582 double zero = INTREPID_TOL*10000.0;
585 for (
unsigned int i=0; i<in_c_l_p_d_d.dimension(0); i++)
586 for (
unsigned int j=0; j<in_c_l_p_d_d.dimension(1); j++)
587 for (
unsigned int k=0; k<in_c_l_p_d_d.dimension(2); k++)
588 for (
unsigned int l=0; l<in_c_l_p_d_d.dimension(3); l++)
589 for (
unsigned int m=0; m<in_c_l_p_d_d.dimension(4); m++)
590 in_c_l_p_d_d(i,j,k,l,m) = Teuchos::ScalarTraits<double>::random();
592 for (
unsigned int i=0; i<data_c_p_d_d.dimension(0); i++)
593 for (
unsigned int j=0; j<data_c_p_d_d.dimension(1); j++)
594 for (
unsigned int k=0; k<data_c_p_d_d.dimension(2); k++)
595 for (
unsigned int l=0; l<data_c_p_d_d.dimension(3); l++)
596 data_c_p_d_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
598 for (
unsigned int i=0; i<data_c_1_d_d.dimension(0); i++)
599 for (
unsigned int j=0; j<data_c_1_d_d.dimension(1); j++)
600 for (
unsigned int k=0; k<data_c_1_d_d.dimension(2); k++)
601 for (
unsigned int l=0; l<data_c_1_d_d.dimension(3); l++)
602 data_c_1_d_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
606 art::contractDataFieldTensor<double>(out1_c_l, data_c_p_d_d, in_c_l_p_d_d, COMP_CPP);
607 art::contractDataFieldTensor<double>(out2_c_l, data_c_p_d_d, in_c_l_p_d_d, COMP_BLAS);
608 rst::subtract(out1_c_l, out2_c_l);
609 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
610 *outStream <<
"\n\nINCORRECT contractDataFieldTensor (1): check COMP_CPP vs. COMP_BLAS; "
611 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
615 art::contractDataFieldTensor<double>(out1_c_l, data_c_1_d_d, in_c_l_p_d_d, COMP_CPP);
616 art::contractDataFieldTensor<double>(out2_c_l, data_c_1_d_d, in_c_l_p_d_d, COMP_BLAS);
617 rst::subtract(out1_c_l, out2_c_l);
618 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
619 *outStream <<
"\n\nINCORRECT contractDataFieldTensor (1): check COMP_CPP vs. COMP_BLAS; "
620 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
624 Kokkos::deep_copy(out1_c_l, 2.0);
625 Kokkos::deep_copy(out2_c_l, 2.0);
626 art::contractDataFieldTensor<double>(out1_c_l, data_c_p_d_d, in_c_l_p_d_d, COMP_CPP,
true);
627 art::contractDataFieldTensor<double>(out2_c_l, data_c_p_d_d, in_c_l_p_d_d, COMP_BLAS,
true);
628 rst::subtract(out1_c_l, out2_c_l);
629 if (rst::vectorNorm(out1_c_l, NORM_ONE) > zero) {
630 *outStream <<
"\n\nINCORRECT contractDataFieldTensor (1): check COMP_CPP vs. COMP_BLAS; "
631 <<
" diff-1norm = " << rst::vectorNorm(out1_c_l, NORM_ONE) <<
"\n\n";
637 *outStream <<
"\n************ Checking contractDataDataScalar ************\n";
641 Kokkos::View<double**> inl_c_p(
"inl_c_p", c, p);
642 Kokkos::View<double**> inr_c_p(
"inr_c_p", c, p);
643 Kokkos::View<double*> out1_c(
"out1_c", c);
644 Kokkos::View<double*> out2_c(
"out2_c", c);
645 double zero = INTREPID_TOL*10000.0;
648 for (
unsigned int i=0; i<inl_c_p.dimension(0); i++)
649 for (
unsigned int j=0; j<inl_c_p.dimension(1); j++)
650 inl_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
652 for (
unsigned int i=0; i<inr_c_p.dimension(0); i++)
653 for (
unsigned int j=0; j<inr_c_p.dimension(1); j++)
654 inr_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
657 art::contractDataDataScalar<double>(out1_c, inl_c_p, inr_c_p, COMP_CPP);
658 art::contractDataDataScalar<double>(out2_c, inl_c_p, inr_c_p, COMP_BLAS);
659 rst::subtract(out1_c, out2_c);
660 if (rst::vectorNorm(out1_c, NORM_ONE) > zero) {
661 *outStream <<
"\n\nINCORRECT contractDataDataScalar (1): check COMP_CPP vs. COMP_BLAS; "
662 <<
" diff-1norm = " << rst::vectorNorm(out1_c, NORM_ONE) <<
"\n\n";
666 Kokkos::deep_copy(out1_c, 2.0);
667 Kokkos::deep_copy(out2_c, 2.0);
668 art::contractDataDataScalar<double>(out1_c, inl_c_p, inr_c_p, COMP_CPP,
true);
669 art::contractDataDataScalar<double>(out2_c, inl_c_p, inr_c_p, COMP_BLAS,
true);
670 rst::subtract(out1_c, out2_c);
671 if (rst::vectorNorm(out1_c, NORM_ONE) > zero) {
672 *outStream <<
"\n\nINCORRECT contractDataDataScalar (1): check COMP_CPP vs. COMP_BLAS; "
673 <<
" diff-1norm = " << rst::vectorNorm(out1_c, NORM_ONE) <<
"\n\n";
679 *outStream <<
"\n************ Checking contractDataDataVector ************\n";
683 Kokkos::View<double***> inl_c_p_d(
"inl_c_p_d", c, p, d);
684 Kokkos::View<double***> inr_c_p_d(
"inr_c_p_d", c, p, d);
685 Kokkos::View<double*> out1_c(
"out1_c", c);
686 Kokkos::View<double*> out2_c(
"out2_c", c);
687 double zero = INTREPID_TOL*10000.0;
690 for (
unsigned int i=0; i<inl_c_p_d.dimension(0); i++)
691 for (
unsigned int j=0; j<inl_c_p_d.dimension(1); j++)
692 for (
unsigned int k=0; k<inl_c_p_d.dimension(2); k++)
693 inl_c_p_d(i,j,k) = Teuchos::ScalarTraits<double>::random();
695 for (
unsigned int i=0; i<inr_c_p_d.dimension(0); i++)
696 for (
unsigned int j=0; j<inr_c_p_d.dimension(1); j++)
697 for (
unsigned int k=0; k<inr_c_p_d.dimension(2); k++)
698 inr_c_p_d(i,j,k) = Teuchos::ScalarTraits<double>::random();
701 art::contractDataDataVector<double>(out1_c, inl_c_p_d, inr_c_p_d, COMP_CPP);
702 art::contractDataDataVector<double>(out2_c, inl_c_p_d, inr_c_p_d, COMP_BLAS);
704 rst::subtract(out1_c, out2_c);
705 if (rst::vectorNorm(out1_c, NORM_ONE) > zero) {
706 *outStream <<
"\n\nINCORRECT contractDataDataVector (1): check COMP_CPP vs. COMP_BLAS; "
707 <<
" diff-1norm = " << rst::vectorNorm(out1_c, NORM_ONE) <<
"\n\n";
712 Kokkos::deep_copy(out1_c, 2.0);
713 Kokkos::deep_copy(out2_c, 2.0);
715 art::contractDataDataVector<double>(out1_c, inl_c_p_d, inr_c_p_d, COMP_CPP,
true);
716 art::contractDataDataVector<double>(out2_c, inl_c_p_d, inr_c_p_d, COMP_BLAS,
true);
718 rst::subtract(out1_c, out2_c);
719 if (rst::vectorNorm(out1_c, NORM_ONE) > zero) {
720 *outStream <<
"\n\nINCORRECT contractDataDataVector (1): check COMP_CPP vs. COMP_BLAS; "
721 <<
" diff-1norm = " << rst::vectorNorm(out1_c, NORM_ONE) <<
"\n\n";
727 *outStream <<
"\n************ Checking contractDataDataTensor ************\n";
729 int c=5, p=9, d1=13, d2=5;
731 Kokkos::View<double****> inl_c_p_d_d(
"inl_c_p_d_d", c, p, d1, d2);
732 Kokkos::View<double****> inr_c_p_d_d(
"inr_c_p_d_d", c, p, d1, d2);
733 Kokkos::View<double*> out1_c(
"out1_c", c);
734 Kokkos::View<double*> out2_c(
"out2_c", c);
735 double zero = INTREPID_TOL*10000.0;
738 for (
unsigned int i=0; i<inl_c_p_d_d.dimension(0); i++)
739 for (
unsigned int j=0; j<inl_c_p_d_d.dimension(1); j++)
740 for (
unsigned int k=0; k<inl_c_p_d_d.dimension(2); k++)
741 for (
unsigned int l=0; l<inl_c_p_d_d.dimension(3); l++)
742 inl_c_p_d_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
744 for (
unsigned int i=0; i<inr_c_p_d_d.dimension(0); i++)
745 for (
unsigned int j=0; j<inr_c_p_d_d.dimension(1); j++)
746 for (
unsigned int k=0; k<inr_c_p_d_d.dimension(2); k++)
747 for (
unsigned int l=0; l<inr_c_p_d_d.dimension(3); l++)
748 inr_c_p_d_d(i,j,k,l) = Teuchos::ScalarTraits<double>::random();
750 art::contractDataDataTensor<double>(out1_c, inl_c_p_d_d, inr_c_p_d_d, COMP_CPP);
751 art::contractDataDataTensor<double>(out2_c, inl_c_p_d_d, inr_c_p_d_d, COMP_BLAS);
753 rst::subtract(out1_c, out2_c);
754 if (rst::vectorNorm(out1_c, NORM_ONE) > zero) {
755 *outStream <<
"\n\nINCORRECT contractDataDataTensor (1): check COMP_CPP vs. COMP_BLAS; "
756 <<
" diff-1norm = " << rst::vectorNorm(out1_c, NORM_ONE) <<
"\n\n";
761 Kokkos::deep_copy(out1_c, 2.0);
762 Kokkos::deep_copy(out2_c, 2.0);
764 art::contractDataDataTensor<double>(out1_c, inl_c_p_d_d, inr_c_p_d_d, COMP_CPP,
true);
765 art::contractDataDataTensor<double>(out2_c, inl_c_p_d_d, inr_c_p_d_d, COMP_BLAS,
true);
767 rst::subtract(out1_c, out2_c);
768 if (rst::vectorNorm(out1_c, NORM_ONE) > zero) {
769 *outStream <<
"\n\nINCORRECT contractDataDataTensor (1): check COMP_CPP vs. COMP_BLAS; "
770 <<
" diff-1norm = " << rst::vectorNorm(out1_c, NORM_ONE) <<
"\n\n";
778 catch (std::logic_error err) {
779 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
780 *outStream << err.what() <<
'\n';
781 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
787 std::cout <<
"End Result: TEST FAILED\n";
789 std::cout <<
"End Result: TEST PASSED\n";
792 std::cout.copyfmt(oldFormatState);
Header file for utility class to provide multidimensional containers.