libMesh
qoi_set.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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.qoi.size(), true) {}
32 
33 
34 
35 unsigned int QoISet::size (const System & sys) const
36 {
37  unsigned int qoi_count = 0;
38  for (std::size_t i=0; i != sys.qoi.size(); ++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 (std::vector<unsigned int>::const_iterator i = indices.begin();
50  i != indices.end(); ++i)
51  max_size = std::max(max_size, *i + 1);
52 
53  _indices.resize(max_size);
54 
55  for (std::vector<unsigned int>::const_iterator i = indices.begin();
56  i != indices.end(); ++i)
57  _indices[*i] = true;
58 }
59 
60 
61 
62 inline
63 void QoISet::remove_indices(const std::vector<unsigned int> & indices)
64 {
65  for (std::vector<unsigned int>::const_iterator i = indices.begin();
66  i != indices.end(); ++i)
67  _indices[*i] = false;
68 }
69 
70 } // namespace libMesh
ImplicitSystem & sys
unsigned int size(const System &sys) const
Definition: qoi_set.C:35
The libMesh namespace provides an interface to certain functionality in the library.
long double max(long double a, double b)
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1553
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
QoISet()
Empty constructor: "calculate all QoIs in the System".
Definition: qoi_set.h:97
void add_indices(const std::vector< unsigned int > &indices)
Add this indices to the set to be calculated.
Definition: qoi_set.C:46
void remove_indices(const std::vector< unsigned int > &indices)
Remove these indices from the set to be calculated.
Definition: qoi_set.C:63
bool has_index(unsigned int) const
Return whether or not this index is in the set to be calculated.
Definition: qoi_set.h:221