Reference documentation for deal.II version Git 122d3af54c 2020-10-24 18:39:52 -0400
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
mapping_collection.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2020 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_mapping_collection_h
17 #define dealii_mapping_collection_h
18 
19 #include <deal.II/base/config.h>
20 
22 
23 #include <deal.II/fe/fe.h>
24 #include <deal.II/fe/mapping_q1.h>
25 
26 #include <memory>
27 #include <vector>
28 
30 
31 namespace hp
32 {
53  template <int dim, int spacedim = dim>
55  {
56  public:
61  MappingCollection() = default;
62 
69  explicit MappingCollection(const Mapping<dim, spacedim> &mapping);
70 
75  const MappingCollection<dim, spacedim> &mapping_collection);
76 
83  template <class... MappingTypes>
84  explicit MappingCollection(const MappingTypes &... mappings);
85 
98  void
99  push_back(const Mapping<dim, spacedim> &new_mapping);
100 
108  const Mapping<dim, spacedim> &operator[](const unsigned int index) const;
109 
113  unsigned int
114  size() const;
115 
120  std::size_t
121  memory_consumption() const;
122 
123  private:
128  std::vector<std::shared_ptr<const Mapping<dim, spacedim>>> mappings;
129  };
130 
131 
148  template <int dim, int spacedim = dim>
150  {
151  public:
156  };
157 
158 
159  /* --------------- inline functions ------------------- */
160 
161  template <int dim, int spacedim>
162  template <class... MappingTypes>
164  const MappingTypes &... mappings)
165  {
166  static_assert(
167  is_base_of_all<Mapping<dim, spacedim>, MappingTypes...>::value,
168  "Not all of the input arguments of this function "
169  "are derived from FiniteElement<dim,spacedim>!");
170 
171  // loop over all of the given arguments and add the mappings to
172  // this collection. Inlining the definition of mapping_pointers causes
173  // internal compiler errors on GCC 7.1.1 so we define it separately:
174  const auto mapping_pointers = {
175  (static_cast<const Mapping<dim, spacedim> *>(&mappings))...};
176  for (const auto p : mapping_pointers)
177  push_back(*p);
178  }
179 
180  template <int dim, int spacedim>
181  inline unsigned int
183  {
184  return mappings.size();
185  }
186 
187 
188 
189  template <int dim, int spacedim>
191  operator[](const unsigned int index) const
192  {
193  AssertIndexRange(index, mappings.size());
194  return *mappings[index];
195  }
196 
197 } // namespace hp
198 
199 
201 
202 #endif
void push_back(const Mapping< dim, spacedim > &new_mapping)
static MappingCollection< dim, spacedim > mapping_collection
#define AssertIndexRange(index, range)
Definition: exceptions.h:1648
MappingCollection()=default
std::vector< std::shared_ptr< const Mapping< dim, spacedim > > > mappings
Abstract base class for mapping classes.
Definition: mapping.h:301
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:369
Definition: hp.h:117
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:368
const Mapping< dim, spacedim > & operator[](const unsigned int index) const
std::size_t memory_consumption() const
unsigned int size() const