Reference documentation for deal.II version 8.4.2
q_collection.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2015 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 
80  void push_back (const Quadrature<dim> &new_quadrature);
81 
88  const Quadrature<dim> &
89  operator[] (const unsigned int index) const;
90 
94  unsigned int size () const;
95 
102  unsigned int max_n_quadrature_points () const;
103 
108  std::size_t memory_consumption () const;
109 
113  DeclException0 (ExcNoQuadrature);
114 
115  private:
120  std::vector<std_cxx11::shared_ptr<const Quadrature<dim> > > quadratures;
121  };
122 
123 
124 
125  /* --------------- inline functions ------------------- */
126 
127  template <int dim>
128  inline
129  unsigned int
131  {
132  return quadratures.size();
133  }
134 
135 
136 
137  template <int dim>
138  inline
139  unsigned int
141  {
142  Assert (quadratures.size() > 0,
143  ExcMessage ("You can't call this function for an empty collection"));
144 
145  unsigned int m = 0;
146  for (unsigned int i=0; i<quadratures.size(); ++i)
147  if (quadratures[i]->size() > m)
148  m = quadratures[i]->size();
149 
150  return m;
151  }
152 
153 
154 
155  template <int dim>
156  inline
157  const Quadrature<dim> &
158  QCollection<dim>::operator[] (const unsigned int index) const
159  {
160  Assert (index < quadratures.size (),
161  ExcIndexRange (index, 0, quadratures.size ()));
162  return *quadratures[index];
163  }
164 
165 
166 
167  template <int dim>
168  inline
170  {}
171 
172 
173 
174  template <int dim>
175  inline
177  {
179  .push_back (std_cxx11::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(quadrature)));
180  }
181 
182 
183 
184  template <int dim>
185  inline
187  QCollection (const QCollection<dim> &q_collection)
188  :
189  Subscriptor (),
190  // copy the array
191  // of shared
192  // pointers. nothing
193  // bad should
194  // happen -- they
195  // simply all point
196  // to the same
197  // objects, and the
198  // last one to die
199  // will delete the
200  // mappings
201  quadratures (q_collection.quadratures)
202  {}
203 
204 
205 
206  template <int dim>
207  inline
208  std::size_t
210  {
211  return (sizeof(*this) +
213  }
214 
215 
216  template <int dim>
217  inline
218  void
220  {
221  quadratures
222  .push_back (std_cxx11::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(new_quadrature)));
223  }
224 
225 } // namespace hp
226 
227 
228 DEAL_II_NAMESPACE_CLOSE
229 
230 #endif
::ExceptionBase & ExcMessage(std::string arg1)
std::size_t memory_consumption() const
Definition: q_collection.h:209
const Quadrature< dim > & operator[](const unsigned int index) const
Definition: q_collection.h:158
unsigned int max_n_quadrature_points() const
Definition: q_collection.h:140
#define Assert(cond, exc)
Definition: exceptions.h:294
DeclException0(ExcNoQuadrature)
unsigned int size() const
Definition: q_collection.h:130
Definition: hp.h:102
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::vector< std_cxx11::shared_ptr< const Quadrature< dim > > > quadratures
Definition: q_collection.h:120
void push_back(const Quadrature< dim > &new_quadrature)
Definition: q_collection.h:219