qoi_set.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 // C++ Includes -------------------------------------
21 #include <vector>
22 
23 // Local Includes -----------------------------------
24 #include "libmesh/qoi_set.h"
25 #include "libmesh/system.h"
26 
27 namespace libMesh
28 {
29 
30 // ------------------------------------------------------------
31 // QoISet implementation
32 
33 
34 QoISet::QoISet(const System &sys) : _indices(sys.qoi.size(), true) {}
35 
36 
37 
38 unsigned int QoISet::size (const System& sys) const
39 {
40  unsigned int qoi_count = 0;
41  for (unsigned int i=0; i != sys.qoi.size(); ++i)
42  if (this->has_index(i))
43  qoi_count++;
44  return qoi_count;
45 }
46 
47 
48 
49 void QoISet::add_indices(const std::vector<unsigned int> &indices)
50 {
51  unsigned int max_size = 0;
52  for (std::vector<unsigned int>::const_iterator i = indices.begin();
53  i != indices.end(); ++i)
54  max_size = std::max(max_size, *i + 1);
55 
56  _indices.resize(max_size);
57 
58  for (std::vector<unsigned int>::const_iterator i = indices.begin();
59  i != indices.end(); ++i)
60  _indices[*i] = true;
61 }
62 
63 
64 
65 inline
66 void QoISet::remove_indices(const std::vector<unsigned int> &indices)
67 {
68  for (std::vector<unsigned int>::const_iterator i = indices.begin();
69  i != indices.end(); ++i)
70  _indices[*i] = false;
71 }
72 
73 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo