From 677299565b78944abf769c55f85b2d7d7c16ad52 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 24 Jan 2017 20:28:06 -0700 Subject: [PATCH] Add a test for the ABF element in 3d. --- tests/fe/abf_02.cc | 557 +++++++++++++++++++++++++++++++++++++++++ tests/fe/abf_02.output | 235 +++++++++++++++++ 2 files changed, 792 insertions(+) create mode 100644 tests/fe/abf_02.cc create mode 100644 tests/fe/abf_02.output diff --git a/tests/fe/abf_02.cc b/tests/fe/abf_02.cc new file mode 100644 index 0000000000..c8de43aee1 --- /dev/null +++ b/tests/fe/abf_02.cc @@ -0,0 +1,557 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// Check that we can generate an ABF(0) element in 3d. There used to +// be a number of exceptions that happened when one tried, so this +// test verifies that that no longer happens. +// +// The test projects a function into the space and checks that the +// error is zero (given that the function itself is inside the space +// -- in fact, it is a constant) + +#include "../tests.h" +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + + + + +/* + * Check the value of the derivative field. + */ + +void EvaluateDerivative (DoFHandler<3> &dof_handler, + Vector &solution) +{ + // This quadrature rule determines the points, where the + // derivative will be evaluated. + QGauss<3> quad (3); + FEValues<3> fe_values (dof_handler.get_fe (), quad, + UpdateFlags(update_values | + update_quadrature_points | + update_gradients | + update_JxW_values)); + + const unsigned int n_q_points = quad.size(); + const unsigned int n_components = dof_handler.get_fe().n_components(); + const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell; + + // Cell iterators + DoFHandler<3>::active_cell_iterator cell = dof_handler.begin_active(), + endc = dof_handler.end(); + + double err_l2 = 0, + err_hdiv = 0; + + std::vector local_dof_indices (dofs_per_cell); + + for (; cell!=endc; ++cell) + { + cell->get_dof_indices (local_dof_indices); + + fe_values.reinit (cell); + + // Get function values + std::vector > this_value(n_q_points, + Vector(n_components)); + fe_values.get_function_values (solution, this_value); + + // Get values from solution vector (For Trap.Rule) + std::vector > > + grads_here (n_q_points, std::vector > (n_components)); + fe_values.get_function_gradients (solution, grads_here); + + for (unsigned int q_point=0; q_pointvertex(v) << std::endl; + } + + + FE_ABF<3> fe (0); + deallog << "Dofs/cell " << fe.dofs_per_cell + << ", Dofs/face " << fe.dofs_per_face << std::endl; + + DoFHandler<3> dof_handler (tria_test); + dof_handler.distribute_dofs (fe); + + deallog << "Dofs total " << dof_handler.n_dofs () << std::endl; + + Vector solution(dof_handler.n_dofs ()); + solution = 1; + + // Project solution onto FE field + ConstraintMatrix hn_constraints; + hn_constraints.clear (); + DoFTools::make_hanging_node_constraints (dof_handler, + hn_constraints); + hn_constraints.close (); + MappingQGeneric<3> map_default(1); + project (map_default, dof_handler, hn_constraints, + QGauss<3> (6), ConstantFunction<3>(1., 3), + solution); + + EvaluateDerivative (dof_handler, solution); + solution.print (deallog); + + DataOut<3> data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (solution, "solution"); + data_out.build_patches (2); + + data_out.write_gnuplot (deallog.get_file_stream()); +} diff --git a/tests/fe/abf_02.output b/tests/fe/abf_02.output new file mode 100644 index 0000000000..c7524e535b --- /dev/null +++ b/tests/fe/abf_02.output @@ -0,0 +1,235 @@ + +DEAL::Cell 0.0 +DEAL:: 0.00000 0.00000 0.00000 +DEAL:: 1.00000 0.00000 0.00000 +DEAL:: 0.00000 1.00000 0.00000 +DEAL:: 1.00000 1.00000 0.00000 +DEAL::Dofs/cell 9, Dofs/face 1 +DEAL::Dofs total 9 +DEAL:cg::Starting value 3.76386 +DEAL:cg::Convergence step 16 value 3.08853e-17 +DEAL::L2-Err=1.04195e-13, Hdiv-Err=7.10593e-13 +DEAL::1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 2.50000 2.00000 1.27452 +# This file was generated by the deal.II library. + + +# +# For a description of the GNUPLOT format see the GNUPLOT manual. +# +# +0.00000 0.00000 0.00000 1.00000 1.00000 1.00000 +0.500000 0.00000 0.00000 -1.66178 1.00000 1.00000 + + +0.00000 0.00000 0.00000 1.00000 1.00000 1.00000 +0.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 + + +0.00000 0.00000 0.00000 1.00000 1.00000 1.00000 +0.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.500000 0.00000 0.00000 -1.66178 1.00000 1.00000 +1.00000 0.00000 0.00000 1.00000 1.00000 1.00000 + + +0.500000 0.00000 0.00000 -1.66178 1.00000 1.00000 +0.500000 0.500000 0.00000 -1.66178 -3.16178 1.00000 + + +0.500000 0.00000 0.00000 -1.66178 1.00000 1.00000 +0.500000 0.00000 0.500000 -1.66178 1.00000 -5.33822 + + +1.00000 0.00000 0.00000 1.00000 1.00000 1.00000 +1.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 + + +1.00000 0.00000 0.00000 1.00000 1.00000 1.00000 +1.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 +0.500000 0.500000 0.00000 -1.66178 -3.16178 1.00000 + + +0.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 +0.00000 1.00000 0.00000 1.00000 1.00000 1.00000 + + +0.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 +0.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 + + +0.500000 0.500000 0.00000 -1.66178 -3.16178 1.00000 +1.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 + + +0.500000 0.500000 0.00000 -1.66178 -3.16178 1.00000 +0.500000 1.00000 0.00000 -1.66178 1.00000 1.00000 + + +0.500000 0.500000 0.00000 -1.66178 -3.16178 1.00000 +0.500000 0.500000 0.500000 -1.66178 -3.16178 -5.33822 + + +1.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 +1.00000 1.00000 0.00000 1.00000 1.00000 1.00000 + + +1.00000 0.500000 0.00000 1.00000 -3.16178 1.00000 +1.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 + + +0.00000 1.00000 0.00000 1.00000 1.00000 1.00000 +0.500000 1.00000 0.00000 -1.66178 1.00000 1.00000 + + +0.00000 1.00000 0.00000 1.00000 1.00000 1.00000 +0.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.500000 1.00000 0.00000 -1.66178 1.00000 1.00000 +1.00000 1.00000 0.00000 1.00000 1.00000 1.00000 + + +0.500000 1.00000 0.00000 -1.66178 1.00000 1.00000 +0.500000 1.00000 0.500000 -1.66178 1.00000 -5.33822 + + +1.00000 1.00000 0.00000 1.00000 1.00000 1.00000 +1.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 +0.500000 0.00000 0.500000 -1.66178 1.00000 -5.33822 + + +0.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 +0.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 + + +0.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 +0.00000 0.00000 1.00000 1.00000 1.00000 1.00000 + + +0.500000 0.00000 0.500000 -1.66178 1.00000 -5.33822 +1.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.500000 0.00000 0.500000 -1.66178 1.00000 -5.33822 +0.500000 0.500000 0.500000 -1.66178 -3.16178 -5.33822 + + +0.500000 0.00000 0.500000 -1.66178 1.00000 -5.33822 +0.500000 0.00000 1.00000 -1.66178 1.00000 1.00000 + + +1.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 +1.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 + + +1.00000 0.00000 0.500000 1.00000 1.00000 -5.33822 +1.00000 0.00000 1.00000 1.00000 1.00000 1.00000 + + +0.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 +0.500000 0.500000 0.500000 -1.66178 -3.16178 -5.33822 + + +0.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 +0.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 +0.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 + + +0.500000 0.500000 0.500000 -1.66178 -3.16178 -5.33822 +1.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 + + +0.500000 0.500000 0.500000 -1.66178 -3.16178 -5.33822 +0.500000 1.00000 0.500000 -1.66178 1.00000 -5.33822 + + +0.500000 0.500000 0.500000 -1.66178 -3.16178 -5.33822 +0.500000 0.500000 1.00000 -1.66178 -3.16178 1.00000 + + +1.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 +1.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 + + +1.00000 0.500000 0.500000 1.00000 -3.16178 -5.33822 +1.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 + + +0.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 +0.500000 1.00000 0.500000 -1.66178 1.00000 -5.33822 + + +0.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 +0.00000 1.00000 1.00000 1.00000 1.00000 1.00000 + + +0.500000 1.00000 0.500000 -1.66178 1.00000 -5.33822 +1.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 + + +0.500000 1.00000 0.500000 -1.66178 1.00000 -5.33822 +0.500000 1.00000 1.00000 -1.66178 1.00000 1.00000 + + +1.00000 1.00000 0.500000 1.00000 1.00000 -5.33822 +1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 + + +0.00000 0.00000 1.00000 1.00000 1.00000 1.00000 +0.500000 0.00000 1.00000 -1.66178 1.00000 1.00000 + + +0.00000 0.00000 1.00000 1.00000 1.00000 1.00000 +0.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 + + +0.500000 0.00000 1.00000 -1.66178 1.00000 1.00000 +1.00000 0.00000 1.00000 1.00000 1.00000 1.00000 + + +0.500000 0.00000 1.00000 -1.66178 1.00000 1.00000 +0.500000 0.500000 1.00000 -1.66178 -3.16178 1.00000 + + +1.00000 0.00000 1.00000 1.00000 1.00000 1.00000 +1.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 + + +0.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 +0.500000 0.500000 1.00000 -1.66178 -3.16178 1.00000 + + +0.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 +0.00000 1.00000 1.00000 1.00000 1.00000 1.00000 + + +0.500000 0.500000 1.00000 -1.66178 -3.16178 1.00000 +1.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 + + +0.500000 0.500000 1.00000 -1.66178 -3.16178 1.00000 +0.500000 1.00000 1.00000 -1.66178 1.00000 1.00000 + + +1.00000 0.500000 1.00000 1.00000 -3.16178 1.00000 +1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 + + +0.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +0.500000 1.00000 1.00000 -1.66178 1.00000 1.00000 + + +0.500000 1.00000 1.00000 -1.66178 1.00000 1.00000 +1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 + + -- 2.39.5