Reference documentation for deal.II version 8.1.0
q_collection.h
1 // ---------------------------------------------------------------------
2 // @f$Id: q_collection.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 2005 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__q_collection_h
18 #define __deal2__q_collection_h
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/subscriptor.h>
22 #include <deal.II/base/quadrature.h>
23 #include <deal.II/base/memory_consumption.h>
24 #include <deal.II/fe/fe.h>
25 
26 #include <vector>
27 #include <deal.II/base/std_cxx1x/shared_ptr.h>
28 
30 
31 namespace hp
32 {
44  template <int dim>
45  class QCollection : public Subscriptor
46  {
47  public:
54  QCollection ();
55 
67  explicit QCollection (const Quadrature<dim> &quadrature);
68 
72  QCollection (const QCollection<dim> &q_collection);
73 
98  void push_back (const Quadrature<dim> &new_quadrature);
99 
109  const Quadrature<dim> &
110  operator[] (const unsigned int index) const;
111 
117  unsigned int size () const;
118 
132  unsigned int max_n_quadrature_points () const;
133 
139  std::size_t memory_consumption () const;
140 
144  DeclException0 (ExcNoQuadrature);
145 
146  private:
152  std::vector<std_cxx1x::shared_ptr<const Quadrature<dim> > > quadratures;
153  };
154 
155 
156 
157  /* --------------- inline functions ------------------- */
158 
159  template <int dim>
160  inline
161  unsigned int
163  {
164  return quadratures.size();
165  }
166 
167 
168 
169  template <int dim>
170  inline
171  unsigned int
173  {
174  Assert (quadratures.size() > 0,
175  ExcMessage ("You can't call this function for an empty collection"));
176 
177  unsigned int m = 0;
178  for (unsigned int i=0; i<quadratures.size(); ++i)
179  if (quadratures[i]->size() > m)
180  m = quadratures[i]->size();
181 
182  return m;
183  }
184 
185 
186 
187  template <int dim>
188  inline
189  const Quadrature<dim> &
190  QCollection<dim>::operator[] (const unsigned int index) const
191  {
192  Assert (index < quadratures.size (),
193  ExcIndexRange (index, 0, quadratures.size ()));
194  return *quadratures[index];
195  }
196 
197 
198 
199  template <int dim>
200  inline
202  {}
203 
204 
205 
206  template <int dim>
207  inline
209  {
211  .push_back (std_cxx1x::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(quadrature)));
212  }
213 
214 
215 
216  template <int dim>
217  inline
219  QCollection (const QCollection<dim> &q_collection)
220  :
221  Subscriptor (),
222  // copy the array
223  // of shared
224  // pointers. nothing
225  // bad should
226  // happen -- they
227  // simply all point
228  // to the same
229  // objects, and the
230  // last one to die
231  // will delete the
232  // mappings
233  quadratures (q_collection.quadratures)
234  {}
235 
236 
237 
238  template <int dim>
239  inline
240  std::size_t
242  {
243  return (sizeof(*this) +
245  }
246 
247 
248  template <int dim>
249  inline
250  void
252  {
254  .push_back (std_cxx1x::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(new_quadrature)));
255  }
256 
257 } // namespace hp
258 
259 
260 DEAL_II_NAMESPACE_CLOSE
261 
262 #endif
::ExceptionBase & ExcMessage(std::string arg1)
unsigned int size() const
Definition: q_collection.h:162
#define Assert(cond, exc)
Definition: exceptions.h:299
std::size_t memory_consumption(const T &t)
DeclException0(ExcNoQuadrature)
::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
const Quadrature< dim > & operator[](const unsigned int index) const
Definition: q_collection.h:190
unsigned int max_n_quadrature_points() const
Definition: q_collection.h:172
Definition: hp.h:103
std::vector< std_cxx1x::shared_ptr< const Quadrature< dim > > > quadratures
Definition: q_collection.h:152
void push_back(const Quadrature< dim > &new_quadrature)
Definition: q_collection.h:251
std::size_t memory_consumption() const
Definition: q_collection.h:241