From a9bdca42151f45a9c98acc6e18abfd0473184c01 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 9 Jan 2006 02:34:30 +0000 Subject: [PATCH] Move the collection classes into namespace hp. Make the collection classes all alike. git-svn-id: https://svn.dealii.org/trunk@11964 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_accessor.h | 20 +- deal.II/deal.II/include/dofs/hp_dof_handler.h | 13 +- deal.II/deal.II/include/dofs/hp_dof_levels.h | 27 +- deal.II/deal.II/include/fe/fe.h | 12 +- deal.II/deal.II/include/fe/fe_collection.h | 425 +++++++++--------- deal.II/deal.II/include/fe/hp_fe_values.h | 48 +- deal.II/deal.II/include/fe/mapping.h | 18 +- deal.II/deal.II/include/fe/mapping_c1.h | 10 +- .../deal.II/include/fe/mapping_cartesian.h | 13 +- .../deal.II/include/fe/mapping_collection.h | 187 ++++---- deal.II/deal.II/include/fe/mapping_q.h | 10 +- deal.II/deal.II/include/fe/mapping_q1.h | 10 +- .../deal.II/include/fe/mapping_q1_eulerian.h | 12 +- deal.II/deal.II/include/fe/q_collection.h | 188 ++++---- deal.II/deal.II/source/dofs/hp_dof_handler.cc | 2 +- deal.II/deal.II/source/fe/fe_collection.cc | 75 ++-- deal.II/deal.II/source/fe/hp_fe_values.cc | 60 +-- deal.II/deal.II/source/fe/mapping_c1.cc | 11 +- .../deal.II/source/fe/mapping_cartesian.cc | 8 + .../deal.II/source/fe/mapping_collection.cc | 89 ++-- deal.II/deal.II/source/fe/mapping_q.cc | 9 + deal.II/deal.II/source/fe/mapping_q1.cc | 9 + .../deal.II/source/fe/mapping_q1_eulerian.cc | 11 +- deal.II/deal.II/source/fe/q_collection.cc | 99 ++-- deal.II/doc/news/changes.html | 8 + deal.II/examples/step-21/step-21.cc | 55 +-- 26 files changed, 776 insertions(+), 653 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index 31c42fc6c4..9746526c0f 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -428,8 +428,9 @@ class DoFObjectAccessor : public DoFAccessor, get_fe () const; /** - * Returns the index inside the FECollection - * of the FiniteElement used for this cell. + * Returns the index inside the + * hp::FECollection of the FiniteElement + * used for this cell. */ unsigned int active_fe_index () const; @@ -734,8 +735,9 @@ class DoFObjectAccessor<1, dim, DH> : public DoFAccessor, get_fe () const; /** - * Returns the index inside the FECollection - * of the FiniteElement used for this cell. + * Returns the index inside the + * hp::FECollection of the FiniteElement + * used for this cell. */ unsigned int active_fe_index () const; @@ -974,8 +976,9 @@ class DoFObjectAccessor<2, dim, DH> : public DoFAccessor, get_fe () const; /** - * Returns the index inside the FECollection - * of the FiniteElement used for this cell. + * Returns the index inside the + * hp::FECollection of the FiniteElement + * used for this cell. */ unsigned int active_fe_index () const; @@ -1222,8 +1225,9 @@ class DoFObjectAccessor<3, dim, DH> : public DoFAccessor, get_fe () const; /** - * Returns the index inside the FECollection - * of the FiniteElement used for this cell. + * Returns the index inside the + * hp::FECollection of the FiniteElement + * used for this cell. */ unsigned int active_fe_index () const; diff --git a/deal.II/deal.II/include/dofs/hp_dof_handler.h b/deal.II/deal.II/include/dofs/hp_dof_handler.h index 5f52df7dba..d298fa8d76 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_handler.h +++ b/deal.II/deal.II/include/dofs/hp_dof_handler.h @@ -129,7 +129,7 @@ namespace hp * releases the lock of this * object to the finite element. */ - virtual void distribute_dofs (const FECollection &fe); + virtual void distribute_dofs (const hp::FECollection &fe); /** * Clear all data of this object and @@ -796,7 +796,7 @@ namespace hp * objects that are used by this * @p DoFHandler. */ - const FECollection & get_fe () const; + const hp::FECollection & get_fe () const; /** * Return a constant reference to the @@ -879,7 +879,7 @@ namespace hp * (this clears all data of this * object as well, though). */ - SmartPointer > finite_elements; + SmartPointer > finite_elements; private: @@ -1002,11 +1002,6 @@ namespace hp * Make accessor objects friends. */ template class DH> friend class DoFObjectAccessor; - - /** - * Make Triangulation friend. - */ -// friend class Triangulation; }; @@ -1147,7 +1142,7 @@ namespace hp template inline - const FECollection & + const hp::FECollection & DoFHandler::get_fe () const { return *finite_elements; diff --git a/deal.II/deal.II/include/dofs/hp_dof_levels.h b/deal.II/deal.II/include/dofs/hp_dof_levels.h index 6245c53504..20f994324c 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_levels.h +++ b/deal.II/deal.II/include/dofs/hp_dof_levels.h @@ -47,25 +47,26 @@ namespace hp * hierarchy. * * In @ref{DoFLevel<0>} all data is stored which is not dependent on the - * dimension, e.g. a field to store the index referring to the FECollection - * class. The data therefore corresponds to cells, rather than vertices, - * lines, quads, etc. + * dimension, e.g. a field to store the index referring to the + * hp::FECollection class. The data therefore corresponds to cells, rather + * than vertices, lines, quads, etc. */ template <> class DoFLevel<0> { public: /** - * Indices specifying the finite element - * of FECollection to use for the - * different cells. The meaning - * what a cell is, is dimension specific, - * therefore also the length of this - * vector depends on the dimension: in - * one dimension, the length of this - * vector equals the length of the - * @p lines vector, in two dimensions - * that of the @p quads vector, etc. + * Indices specifying the finite + * element of hp::FECollection to use + * for the different cells. The + * meaning what a cell is, is + * dimension specific, therefore also + * the length of this vector depends + * on the dimension: in one dimension, + * the length of this vector equals + * the length of the @p lines vector, + * in two dimensions that of the @p + * quads vector, etc. */ std::vector active_fe_indices; diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h index 27713d5aeb..d28a420a11 100644 --- a/deal.II/deal.II/include/fe/fe.h +++ b/deal.II/deal.II/include/fe/fe.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -23,7 +23,11 @@ template class FEValues; template class FEFaceValues; template class FESubfaceValues; template class FESystem; -template class FECollection; +namespace hp +{ + template class FECollection; +} + /*!@addtogroup febase */ /*@{*/ @@ -1999,7 +2003,7 @@ class FiniteElement : public Subscriptor, * * This function is needed by the * constructors of FESystem as well - * as by the FECollection class. + * as by the hp::FECollection class. */ virtual FiniteElement *clone() const = 0; @@ -2136,7 +2140,7 @@ class FiniteElement : public Subscriptor, friend class FEFaceValues; friend class FESubfaceValues; friend class FESystem; - friend class FECollection; + friend class hp::FECollection; }; /*@}*/ diff --git a/deal.II/deal.II/include/fe/fe_collection.h b/deal.II/deal.II/include/fe/fe_collection.h index 04816909a8..67d01f48fe 100644 --- a/deal.II/deal.II/include/fe/fe_collection.h +++ b/deal.II/deal.II/include/fe/fe_collection.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -14,14 +14,17 @@ #define __deal2__fe_collection_h #include -#include +#include #include +namespace hp +{ + /** * This class acts as a collection of finite element objects used in the - * hp::DoFHandler(). It is thus to a hp::DoFHandler() what a - * FiniteElement is to a DoFHandler. This collection stores copies + * hp::DoFHandler. It is thus to a hp::DoFHandler what a + * FiniteElement is to a ::DoFHandler. This collection stores copies * of the original elements added to it, and is therefore handling its memory * manegement itself. * @@ -33,247 +36,243 @@ * * @author Wolfgang Bangerth, 2003 */ -template -class FECollection : public Subscriptor -{ - public: - /** - * Destructor. Destroy the elements of - * the collection. - */ - ~FECollection (); + template + class FECollection : public Subscriptor + { + public: + /** + * Add a finite element. This function + * generates a copy of the given + * element, i.e. you can do things like + * add_fe(FE_Q(1));. The + * internal copy is later destroyed by + * this object upon destruction of the + * entire collection. + * + * The returned value is the new number + * of finite elements in the collection. + * + * When a new element is added, it needs + * to have the same number of vector + * components as all other elements + * already in the collection. + */ + unsigned int + add_fe (const FiniteElement &new_fe); + + /** + * Get a reference to the given element + * in this collection. + */ + const FiniteElement & + get_fe (const unsigned int index) const; + + /** + * Return the number of finite element + * objects stored in this collection. + */ + unsigned int n_finite_elements () const; + + /** + * Return the number of vector + * components of the finite elements in + * this collection. This number must + * be the same for all elements in the + * collection. + */ + unsigned int n_components () const; + + /** + * Return the maximal number of degrees + * of freedom per vertex over all + * elements of this collection. + */ + unsigned int max_dofs_per_vertex () const; + + /** + * Return the maximal number of degrees + * of freedom per line over all elements + * of this collection. + */ + unsigned int max_dofs_per_line () const; + + /** + * Return the maximal number of degrees + * of freedom per quad over all elements + * of this collection. + */ + unsigned int max_dofs_per_quad () const; + + /** + * Return the maximal number of degrees + * of freedom per hex over all elements + * of this collection. + */ + unsigned int max_dofs_per_hex () const; + + /** + * Return the maximal number of degrees + * of freedom per face over all elements + * of this collection. + */ + unsigned int max_dofs_per_face () const; + + /** + * Return the maximal number of degrees + * of freedom per cell over all elements + * of this collection. + */ + unsigned int max_dofs_per_cell () const; + + /** + * Return an estimate for the memory + * allocated for this object. + */ + unsigned int memory_consumption () const; + + /** + * Exception + */ + DeclException0 (ExcNoFiniteElements); - /** - * Add a finite element. This function - * generates a copy of the given element, - * i.e. you can do things like - * add_fe(FE_Q(1));. The - * internal copy is later destroyed by - * this object upon destruction of the - * entire collection. - * - * The returned value is the new number - * of finite elements in the collection. - * - * When a new element is added, it needs - * to have the same number of vector - * components as all other elements - * already in the collection. - */ - unsigned int - add_fe (const FiniteElement &new_fe); - - /** - * Get a reference to the given element - * in this collection. - */ - const FiniteElement & - get_fe (const unsigned int index) const; - - /** - * Return the number of finite element - * objects stored in this collection. - */ - unsigned int n_finite_elements () const; - - /** - * Return the number of vector components - * of the finite elements in this - * collection. This number must be the - * same for all elements in the - * collection. - */ - unsigned int n_components () const; - - /** - * Return the maximal number of degrees - * of freedom per vertex over all - * elements of this collection. - */ - unsigned int max_dofs_per_vertex () const; - - /** - * Return the maximal number of degrees - * of freedom per line over all elements - * of this collection. - */ - unsigned int max_dofs_per_line () const; - - /** - * Return the maximal number of degrees - * of freedom per quad over all elements - * of this collection. - */ - unsigned int max_dofs_per_quad () const; - - /** - * Return the maximal number of degrees - * of freedom per hex over all elements - * of this collection. - */ - unsigned int max_dofs_per_hex () const; - - /** - * Return the maximal number of degrees - * of freedom per face over all elements - * of this collection. - */ - unsigned int max_dofs_per_face () const; - - /** - * Return the maximal number of degrees - * of freedom per cell over all elements - * of this collection. - */ - unsigned int max_dofs_per_cell () const; - - /** - * Return an estimate for the memory - * allocated for this object. - */ - unsigned int memory_consumption () const; - - /** - * Exception - */ - DeclException0 (ExcNoFiniteElements); - - private: - /** - * Array of pointers to the finite - * elements stored by this collection. - */ - std::vector > > finite_elements; -}; + private: + /** + * Array of pointers to the finite + * elements stored by this collection. + */ + std::vector > > finite_elements; + }; /* --------------- inline functions ------------------- */ -template -inline -unsigned int -FECollection::n_finite_elements () const -{ - return finite_elements.size(); -} - - -template -inline -unsigned int -FECollection::n_components () const -{ - Assert (finite_elements.size () > 0, ExcNoFiniteElements()); - return finite_elements[0]->n_components (); -} - - -template -inline -const FiniteElement & -FECollection::get_fe (const unsigned int index) const -{ - Assert (index < finite_elements.size(), - ExcIndexRange (index, 0, finite_elements.size())); - return *finite_elements[index]; -} - - - -template -unsigned int -FECollection::max_dofs_per_vertex () const -{ - Assert (finite_elements.size() > 0, ExcNoFiniteElements()); + template + inline + unsigned int + FECollection::n_finite_elements () const + { + return finite_elements.size(); + } + + + template + inline + unsigned int + FECollection::n_components () const + { + Assert (finite_elements.size () > 0, ExcNoFiniteElements()); + return finite_elements[0]->n_components (); + } + + + template + inline + const FiniteElement & + FECollection::get_fe (const unsigned int index) const + { + Assert (index < finite_elements.size(), + ExcIndexRange (index, 0, finite_elements.size())); + return *finite_elements[index]; + } + + + + template + unsigned int + FECollection::max_dofs_per_vertex () const + { + Assert (finite_elements.size() > 0, ExcNoFiniteElements()); - unsigned int max = 0; - for (unsigned int i=0; idofs_per_vertex > max) - max = finite_elements[i]->dofs_per_vertex; + unsigned int max = 0; + for (unsigned int i=0; idofs_per_vertex > max) + max = finite_elements[i]->dofs_per_vertex; - return max; -} + return max; + } -template -unsigned int -FECollection::max_dofs_per_line () const -{ - Assert (finite_elements.size() > 0, ExcNoFiniteElements()); + template + unsigned int + FECollection::max_dofs_per_line () const + { + Assert (finite_elements.size() > 0, ExcNoFiniteElements()); - unsigned int max = 0; - for (unsigned int i=0; idofs_per_line > max) - max = finite_elements[i]->dofs_per_line; + unsigned int max = 0; + for (unsigned int i=0; idofs_per_line > max) + max = finite_elements[i]->dofs_per_line; - return max; -} + return max; + } -template -unsigned int -FECollection::max_dofs_per_quad () const -{ - Assert (finite_elements.size() > 0, ExcNoFiniteElements()); + template + unsigned int + FECollection::max_dofs_per_quad () const + { + Assert (finite_elements.size() > 0, ExcNoFiniteElements()); - unsigned int max = 0; - for (unsigned int i=0; idofs_per_quad > max) - max = finite_elements[i]->dofs_per_quad; + unsigned int max = 0; + for (unsigned int i=0; idofs_per_quad > max) + max = finite_elements[i]->dofs_per_quad; - return max; -} + return max; + } -template -unsigned int -FECollection::max_dofs_per_hex () const -{ - Assert (finite_elements.size() > 0, ExcNoFiniteElements()); + template + unsigned int + FECollection::max_dofs_per_hex () const + { + Assert (finite_elements.size() > 0, ExcNoFiniteElements()); - unsigned int max = 0; - for (unsigned int i=0; idofs_per_hex > max) - max = finite_elements[i]->dofs_per_hex; + unsigned int max = 0; + for (unsigned int i=0; idofs_per_hex > max) + max = finite_elements[i]->dofs_per_hex; - return max; -} + return max; + } -template -unsigned int -FECollection::max_dofs_per_face () const -{ - Assert (finite_elements.size() > 0, ExcNoFiniteElements()); + template + unsigned int + FECollection::max_dofs_per_face () const + { + Assert (finite_elements.size() > 0, ExcNoFiniteElements()); - unsigned int max = 0; - for (unsigned int i=0; idofs_per_face > max) - max = finite_elements[i]->dofs_per_face; + unsigned int max = 0; + for (unsigned int i=0; idofs_per_face > max) + max = finite_elements[i]->dofs_per_face; - return max; -} + return max; + } -template -unsigned int -FECollection::max_dofs_per_cell () const -{ - Assert (finite_elements.size() > 0, ExcNoFiniteElements()); + template + unsigned int + FECollection::max_dofs_per_cell () const + { + Assert (finite_elements.size() > 0, ExcNoFiniteElements()); - unsigned int max = 0; - for (unsigned int i=0; idofs_per_cell > max) - max = finite_elements[i]->dofs_per_cell; - - return max; -} + unsigned int max = 0; + for (unsigned int i=0; idofs_per_cell > max) + max = finite_elements[i]->dofs_per_cell; + return max; + } + +} // namespace hp + #endif diff --git a/deal.II/deal.II/include/fe/hp_fe_values.h b/deal.II/deal.II/include/fe/hp_fe_values.h index dfc7bd1cba..dd42c6e75c 100644 --- a/deal.II/deal.II/include/fe/hp_fe_values.h +++ b/deal.II/deal.II/include/fe/hp_fe_values.h @@ -167,8 +167,8 @@ namespace hp * indicated by the parameters * to the constructor. */ - FEValuesBase (const MappingCollection &mapping_collection, - const QCollection &qcollection, + FEValuesBase (const hp::MappingCollection &mapping_collection, + const hp::QCollection &q_collection, const UpdateFlags update_flags); @@ -181,18 +181,18 @@ namespace hp * object for the mapping * object. */ - FEValuesBase (const QCollection &qcollection, + FEValuesBase (const hp::QCollection &q_collection, const UpdateFlags update_flags); protected: /** - * A copy of the MappingCollection + * A copy of the hp::MappingCollection * object, which was specified * upon construction of the * object. */ - const MappingCollection mapping_collection; + const hp::MappingCollection mapping_collection; /** * Copy of the quadrature @@ -200,7 +200,7 @@ namespace hp * provided to the * constructor. */ - const QCollection qcollection; + const hp::QCollection q_collection; /** * Values of the update flags as @@ -237,9 +237,9 @@ namespace hp * DoFHandler::get_fe() * function. */ - FEValues (const MappingCollection &mapping_collection, - const FECollection &fe_collection, - const QCollection &qcollection, + FEValues (const hp::MappingCollection &mapping_collection, + const hp::FECollection &fe_collection, + const hp::QCollection &q_collection, const UpdateFlags update_flags); @@ -265,9 +265,9 @@ namespace hp * DoFHandler::get_fe() * function. */ - FEValues (const FECollection &fe_collection, - const QCollection &qcollection, - const UpdateFlags update_flags); + FEValues (const hp::FECollection &fe_collection, + const hp::QCollection &q_collection, + const UpdateFlags update_flags); /** @@ -321,9 +321,9 @@ namespace hp * DoFHandler::get_fe() * function. */ - FEFaceValues (const MappingCollection &mapping_collection, - const FECollection &fe_collection, - const QCollection &qcollection, + FEFaceValues (const hp::MappingCollection &mapping_collection, + const hp::FECollection &fe_collection, + const hp::QCollection &q_collection, const UpdateFlags update_flags); @@ -349,9 +349,9 @@ namespace hp * DoFHandler::get_fe() * function. */ - FEFaceValues (const FECollection &fe_collection, - const QCollection &qcollection, - const UpdateFlags update_flags); + FEFaceValues (const hp::FECollection &fe_collection, + const hp::QCollection &q_collection, + const UpdateFlags update_flags); /** @@ -430,9 +430,9 @@ namespace hp * DoFHandler::get_fe() * function. */ - FESubfaceValues (const MappingCollection &mapping_collection, - const FECollection &fe_collection, - const QCollection &qcollection, + FESubfaceValues (const hp::MappingCollection &mapping_collection, + const hp::FECollection &fe_collection, + const hp::QCollection &q_collection, const UpdateFlags update_flags); @@ -458,9 +458,9 @@ namespace hp * DoFHandler::get_fe() * function. */ - FESubfaceValues (const FECollection &fe_collection, - const QCollection &qcollection, - const UpdateFlags update_flags); + FESubfaceValues (const hp::FECollection &fe_collection, + const hp::QCollection &q_collection, + const UpdateFlags update_flags); /** diff --git a/deal.II/deal.II/include/fe/mapping.h b/deal.II/deal.II/include/fe/mapping.h index 157d7c74b4..83950c4ee6 100644 --- a/deal.II/deal.II/include/fe/mapping.h +++ b/deal.II/deal.II/include/fe/mapping.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -354,6 +354,22 @@ class Mapping : public Subscriptor * each grid cell. */ virtual UpdateFlags update_each (const UpdateFlags) const = 0; + + /** + * Return a pointer to a copy of the + * present object. The caller of this + * copy then assumes ownership of it. + * + * Since one can't create + * objects of class Mapping, this + * function of course has to be + * implemented by derived classes. + * + * This function is mainly used by the + * hp::MappingCollection class. + */ + virtual + Mapping * clone () const = 0; /** * Exception diff --git a/deal.II/deal.II/include/fe/mapping_c1.h b/deal.II/deal.II/include/fe/mapping_c1.h index d7405a65c3..f3c5c32ab5 100644 --- a/deal.II/deal.II/include/fe/mapping_c1.h +++ b/deal.II/deal.II/include/fe/mapping_c1.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -50,6 +50,14 @@ class MappingC1 : public MappingQ */ MappingC1 (); + /** + * Return a pointer to a copy of the + * present object. The caller of this + * copy then assumes ownership of it. + */ + virtual + Mapping * clone () const; + protected: /** * For dim=2,3. Append the diff --git a/deal.II/deal.II/include/fe/mapping_cartesian.h b/deal.II/deal.II/include/fe/mapping_cartesian.h index dde71233a3..804ab76a9e 100644 --- a/deal.II/deal.II/include/fe/mapping_cartesian.h +++ b/deal.II/deal.II/include/fe/mapping_cartesian.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -143,7 +143,16 @@ class MappingCartesian : public Mapping virtual UpdateFlags update_once (const UpdateFlags) const; virtual UpdateFlags update_each (const UpdateFlags) const; - /** + + /** + * Return a pointer to a copy of the + * present object. The caller of this + * copy then assumes ownership of it. + */ + virtual + Mapping * clone () const; + + /** * Exception */ DeclException0 (ExcInvalidData); diff --git a/deal.II/deal.II/include/fe/mapping_collection.h b/deal.II/deal.II/include/fe/mapping_collection.h index 65377a67ee..f8bc4a0ee4 100644 --- a/deal.II/deal.II/include/fe/mapping_collection.h +++ b/deal.II/deal.II/include/fe/mapping_collection.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005 by the deal.II authors +// Copyright (C) 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -23,107 +22,113 @@ #include +namespace hp +{ /** - * This class implements a collection of mapping objects used in the - * hp::DoFHandler(). It is thus to a hp::DoFHandler() what a Mapping is to a - * DoFHandler. This collection stores pointers to the original mapping - * objects added to it. Hence the handling of the memory consumed by - * the mapping objects must be done by the user of the class. + * This class implements a collection of mapping objects in the same way as + * the hp::FECollection implements a collection of finite element classes. * - * Although it is strongly recommended to supply an appropriate mapping - * for each finite element type used in a hp-computation, the MappingCollection - * class implements a conversion constructor from a single mapping. - * Therefore it is possible to offer only a single mapping to the - * hpFEValues class instead of a MappingCollection. This is for the - * convenience of the user, as many simple geometries do not require - * different mappings along the boundary to achieve optimal convergence rates. - * Hence providing a single mapping object will usually suffice. + * Although it is recommended to supply an appropriate mapping for each finite + * element kind used in a hp-computation, the MappingCollection class + * implements a conversion constructor from a single mapping. Therefore it is + * possible to offer only a single mapping to the hpFEValues class instead of + * a MappingCollection. This is for the convenience of the user, as many + * simple geometries do not require different mappings along the boundary to + * achieve optimal convergence rates. Hence providing a single mapping object + * will usually suffice. * * @author Oliver Kayser-Herold, 2005 */ -template -class MappingCollection : public Subscriptor -{ - public: - /** - * Default constructor. Initialises - * this QCollection. - */ - MappingCollection (); - - /** - * Conversion constructor. This - * constructor creates a MappingCollection - * from a single mapping. In - * the newly created MappingCollection, this - * mapping is used for all active_fe - * indices. - */ - MappingCollection (const Mapping &mapping); - - /** - * Returns the number of mapping - * objects stored in this container. - */ - unsigned int n_mappings () const; - - /** - * Returns the mapping object which - * was specified by the user for the - * active_fe_index which is provided - * as a parameter to this method. - */ - const Mapping & - get_mapping (const unsigned int active_fe_index) const; + template + class MappingCollection : public Subscriptor + { + public: + /** + * Default constructor. Initialises + * this MappingCollection. + */ + MappingCollection (); + + /** + * Conversion constructor. This + * constructor creates a MappingCollection + * from a single mapping. In + * the newly created MappingCollection, this + * mapping is used for all active_fe + * indices. + */ + MappingCollection (const Mapping &mapping); + + /** + * Returns the number of mapping + * objects stored in this container. + */ + unsigned int n_mappings () const; + + /** + * Returns the mapping object which + * was specified by the user for the + * active_fe_index which is provided + * as a parameter to this method. + */ + const Mapping & + get_mapping (const unsigned int active_fe_index) const; - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. - */ - unsigned int memory_consumption () const; - - /** - * Adds a new mapping to the MappingCollection. - * The mappings have to be added in the order - * of the active_fe_indices. Thus the reference - * to the mapping object for active_fe_index 0 - * has to be added first, followed by the - * mapping object for active_fe_index 1. - */ - unsigned int add_mapping (const Mapping &new_mapping); - - private: - /** - * Upon construction of a MappingCollection - * the later functionality of the class is specified. - * Either it is a real collection, which provides - * different mappings for each active_fe_index - * or its a "unreal" collection, which returns - * a the same mapping for all active_fe_indices. - * This boolean remembers which type this object - * is. - */ - bool single_mapping; - - /** - * The real container, which stores pointers - * to the different Mapping objects. - */ - std::vector > > mappings; -}; + /** + * Determine an estimate for the + * memory consumption (in bytes) + * of this object. + */ + unsigned int memory_consumption () const; + + /** + * Adds a new mapping to the + * MappingCollection. The mappings + * have to be added in the order of the + * active_fe_indices. Thus the + * reference to the mapping object for + * active_fe_index 0 has to be added + * first, followed by the mapping + * object for active_fe_index 1. + */ + unsigned int add_mapping (const Mapping &new_mapping); + + private: + /** + * Upon construction of a + * MappingCollection the later + * functionality of the class is + * specified. Either it is a real + * collection, which provides different + * mappings for each active_fe_index or + * its a "unreal" collection, which + * returns a the same mapping for all + * active_fe_indices. This boolean + * remembers which type this object is. + */ + const bool single_mapping; + + /** + * The real container, which stores + * pointers to the different Mapping + * objects. + */ + std::vector > > mappings; + }; /* --------------- inline functions ------------------- */ -template -inline -unsigned int -MappingCollection::n_mappings () const -{ + template + inline + unsigned int + MappingCollection::n_mappings () const + { return mappings.size(); -} + } + +} // namespace hp #endif diff --git a/deal.II/deal.II/include/fe/mapping_q.h b/deal.II/deal.II/include/fe/mapping_q.h index 135e855400..82df1bda2c 100644 --- a/deal.II/deal.II/include/fe/mapping_q.h +++ b/deal.II/deal.II/include/fe/mapping_q.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -123,6 +123,14 @@ class MappingQ : public MappingQ1 * was passed to the constructor. */ unsigned int get_degree () const; + + /** + * Return a pointer to a copy of the + * present object. The caller of this + * copy then assumes ownership of it. + */ + virtual + Mapping * clone () const; /** * Storage for internal data of diff --git a/deal.II/deal.II/include/fe/mapping_q1.h b/deal.II/deal.II/include/fe/mapping_q1.h index d02932a4ec..1810833ab5 100644 --- a/deal.II/deal.II/include/fe/mapping_q1.h +++ b/deal.II/deal.II/include/fe/mapping_q1.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -194,6 +194,14 @@ class MappingQ1 : public Mapping */ virtual UpdateFlags update_each (const UpdateFlags flags) const; + /** + * Return a pointer to a copy of the + * present object. The caller of this + * copy then assumes ownership of it. + */ + virtual + Mapping * clone () const; + /** * Storage for internal data of * d-linear transformation. diff --git a/deal.II/deal.II/include/fe/mapping_q1_eulerian.h b/deal.II/deal.II/include/fe/mapping_q1_eulerian.h index 6851cb9015..24e447d4ce 100644 --- a/deal.II/deal.II/include/fe/mapping_q1_eulerian.h +++ b/deal.II/deal.II/include/fe/mapping_q1_eulerian.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -107,8 +107,16 @@ class MappingQ1Eulerian : public MappingQ1 */ MappingQ1Eulerian (const EulerVectorType &euler_transform_vectors, const DoFHandler &shiftmap_dof_handler); + + /** + * Return a pointer to a copy of the + * present object. The caller of this + * copy then assumes ownership of it. + */ + virtual + Mapping * clone () const; - + /** * Exception */ diff --git a/deal.II/deal.II/include/fe/q_collection.h b/deal.II/deal.II/include/fe/q_collection.h index aba72b788f..efe6c6a566 100644 --- a/deal.II/deal.II/include/fe/q_collection.h +++ b/deal.II/deal.II/include/fe/q_collection.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005 by the deal.II authors +// Copyright (C) 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,12 +22,12 @@ #include #include + +namespace hp +{ /** - * This class implements a collection of quadrature objects used in the - * hp::DoFHandler(). It is thus to a hp::DoFHandler() what a Quadrature is to a - * DoFHandler. This collection stores pointers to the original quadrature - * elements added to it. Hence the handling of the memory consumed by - * the quadrature objects must be done by the user of the class. + * This class implements a collection of quadrature objects in the same way as + * the hp::FECollection implements a collection of finite element classes. * * Although it is strongly recommended to supply an appropriate quadrature * for each finite element type used in a hp-computation, the QCollection @@ -42,91 +42,113 @@ * * @author Oliver Kayser-Herold, 2005 */ -template -class QCollection : public Subscriptor -{ - public: - /** - * Default constructor. Initialises - * this QCollection. - */ - QCollection (); - - /** - * Conversion constructor. This - * constructor creates a QCollection - * from a single quadrature rule. In - * the newly created QCollection, this - * quadrature is used for all active_fe - * indices. - */ - QCollection (const Quadrature &quadrature); - - /** - * Returns the number of quadrature - * pointers stored in this object. - */ - unsigned int n_quadratures () const; - - /** - * Returns a reference to the quadrature rule which - * was specified by the user for the - * active_fe_index which is provided - * as a parameter to this method. - */ - const Quadrature & - get_quadrature (const unsigned int active_fe_index) const; + template + class QCollection : public Subscriptor + { + public: + /** + * Default constructor. Initialises + * this QCollection. + */ + QCollection (); + + /** + * Conversion constructor. This + * constructor creates a QCollection + * from a single quadrature rule. In + * the newly created QCollection, this + * quadrature is used for all active_fe + * indices. + */ + QCollection (const Quadrature &quadrature); + + /** + * Returns the number of quadrature + * pointers stored in this object. + */ + unsigned int n_quadratures () const; + + /** + * Returns a reference to the + * quadrature rule which was specified + * by the user for the active_fe_index + * which is provided as a parameter to + * this method. + */ + const Quadrature & + get_quadrature (const unsigned int active_fe_index) const; + + /** + * Adds a new quadrature rule to the + * QCollection. The quadrature rules + * have to be added in the same order + * as for the FECollection for which + * this quadrature rule collection is + * meant. Thus the reference to the + * quadrature rule for active_fe_index + * 0 has to be added first, followed by + * the quadrature rule for + * active_fe_index 1. + * + * This class creates a copy of the + * given quadrature object, i.e. you + * can do things like + * add_quadrature(QGauss(3));. The + * internal copy is later destroyed by + * this object upon destruction of the + * entire collection. + */ + unsigned int add_quadrature (const Quadrature &new_quadrature); - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. - */ - unsigned int memory_consumption () const; - - /** - * Adds a new quadrature rule to the QCollection. - * The quadrature rules have to be added in the order - * of the active_fe_indices. Thus the reference - * to the quadrature rule for active_fe_index 0 - * has to be added first, followed by the - * quadrature rule for active_fe_index 1. - */ - unsigned int add_quadrature (const Quadrature &new_quadrature); - - DeclException0 (ExcNoQuadrature); + /** + * Determine an estimate for the + * memory consumption (in bytes) + * of this object. + */ + unsigned int memory_consumption () const; + + /** + * Exception + */ + DeclException0 (ExcNoQuadrature); - private: - /** - * Upon construction of a QCollection - * the later functionality of the class is specified. - * Either it is a real collection, which provides - * different quadrature rules for each active_fe_index - * or its a "unreal" collection, which returns - * a the same quadrature rule for all active_fe_indices. - * This boolean remembers which type this object - * is. - */ - bool single_quadrature; - - /** - * The real container, which stores pointers - * to the different quadrature objects. - */ - std::vector > > quadratures; -}; + private: + /** + * Upon construction of a + * QCollection the later + * functionality of the class is + * specified. Either it is a real + * collection, which provides different + * quadrature rules for each + * active_fe_index or its a "unreal" + * collection, which returns a the same + * quadrature rule for all + * active_fe_indices. This boolean + * remembers which type this object is. + */ + const bool single_quadrature; + + /** + * The real container, which stores + * pointers to the different quadrature + * objects. + */ + std::vector > > quadratures; + }; /* --------------- inline functions ------------------- */ -template -inline -unsigned int -QCollection::n_quadratures () const -{ + template + inline + unsigned int + QCollection::n_quadratures () const + { return quadratures.size(); -} + } + +} // namespace hp #endif diff --git a/deal.II/deal.II/source/dofs/hp_dof_handler.cc b/deal.II/deal.II/source/dofs/hp_dof_handler.cc index 291fc44265..d4045a9e02 100644 --- a/deal.II/deal.II/source/dofs/hp_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/hp_dof_handler.cc @@ -1377,7 +1377,7 @@ namespace hp template - void DoFHandler::distribute_dofs (const FECollection &ff) + void DoFHandler::distribute_dofs (const hp::FECollection &ff) { Assert (tria->n_levels() > 0, ExcInvalidTriangulation()); diff --git a/deal.II/deal.II/source/fe/fe_collection.cc b/deal.II/deal.II/source/fe/fe_collection.cc index 0587a091b1..917e3ba2d8 100644 --- a/deal.II/deal.II/source/fe/fe_collection.cc +++ b/deal.II/deal.II/source/fe/fe_collection.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -15,53 +15,44 @@ #include -template -FECollection::~FECollection () +namespace hp { - for (unsigned int i=0; i *p = finite_elements[i]; - finite_elements[i] = 0; - delete p; - } + template + unsigned int FECollection::add_fe (const FiniteElement &new_fe) + { + // check that the new element has the right + // number of components. only check with + // the first element, since all the other + // elements have already passed the test + // against the first element + if (finite_elements.size() != 0) + Assert (new_fe.n_components() == finite_elements[0]->n_components(), + ExcMessage ("All elements inside a collection need to have the " + "same number of vector components!")); - finite_elements.clear (); -} - + finite_elements + .push_back (boost::shared_ptr >(new_fe.clone())); + + return finite_elements.size (); + } -template -unsigned int FECollection::add_fe (const FiniteElement &new_fe) -{ - // check that the new element has the right - // number of components. only check with - // the first element, since all the other - // elements have already passed the test - // against the first element - if (finite_elements.size() != 0) - Assert (new_fe.n_components() == finite_elements[0]->n_components(), - ExcMessage ("All elements inside a collection need to have the " - "same number of vector components!")); - - finite_elements.push_back (new_fe.clone()); - return (finite_elements.size ()); -} + template + unsigned int + FECollection::memory_consumption () const + { + unsigned int mem + = (sizeof(*this) + + MemoryConsumption::memory_consumption (finite_elements)); + for (unsigned int i=0; imemory_consumption(); - -template -unsigned int -FECollection::memory_consumption () const -{ - unsigned int mem - = (sizeof(*this) + - MemoryConsumption::memory_consumption (finite_elements)); - for (unsigned int i=0; imemory_consumption(); - - return mem; -} + return mem; + } // explicit instantiations -template class FECollection; + template class FECollection; + +} diff --git a/deal.II/deal.II/source/fe/hp_fe_values.cc b/deal.II/deal.II/source/fe/hp_fe_values.cc index 243e0df076..89d711a596 100644 --- a/deal.II/deal.II/source/fe/hp_fe_values.cc +++ b/deal.II/deal.II/source/fe/hp_fe_values.cc @@ -61,22 +61,22 @@ namespace hp template FEValuesBase::FEValuesBase ( - const MappingCollection &mapping_collection, - const QCollection &qcollection, + const hp::MappingCollection &mapping_collection, + const hp::QCollection &q_collection, const UpdateFlags update_flags) : mapping_collection (mapping_collection), - qcollection (qcollection), + q_collection (q_collection), update_flags (update_flags) {} template - FEValuesBase::FEValuesBase (const QCollection &qcollection, + FEValuesBase::FEValuesBase (const hp::QCollection &q_collection, const UpdateFlags update_flags) : mapping_collection (default_mapping), - qcollection (qcollection), + q_collection (q_collection), update_flags (update_flags) {} @@ -87,23 +87,23 @@ namespace hp template - FEValues::FEValues (const MappingCollection &mapping, - const FECollection &/*fe_collection*/, - const QCollection &qcollection, + FEValues::FEValues (const hp::MappingCollection &mapping, + const hp::FECollection &/*fe_collection*/, + const hp::QCollection &q_collection, const UpdateFlags update_flags) : internal::FEValuesBase (mapping, - qcollection, + q_collection, update_flags) {} template - FEValues::FEValues (const FECollection &/*fe_collection*/, - const QCollection &qcollection, - const UpdateFlags update_flags) + FEValues::FEValues (const hp::FECollection &/*fe_collection*/, + const hp::QCollection &q_collection, + const UpdateFlags update_flags) : - internal::FEValuesBase (qcollection, + internal::FEValuesBase (q_collection, update_flags) {} @@ -125,7 +125,7 @@ namespace hp { return new ::FEValues ( this->mapping_collection.get_mapping (active_fe_index), fe, - this->qcollection.get_quadrature (active_fe_index), + this->q_collection.get_quadrature (active_fe_index), this->update_flags); } @@ -134,23 +134,23 @@ namespace hp template - FEFaceValues::FEFaceValues (const MappingCollection &mapping, - const FECollection &/*fe_collection*/, - const QCollection &qcollection, + FEFaceValues::FEFaceValues (const hp::MappingCollection &mapping, + const hp::FECollection &/*fe_collection*/, + const hp::QCollection &q_collection, const UpdateFlags update_flags) : internal::FEValuesBase (mapping, - qcollection, + q_collection, update_flags) {} template - FEFaceValues::FEFaceValues (const FECollection &/*fe_collection*/, - const QCollection &qcollection, + FEFaceValues::FEFaceValues (const hp::FECollection &/*fe_collection*/, + const hp::QCollection &q_collection, const UpdateFlags update_flags) : - internal::FEValuesBase (qcollection, + internal::FEValuesBase (q_collection, update_flags) {} @@ -183,7 +183,7 @@ namespace hp { return new ::FEFaceValues ( this->mapping_collection.get_mapping (active_fe_index), fe, - this->qcollection.get_quadrature (active_fe_index), + this->q_collection.get_quadrature (active_fe_index), this->update_flags); } @@ -192,23 +192,23 @@ namespace hp template - FESubfaceValues::FESubfaceValues (const MappingCollection &mapping, - const FECollection &/*fe_collection*/, - const QCollection &qcollection, + FESubfaceValues::FESubfaceValues (const hp::MappingCollection &mapping, + const hp::FECollection &/*fe_collection*/, + const hp::QCollection &q_collection, const UpdateFlags update_flags) : internal::FEValuesBase (mapping, - qcollection, + q_collection, update_flags) {} template - FESubfaceValues::FESubfaceValues (const FECollection &/*fe_collection*/, - const QCollection &qcollection, + FESubfaceValues::FESubfaceValues (const hp::FECollection &/*fe_collection*/, + const hp::QCollection &q_collection, const UpdateFlags update_flags) : - internal::FEValuesBase (qcollection, + internal::FEValuesBase (q_collection, update_flags) {} @@ -243,7 +243,7 @@ namespace hp { return new ::FESubfaceValues ( this->mapping_collection.get_mapping (active_fe_index), fe, - this->qcollection.get_quadrature (active_fe_index), + this->q_collection.get_quadrature (active_fe_index), this->update_flags); } diff --git a/deal.II/deal.II/source/fe/mapping_c1.cc b/deal.II/deal.II/source/fe/mapping_c1.cc index 01465466ef..d989af09ab 100644 --- a/deal.II/deal.II/source/fe/mapping_c1.cc +++ b/deal.II/deal.II/source/fe/mapping_c1.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -241,6 +241,15 @@ MappingC1::add_quad_support_points (const typename Triangulation::cell +template +Mapping * +MappingC1::clone () const +{ + return new MappingC1(*this); +} + + + // explicit instantiations template class MappingC1; diff --git a/deal.II/deal.II/source/fe/mapping_cartesian.cc b/deal.II/deal.II/source/fe/mapping_cartesian.cc index 911ee35538..35e43ed841 100644 --- a/deal.II/deal.II/source/fe/mapping_cartesian.cc +++ b/deal.II/deal.II/source/fe/mapping_cartesian.cc @@ -603,6 +603,14 @@ MappingCartesian::transform_real_to_unit_cell ( } +template +Mapping * +MappingCartesian::clone () const +{ + return new MappingCartesian(*this); +} + + //--------------------------------------------------------------------------- // explicit instantiations diff --git a/deal.II/deal.II/source/fe/mapping_collection.cc b/deal.II/deal.II/source/fe/mapping_collection.cc index a29d3c5327..f2086f5f9e 100644 --- a/deal.II/deal.II/source/fe/mapping_collection.cc +++ b/deal.II/deal.II/source/fe/mapping_collection.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003 by the deal.II authors +// Copyright (C) 2003, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -15,62 +15,69 @@ #include -template -MappingCollection::MappingCollection () : - single_mapping (false) +namespace hp { -} + template + MappingCollection::MappingCollection () : + single_mapping (false) + { + } -template -MappingCollection::MappingCollection (const Mapping &mapping) : - single_mapping (true) -{ - mappings.push_back (&mapping); -} + template + MappingCollection::MappingCollection (const Mapping &mapping) : + single_mapping (true) + { + mappings + .push_back (boost::shared_ptr >(mapping.clone())); + } -template -inline -const Mapping & -MappingCollection::get_mapping (const unsigned int active_fe_index) const -{ - SmartPointer > mapping; + template + inline + const Mapping & + MappingCollection::get_mapping (const unsigned int active_fe_index) const + { if (single_mapping) - mapping = mappings[0]; + return *mappings[0]; else - { + { Assert (active_fe_index < mappings.size (), ExcIndexRange (active_fe_index, 0, mappings.size ())); - mapping = mappings[active_fe_index]; - } - - return *mapping; -} + return *mappings[active_fe_index]; + } + } -template -unsigned int -MappingCollection::memory_consumption () const -{ + template + unsigned int + MappingCollection::memory_consumption () const + { return (sizeof(*this) + MemoryConsumption::memory_consumption (mappings)); -} + } -template -unsigned int MappingCollection:: -add_mapping (const Mapping &new_mapping) -{ - // A MappingCollection, which was initialized as single - // MappingCollection cannot administrate other Mappings. - Assert (!single_mapping, - ExcNotInitialized ()); - mappings.push_back (&new_mapping); - return (mappings.size ()); -} + template + unsigned int MappingCollection:: + add_mapping (const Mapping &new_mapping) + { + // A MappingCollection, which was + // initialized as single + // MappingCollection cannot administrate + // other Mappings. + Assert (!single_mapping, ExcNotInitialized ()); + + mappings + .push_back (boost::shared_ptr >(new_mapping.clone())); + + return mappings.size (); + } // explicit instantiations -template class MappingCollection; + template class MappingCollection; + + +} diff --git a/deal.II/deal.II/source/fe/mapping_q.cc b/deal.II/deal.II/source/fe/mapping_q.cc index b049360125..720d820146 100644 --- a/deal.II/deal.II/source/fe/mapping_q.cc +++ b/deal.II/deal.II/source/fe/mapping_q.cc @@ -1299,6 +1299,15 @@ MappingQ::get_degree() const return degree; } + + +template +Mapping * +MappingQ::clone () const +{ + return new MappingQ(*this); +} + // explicit instantiation template class MappingQ; diff --git a/deal.II/deal.II/source/fe/mapping_q1.cc b/deal.II/deal.II/source/fe/mapping_q1.cc index 4c68f11193..c1a5cc54dc 100644 --- a/deal.II/deal.II/source/fe/mapping_q1.cc +++ b/deal.II/deal.II/source/fe/mapping_q1.cc @@ -1021,6 +1021,15 @@ transform_real_to_unit_cell_internal } } + + +template +Mapping * +MappingQ1::clone () const +{ + return new MappingQ1(*this); +} + //--------------------------------------------------------------------------- template class MappingQ1; diff --git a/deal.II/deal.II/source/fe/mapping_q1_eulerian.cc b/deal.II/deal.II/source/fe/mapping_q1_eulerian.cc index e305c1471e..1fac0108ec 100644 --- a/deal.II/deal.II/source/fe/mapping_q1_eulerian.cc +++ b/deal.II/deal.II/source/fe/mapping_q1_eulerian.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -104,6 +104,15 @@ compute_mapping_support_points(const typename Triangulation::cell_iterator } + +template +Mapping * +MappingQ1Eulerian::clone () const +{ + return new MappingQ1Eulerian(*this); +} + + // explicit instantiation template class MappingQ1Eulerian >; #ifdef DEAL_II_USE_PETSC diff --git a/deal.II/deal.II/source/fe/q_collection.cc b/deal.II/deal.II/source/fe/q_collection.cc index bdfe0fc882..32e84e8edf 100644 --- a/deal.II/deal.II/source/fe/q_collection.cc +++ b/deal.II/deal.II/source/fe/q_collection.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003 by the deal.II authors +// Copyright (C) 2003, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -15,65 +15,78 @@ #include -template -QCollection::QCollection () : - single_quadrature (false) -{ -} - -template -QCollection::QCollection (const Quadrature &quadrature) : - single_quadrature (true) +namespace hp { - quadratures.push_back (&quadrature); -} + + template + QCollection::QCollection () + : + single_quadrature (false) + { + } -template -inline -const Quadrature & -QCollection::get_quadrature (const unsigned int active_fe_index) const -{ - SmartPointer > quad; + template + QCollection::QCollection (const Quadrature &quadrature) + : + single_quadrature (true) + { + quadratures + .push_back (boost::shared_ptr >(new Quadrature(quadrature))); + } + + + template + inline + const Quadrature & + QCollection::get_quadrature (const unsigned int active_fe_index) const + { + // if we have only a single quadrature + // that was given during construction, + // return this one. otherwise pick out + // the correct one if (single_quadrature) - quad = quadratures[0]; + return *quadratures[0]; else - { + { Assert (active_fe_index < quadratures.size (), ExcIndexRange (active_fe_index, 0, quadratures.size ())); - quad = quadratures[active_fe_index]; - } - - return *quad; -} + return *quadratures[active_fe_index]; + } + } -template -unsigned int -QCollection::memory_consumption () const -{ + template + unsigned int + QCollection::memory_consumption () const + { return (sizeof(*this) + MemoryConsumption::memory_consumption (quadratures)); -} + } -template -unsigned int QCollection:: -add_quadrature (const Quadrature &new_quadrature) -{ - // A QCollection, which was initialized as single QCollection cannot - // administrate other Quadratures. - Assert (!single_quadrature, - ExcNotInitialized ()); - quadratures.push_back (&new_quadrature); - return (quadratures.size ()); -} + template + unsigned int QCollection:: + add_quadrature (const Quadrature &new_quadrature) + { + // A QCollection, which was initialized + // as single QCollection cannot + // administrate other Quadratures. + Assert (!single_quadrature, ExcNotInitialized ()); + + quadratures + .push_back (boost::shared_ptr >(new Quadrature(new_quadrature))); + return quadratures.size (); + } // explicit instantiations -template class QCollection; + template class QCollection; #if deal_II_dimension >= 2 -template class QCollection; + template class QCollection; #endif + + +} diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 779ed6ff1a..f0d95d64c6 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -258,6 +258,14 @@ inconvenience this causes.

deal.II

    +
  1. + New: The Mapping class and derived classes now have + functions clone() that return a new object of the same + (derived) type. +
    + (WB 2006/1/8) +

    +
  2. Improved: The KellyErrorEstimator class now also allows to select the cells on which it is supposed to work by giving a material diff --git a/deal.II/examples/step-21/step-21.cc b/deal.II/examples/step-21/step-21.cc index f4bb9e71b6..35ff4bd5ba 100644 --- a/deal.II/examples/step-21/step-21.cc +++ b/deal.II/examples/step-21/step-21.cc @@ -614,7 +614,7 @@ class DGMethod // objects for the different polynomial // degrees will be stored in the // fe_collection object. - FECollection fe_collection; + hp::FECollection fe_collection; // As already mentioned, the // standard DoFHandler has to be @@ -633,10 +633,8 @@ class DGMethod // rules for each polynomial // degree which will be used in the // computations. - std::vector *> quad; - QCollection *quadrature; - std::vector *> face_quad; - QCollection *face_quadrature; + hp::QCollection quadratures; + hp::QCollection face_quadratures; // And there are two solution // vectors, that store the @@ -664,11 +662,6 @@ DGMethod::DGMethod () dof_handler (triangulation), dg () { - quadrature = new QCollection (); - face_quadrature = new QCollection (); - - Quadrature *quad_temp; - Quadrature *face_quad_temp; // Change here for hp // methods of // different maximum degrees. @@ -677,15 +670,8 @@ DGMethod::DGMethod () for (unsigned int i = 0; i < hp_degree; ++i) { elm_no = fe_collection.add_fe (FE_DGQ (i+1)); - - quad_temp = new QGauss (i+2); - quad.push_back (quad_temp); - quadrature->add_quadrature (*quad_temp); - - // face_quad_temp = new QGauss (7); - face_quad_temp = new QGauss (i+2); - face_quad.push_back (face_quad_temp); - face_quadrature->add_quadrature (*face_quad_temp); + quadratures.add_quadrature (QGauss (i+2)); + face_quadratures.add_quadrature (QGauss (i+2)); } } @@ -694,19 +680,6 @@ template DGMethod::~DGMethod () { dof_handler.clear (); - - // Free the dynamically created quadrature rules - delete quadrature; - delete face_quadrature; - - typename std::vector *>::iterator quad_iter; - for (quad_iter = quad.begin (); quad_iter != quad.end (); ++quad_iter) - delete (*quad_iter); - - typename std::vector *>::iterator face_quad_iter; - for (face_quad_iter = face_quad.begin (); - face_quad_iter != face_quad.end (); ++face_quad_iter) - delete (*face_quad_iter); } @@ -854,7 +827,7 @@ void DGMethod::assemble_system1 () // assumes a ``MappingQ1'' mapping) // and makes it easier to change // the mapping object later. - hp::FEValues fe_v_x (mapping, fe_collection, *quadrature, update_flags); + hp::FEValues fe_v_x (mapping, fe_collection, quadratures, update_flags); // Similarly we create the // ``FEFaceValues'' and @@ -867,13 +840,13 @@ void DGMethod::assemble_system1 () // current cell and the face (and // subface) number. hp::FEFaceValues fe_v_face_x ( - mapping, fe_collection, *face_quadrature, face_update_flags); + mapping, fe_collection, face_quadratures, face_update_flags); hp::FESubfaceValues fe_v_subface_x ( - mapping, fe_collection, *face_quadrature, face_update_flags); + mapping, fe_collection, face_quadratures, face_update_flags); hp::FEFaceValues fe_v_face_neighbor_x ( - mapping, fe_collection, *face_quadrature, neighbor_face_update_flags); + mapping, fe_collection, face_quadratures, neighbor_face_update_flags); hp::FESubfaceValues fe_v_subface_neighbor_x ( - mapping, fe_collection, *face_quadrature, neighbor_face_update_flags); + mapping, fe_collection, face_quadratures, neighbor_face_update_flags); // Now we create the cell matrices // and vectors. Here we need two @@ -1348,13 +1321,13 @@ void DGMethod::assemble_system2 () // ``fe_v_face_neighbor'' as case 4 // does not occur. hp::FEValues fe_v_x ( - mapping, fe_collection, *quadrature, update_flags); + mapping, fe_collection, quadratures, update_flags); hp::FEFaceValues fe_v_face_x ( - mapping, fe_collection, *face_quadrature, face_update_flags); + mapping, fe_collection, face_quadratures, face_update_flags); hp::FESubfaceValues fe_v_subface_x ( - mapping, fe_collection, *face_quadrature, face_update_flags); + mapping, fe_collection, face_quadratures, face_update_flags); hp::FEFaceValues fe_v_face_neighbor_x ( - mapping, fe_collection, *face_quadrature, neighbor_face_update_flags); + mapping, fe_collection, face_quadratures, neighbor_face_update_flags); const unsigned int max_dofs_per_cell = fe_collection.max_dofs_per_cell (); -- 2.39.5