From 954162c8decc55c844d9e776a97c3e1282f4bee5 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 12 Nov 2002 16:08:33 +0000 Subject: [PATCH] Add test denis_1. git-svn-id: https://svn.dealii.org/trunk@6756 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/Makefile | 4 +- tests/bits/denis_1.cc | 96 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 tests/bits/denis_1.cc diff --git a/tests/bits/Makefile b/tests/bits/Makefile index ff2ea93248..6d7a678a19 100644 --- a/tests/bits/Makefile +++ b/tests/bits/Makefile @@ -28,10 +28,12 @@ anna_3.exe : anna_3.g.$(OBJEXT) $(libraries) anna_5.exe : anna_5.g.$(OBJEXT) $(libraries) gerold_1.exe : gerold_1.g.$(OBJEXT) $(libraries) roy_1.exe : roy_1.g.$(OBJEXT) $(libraries) +denis_1.exe : denis_1.g.$(OBJEXT) $(libraries) tests = anna_1 anna_2 anna_3 anna_5 \ gerold_1 \ - roy_1 + roy_1 \ + denis_1 ############################################################ diff --git a/tests/bits/denis_1.cc b/tests/bits/denis_1.cc new file mode 100644 index 0000000000..457957c259 --- /dev/null +++ b/tests/bits/denis_1.cc @@ -0,0 +1,96 @@ +//---------------------------- denis_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2002 by the deal.II authors and Anna Schneebeli +// +// 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. +// +//---------------------------- denis_1.cc --------------------------- + + +// check for a bug in DerivativeApproximation::approximate_gradient +// +// this program is a modified version of one by +// Denis Danilov , + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + std::ofstream logfile("denis_1.output"); + deallog.attach(logfile); + deallog.depth_console(0); + + Triangulation<2> triangulation; + FE_Q<2> fe(2); + DoFHandler<2> dof_handler(triangulation); + Vector phi_solution; + Vector gradient_phi; + float gradient_phi_min, gradient_phi_max; + double delta = 0.05; + + GridGenerator::hyper_cube(triangulation, 0, 1); + triangulation.refine_global(5); + + dof_handler.distribute_dofs(fe); + + DoFHandler<2>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); + + phi_solution.reinit(dof_handler.n_dofs()); + + for(; cell!=endc; ++cell) + { + for(unsigned int vertex=0; + vertex < GeometryInfo<2>::vertices_per_cell; + ++vertex) + { + double x, y, r; + x = cell->vertex(vertex)(0); + y = cell->vertex(vertex)(1); + r = sqrt( x*x + y*y ); + phi_solution( cell->vertex_dof_index(vertex,0) ) + = 0.5 * ( 1 - tanh( ( r - 0.5 ) + /( 2*M_SQRT2 * delta ) ) ) ; + } + } + + gradient_phi.reinit(triangulation.n_active_cells()); + DerivativeApproximation::approximate_gradient(dof_handler, phi_solution, gradient_phi); + + gradient_phi_min = 1e30; + gradient_phi_max = -1; + + cell = dof_handler.begin_active(); + for(unsigned int cell_no=0; cell!=endc; ++cell, ++cell_no) + { + if( gradient_phi(cell_no) < gradient_phi_min ) + gradient_phi_min = gradient_phi(cell_no); + + if( gradient_phi(cell_no) > gradient_phi_max ) + gradient_phi_max = gradient_phi(cell_no); + + } + + deallog << "gradient_phi_min: " << gradient_phi_min << std::endl; + deallog << "gradient_phi_max: " << gradient_phi_max << std::endl; + + ////////////////////// + + +}; -- 2.39.5