From ff6d82b0163d218385d66a8e0efdfea06bdc8463 Mon Sep 17 00:00:00 2001 From: Ralf Hartmann Date: Tue, 8 May 2001 10:02:47 +0000 Subject: [PATCH] Implementation of tests for the new FE::shape_value, shape_grad and shape_grad_grad functions. git-svn-id: https://svn.dealii.org/trunk@4561 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/fe/shapes.cc | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/fe/shapes.cc b/tests/fe/shapes.cc index 952e7190b7..1bde5701aa 100644 --- a/tests/fe/shapes.cc +++ b/tests/fe/shapes.cc @@ -161,6 +161,69 @@ void plot_face_shape_functions (Mapping<1>&, {} +template +void test_compute_functions (const Mapping &mapping, + const FiniteElement &fe, + const char* name) +{ + Triangulation tr; + DoFHandler dof(tr); + GridGenerator::hyper_cube(tr, 0., 1.); + dof.distribute_dofs(fe); + const QGauss6 q; + FEValues fe_values(mapping, fe, q, UpdateFlags(update_values| + update_gradients| + update_second_derivatives)); + DoFHandler::active_cell_iterator cell = dof.begin_active(); + fe_values.reinit(cell); + + bool coincide=true; + for (unsigned int x=0; x1e-14) + coincide=false; + + if (!coincide) + deallog << "Error in fe.shape_value for " << name << endl; + + coincide=true; + for (unsigned int x=0; x tmp=fe_values.shape_grad(i,x); + tmp-=fe.shape_grad(i,q.point(x)); + if (sqrt(tmp*tmp)>1e-14) + coincide=false; + } + + if (!coincide) + deallog << "Error in fe.shape_grad for " << name << endl; + + coincide=true; + double max_diff=0.; + for (unsigned int x=0; x tmp=fe_values.shape_2nd_derivative(i,x); + tmp-=fe.shape_grad_grad(i,q.point(x)); + for (unsigned int j=0; jmax_diff) max_diff=diff; + if (fabs(tmp[j][k])>1e-6) + coincide=false; + } + + } + + if (!coincide) + deallog << "Error in fe.shape_grad_grad for " << name << endl + << "max_diff=" << max_diff << endl; +} + + + template void plot_FE_Q_shape_functions() { @@ -168,15 +231,19 @@ void plot_FE_Q_shape_functions() FE_Q q1(1); plot_shape_functions(m, q1, "Q1"); plot_face_shape_functions(m, q1, "Q1"); + test_compute_functions(m, q1, "Q1"); FE_Q q2(2); plot_shape_functions(m, q2, "Q2"); plot_face_shape_functions(m, q2, "Q2"); + test_compute_functions(m, q2, "Q2"); FE_Q q3(3); plot_shape_functions(m, q3, "Q3"); plot_face_shape_functions(m, q3, "Q3"); + test_compute_functions(m, q3, "Q3"); FE_Q q4(4); plot_shape_functions(m, q4, "Q4"); plot_face_shape_functions(m, q4, "Q4"); + test_compute_functions(m, q4, "Q4"); // FE_Q q5(5); // plot_shape_functions(m, q5, "Q5"); // FE_Q q6(6); @@ -199,15 +266,19 @@ void plot_FE_DGQ_shape_functions() FE_DGQ q1(1); plot_shape_functions(m, q1, "DGQ1"); plot_face_shape_functions(m, q1, "DGQ1"); + test_compute_functions(m, q1, "DGQ1"); FE_DGQ q2(2); plot_shape_functions(m, q2, "DGQ2"); plot_face_shape_functions(m, q2, "DGQ2"); + test_compute_functions(m, q2, "DGQ2"); FE_DGQ q3(3); plot_shape_functions(m, q3, "DGQ3"); plot_face_shape_functions(m, q3, "DGQ3"); + test_compute_functions(m, q3, "DGQ3"); FE_DGQ q4(4); plot_shape_functions(m, q4, "DGQ4"); plot_face_shape_functions(m, q4, "DGQ4"); + test_compute_functions(m, q4, "DGQ4"); // FE_DGQ q5(5); // plot_shape_functions(m, q5, "DGQ5"); // FE_DGQ q6(6); @@ -241,6 +312,7 @@ main() MappingQ1<2> m; FESystem<2> q2_q3(FE_Q<2>(2), 1, FE_Q<2>(3), 1); + test_compute_functions(m, q2_q3, "Q2_Q3"); // plot_shape_functions(m, q2_q3, "Q2_Q3"); return 0; -- 2.39.5