From: bangerth Date: Sat, 13 Nov 2010 00:51:14 +0000 (+0000) Subject: Disallow assignment of DoF accessors. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59a497ded26141697c3ff922216af62ee770b2c8;p=dealii-svn.git Disallow assignment of DoF accessors. git-svn-id: https://svn.dealii.org/trunk@22712 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index a6ec3164fe..371e5af56d 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -347,6 +347,16 @@ through DoFHandler::get_tria() and DoFHandler::get_fe(), respectively.

deal.II

    +
  1. Fixed: For DoF iterators, it was previously possible to write + code like *it1 = *it2, presumably with the intent to + copy the entire cell pointed to on the right hand side onto the cell + pointed to at the left. However, this is not what happens since + iterators are not pointers but only point to accessor classes. The + assignment operator has therefore been removed. +
    + (WB, 2010/11/12) +

  2. +
  3. New: There is now a class TriaAccessor<0,1,spacedim> that allows to write things like @code diff --git a/deal.II/include/deal.II/dofs/dof_accessor.h b/deal.II/include/deal.II/dofs/dof_accessor.h index ba7b68c90c..4827e71b32 100644 --- a/deal.II/include/deal.II/dofs/dof_accessor.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.h @@ -270,12 +270,6 @@ class DoFAccessor : public internal::DoFAccessor::Inheritance & - operator = (const DoFAccessor &da); - /** * Implement the copy operator needed * for the iterator classes. @@ -726,6 +720,27 @@ class DoFAccessor : public internal::DoFAccessor::Inheritance friend class TriaRawIterator; + private: + /** + * Copy operator. This is normally used + * in a context like iterator a,b; + * *a=*b;. Presumably, the intent + * here is to copy the object pointed to + * by @p b to the object pointed to by + * @p a. However, the result of + * dereferencing an iterator is not an + * object but an accessor; consequently, + * this operation is not useful for + * iterators on triangulations. We + * declare this function here private, + * thus it may not be used from outside. + * Furthermore it is not implemented and + * will give a linker error if used + * anyway. + */ + DoFAccessor & + operator = (const DoFAccessor &da); + /** * Make the DoFHandler class a friend so * that it can call the set_xxx() diff --git a/deal.II/include/deal.II/dofs/dof_accessor.templates.h b/deal.II/include/deal.II/dofs/dof_accessor.templates.h index 7c0b4244b4..ec9e7a713c 100644 --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@ -97,18 +97,6 @@ DoFAccessor::get_dof_handler () const } -//TODO: This seems to set only the DH, not the other data. - -template -inline -DoFAccessor & -DoFAccessor::operator = (const DoFAccessor &da) -{ - this->set_dof_handler (da.dof_handler); - return *this; -} - - template inline diff --git a/tests/deal.II/dof_accessor_01.cc b/tests/deal.II/dof_accessor_01.cc new file mode 100644 index 0000000000..5b38de4862 --- /dev/null +++ b/tests/deal.II/dof_accessor_01.cc @@ -0,0 +1,73 @@ +//---------------------------- dof_accessor_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 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. +// +//---------------------------- dof_accessor_01.cc --------------------------- + +// verify that iterators can be copied. when you just copy the +// iterator itself, everything is alright: the copy operator of the +// iterator calls Accessor::copy_from. +// +// the test was originally written because at that time it was +// possible to do something like *it1 = *it2 for DoF iterators -- +// likely not what the author intended since it does not copy the +// cell2 into the cell1, only the accessor. furthermore, the operator= +// was wrongly implemented, so it was removed in the process + + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + +template +void test () +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + tria.refine_global (2); + + FE_Q fe(1); + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); + ++cell; + + typename DoFHandler::face_iterator + face = dof_handler.begin_active()->face(0); + face = cell->face(0); + deallog << cell->face(0) << ' ' << face << std::endl; +} + + + +int main () +{ + std::ofstream logfile("dof_accessor_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + + test<1> (); + test<2> (); + test<3> (); + + return 0; +} diff --git a/tests/deal.II/dof_accessor_01/cmp/generic b/tests/deal.II/dof_accessor_01/cmp/generic new file mode 100644 index 0000000000..0c55aa31de --- /dev/null +++ b/tests/deal.II/dof_accessor_01/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::-1 -1 +DEAL::40 40 +DEAL::281 281