QoISet Class Reference

#include <qoi_set.h>

List of all members.

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

Private Attributes

std::vector< bool > _indices
std::vector< bool > _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 42 of file qoi_set.h.


Constructor & Destructor Documentation

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 94 of file qoi_set.h.

00094 {}

QoISet::QoISet ( const System sys  ) 

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

Definition at line 35 of file qoi_set.C.

00035 : _indices(sys.qoi.size(), true) {}

QoISet::QoISet ( const std::vector< bool > &  indices  )  [inline]

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

Definition at line 106 of file qoi_set.h.

00106 : _indices(indices) {}

QoISet::QoISet ( const std::vector< unsigned int > &  indices  )  [inline]

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

Definition at line 180 of file qoi_set.h.

References add_indices().

00181 {
00182   this->add_indices(indices);
00183 }


Member Function Documentation

void QoISet::add_index ( unsigned int  i  )  [inline]

Add this index to the set to be calculated

Definition at line 188 of file qoi_set.h.

References _indices.

00189 {
00190   if (i >= _indices.size())
00191     _indices.resize(i+1);
00192   _indices[i] = true;
00193 }

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

Add this indices to the set to be calculated

Definition at line 50 of file qoi_set.C.

References _indices, std::max(), and size().

Referenced by QoISet().

00051 {
00052   unsigned int size = 0;
00053   for (std::vector<unsigned int>::const_iterator i = indices.begin();
00054        i != indices.end(); ++i)
00055     size = std::max(size, *i + 1);
00056 
00057   _indices.resize(size);
00058 
00059   for (std::vector<unsigned int>::const_iterator i = indices.begin();
00060        i != indices.end(); ++i)
00061     _indices[*i] = true;
00062 }

void QoISet::clear (  )  [inline]

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

Definition at line 117 of file qoi_set.h.

References _indices, and _weights.

00117 { _indices.clear(); _weights.clear(); }

void QoISet::remove_index ( unsigned int  i  )  [inline]

Remove this index from the set to be calculated

Definition at line 198 of file qoi_set.h.

References _indices.

00199 {
00200   libmesh_assert(i < _indices.size());
00201   _indices[i] = false;
00202 }

void QoISet::remove_indices ( const std::vector< unsigned int > &  indices  )  [inline]

Remove these indices from the set to be calculated

Definition at line 67 of file qoi_set.C.

References _indices.

00068 {
00069   for (std::vector<unsigned int>::const_iterator i = indices.begin();
00070        i != indices.end(); ++i)
00071     _indices[*i] = false;
00072 }

void QoISet::set_weight ( unsigned int  i,
Real  w 
) [inline]

Set the weight for this index

Definition at line 215 of file qoi_set.h.

References _weights.

00216 {
00217   if (_weights.size() <= i)
00218     _weights.resize(i+1, 1.0);
00219 
00220   _weights[i] = w;
00221 }

unsigned int QoISet::size ( const System sys  )  const

Returns the number of QoIs that would be computed for the System sys

Definition at line 39 of file qoi_set.C.

References has_index(), and System::qoi.

Referenced by add_indices(), and System::qoi_parameter_sensitivity().

00040 {
00041   unsigned int qoi_count = 0;
00042   for (unsigned int i=0; i != sys.qoi.size(); ++i)
00043     if (this->has_index(i))
00044       qoi_count++;
00045   return qoi_count;
00046 }

Real QoISet::weight ( unsigned int  i  )  const [inline]

Get the weight for this index (default 1.0)

Definition at line 226 of file qoi_set.h.

References _weights.

Referenced by AdjointResidualErrorEstimator::estimate_error().

00227 {
00228   if (_weights.size() <= i)
00229     return 1.0;
00230   return _weights[i];
00231 }


Member Data Documentation

std::vector<bool> QoISet::_indices [private]

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

Definition at line 164 of file qoi_set.h.

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

std::vector<bool> QoISet::_weights [private]

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

Definition at line 169 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: November 25 2009 03:44:53.

Hosted By:
SourceForge.net Logo