libMesh
Loading...
Searching...
No Matches
qoi_set.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
28namespace libMesh
29{
30
31QoISet::QoISet(const System & sys) : _indices(sys.n_qois(), true) {}
32
33
34
35std::size_t QoISet::size (const System & sys) const
36{
37 std::size_t qoi_count = 0;
38 for (auto i : make_range(sys.n_qois()))
39 if (this->has_index(i))
40 qoi_count++;
41 return qoi_count;
42}
43
44
45
46void 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
60inline
61void 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
void add_indices(const std::vector< unsigned int > &indices)
Add this indices to the set to be calculated.
Definition qoi_set.C:46
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition qoi_set.h:179
QoISet()
Empty constructor: "calculate all QoIs in the System".
Definition qoi_set.h:100
void remove_indices(const std::vector< unsigned int > &indices)
Remove these indices from the set to be calculated.
Definition qoi_set.C:61
std::size_t size(const System &sys) const
Definition qoi_set.C:35
bool has_index(std::size_t) const
Return whether or not this index is in the set to be calculated.
Definition qoi_set.h:224
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition system.h:2562
The libMesh namespace provides an interface to certain functionality in the library.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176