From: Peter Munch Date: Mon, 17 May 2021 13:17:04 +0000 (+0200) Subject: Test new methods of n_vector X-Git-Tag: v9.3.0-rc1~49^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12229%2Fhead;p=dealii.git Test new methods of n_vector --- diff --git a/tests/sundials/n_vector.cc b/tests/sundials/n_vector.cc index 1a9a2697c3..ab5d1b4c32 100644 --- a/tests/sundials/n_vector.cc +++ b/tests/sundials/n_vector.cc @@ -229,7 +229,7 @@ test_nvector_view_unwrap() unwrap_nvector(const_n_vector); Assert(false, NVectorTestError()); } - catch (ExcMessage e) + catch (const ExcMessage &e) { const std::string msg(e.what()); Assert(msg.find( @@ -612,6 +612,30 @@ test_weighted_rms_norm_mask() +template +void +test_weighted_l2_norm() +{ + const auto vector_a = create_test_vector(2.0); + const auto vector_b = create_test_vector(3.0); + + auto nv_a = make_nvector_view(vector_a); + auto nv_b = make_nvector_view(vector_b); + + const auto result = N_VWL2Norm(nv_a, nv_b); + + auto vector_a_reference = create_test_vector(2.0); + auto vector_b_reference = create_test_vector(3.0); + vector_a_reference.scale(vector_b_reference); + const auto result_reference = vector_a_reference.l2_norm(); + + Assert(std::fabs(result - result_reference) < 1e-12, NVectorTestError()); + + deallog << "test_weighted_l2_norm OK" << std::endl; +} + + + template void test_max_norm() @@ -633,6 +657,27 @@ test_max_norm() +template +void +test_l1_norm() +{ + const auto vector_a = create_test_vector(2.0); + const auto vector_b = create_test_vector(-3.0); + + auto nv_a = make_nvector_view(vector_a); + auto nv_b = make_nvector_view(vector_b); + + auto result = N_VL1Norm(nv_a); + Assert(std::fabs(result - vector_a.l1_norm()) < 1e-12, NVectorTestError()); + + result = N_VL1Norm(nv_b); + Assert(std::fabs(result - vector_b.l1_norm()) < 1e-12, NVectorTestError()); + + deallog << "test_l1_norm OK" << std::endl; +} + + + template void test_min_element() @@ -702,7 +747,9 @@ run_all_tests(const std::string &prefix) test_elementwise_abs(); test_weighted_rms_norm(); test_weighted_rms_norm_mask(); + test_weighted_l2_norm(); test_max_norm(); + test_l1_norm(); test_min_element(); test_scale(); } diff --git a/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_mpi=true.mpirun=2.with_trilinos=true.with_petsc=true.output b/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_mpi=true.mpirun=2.with_trilinos=true.with_petsc=true.output index 1ff8003c1c..327f8d85a7 100644 --- a/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_mpi=true.mpirun=2.with_trilinos=true.with_petsc=true.output +++ b/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_mpi=true.mpirun=2.with_trilinos=true.with_petsc=true.output @@ -16,7 +16,9 @@ DEAL:0:Vector::test_elementwise_abs OK DEAL:0:Vector::test_weighted_rms_norm OK DEAL:0:Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:Vector::test_weighted_l2_norm OK DEAL:0:Vector::test_max_norm OK +DEAL:0:Vector::test_l1_norm OK DEAL:0:Vector::test_min_element OK DEAL:0:Vector::test_scale OK DEAL:0:BlockVector::test_nvector_view_unwrap OK @@ -36,7 +38,9 @@ DEAL:0:BlockVector::test_elementwise_abs OK DEAL:0:BlockVector::test_weighted_rms_norm OK DEAL:0:BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:BlockVector::test_weighted_l2_norm OK DEAL:0:BlockVector::test_max_norm OK +DEAL:0:BlockVector::test_l1_norm OK DEAL:0:BlockVector::test_min_element OK DEAL:0:BlockVector::test_scale OK DEAL:0:LinearAlgebra::distributed::Vector::test_nvector_view_unwrap OK @@ -56,7 +60,9 @@ DEAL:0:LinearAlgebra::distributed::Vector::test_elementwise_abs OK DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_rms_norm OK DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_l2_norm OK DEAL:0:LinearAlgebra::distributed::Vector::test_max_norm OK +DEAL:0:LinearAlgebra::distributed::Vector::test_l1_norm OK DEAL:0:LinearAlgebra::distributed::Vector::test_min_element OK DEAL:0:LinearAlgebra::distributed::Vector::test_scale OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_nvector_view_unwrap OK @@ -76,7 +82,9 @@ DEAL:0:LinearAlgebra::distributed::BlockVector::test_elementwise_abs OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_l2_norm OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_max_norm OK +DEAL:0:LinearAlgebra::distributed::BlockVector::test_l1_norm OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_min_element OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_scale OK DEAL:0:TrilinosWrappers::MPI::Vector::test_nvector_view_unwrap OK @@ -96,7 +104,9 @@ DEAL:0:TrilinosWrappers::MPI::Vector::test_elementwise_abs OK DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm OK DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_l2_norm OK DEAL:0:TrilinosWrappers::MPI::Vector::test_max_norm OK +DEAL:0:TrilinosWrappers::MPI::Vector::test_l1_norm OK DEAL:0:TrilinosWrappers::MPI::Vector::test_min_element OK DEAL:0:TrilinosWrappers::MPI::Vector::test_scale OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_nvector_view_unwrap OK @@ -116,7 +126,9 @@ DEAL:0:TrilinosWrappers::MPI::BlockVector::test_elementwise_abs OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_l2_norm OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_max_norm OK +DEAL:0:TrilinosWrappers::MPI::BlockVector::test_l1_norm OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_min_element OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_scale OK DEAL:0:PETScWrappers::MPI::Vector::test_nvector_view_unwrap OK @@ -136,7 +148,9 @@ DEAL:0:PETScWrappers::MPI::Vector::test_elementwise_abs OK DEAL:0:PETScWrappers::MPI::Vector::test_weighted_rms_norm OK DEAL:0:PETScWrappers::MPI::Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:PETScWrappers::MPI::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:PETScWrappers::MPI::Vector::test_weighted_l2_norm OK DEAL:0:PETScWrappers::MPI::Vector::test_max_norm OK +DEAL:0:PETScWrappers::MPI::Vector::test_l1_norm OK DEAL:0:PETScWrappers::MPI::Vector::test_min_element OK DEAL:0:PETScWrappers::MPI::Vector::test_scale OK DEAL:0:PETScWrappers::MPI::BlockVector::test_nvector_view_unwrap OK @@ -156,7 +170,9 @@ DEAL:0:PETScWrappers::MPI::BlockVector::test_elementwise_abs OK DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm OK DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_l2_norm OK DEAL:0:PETScWrappers::MPI::BlockVector::test_max_norm OK +DEAL:0:PETScWrappers::MPI::BlockVector::test_l1_norm OK DEAL:0:PETScWrappers::MPI::BlockVector::test_min_element OK DEAL:0:PETScWrappers::MPI::BlockVector::test_scale OK @@ -177,7 +193,9 @@ DEAL:1:Vector::test_elementwise_abs OK DEAL:1:Vector::test_weighted_rms_norm OK DEAL:1:Vector::test_weighted_rms_norm_mask 1 OK DEAL:1:Vector::test_weighted_rms_norm_mask 0 OK +DEAL:1:Vector::test_weighted_l2_norm OK DEAL:1:Vector::test_max_norm OK +DEAL:1:Vector::test_l1_norm OK DEAL:1:Vector::test_min_element OK DEAL:1:Vector::test_scale OK DEAL:1:BlockVector::test_nvector_view_unwrap OK @@ -197,7 +215,9 @@ DEAL:1:BlockVector::test_elementwise_abs OK DEAL:1:BlockVector::test_weighted_rms_norm OK DEAL:1:BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:1:BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:1:BlockVector::test_weighted_l2_norm OK DEAL:1:BlockVector::test_max_norm OK +DEAL:1:BlockVector::test_l1_norm OK DEAL:1:BlockVector::test_min_element OK DEAL:1:BlockVector::test_scale OK DEAL:1:LinearAlgebra::distributed::Vector::test_nvector_view_unwrap OK @@ -217,7 +237,9 @@ DEAL:1:LinearAlgebra::distributed::Vector::test_elementwise_abs OK DEAL:1:LinearAlgebra::distributed::Vector::test_weighted_rms_norm OK DEAL:1:LinearAlgebra::distributed::Vector::test_weighted_rms_norm_mask 1 OK DEAL:1:LinearAlgebra::distributed::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:1:LinearAlgebra::distributed::Vector::test_weighted_l2_norm OK DEAL:1:LinearAlgebra::distributed::Vector::test_max_norm OK +DEAL:1:LinearAlgebra::distributed::Vector::test_l1_norm OK DEAL:1:LinearAlgebra::distributed::Vector::test_min_element OK DEAL:1:LinearAlgebra::distributed::Vector::test_scale OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_nvector_view_unwrap OK @@ -237,7 +259,9 @@ DEAL:1:LinearAlgebra::distributed::BlockVector::test_elementwise_abs OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:1:LinearAlgebra::distributed::BlockVector::test_weighted_l2_norm OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_max_norm OK +DEAL:1:LinearAlgebra::distributed::BlockVector::test_l1_norm OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_min_element OK DEAL:1:LinearAlgebra::distributed::BlockVector::test_scale OK DEAL:1:TrilinosWrappers::MPI::Vector::test_nvector_view_unwrap OK @@ -257,7 +281,9 @@ DEAL:1:TrilinosWrappers::MPI::Vector::test_elementwise_abs OK DEAL:1:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm OK DEAL:1:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm_mask 1 OK DEAL:1:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:1:TrilinosWrappers::MPI::Vector::test_weighted_l2_norm OK DEAL:1:TrilinosWrappers::MPI::Vector::test_max_norm OK +DEAL:1:TrilinosWrappers::MPI::Vector::test_l1_norm OK DEAL:1:TrilinosWrappers::MPI::Vector::test_min_element OK DEAL:1:TrilinosWrappers::MPI::Vector::test_scale OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_nvector_view_unwrap OK @@ -277,7 +303,9 @@ DEAL:1:TrilinosWrappers::MPI::BlockVector::test_elementwise_abs OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:1:TrilinosWrappers::MPI::BlockVector::test_weighted_l2_norm OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_max_norm OK +DEAL:1:TrilinosWrappers::MPI::BlockVector::test_l1_norm OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_min_element OK DEAL:1:TrilinosWrappers::MPI::BlockVector::test_scale OK DEAL:1:PETScWrappers::MPI::Vector::test_nvector_view_unwrap OK @@ -297,7 +325,9 @@ DEAL:1:PETScWrappers::MPI::Vector::test_elementwise_abs OK DEAL:1:PETScWrappers::MPI::Vector::test_weighted_rms_norm OK DEAL:1:PETScWrappers::MPI::Vector::test_weighted_rms_norm_mask 1 OK DEAL:1:PETScWrappers::MPI::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:1:PETScWrappers::MPI::Vector::test_weighted_l2_norm OK DEAL:1:PETScWrappers::MPI::Vector::test_max_norm OK +DEAL:1:PETScWrappers::MPI::Vector::test_l1_norm OK DEAL:1:PETScWrappers::MPI::Vector::test_min_element OK DEAL:1:PETScWrappers::MPI::Vector::test_scale OK DEAL:1:PETScWrappers::MPI::BlockVector::test_nvector_view_unwrap OK @@ -317,7 +347,9 @@ DEAL:1:PETScWrappers::MPI::BlockVector::test_elementwise_abs OK DEAL:1:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm OK DEAL:1:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:1:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:1:PETScWrappers::MPI::BlockVector::test_weighted_l2_norm OK DEAL:1:PETScWrappers::MPI::BlockVector::test_max_norm OK +DEAL:1:PETScWrappers::MPI::BlockVector::test_l1_norm OK DEAL:1:PETScWrappers::MPI::BlockVector::test_min_element OK DEAL:1:PETScWrappers::MPI::BlockVector::test_scale OK diff --git a/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_trilinos=true.with_petsc=true.output b/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_trilinos=true.with_petsc=true.output index ec2624d748..36ed4bc06b 100644 --- a/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_trilinos=true.with_petsc=true.output +++ b/tests/sundials/n_vector.with_sundials.geq.5.0.0.with_trilinos=true.with_petsc=true.output @@ -16,7 +16,9 @@ DEAL:0:Vector::test_elementwise_abs OK DEAL:0:Vector::test_weighted_rms_norm OK DEAL:0:Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:Vector::test_weighted_l2_norm OK DEAL:0:Vector::test_max_norm OK +DEAL:0:Vector::test_l1_norm OK DEAL:0:Vector::test_min_element OK DEAL:0:Vector::test_scale OK DEAL:0:BlockVector::test_nvector_view_unwrap OK @@ -36,7 +38,9 @@ DEAL:0:BlockVector::test_elementwise_abs OK DEAL:0:BlockVector::test_weighted_rms_norm OK DEAL:0:BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:BlockVector::test_weighted_l2_norm OK DEAL:0:BlockVector::test_max_norm OK +DEAL:0:BlockVector::test_l1_norm OK DEAL:0:BlockVector::test_min_element OK DEAL:0:BlockVector::test_scale OK DEAL:0:LinearAlgebra::distributed::Vector::test_nvector_view_unwrap OK @@ -56,7 +60,9 @@ DEAL:0:LinearAlgebra::distributed::Vector::test_elementwise_abs OK DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_rms_norm OK DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:LinearAlgebra::distributed::Vector::test_weighted_l2_norm OK DEAL:0:LinearAlgebra::distributed::Vector::test_max_norm OK +DEAL:0:LinearAlgebra::distributed::Vector::test_l1_norm OK DEAL:0:LinearAlgebra::distributed::Vector::test_min_element OK DEAL:0:LinearAlgebra::distributed::Vector::test_scale OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_nvector_view_unwrap OK @@ -76,7 +82,9 @@ DEAL:0:LinearAlgebra::distributed::BlockVector::test_elementwise_abs OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:LinearAlgebra::distributed::BlockVector::test_weighted_l2_norm OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_max_norm OK +DEAL:0:LinearAlgebra::distributed::BlockVector::test_l1_norm OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_min_element OK DEAL:0:LinearAlgebra::distributed::BlockVector::test_scale OK DEAL:0:TrilinosWrappers::MPI::Vector::test_nvector_view_unwrap OK @@ -96,7 +104,9 @@ DEAL:0:TrilinosWrappers::MPI::Vector::test_elementwise_abs OK DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm OK DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:TrilinosWrappers::MPI::Vector::test_weighted_l2_norm OK DEAL:0:TrilinosWrappers::MPI::Vector::test_max_norm OK +DEAL:0:TrilinosWrappers::MPI::Vector::test_l1_norm OK DEAL:0:TrilinosWrappers::MPI::Vector::test_min_element OK DEAL:0:TrilinosWrappers::MPI::Vector::test_scale OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_nvector_view_unwrap OK @@ -116,7 +126,9 @@ DEAL:0:TrilinosWrappers::MPI::BlockVector::test_elementwise_abs OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:TrilinosWrappers::MPI::BlockVector::test_weighted_l2_norm OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_max_norm OK +DEAL:0:TrilinosWrappers::MPI::BlockVector::test_l1_norm OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_min_element OK DEAL:0:TrilinosWrappers::MPI::BlockVector::test_scale OK DEAL:0:PETScWrappers::MPI::Vector::test_nvector_view_unwrap OK @@ -136,7 +148,9 @@ DEAL:0:PETScWrappers::MPI::Vector::test_elementwise_abs OK DEAL:0:PETScWrappers::MPI::Vector::test_weighted_rms_norm OK DEAL:0:PETScWrappers::MPI::Vector::test_weighted_rms_norm_mask 1 OK DEAL:0:PETScWrappers::MPI::Vector::test_weighted_rms_norm_mask 0 OK +DEAL:0:PETScWrappers::MPI::Vector::test_weighted_l2_norm OK DEAL:0:PETScWrappers::MPI::Vector::test_max_norm OK +DEAL:0:PETScWrappers::MPI::Vector::test_l1_norm OK DEAL:0:PETScWrappers::MPI::Vector::test_min_element OK DEAL:0:PETScWrappers::MPI::Vector::test_scale OK DEAL:0:PETScWrappers::MPI::BlockVector::test_nvector_view_unwrap OK @@ -156,6 +170,8 @@ DEAL:0:PETScWrappers::MPI::BlockVector::test_elementwise_abs OK DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm OK DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 1 OK DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_rms_norm_mask 0 OK +DEAL:0:PETScWrappers::MPI::BlockVector::test_weighted_l2_norm OK DEAL:0:PETScWrappers::MPI::BlockVector::test_max_norm OK +DEAL:0:PETScWrappers::MPI::BlockVector::test_l1_norm OK DEAL:0:PETScWrappers::MPI::BlockVector::test_min_element OK DEAL:0:PETScWrappers::MPI::BlockVector::test_scale OK