Reference documentation for deal.II version 8.5.1
q_collection.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__q_collection_h
17 #define dealii__q_collection_h
18 
19 #include <deal.II/base/config.h>
20 #include <deal.II/base/subscriptor.h>
21 #include <deal.II/base/quadrature.h>
22 #include <deal.II/base/memory_consumption.h>
23 #include <deal.II/fe/fe.h>
24 
25 #include <vector>
26 #include <deal.II/base/std_cxx11/shared_ptr.h>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 namespace hp
31 {
45  template <int dim>
46  class QCollection : public Subscriptor
47  {
48  public:
53  QCollection ();
54 
61  explicit QCollection (const Quadrature<dim> &quadrature);
62 
66  QCollection (const QCollection<dim> &q_collection);
67 
92  void push_back (const Quadrature<dim> &new_quadrature);
93 
100  const Quadrature<dim> &
101  operator[] (const unsigned int index) const;
102 
106  unsigned int size () const;
107 
114  unsigned int max_n_quadrature_points () const;
115 
120  std::size_t memory_consumption () const;
121 
126 
127  private:
132  std::vector<std_cxx11::shared_ptr<const Quadrature<dim> > > quadratures;
133  };
134 
135 
136 
137  /* --------------- inline functions ------------------- */
138 
139  template <int dim>
140  inline
141  unsigned int
143  {
144  return quadratures.size();
145  }
146 
147 
148 
149  template <int dim>
150  inline
151  unsigned int
153  {
154  Assert (quadratures.size() > 0,
155  ExcMessage ("You can't call this function for an empty collection"));
156 
157  unsigned int m = 0;
158  for (unsigned int i=0; i<quadratures.size(); ++i)
159  if (quadratures[i]->size() > m)
160  m = quadratures[i]->size();
161 
162  return m;
163  }
164 
165 
166 
167  template <int dim>
168  inline
169  const Quadrature<dim> &
170  QCollection<dim>::operator[] (const unsigned int index) const
171  {
172  Assert (index < quadratures.size (),
173  ExcIndexRange (index, 0, quadratures.size ()));
174  return *quadratures[index];
175  }
176 
177 
178 
179  template <int dim>
180  inline
182  {}
183 
184 
185 
186  template <int dim>
187  inline
189  {
190  quadratures
191  .push_back (std_cxx11::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(quadrature)));
192  }
193 
194 
195 
196  template <int dim>
197  inline
199  QCollection (const QCollection<dim> &q_collection)
200  :
201  Subscriptor (),
202  // copy the array
203  // of shared
204  // pointers. nothing
205  // bad should
206  // happen -- they
207  // simply all point
208  // to the same
209  // objects, and the
210  // last one to die
211  // will delete the
212  // mappings
213  quadratures (q_collection.quadratures)
214  {}
215 
216 
217 
218  template <int dim>
219  inline
220  std::size_t
222  {
223  return (sizeof(*this) +
225  }
226 
227 
228  template <int dim>
229  inline
230  void
232  {
233  quadratures
234  .push_back (std_cxx11::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(new_quadrature)));
235  }
236 
237 } // namespace hp
238 
239 
240 DEAL_II_NAMESPACE_CLOSE
241 
242 #endif
std::size_t memory_consumption() const
Definition: q_collection.h:221
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
const Quadrature< dim > & operator[](const unsigned int index) const
Definition: q_collection.h:170
static ::ExceptionBase & ExcMessage(std::string arg1)
unsigned int max_n_quadrature_points() const
Definition: q_collection.h:152
#define Assert(cond, exc)
Definition: exceptions.h:313
#define DeclException0(Exception0)
Definition: exceptions.h:541
unsigned int size() const
Definition: q_collection.h:142
Definition: hp.h:102
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcNoQuadrature()
std::vector< std_cxx11::shared_ptr< const Quadrature< dim > > > quadratures
Definition: q_collection.h:132
void push_back(const Quadrature< dim > &new_quadrature)
Definition: q_collection.h:231