libMesh::QoISet Class Reference

#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

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

Definition at line 41 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 93 of file qoi_set.h.

93 : _indices(), _weights() {}
libMesh::QoISet::QoISet ( const System sys)
explicit

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

Definition at line 34 of file qoi_set.C.

34 : _indices(sys.qoi.size(), true) {}
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 107 of file qoi_set.h.

107  :
108  _indices(indices), _weights() {}
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 188 of file qoi_set.h.

References add_indices().

188  :
189  _indices(), _weights()
190 {
191  this->add_indices(indices);
192 }

Member Function Documentation

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

Add this index to the set to be calculated

Definition at line 197 of file qoi_set.h.

References _indices.

198 {
199  if (i >= _indices.size())
200  _indices.resize(i+1, true);
201  _indices[i] = true;
202 }
void libMesh::QoISet::add_indices ( const std::vector< unsigned int > &  indices)

Add this indices to the set to be calculated

Definition at line 49 of file qoi_set.C.

References _indices, and std::max().

Referenced by QoISet().

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 }
iterator libMesh::QoISet::begin ( ) const
inline

Return an iterator pointing to the first index in the set

Definition at line 166 of file qoi_set.h.

References _indices.

166 { return iterator(0, _indices); }
void libMesh::QoISet::clear ( )
inline

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

Definition at line 120 of file qoi_set.h.

References _indices, and _weights.

120 { _indices.clear(); _weights.clear(); }
void libMesh::QoISet::remove_index ( unsigned int  i)
inline

Remove this index from the set to be calculated

Definition at line 207 of file qoi_set.h.

References _indices.

208 {
209  if (i >= _indices.size())
210  _indices.resize(i+1, true);
211  _indices[i] = false;
212 }
void libMesh::QoISet::remove_indices ( const std::vector< unsigned int > &  indices)
inline

Remove these indices from the set to be calculated

Definition at line 66 of file qoi_set.C.

References _indices.

67 {
68  for (std::vector<unsigned int>::const_iterator i = indices.begin();
69  i != indices.end(); ++i)
70  _indices[*i] = false;
71 }
void libMesh::QoISet::set_weight ( unsigned int  i,
Real  w 
)
inline

Set the weight for this index

Definition at line 225 of file qoi_set.h.

References _weights.

226 {
227  if (_weights.size() <= i)
228  _weights.resize(i+1, 1.0);
229 
230  _weights[i] = w;
231 }
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 38 of file qoi_set.C.

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

Referenced by libMesh::System::qoi_parameter_sensitivity().

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 }
Real libMesh::QoISet::weight ( unsigned int  i) const
inline

Get the weight for this index (default 1.0)

Definition at line 236 of file qoi_set.h.

References _weights.

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

237 {
238  if (_weights.size() <= i)
239  return 1.0;
240  return _weights[i];
241 }

Member Data Documentation

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

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

Definition at line 172 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 177 of file qoi_set.h.

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


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

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

Hosted By:
SourceForge.net Logo