include/deal.II/hp/q_collection.h

00001 //----------------------------  q_collection.h  ----------------------------
00002 //    @f$Id: q_collection.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //----------------------------  q_collection.h  ----------------------------
00012 #ifndef __deal2__q_collection_h
00013 #define __deal2__q_collection_h
00014 
00015 #include <deal.II/base/config.h>
00016 #include <deal.II/base/subscriptor.h>
00017 #include <deal.II/base/quadrature.h>
00018 #include <deal.II/base/memory_consumption.h>
00019 #include <deal.II/fe/fe.h>
00020 
00021 #include <vector>
00022 #include <deal.II/base/std_cxx1x/shared_ptr.h>
00023 
00024 DEAL_II_NAMESPACE_OPEN
00025 
00026 namespace hp
00027 {
00039   template <int dim>
00040   class QCollection : public Subscriptor
00041   {
00042     public:
00049       QCollection ();
00050 
00062       explicit QCollection (const Quadrature<dim> &quadrature);
00063 
00067       QCollection (const QCollection<dim> &q_collection);
00068 
00093       void push_back (const Quadrature<dim> &new_quadrature);
00094 
00104       const Quadrature<dim> &
00105       operator[] (const unsigned int index) const;
00106 
00112       unsigned int size () const;
00113 
00127       unsigned int max_n_quadrature_points () const;
00128 
00134       std::size_t memory_consumption () const;
00135 
00139       DeclException0 (ExcNoQuadrature);
00140 
00141     private:
00147       std::vector<std_cxx1x::shared_ptr<const Quadrature<dim> > > quadratures;
00148   };
00149 
00150 
00151 
00152 /* --------------- inline functions ------------------- */
00153 
00154   template <int dim>
00155   inline
00156   unsigned int
00157   QCollection<dim>::size () const
00158   {
00159     return quadratures.size();
00160   }
00161 
00162 
00163 
00164   template <int dim>
00165   inline
00166   unsigned int
00167   QCollection<dim>::max_n_quadrature_points () const
00168   {
00169     Assert (quadratures.size() > 0,
00170             ExcMessage ("You can't call this function for an empty collection"));
00171 
00172     unsigned int m = 0;
00173     for (unsigned int i=0; i<quadratures.size(); ++i)
00174       if (quadratures[i]->size() > m)
00175         m = quadratures[i]->size();
00176 
00177     return m;
00178   }
00179 
00180 
00181 
00182   template <int dim>
00183   inline
00184   const Quadrature<dim> &
00185   QCollection<dim>::operator[] (const unsigned int index) const
00186   {
00187     Assert (index < quadratures.size (),
00188             ExcIndexRange (index, 0, quadratures.size ()));
00189     return *quadratures[index];
00190   }
00191 
00192 
00193 
00194   template <int dim>
00195   inline
00196   QCollection<dim>::QCollection ()
00197   {}
00198 
00199 
00200 
00201   template <int dim>
00202   inline
00203   QCollection<dim>::QCollection (const Quadrature<dim> &quadrature)
00204   {
00205     quadratures
00206       .push_back (std_cxx1x::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(quadrature)));
00207   }
00208 
00209 
00210 
00211   template <int dim>
00212   inline
00213   QCollection<dim>::
00214   QCollection (const QCollection<dim> &q_collection)
00215                   :
00216                   Subscriptor (),
00217                                                    // copy the array
00218                                                    // of shared
00219                                                    // pointers. nothing
00220                                                    // bad should
00221                                                    // happen -- they
00222                                                    // simply all point
00223                                                    // to the same
00224                                                    // objects, and the
00225                                                    // last one to die
00226                                                    // will delete the
00227                                                    // mappings
00228                   quadratures (q_collection.quadratures)
00229   {}
00230 
00231 
00232 
00233   template <int dim>
00234   inline
00235   std::size_t
00236   QCollection<dim>::memory_consumption () const
00237   {
00238     return (sizeof(*this) +
00239             MemoryConsumption::memory_consumption (quadratures));
00240   }
00241 
00242 
00243   template <int dim>
00244   inline
00245   void
00246   QCollection<dim>::push_back (const Quadrature<dim> &new_quadrature)
00247   {
00248     quadratures
00249       .push_back (std_cxx1x::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(new_quadrature)));
00250   }
00251 
00252 } // namespace hp
00253 
00254 
00255 DEAL_II_NAMESPACE_CLOSE
00256 
00257 #endif
00258 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Wed May 23 2012 06:07:35 by doxygen 1.7.3