From 1cb393edebd869ea370d25c7489aaf3c10308282 Mon Sep 17 00:00:00 2001 From: Jiaqi Zhang Date: Wed, 13 Apr 2022 10:32:22 -0400 Subject: [PATCH] address comments --- include/deal.II/fe/fe_interface_values.h | 100 ++++---------------- tests/feinterface/fe_interface_values_10.cc | 6 +- 2 files changed, 20 insertions(+), 86 deletions(-) diff --git a/include/deal.II/fe/fe_interface_values.h b/include/deal.II/fe/fe_interface_values.h index 543a8c8a44..3dd232ff74 100644 --- a/include/deal.II/fe/fe_interface_values.h +++ b/include/deal.II/fe/fe_interface_values.h @@ -2844,16 +2844,8 @@ FEInterfaceValues::get_jump_in_function_values( { AssertDimension(values.size(), n_quadrature_points); - std::vector values_0(n_quadrature_points); - std::vector values_1(n_quadrature_points); - - get_fe_face_values(0).get_function_values(fe_function, values_0); - get_fe_face_values(1).get_function_values(fe_function, values_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - values[q] = values_0[q] - values_1[q]; - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_jump_in_function_values(fe_function, values); } @@ -2868,18 +2860,9 @@ FEInterfaceValues::get_jump_in_function_gradients( { AssertDimension(gradients.size(), n_quadrature_points); - std::vector> - gradients_0(n_quadrature_points); - std::vector> - gradients_1(n_quadrature_points); - - get_fe_face_values(0).get_function_gradients(fe_function, gradients_0); - get_fe_face_values(1).get_function_gradients(fe_function, gradients_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - gradients[q] = gradients_0[q] - gradients_1[q]; - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_jump_in_function_gradients(fe_function, + gradients); } @@ -2894,18 +2877,8 @@ FEInterfaceValues::get_jump_in_function_hessians( { AssertDimension(hessians.size(), n_quadrature_points); - std::vector> hessians_0( - n_quadrature_points); - std::vector> hessians_1( - n_quadrature_points); - - get_fe_face_values(0).get_function_hessians(fe_function, hessians_0); - get_fe_face_values(1).get_function_hessians(fe_function, hessians_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - hessians[q] = (hessians_0[q] - hessians_1[q]); - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_jump_in_function_hessians(fe_function, hessians); } @@ -2920,20 +2893,9 @@ FEInterfaceValues::get_jump_in_function_third_derivatives( { AssertDimension(third_derivatives.size(), n_quadrature_points); - std::vector> - third_derivatives_0(n_quadrature_points); - std::vector> - third_derivatives_1(n_quadrature_points); - - get_fe_face_values(0).get_function_third_derivatives(fe_function, - third_derivatives_0); - get_fe_face_values(1).get_function_third_derivatives(fe_function, - third_derivatives_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - third_derivatives[q] = (third_derivatives_0[q] - third_derivatives_1[q]); - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_jump_in_function_third_derivatives( + fe_function, third_derivatives); } @@ -2947,16 +2909,8 @@ FEInterfaceValues::get_average_of_function_values( { AssertDimension(values.size(), n_quadrature_points); - std::vector values_0(n_quadrature_points); - std::vector values_1(n_quadrature_points); - - get_fe_face_values(0).get_function_values(fe_function, values_0); - get_fe_face_values(1).get_function_values(fe_function, values_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - values[q] = (values_0[q] + values_1[q]) * 0.5; - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_average_of_function_values(fe_function, values); } @@ -2971,18 +2925,9 @@ FEInterfaceValues::get_average_of_function_gradients( { AssertDimension(gradients.size(), n_quadrature_points); - std::vector> - gradients_0(n_quadrature_points); - std::vector> - gradients_1(n_quadrature_points); - - get_fe_face_values(0).get_function_gradients(fe_function, gradients_0); - get_fe_face_values(1).get_function_gradients(fe_function, gradients_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - gradients[q] = (gradients_0[q] + gradients_1[q]) * 0.5; - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_average_of_function_gradients(fe_function, + gradients); } @@ -2997,18 +2942,9 @@ FEInterfaceValues::get_average_of_function_hessians( { AssertDimension(hessians.size(), n_quadrature_points); - std::vector> hessians_0( - n_quadrature_points); - std::vector> hessians_1( - n_quadrature_points); - - get_fe_face_values(0).get_function_hessians(fe_function, hessians_0); - get_fe_face_values(1).get_function_hessians(fe_function, hessians_1); - - for (unsigned int q = 0; q < n_quadrature_points; ++q) - { - hessians[q] = (hessians_0[q] + hessians_1[q]) * 0.5; - } + const FEValuesExtractors::Scalar scalar(0); + this->operator[](scalar).get_average_of_function_hessians(fe_function, + hessians); } diff --git a/tests/feinterface/fe_interface_values_10.cc b/tests/feinterface/fe_interface_values_10.cc index a41c770636..49bfccb751 100644 --- a/tests/feinterface/fe_interface_values_10.cc +++ b/tests/feinterface/fe_interface_values_10.cc @@ -161,7 +161,7 @@ test() std::vector> average_of_3rd_derivatives(n_face_q_points); std::vector> exact_average_of_3rd_derivatives(n_face_q_points); - const double tol = 1e-11; + const double tol = 1e-15; typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(); @@ -244,15 +244,13 @@ main(int argc, char **argv) { initlog(); - Utilities::MPI::MPI_InitFinalize mpi_initialization( - argc, argv, testing_max_num_threads()); - deallog.push("Test jump in function values"); { test_jump_function(); } deallog.pop(); deallog << "OK" << std::endl; + deallog.push("Test all functions"); { test(); -- 2.39.5