From: Wolfgang Bangerth Date: Fri, 6 Apr 2001 13:08:25 +0000 (+0000) Subject: Add test to check finite difference approximations of derivatives. X-Git-Tag: v8.0.0~19390 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86e9dd2ce6773ebbf9fcc2f029a8d40c57b97958;p=dealii.git Add test to check finite difference approximations of derivatives. git-svn-id: https://svn.dealii.org/trunk@4392 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/deal.II/Makefile.in b/tests/deal.II/Makefile.in index 624cab761b..14cd8eea2c 100644 --- a/tests/deal.II/Makefile.in +++ b/tests/deal.II/Makefile.in @@ -68,6 +68,7 @@ all: grid_test.check dof_test.check data_out.check \ derivatives.check gradients.check \ constraints.check mg.check mglocal.check \ block_matrices.check second_derivatives.check \ + derivative_approximation.check \ intergrid_constraints.check intergrid_map.check wave-test-3.check exe: $(all:.check=.testcase) benchmark @@ -161,6 +162,20 @@ derivatives.testcase: $(derivatives-o-files) $(libdeal1d) $(libdeal3d) $(librari ############################################################ +derivative_approximation-cc-files = derivative_approximation.cc + +ifeq ($(debug-mode),on) +derivative_approximation-o-files = $(derivative_approximation-cc-files:.cc=.go) +else +derivative_approximation-o-files = $(derivative_approximation-cc-files:.cc=.o) +endif + +derivative_approximation.testcase: $(derivative_approximation-o-files) $(libdeal1d) $(libdeal3d) $(libraries) + @echo =====linking======= $< + @$(CXX) $(LDFLAGS) -g -o $@ $^ $(LIBS) + +############################################################ + gradients-cc-files = gradients.cc ifeq ($(debug-mode),on) diff --git a/tests/deal.II/derivative_approximation.cc b/tests/deal.II/derivative_approximation.cc new file mode 100644 index 0000000000..8ed90c9421 --- /dev/null +++ b/tests/deal.II/derivative_approximation.cc @@ -0,0 +1,94 @@ +//---------------------------- derivative_approximation.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- derivative_approximation.cc --------------------------- + + +/* Author: Wolfgang Bangerth, University of Heidelberg, 2001 */ + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void +check () +{ + CosineFunction cosine; + + Triangulation tr; + if (dim==2) + GridGenerator::hyper_ball(tr); + else + GridGenerator::hyper_cube(tr, -1,1); + tr.refine_global (1); + tr.begin_active()->set_refine_flag (); + tr.execute_coarsening_and_refinement (); + if (dim==1) + tr.refine_global(2); + + FE_Q element(3); + DoFHandler dof(tr); + dof.distribute_dofs(element); + + Vector v (dof.n_dofs()); + VectorTools::interpolate (dof, cosine, v); + + Vector gradient (tr.n_active_cells()); + Vector second (tr.n_active_cells()); + + DerivativeApproximation:: + approximate_gradient (dof, v, gradient); + DerivativeApproximation:: + approximate_second_derivative (dof, v, second); + + deallog << "Approximated gradient:" << std::endl; + for (unsigned int i=0; i (); + deallog.pop (); + deallog.push ("2d"); + check<2> (); + deallog.pop (); +// deallog.push ("3d"); +// check<3> (); +// deallog.pop (); +} diff --git a/tests/deal.II/derivative_approximation.checked b/tests/deal.II/derivative_approximation.checked new file mode 100644 index 0000000000..7588d0ae53 --- /dev/null +++ b/tests/deal.II/derivative_approximation.checked @@ -0,0 +1,75 @@ + +DEAL:1d::Approximated gradient: +DEAL:1d::33.70 +DEAL:1d::85.04 +DEAL:1d::127.27 +DEAL:1d::144.19 +DEAL:1d::153.81 +DEAL:1d::149.35 +DEAL:1d::137.64 +DEAL:1d::120.65 +DEAL:1d::99.01 +DEAL:1d::73.57 +DEAL:1d::45.31 +DEAL:1d::11.46 +DEAL:1d::Approximated second derivative: +DEAL:1d::236.02 +DEAL:1d::199.92 +DEAL:1d::133.59 +DEAL:1d::93.82 +DEAL:1d::48.06 +DEAL:1d::71.17 +DEAL:1d::115.57 +DEAL:1d::155.53 +DEAL:1d::189.51 +DEAL:1d::216.21 +DEAL:1d::234.60 +DEAL:1d::243.58 +DEAL:2d::Approximated gradient: +DEAL:2d::83.95 +DEAL:2d::78.64 +DEAL:2d::84.25 +DEAL:2d::91.43 +DEAL:2d::78.64 +DEAL:2d::78.64 +DEAL:2d::85.03 +DEAL:2d::47.74 +DEAL:2d::47.74 +DEAL:2d::47.74 +DEAL:2d::47.74 +DEAL:2d::85.03 +DEAL:2d::85.03 +DEAL:2d::78.64 +DEAL:2d::78.64 +DEAL:2d::85.03 +DEAL:2d::78.64 +DEAL:2d::78.64 +DEAL:2d::85.03 +DEAL:2d::94.21 +DEAL:2d::123.42 +DEAL:2d::115.45 +DEAL:2d::97.15 +DEAL:2d::Approximated second derivative: +DEAL:2d::192.62 +DEAL:2d::236.14 +DEAL:2d::229.11 +DEAL:2d::269.15 +DEAL:2d::225.54 +DEAL:2d::225.54 +DEAL:2d::215.57 +DEAL:2d::239.92 +DEAL:2d::239.92 +DEAL:2d::239.92 +DEAL:2d::239.92 +DEAL:2d::215.57 +DEAL:2d::215.57 +DEAL:2d::225.54 +DEAL:2d::225.54 +DEAL:2d::201.62 +DEAL:2d::236.14 +DEAL:2d::236.14 +DEAL:2d::201.62 +DEAL:2d::233.72 +DEAL:2d::168.05 +DEAL:2d::185.42 +DEAL:2d::215.27