qoi_set.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // Local Includes
21 #include "libmesh/qoi_set.h"
22 #include "libmesh/system.h"
23 
24 // C++ Includes
25 #include <vector>
26 
27 
28 namespace libMesh
29 {
30 
31 QoISet::QoISet(const System & sys) : _indices(sys.n_qois(), true) {}
32 
33 
34 
35 std::size_t QoISet::size (const System & sys) const
36 {
37  std::size_t qoi_count = 0;
38  for (unsigned int i=0; i != sys.n_qois(); ++i)
39  if (this->has_index(i))
40  qoi_count++;
41  return qoi_count;
42 }
43 
44 
45 
46 void QoISet::add_indices(const std::vector<unsigned int> & indices)
47 {
48  unsigned int max_size = 0;
49  for (const auto & i : indices)
50  max_size = std::max(max_size, i + 1);
51 
52  _indices.resize(max_size);
53 
54  for (const auto & i : indices)
55  _indices[i] = true;
56 }
57 
58 
59 
60 inline
61 void QoISet::remove_indices(const std::vector<unsigned int> & indices)
62 {
63  for (const auto & i : indices)
64  _indices[i] = false;
65 }
66 
67 } // namespace libMesh
unsigned int n_qois() const
Definition: system.h:2278
long double max(long double a, double b)
std::vector< bool > _indices
Definition: qoi_set.h:176
bool has_index(std::size_t) const
Definition: qoi_set.h:221
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:92
std::size_t size(const System &sys) const
Definition: qoi_set.C:35
void add_indices(const std::vector< unsigned int > &indices)
Definition: qoi_set.C:46
void remove_indices(const std::vector< unsigned int > &indices)
Definition: qoi_set.C:61