From 148e782758bd990438c9c7af41890ebc3de1e49b Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 14 Feb 2013 20:41:17 +0000 Subject: [PATCH] In 1d, VectorTools::interpolate_boundary_values still assumed the old scheme where we have only zero boundary indicator on the left and one on the right. Fix this. git-svn-id: https://svn.dealii.org/trunk@28398 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 7 ++ .../deal.II/numerics/vector_tools.templates.h | 9 +- .../deal.II/interpolate_boundary_values_02.cc | 85 +++++++++++++++++++ .../cmp/generic | 33 +++++++ 4 files changed, 127 insertions(+), 7 deletions(-) create mode 100644 tests/deal.II/interpolate_boundary_values_02.cc create mode 100644 tests/deal.II/interpolate_boundary_values_02/cmp/generic diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 29420ce85f..f863bdf26b 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -186,6 +186,13 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. Fixed: VectorTools::interpolate did not work properly in 1d if +boundary indicators had been set to anything but the default (i.e., +zero at the left and one at the right end of the domain). This was +a hold-over from the past when these were the only possible values. +This is now fixed. +
    +(Kevin Dugan, Wolfgang Bangerth, 2013/02/14)
  2. Improved: The iterator class of the deal.II SparseMatrix class and SparsityPattern have been revised for performance. Iterating over diff --git a/deal.II/include/deal.II/numerics/vector_tools.templates.h b/deal.II/include/deal.II/numerics/vector_tools.templates.h index 8a81c86a50..ed7f40969d 100644 --- a/deal.II/include/deal.II/numerics/vector_tools.templates.h +++ b/deal.II/include/deal.II/numerics/vector_tools.templates.h @@ -1511,21 +1511,16 @@ namespace VectorTools if (function_map.size() == 0) return; - for (typename FunctionMap::type::const_iterator i=function_map.begin(); - i!=function_map.end(); ++i) - Assert (i->first < 2, - ExcInvalidBoundaryIndicator()); - for (typename DH::active_cell_iterator cell = dof.begin_active(); cell != dof.end(); ++cell) for (unsigned int direction=0; direction::faces_per_cell; ++direction) if (cell->at_boundary(direction) && - (function_map.find(direction) != function_map.end())) + (function_map.find(cell->face(direction)->boundary_indicator()) != function_map.end())) { const Function &boundary_function - = *function_map.find(direction)->second; + = *function_map.find(cell->face(direction)->boundary_indicator())->second; // get the FE corresponding to this // cell diff --git a/tests/deal.II/interpolate_boundary_values_02.cc b/tests/deal.II/interpolate_boundary_values_02.cc new file mode 100644 index 0000000000..fdb148c732 --- /dev/null +++ b/tests/deal.II/interpolate_boundary_values_02.cc @@ -0,0 +1,85 @@ +//---------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006, 2007, 2013 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. +// +//---------------------------------------------------------------------- + + +// VectorTools::interpolate_boundary_values still had bugs in 1d after +// switching to a scheme where we can assign boundary indicators also in 1d + +#include "../tests.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + + +template +void test () +{ + deallog << "dim = " << dim << std::endl; + + Triangulation triangulation; + FE_Q fe(1); + DoFHandler dof_handler(triangulation); + + GridGenerator::hyper_cube (triangulation, 0, 1); + triangulation.begin_active()->face(0)->set_boundary_indicator(10); + triangulation.begin_active()->face(1)->set_boundary_indicator(20); + triangulation.refine_global (1); + + dof_handler.distribute_dofs (fe); + + std::map boundary_values; + VectorTools::interpolate_boundary_values (dof_handler, + 10, + Functions::SquareFunction(), + boundary_values); + VectorTools::interpolate_boundary_values (dof_handler, + 20, + Functions::SquareFunction(), + boundary_values); + deallog << boundary_values.size() << std::endl; + for (std::map::const_iterator + p = boundary_values.begin(); + p != boundary_values.end(); ++p) + deallog << p->first << ' ' << p->second << std::endl; +} + + +int main () +{ + std::ofstream logfile("interpolate_boundary_values_02/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/interpolate_boundary_values_02/cmp/generic b/tests/deal.II/interpolate_boundary_values_02/cmp/generic new file mode 100644 index 0000000000..fc6fb37d01 --- /dev/null +++ b/tests/deal.II/interpolate_boundary_values_02/cmp/generic @@ -0,0 +1,33 @@ + +DEAL::dim = 1 +DEAL::2 +DEAL::0 0 +DEAL::2 1.00000 +DEAL::dim = 2 +DEAL::6 +DEAL::0 0 +DEAL::2 0.250000 +DEAL::4 1.00000 +DEAL::5 1.25000 +DEAL::6 1.00000 +DEAL::8 2.00000 +DEAL::dim = 3 +DEAL::18 +DEAL::0 0 +DEAL::2 0.250000 +DEAL::4 0.250000 +DEAL::6 0.500000 +DEAL::8 1.00000 +DEAL::9 1.25000 +DEAL::10 1.25000 +DEAL::11 1.50000 +DEAL::12 1.00000 +DEAL::14 1.25000 +DEAL::16 2.00000 +DEAL::17 2.25000 +DEAL::18 1.00000 +DEAL::20 1.25000 +DEAL::22 2.00000 +DEAL::23 2.25000 +DEAL::24 2.00000 +DEAL::26 3.00000 -- 2.39.5