libMesh::QoISet Class Reference

Used to specify quantities of interest in a simulation. More...

#include <qoi_set.h>

Classes

class  iterator
 

Public Member Functions

 QoISet ()
 
 QoISet (const System &sys)
 
 QoISet (const std::vector< bool > &indices)
 
 QoISet (const std::vector< unsigned int > &indices)
 
void clear ()
 
unsigned int size (const System &sys) const
 
void add_indices (const std::vector< unsigned int > &indices)
 
void add_index (unsigned int)
 
void remove_indices (const std::vector< unsigned int > &indices)
 
void remove_index (unsigned int)
 
void set_weight (unsigned int, Real)
 
Real weight (unsigned int) const
 
bool has_index (unsigned int) const
 
iterator begin () const
 

Private Attributes

std::vector< bool > _indices
 
std::vector< Real_weights
 

Detailed Description

Used to specify quantities of interest in a simulation.

Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a parameter sensitivity calculation.

Author
Roy Stogner
Date
2009

Definition at line 45 of file qoi_set.h.

Constructor & Destructor Documentation

libMesh::QoISet::QoISet ( )
inline

Empty constructor: "calculate all QoIs in the System"

No further changes to this special QoISet should be made; it doesn't even know how many QoIs your system has, it just knows to instruct a function to use all of them.

Definition at line 97 of file qoi_set.h.

References libMesh::sys.

Referenced by QoISet().

97 : _indices(), _weights() {}
std::vector< bool > _indices
Definition: qoi_set.h:176
std::vector< Real > _weights
Definition: qoi_set.h:181
libMesh::QoISet::QoISet ( const System sys)
explicit

Default constructor: "calculate all QoIs in the System", "give every QoI weight 1.0"

Definition at line 31 of file qoi_set.C.

31 : _indices(sys.qoi.size(), true) {}
ImplicitSystem & sys
std::vector< bool > _indices
Definition: qoi_set.h:176
std::vector< Number > qoi
Definition: system.h:1551
libMesh::QoISet::QoISet ( const std::vector< bool > &  indices)
inlineexplicit

Constructor-from-vector-of-bool: "calculate the QoIs for which \p indices[q] is true"

Definition at line 111 of file qoi_set.h.

References QoISet().

111  :
112  _indices(indices), _weights() {}
std::vector< bool > _indices
Definition: qoi_set.h:176
std::vector< Real > _weights
Definition: qoi_set.h:181
libMesh::QoISet::QoISet ( const std::vector< unsigned int > &  indices)
inlineexplicit

Constructor-from-vector: "calculate the listed QoIs", "give every QoI weight 1.0"

Definition at line 192 of file qoi_set.h.

References add_indices().

192  :
193  _indices(), _weights()
194 {
195  this->add_indices(indices);
196 }
std::vector< bool > _indices
Definition: qoi_set.h:176
std::vector< Real > _weights
Definition: qoi_set.h:181
void add_indices(const std::vector< unsigned int > &indices)
Definition: qoi_set.C:46

Member Function Documentation

void libMesh::QoISet::add_index ( unsigned int  i)
inline

Add this index to the set to be calculated

Definition at line 201 of file qoi_set.h.

References _indices.

Referenced by clear().

202 {
203  if (i >= _indices.size())
204  _indices.resize(i+1, true);
205  _indices[i] = true;
206 }
std::vector< bool > _indices
Definition: qoi_set.h:176
void libMesh::QoISet::add_indices ( const std::vector< unsigned int > &  indices)

Add this indices to the set to be calculated

Definition at line 46 of file qoi_set.C.

References _indices, and std::max().

Referenced by clear(), and QoISet().

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 }
long double max(long double a, double b)
std::vector< bool > _indices
Definition: qoi_set.h:176
iterator libMesh::QoISet::begin ( ) const
inline

Return an iterator pointing to the first index in the set

Definition at line 170 of file qoi_set.h.

References _indices, and libMesh::QoISet::iterator::iterator().

170 { return iterator(0, _indices); }
std::vector< bool > _indices
Definition: qoi_set.h:176
void libMesh::QoISet::clear ( )
inline

Resets to "calculate all QoIs, give every QoI weight 1.0"

Definition at line 124 of file qoi_set.h.

References _indices, _weights, add_index(), add_indices(), has_index(), libMesh::Real, remove_index(), remove_indices(), set_weight(), size(), and weight().

124 { _indices.clear(); _weights.clear(); }
std::vector< bool > _indices
Definition: qoi_set.h:176
std::vector< Real > _weights
Definition: qoi_set.h:181
void libMesh::QoISet::remove_index ( unsigned int  i)
inline

Remove this index from the set to be calculated

Definition at line 211 of file qoi_set.h.

References _indices.

Referenced by clear().

212 {
213  if (i >= _indices.size())
214  _indices.resize(i+1, true);
215  _indices[i] = false;
216 }
std::vector< bool > _indices
Definition: qoi_set.h:176
void libMesh::QoISet::remove_indices ( const std::vector< unsigned int > &  indices)
inline

Remove these indices from the set to be calculated

Definition at line 63 of file qoi_set.C.

References _indices.

Referenced by clear().

64 {
65  for (std::vector<unsigned int>::const_iterator i = indices.begin();
66  i != indices.end(); ++i)
67  _indices[*i] = false;
68 }
std::vector< bool > _indices
Definition: qoi_set.h:176
void libMesh::QoISet::set_weight ( unsigned int  i,
Real  w 
)
inline

Set the weight for this index

Definition at line 229 of file qoi_set.h.

References _weights.

Referenced by clear().

230 {
231  if (_weights.size() <= i)
232  _weights.resize(i+1, 1.0);
233 
234  _weights[i] = w;
235 }
std::vector< Real > _weights
Definition: qoi_set.h:181
unsigned int libMesh::QoISet::size ( const System sys) const
Returns
The number of QoIs that would be computed for the System sys

Definition at line 35 of file qoi_set.C.

References has_index(), and libMesh::System::qoi.

Referenced by clear(), and libMesh::System::qoi_parameter_sensitivity().

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 }
ImplicitSystem & sys
std::vector< Number > qoi
Definition: system.h:1551
bool has_index(unsigned int) const
Definition: qoi_set.h:221
Real libMesh::QoISet::weight ( unsigned int  i) const
inline

Get the weight for this index (default 1.0)

Definition at line 240 of file qoi_set.h.

References _weights.

Referenced by clear(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::AdjointResidualErrorEstimator::estimate_error().

241 {
242  if (_weights.size() <= i)
243  return 1.0;
244  return _weights[i];
245 }
std::vector< Real > _weights
Definition: qoi_set.h:181

Member Data Documentation

std::vector<bool> libMesh::QoISet::_indices
private

Interpret _indices.empty() to mean "calculate all indices"

Definition at line 176 of file qoi_set.h.

Referenced by add_index(), add_indices(), begin(), clear(), has_index(), remove_index(), and remove_indices().

std::vector<Real> libMesh::QoISet::_weights
private

Interpret _weights.size() <= i to mean "weight i = 1.0"

Definition at line 181 of file qoi_set.h.

Referenced by clear(), set_weight(), and weight().


The documentation for this class was generated from the following files: