From 839ace2dbb277517517950d0bbc53f79fa04f3c0 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 16 Aug 2019 10:27:36 -0400 Subject: [PATCH] Fix tests --- .../helper_scalar_coupled_2_components_03.h | 6 +-- tests/ad_common_tests/tensor_functions_01.h | 8 ++-- tests/adolc/tensor_ops_01.cc | 9 ++-- tests/base/full_tensor_06.cc | 2 +- tests/fe/fe_project_3d.cc | 13 ++--- tests/tensors/tensor_09.cc | 47 ------------------- tests/tensors/tensor_09.output | 28 ----------- 7 files changed, 18 insertions(+), 95 deletions(-) diff --git a/tests/ad_common_tests/helper_scalar_coupled_2_components_03.h b/tests/ad_common_tests/helper_scalar_coupled_2_components_03.h index 4fa4e3b923..2e347ed76e 100644 --- a/tests/ad_common_tests/helper_scalar_coupled_2_components_03.h +++ b/tests/ad_common_tests/helper_scalar_coupled_2_components_03.h @@ -43,7 +43,7 @@ struct FunctionsTestTensorScalarCoupled static NumberType psi(const Tensor<2, dim, NumberType> &t, const NumberType &s) { - return double_contract(t, t) * std::pow(s, 3); + return double_contract<0, 0, 1, 1>(t, t) * std::pow(s, 3); }; static Tensor<2, dim, NumberType> @@ -55,7 +55,7 @@ struct FunctionsTestTensorScalarCoupled static NumberType dpsi_ds(const Tensor<2, dim, NumberType> &t, const NumberType &s) { - return 3.0 * double_contract(t, t) * std::pow(s, 2); + return 3.0 * double_contract<0, 0, 1, 1>(t, t) * std::pow(s, 2); }; static Tensor<4, dim, NumberType> @@ -89,7 +89,7 @@ struct FunctionsTestTensorScalarCoupled static NumberType d2psi_ds_ds(const Tensor<2, dim, NumberType> &t, const NumberType &s) { - return 6.0 * double_contract(t, t) * std::pow(s, 1); + return 6.0 * double_contract<0, 0, 1, 1>(t, t) * std::pow(s, 1); }; }; diff --git a/tests/ad_common_tests/tensor_functions_01.h b/tests/ad_common_tests/tensor_functions_01.h index c234d0ff65..e00e044980 100644 --- a/tests/ad_common_tests/tensor_functions_01.h +++ b/tests/ad_common_tests/tensor_functions_01.h @@ -64,10 +64,10 @@ test_tensor() const ADNumberType A_l1_norm = l1_norm(A); const ADNumberType A_linf_norm = linfty_norm(A); - const ADNumberType A_ddot_B = double_contract(A, B); - const Tensor<2, dim, ADNumberType> A_dot_B = contract<1, 0>(A, B); - const ADNumberType sp_A_B = scalar_product(A, B); - const Tensor<4, dim, ADNumberType> op_A_B = outer_product(A, B); + const ADNumberType A_ddot_B = double_contract<0, 0, 1, 1>(A, B); + const Tensor<2, dim, ADNumberType> A_dot_B = contract<1, 0>(A, B); + const ADNumberType sp_A_B = scalar_product(A, B); + const Tensor<4, dim, ADNumberType> op_A_B = outer_product(A, B); if (dim == 2) const Tensor<1, dim, ADNumberType> v3 = cross_product_2d(v1); diff --git a/tests/adolc/tensor_ops_01.cc b/tests/adolc/tensor_ops_01.cc index 6e14dc36b7..9ca2dcc675 100644 --- a/tests/adolc/tensor_ops_01.cc +++ b/tests/adolc/tensor_ops_01.cc @@ -81,10 +81,11 @@ test_tensor() // Contractions const ad_number_t ad_res1 = scalar_product(adt1, adt2); - const ad_number_t ad_res2 = double_contract(adt1, adt2); - // ad_res1 = double_contract(adt1,t1); // TODO: Not defined. Conflicting - // number types ad_res1 = double_contract(t1,adt2); // TODO: Not defined. - // Conflicting number types + const ad_number_t ad_res2 = double_contract<0, 0, 1, 1>(adt1, adt2); + // TODO: Not defined. Conflicting number types + // ad_res1 = double_contract(adt1,t1); + // TODO: Not defined. Conflicting number types + // ad_res1 = double_contract(t1,adt2); AD_Tensor adt7 = adt1 * adt2; adt7 = t1 * adt2; adt7 = adt1 * t1; diff --git a/tests/base/full_tensor_06.cc b/tests/base/full_tensor_06.cc index ada7f19766..1502cb66dc 100644 --- a/tests/base/full_tensor_06.cc +++ b/tests/base/full_tensor_06.cc @@ -63,7 +63,7 @@ test() } bs[i][j] = tmp_ij; } - double_contract(ba, ta, aa); + ba = double_contract<2, 0, 3, 1>(ta, aa); for (unsigned int i = 0; i < dim; ++i) for (unsigned int j = 0; j < dim; ++j) diff --git a/tests/fe/fe_project_3d.cc b/tests/fe/fe_project_3d.cc index 66cd5cb2d9..9f603b775a 100644 --- a/tests/fe/fe_project_3d.cc +++ b/tests/fe/fe_project_3d.cc @@ -362,9 +362,7 @@ test(const FiniteElement &fe, n_x_v[0] = (-normal[1] * face_values[q_point][0] + normal[0] * face_values[q_point][1]); else if (dim == 3) - cross_product(*reinterpret_cast *>(&n_x_v), - normal, - face_values[q_point]); + n_x_v = cross_product_3d(normal, face_values[q_point]); if (cell->at_boundary(face)) boundary_tangentials += face_JxW_values[q_point] * n_x_v; @@ -374,11 +372,10 @@ test(const FiniteElement &fe, // boundary curl curl traces if (dim == 3) { - Tensor<1, dim> n_x_curl_u; - cross_product(n_x_curl_u, - normal, - *reinterpret_cast *>( - &face_curls[q_point])); + Tensor<1, dim> n_x_curl_u = + cross_product_3d(normal, + *reinterpret_cast *>( + &face_curls[q_point])); if (cell->at_boundary(face)) boundary_curl_curl_traces += face_JxW_values[q_point] * n_x_curl_u; diff --git a/tests/tensors/tensor_09.cc b/tests/tensors/tensor_09.cc index 4376d55ac8..6793df1040 100644 --- a/tests/tensors/tensor_09.cc +++ b/tests/tensors/tensor_09.cc @@ -49,84 +49,37 @@ main() // rank3 * rank1 over all possible indices: { - Tensor<2, 3, int> result; - deallog << contract<0, 0>(rank3, rank1) << std::endl; - contract(result, rank3, 1, rank1); - deallog << result << std::endl << std::endl; - deallog << contract<1, 0>(rank3, rank1) << std::endl; - contract(result, rank3, 2, rank1); - deallog << result << std::endl << std::endl; - deallog << contract<2, 0>(rank3, rank1) << std::endl; - contract(result, rank3, 3, rank1); - deallog << result << std::endl << std::endl; } // rank2 * rank2 over all possible indices: { - Tensor<2, 3, int> result; - deallog << contract<0, 0>(rank2, rank2) << std::endl; - contract(result, rank2, 1, rank2, 1); - deallog << result << std::endl << std::endl; - deallog << contract<1, 0>(rank2, rank2) << std::endl; - contract(result, rank2, 2, rank2, 1); - deallog << result << std::endl << std::endl; - deallog << contract<0, 1>(rank2, rank2) << std::endl; - contract(result, rank2, 1, rank2, 2); - deallog << result << std::endl << std::endl; - deallog << contract<1, 1>(rank2, rank2) << std::endl; - contract(result, rank2, 2, rank2, 2); - deallog << result << std::endl << std::endl; } // rank3 * rank2 over all possible indices: { - Tensor<3, 3, int> result; - deallog << contract<0, 0>(rank3, rank2) << std::endl; - contract(result, rank3, 1, rank2, 1); - deallog << result << std::endl << std::endl; - deallog << contract<1, 0>(rank3, rank2) << std::endl; - contract(result, rank3, 2, rank2, 1); - deallog << result << std::endl << std::endl; - deallog << contract<2, 0>(rank3, rank2) << std::endl; - contract(result, rank3, 3, rank2, 1); - deallog << result << std::endl << std::endl; - deallog << contract<0, 1>(rank3, rank2) << std::endl; - contract(result, rank3, 1, rank2, 2); - deallog << result << std::endl << std::endl; - deallog << contract<1, 1>(rank3, rank2) << std::endl; - contract(result, rank3, 2, rank2, 2); - deallog << result << std::endl << std::endl; - deallog << contract<2, 1>(rank3, rank2) << std::endl; - contract(result, rank3, 3, rank2, 2); - deallog << result << std::endl << std::endl; } // rank4 ** rank2, double contraction: { - Tensor<2, 3, int> result; - deallog << double_contract<2, 0, 3, 1>(rank4, rank2) << std::endl; deallog << double_contract<3, 1, 2, 0>(rank4, rank2) << std::endl; deallog << double_contract<0, 2, 1, 3>(rank2, rank4) << std::endl; deallog << double_contract<1, 3, 0, 2>(rank2, rank4) << std::endl; - - double_contract(result, rank4, rank2); - deallog << result << std::endl << std::endl; } } diff --git a/tests/tensors/tensor_09.output b/tests/tensors/tensor_09.output index 993e7d6f6c..c7219f45a0 100644 --- a/tests/tensors/tensor_09.output +++ b/tests/tensors/tensor_09.output @@ -1,46 +1,18 @@ DEAL::220 440 880 110 220 440 55 110 220 -DEAL::220 440 880 110 220 440 55 110 220 -DEAL:: -DEAL::84 168 336 72 144 288 108 216 432 DEAL::84 168 336 72 144 288 108 216 432 -DEAL:: DEAL::588 294 147 504 252 126 756 378 189 -DEAL::588 294 147 504 252 126 756 378 189 -DEAL:: -DEAL::21 42 84 42 84 168 84 168 336 DEAL::21 42 84 42 84 168 84 168 336 -DEAL:: DEAL::48 96 192 24 48 96 12 24 48 -DEAL::48 96 192 24 48 96 12 24 48 -DEAL:: -DEAL::48 24 12 96 48 24 192 96 48 DEAL::48 24 12 96 48 24 192 96 48 -DEAL:: -DEAL::336 168 84 168 84 42 84 42 21 DEAL::336 168 84 168 84 42 84 42 21 -DEAL:: DEAL::196 392 784 392 784 1568 784 1568 3136 98 196 392 196 392 784 392 784 1568 49 98 196 98 196 392 196 392 784 -DEAL::196 392 784 392 784 1568 784 1568 3136 98 196 392 196 392 784 392 784 1568 49 98 196 98 196 392 196 392 784 -DEAL:: -DEAL::147 294 588 294 588 1176 588 1176 2352 126 252 504 252 504 1008 504 1008 2016 189 378 756 378 756 1512 756 1512 3024 DEAL::147 294 588 294 588 1176 588 1176 2352 126 252 504 252 504 1008 504 1008 2016 189 378 756 378 756 1512 756 1512 3024 -DEAL:: DEAL::336 672 1344 168 336 672 84 168 336 288 576 1152 144 288 576 72 144 288 432 864 1728 216 432 864 108 216 432 -DEAL::336 672 1344 168 336 672 84 168 336 288 576 1152 144 288 576 72 144 288 432 864 1728 216 432 864 108 216 432 -DEAL:: -DEAL::880 440 220 1760 880 440 3520 1760 880 440 220 110 880 440 220 1760 880 440 220 110 55 440 220 110 880 440 220 DEAL::880 440 220 1760 880 440 3520 1760 880 440 220 110 880 440 220 1760 880 440 220 110 55 440 220 110 880 440 220 -DEAL:: DEAL::336 168 84 672 336 168 1344 672 336 288 144 72 576 288 144 1152 576 288 432 216 108 864 432 216 1728 864 432 -DEAL::336 168 84 672 336 168 1344 672 336 288 144 72 576 288 144 1152 576 288 432 216 108 864 432 216 1728 864 432 -DEAL:: -DEAL::2352 1176 588 1176 588 294 588 294 147 2016 1008 504 1008 504 252 504 252 126 3024 1512 756 1512 756 378 756 378 189 DEAL::2352 1176 588 1176 588 294 588 294 147 2016 1008 504 1008 504 252 504 252 126 3024 1512 756 1512 756 378 756 378 189 -DEAL:: -DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938 DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938 DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938 DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938 DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938 -DEAL:: -- 2.39.5