Reference documentation for deal.II version 9.2.0
\(\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\}}\)
named_selection.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2018 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_named_selection_h
17 #define dealii_named_selection_h
18 
19 #include <deal.II/base/config.h>
20 
22 
23 #include <string>
24 
26 
36 {
37 public:
43  void
44  add(const std::string &name);
45 
46 
50  void
51  initialize(const AnyData &data);
52 
53 
58  unsigned int
59  size() const;
60 
61 
68  unsigned int
69  operator()(unsigned int i) const;
70 
71 
72 private:
76  std::vector<std::string> names;
77 
81  std::vector<unsigned int> indices;
82 };
83 
84 
85 inline unsigned int
87 {
88  return names.size();
89 }
90 
91 
92 inline void
93 NamedSelection::add(const std::string &s)
94 {
95  names.push_back(s);
96 }
97 
98 
99 inline unsigned int
100 NamedSelection::operator()(unsigned int i) const
101 {
102  Assert(indices.size() == names.size(), ExcNotInitialized());
103 
104  AssertIndexRange(i, size());
105 
106  return indices[i];
107 }
108 
110 
111 #endif
AnyData
Definition: any_data.h:37
NamedSelection::initialize
void initialize(const AnyData &data)
Definition: named_selection.cc:22
NamedSelection::size
unsigned int size() const
Definition: named_selection.h:86
NamedSelection::add
void add(const std::string &name)
Definition: named_selection.h:93
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
NamedSelection
Definition: named_selection.h:35
NamedSelection::operator()
unsigned int operator()(unsigned int i) const
Definition: named_selection.h:100
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
StandardExceptions::ExcNotInitialized
static ::ExceptionBase & ExcNotInitialized()
any_data.h
NamedSelection::indices
std::vector< unsigned int > indices
Definition: named_selection.h:81
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
NamedSelection::names
std::vector< std::string > names
Definition: named_selection.h:76