From: kanschat Date: Tue, 16 Jul 2013 08:23:09 +0000 (+0000) Subject: make virtual functions softly pure X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ae03903478e305fdb759005900f6480b37f04b4;p=dealii-svn.git make virtual functions softly pure git-svn-id: https://svn.dealii.org/trunk@30004 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index a74be3c712..db1abd057f 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -155,6 +155,12 @@ this function.
    +
  1. Improved: the "pure" functions in MeshWorker::LocalIntegrator are now implemented and throw +an exception if not overloaded. +
    +(Guido Kanschat, 2013/07/16) +
  2. +
  3. New: The function SparseDirectUMFPACK::Tvmult is now implemented.
    (Matthias Maier, 2013/07/03) diff --git a/deal.II/include/deal.II/meshworker/local_integrator.h b/deal.II/include/deal.II/meshworker/local_integrator.h index c46173eb21..941ee20d3e 100644 --- a/deal.II/include/deal.II/meshworker/local_integrator.h +++ b/deal.II/include/deal.II/meshworker/local_integrator.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors +// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -35,6 +35,10 @@ namespace MeshWorker * integrate on boundary and interior faces. Thes flags are true by * default, but can be modified by applications to speed up the loop. * + * If a function is not overloaded in a derived class, but its usage + * flag is true, the function will cause an exception + * ExcPureFunction. + * * @ingroup MeshWorker * @author Guido Kanschat * @date 2012 @@ -44,64 +48,68 @@ namespace MeshWorker { public: /** - * The constructor setting - * default values. + * The constructor setting default values, namely all integration flags to true. */ LocalIntegrator(); + /** + * The constructor setting integration flags to specified values. + */ + LocalIntegrator(bool use_cell, bool use_boundary, bool use_face); + /** * The empty virtual destructor. */ ~LocalIntegrator(); /** - * Virtual function for - * integrating on cells. + * Virtual function for integrating on cells. Throws exception + * PureFunctionCalled if not overloaded by a derived class. */ virtual void cell(DoFInfo &dinfo, - IntegrationInfo &info) const = 0; + IntegrationInfo &info) const; /** - * Virtual function for - * integrating on boundary faces. + * Virtual function for integrating on boundary faces. Throws exception + * PureFunctionCalled if not overloaded by a derived class. */ virtual void boundary(DoFInfo &dinfo, - IntegrationInfo &info) const = 0; + IntegrationInfo &info) const; /** - * Virtual function for - * integrating on interior faces. + * Virtual function for integrating on interior faces. Throws exception + * PureFunctionCalled if not overloaded by a derived class. */ virtual void face(DoFInfo &dinfo1, DoFInfo &dinfo2, IntegrationInfo &info1, - IntegrationInfo &info2) const = 0; + IntegrationInfo &info2) const; /** - * The flag indicating whether - * the cell integrator cell() - * is to be used in the - * loop. Defaults to - * true. + * The flag indicating whether the cell integrator cell() is to be + * used in the loop. Defaults to true. */ bool use_cell; /** - * The flag indicating whether - * the boundary integrator - * boundary() is to be - * used in the loop. Defaults - * to true. + * The flag indicating whether the boundary integrator boundary() + * is to be used in the loop. Defaults to true. */ bool use_boundary; /** - * The flag indicating whether - * the interior face integrator - * face() is to be used in the - * loop. Defaults to - * true. + * The flag indicating whether the interior face integrator face() + * is to be used in the loop. Defaults to true. */ bool use_face; - + + /** + * This error is thrown if one of the virtual functions cell(), + * boundary(), or face() is called without being overloaded in a + * derived class. Consider setting #use_cell, #use_boundary, and + * #use_face to false, respectively. + * + * @ingroup Exceptions + */ + DeclException0(ExcPureFunction); }; } diff --git a/deal.II/source/meshworker/mesh_worker.cc b/deal.II/source/meshworker/mesh_worker.cc index 211a7e5764..b1ff198ebf 100644 --- a/deal.II/source/meshworker/mesh_worker.cc +++ b/deal.II/source/meshworker/mesh_worker.cc @@ -61,10 +61,46 @@ namespace MeshWorker {} + template + LocalIntegrator::LocalIntegrator (bool c, bool b, bool f) + : + use_cell(c), use_boundary(b), use_face(f) + {} + + template LocalIntegrator::~LocalIntegrator () {} + template + void + LocalIntegrator::cell (DoFInfo &, + IntegrationInfo &) const + { + Assert(false, ExcPureFunction()); + } + + + template + void + LocalIntegrator::boundary (DoFInfo &, + IntegrationInfo &) const + { + Assert(false, ExcPureFunction()); + } + + + template + void + LocalIntegrator::face (DoFInfo &, + DoFInfo &, + IntegrationInfo &, + IntegrationInfo &) const + { + Assert(false, ExcPureFunction()); + } + + template class LocalIntegrator<1,1,float>; template class LocalIntegrator<1,1,double>; template class LocalIntegrator<1,2,float>;