From c83334e68e80d689478e44cc99d574b127956942 Mon Sep 17 00:00:00 2001 From: Daniel Garcia-Sanchez Date: Sat, 22 Jun 2019 11:14:34 +0200 Subject: [PATCH] Add test for std::complex cross_product_3d --- tests/tensors/tensor_complex_02.cc | 54 +++++++++++++++++++ ...r_complex_02.with_complex_values=on.output | 4 ++ 2 files changed, 58 insertions(+) create mode 100644 tests/tensors/tensor_complex_02.cc create mode 100644 tests/tensors/tensor_complex_02.with_complex_values=on.output diff --git a/tests/tensors/tensor_complex_02.cc b/tests/tensors/tensor_complex_02.cc new file mode 100644 index 0000000000..b016a42052 --- /dev/null +++ b/tests/tensors/tensor_complex_02.cc @@ -0,0 +1,54 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Based on tensor_complex.cc. It tests cross_product_3d when one tensor is +// std::complex and the other is double. + +#include + +#include + +#include + +#include "../tests.h" + +int +main() +{ + initlog(); + deallog << std::setprecision(3); + + deallog.push("Cross product"); + Tensor<1, 3, std::complex> e1; + Tensor<1, 3, double> e2; + Tensor<1, 3, std::complex> e3; + e1[0] = std::complex(1., 1.); + e2[1] = 1.; + e3[2] = std::complex(1., -1.); + Tensor<1, 3, std::complex> result = cross_product_3d(e1, e2); + deallog << '\t' << result[0] << '\t' << result[1] << '\t' << result[2] + << std::endl; + + result = cross_product_3d(e2, e3); + deallog << '\t' << result[0] << '\t' << result[1] << '\t' << result[2] + << std::endl; + + result = cross_product_3d(e3, e1); + deallog << '\t' << result[0] << '\t' << result[1] << '\t' << result[2] + << std::endl; + + deallog.pop(); +} diff --git a/tests/tensors/tensor_complex_02.with_complex_values=on.output b/tests/tensors/tensor_complex_02.with_complex_values=on.output new file mode 100644 index 0000000000..a979447ec6 --- /dev/null +++ b/tests/tensors/tensor_complex_02.with_complex_values=on.output @@ -0,0 +1,4 @@ + +DEAL:Cross product:: (0.00,0.00) (0.00,0.00) (1.00,1.00) +DEAL:Cross product:: (1.00,-1.00) (0.00,0.00) (0.00,0.00) +DEAL:Cross product:: (0.00,0.00) (2.00,0.00) (0.00,0.00) -- 2.39.5