libMesh
Classes | Public Member Functions | Private Attributes | List of all members
libMesh::QoISet Class Reference

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

#include <qoi_set.h>

Classes

class  iterator
 

Public Member Functions

 QoISet ()
 Empty constructor: "calculate all QoIs in the System". More...
 
 QoISet (const System &sys)
 Default constructor: "calculate all QoIs in the System", "give every QoI weight 1.0". More...
 
 QoISet (const std::vector< bool > &indices)
 Constructor-from-vector-of-bool: "calculate the QoIs for which \p indices[q] is true". More...
 
 QoISet (const std::vector< unsigned int > &indices)
 Constructor-from-vector: "calculate the listed QoIs", "give every QoI weight 1.0". More...
 
void clear ()
 Resets to "calculate all QoIs, give every QoI weight 1.0". More...
 
std::size_t size (const System &sys) const
 
void add_indices (const std::vector< unsigned int > &indices)
 Add this indices to the set to be calculated. More...
 
void add_index (std::size_t)
 Add this index to the set to be calculated. More...
 
void remove_indices (const std::vector< unsigned int > &indices)
 Remove these indices from the set to be calculated. More...
 
void remove_index (std::size_t)
 Remove this index from the set to be calculated. More...
 
void set_weight (std::size_t, Real)
 Set the weight for this index. More...
 
Real weight (std::size_t) const
 Get the weight for this index (default 1.0) More...
 
bool has_index (std::size_t) const
 Return whether or not this index is in the set to be calculated. More...
 
iterator begin () const
 Return an iterator pointing to the first index in the set. More...
 

Private Attributes

std::vector< bool > _indices
 Interpret _indices.empty() to mean "calculate all indices". More...
 
std::vector< Real_weights
 Interpret _weights.size() <= i to mean "weight i = 1.0". More...
 

Detailed Description

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

Author
Roy Stogner
Date
2009 Used to specify quantities of interest in a simulation.

Definition at line 45 of file qoi_set.h.

Constructor & Destructor Documentation

◆ QoISet() [1/4]

libMesh::QoISet::QoISet ( )

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.

97 : _indices(), _weights() {}
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176
std::vector< Real > _weights
Interpret _weights.size() <= i to mean "weight i = 1.0".
Definition: qoi_set.h:181

◆ QoISet() [2/4]

libMesh::QoISet::QoISet ( const System sys)
explicit

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

◆ QoISet() [3/4]

libMesh::QoISet::QoISet ( const std::vector< bool > &  indices)
explicit

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

Definition at line 111 of file qoi_set.h.

111  :
112  _indices(indices), _weights() {}
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176
std::vector< Real > _weights
Interpret _weights.size() <= i to mean "weight i = 1.0".
Definition: qoi_set.h:181

◆ QoISet() [4/4]

libMesh::QoISet::QoISet ( const std::vector< unsigned int > &  indices)
explicit

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
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176
std::vector< Real > _weights
Interpret _weights.size() <= i to mean "weight i = 1.0".
Definition: qoi_set.h:181
void add_indices(const std::vector< unsigned int > &indices)
Add this indices to the set to be calculated.

Member Function Documentation

◆ add_index()

void libMesh::QoISet::add_index ( std::size_t  i)

Add this index to the set to be calculated.

Definition at line 201 of file qoi_set.h.

References _indices.

202 {
203  if (i >= _indices.size())
204  _indices.resize(i+1, true);
205  _indices[i] = true;
206 }
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176

◆ add_indices()

void libMesh::QoISet::add_indices ( const std::vector< unsigned int > &  indices)

Add this indices to the set to be calculated.

Referenced by QoISet().

◆ begin()

iterator libMesh::QoISet::begin ( ) const

Return an iterator pointing to the first index in the set.

Definition at line 170 of file qoi_set.h.

References _indices.

170 { return iterator(0, _indices); }
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176

◆ clear()

void libMesh::QoISet::clear ( )

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

Definition at line 124 of file qoi_set.h.

References _indices, and _weights.

124 { _indices.clear(); _weights.clear(); }
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176
std::vector< Real > _weights
Interpret _weights.size() <= i to mean "weight i = 1.0".
Definition: qoi_set.h:181

◆ has_index()

bool libMesh::QoISet::has_index ( std::size_t  i) const

Return whether or not this index is in the set to be calculated.

Definition at line 221 of file qoi_set.h.

References _indices.

Referenced by libMesh::SensitivityData::allocate_data(), and libMesh::SensitivityData::allocate_hessian_data().

222 {
223  return (_indices.size() <= i || _indices[i]);
224 }
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176

◆ remove_index()

void libMesh::QoISet::remove_index ( std::size_t  i)

Remove this index from the set to be calculated.

Definition at line 211 of file qoi_set.h.

References _indices.

212 {
213  if (i >= _indices.size())
214  _indices.resize(i+1, true);
215  _indices[i] = false;
216 }
std::vector< bool > _indices
Interpret _indices.empty() to mean "calculate all indices".
Definition: qoi_set.h:176

◆ remove_indices()

void libMesh::QoISet::remove_indices ( const std::vector< unsigned int > &  indices)

Remove these indices from the set to be calculated.

◆ set_weight()

void libMesh::QoISet::set_weight ( std::size_t  i,
Real  w 
)

Set the weight for this index.

Definition at line 229 of file qoi_set.h.

References _weights.

230 {
231  if (_weights.size() <= i)
232  _weights.resize(i+1, 1.0);
233 
234  _weights[i] = w;
235 }
std::vector< Real > _weights
Interpret _weights.size() <= i to mean "weight i = 1.0".
Definition: qoi_set.h:181

◆ size()

std::size_t libMesh::QoISet::size ( const System sys) const
Returns
The number of QoIs that would be computed for the System sys

◆ weight()

Real libMesh::QoISet::weight ( std::size_t  i) const

Get the weight for this index (default 1.0)

Definition at line 240 of file qoi_set.h.

References _weights.

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

Member Data Documentation

◆ _indices

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(), begin(), clear(), has_index(), and remove_index().

◆ _weights

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 file: