libMesh::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
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.

00093 : _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.

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

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

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

Definition at line 107 of file qoi_set.h.

00107                                          :
00108     _indices(indices), _weights() {}

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

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().

00188                                                      :
00189   _indices(), _weights()
00190 {
00191   this->add_indices(indices);
00192 }


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.

00198 {
00199   if (i >= _indices.size())
00200     _indices.resize(i+1, true);
00201   _indices[i] = true;
00202 }

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().

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

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.

00166 { 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.

00120 { _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.

00208 {
00209   if (i >= _indices.size())
00210     _indices.resize(i+1, true);
00211   _indices[i] = false;
00212 }

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.

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

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.

00226 {
00227   if (_weights.size() <= i)
00228     _weights.resize(i+1, 1.0);
00229 
00230   _weights[i] = w;
00231 }

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().

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

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::AdjointResidualErrorEstimator::estimate_error(), and libMesh::AdjointRefinementEstimator::estimate_error().

00237 {
00238   if (_weights.size() <= i)
00239     return 1.0;
00240   return _weights[i];
00241 }


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 05 2013 19:55:34 UTC

Hosted By:
SourceForge.net Logo