libMesh::ParameterVector Class Reference

#include <parameter_vector.h>

Public Member Functions

 ParameterVector ()
 
 ParameterVector (const std::vector< Number * > &params)
 
void deep_copy (ParameterVector &target) const
 
void shallow_copy (ParameterVector &target) const
 
void value_copy (const ParameterVector &target) const
 
void clear ()
 
std::size_t size () const
 
void resize (unsigned int s)
 
void deep_resize (unsigned int s)
 
Numberoperator[] (unsigned int i) const
 
Number *& operator[] (unsigned int i)
 
ParameterVectoroperator*= (const Number a)
 
ParameterVectoroperator+= (const ParameterVector &a)
 
const ParameterVectoroperator+= (const ParameterVector &a) const
 

Private Attributes

std::vector< Number * > _params
 
std::vector< Number_my_data
 

Detailed Description

Data structure for specifying which Parameters should be independent variables in a parameter sensitivity calculation.

Definition at line 38 of file parameter_vector.h.

Constructor & Destructor Documentation

libMesh::ParameterVector::ParameterVector ( )
inline

Default constructor: "no parameters"

Definition at line 44 of file parameter_vector.h.

44 {}
libMesh::ParameterVector::ParameterVector ( const std::vector< Number * > &  params)
inlineexplicit

Constructor-from-vector-of-Number*: each points to a parameter

Definition at line 50 of file parameter_vector.h.

50 : _params(params) {}

Member Function Documentation

void libMesh::ParameterVector::clear ( )
inline

Resets to "no parameters"

Definition at line 74 of file parameter_vector.h.

References _params.

74 { _params.clear(); }
void libMesh::ParameterVector::deep_copy ( ParameterVector target) const

Deep copy constructor: the target will now own new copies of all the parameter values I'm pointing to

Definition at line 33 of file parameter_vector.C.

References _my_data, and _params.

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

34 {
35  const unsigned int Np = libmesh_cast_int<unsigned int>
36  (this->_params.size());
37  target._params.resize(Np);
38  target._my_data.resize(Np);
39  for (unsigned int i=0; i != Np; ++i)
40  {
41  target._params[i] = &target._my_data[i];
42  target._my_data[i] = *(this->_params[i]);
43  }
44 }
void libMesh::ParameterVector::deep_resize ( unsigned int  s)

Sets the number of parameters to be used. This method is for resizing a ParameterVector that owns its own parameter values

Definition at line 68 of file parameter_vector.C.

References _my_data, and _params.

69 {
70  this->_params.resize(s);
71  this->_my_data.resize(s);
72  for (unsigned int i=0; i != s; ++i)
73  this->_params[i] = &this->_my_data[i];
74 }
ParameterVector & libMesh::ParameterVector::operator*= ( const Number  a)

Multiplication operator; acts individually on each parameter.

Definition at line 78 of file parameter_vector.C.

References _params.

79 {
80  const unsigned int Np = libmesh_cast_int<unsigned int>
81  (this->_params.size());
82  for (unsigned int i=0; i != Np; ++i)
83  *(this->_params[i]) *= a;
84  return *this;
85 }
ParameterVector & libMesh::ParameterVector::operator+= ( const ParameterVector a)

Addition operator. The parameter vector to be added in must have the same number of values.

Definition at line 100 of file parameter_vector.C.

101 {
102  (*this) += a;
103  return *this;
104 }
const ParameterVector & libMesh::ParameterVector::operator+= ( const ParameterVector a) const

Addition operator. The parameter vector to be added in must have the same number of values.

Definition at line 89 of file parameter_vector.C.

References _params.

90 {
91  const unsigned int Np = libmesh_cast_int<unsigned int>
92  (this->_params.size());
93  libmesh_assert_equal_to (a._params.size(), Np);
94  for (unsigned int i=0; i != Np; ++i)
95  *(this->_params[i]) += *(a._params[i]);
96  return *this;
97 }
Number * libMesh::ParameterVector::operator[] ( unsigned int  i) const
inline

Returns a pointer to a parameter value

Definition at line 142 of file parameter_vector.h.

References _params, and libMesh::libmesh_assert_greater().

143 {
144  libmesh_assert_greater (_params.size(), i);
145 
146  return _params[i];
147 }
Number *& libMesh::ParameterVector::operator[] ( unsigned int  i)
inline

Returns a reference to a pointer to a parameter value, suitable for repointing it to a different address.

Definition at line 152 of file parameter_vector.h.

References _params, and libMesh::libmesh_assert_greater().

153 {
154  libmesh_assert_greater (_params.size(), i);
155 
156  return _params[i];
157 }
void libMesh::ParameterVector::resize ( unsigned int  s)
inline

Sets the number of parameters to be used. This method is for resizing a ParameterVector that acts as a proxy to other parameter values

Definition at line 86 of file parameter_vector.h.

References _params.

86 { _params.resize(s); }
void libMesh::ParameterVector::shallow_copy ( ParameterVector target) const

Shallow copy constructor: the target will now point to all the parameter values I'm pointing to

Definition at line 48 of file parameter_vector.C.

References _my_data, and _params.

49 {
50  target._my_data.clear();
51  target._params = this->_params;
52 }
void libMesh::ParameterVector::value_copy ( const ParameterVector target) const

Value copy method: the target, which should already have as many parameters as I do, will now have those parameters set to my values.

Definition at line 56 of file parameter_vector.C.

References _params.

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

57 {
58  const unsigned int Np = libmesh_cast_int<unsigned int>
59  (this->_params.size());
60  libmesh_assert_equal_to (target._params.size(), Np);
61 
62  for (unsigned int i=0; i != Np; ++i)
63  *(this->_params[i]) = *(target._params[i]);
64 }

Member Data Documentation

std::vector<Number> libMesh::ParameterVector::_my_data
private

Parameters which I own; e.g. as the result of a deep copy

Definition at line 131 of file parameter_vector.h.

Referenced by deep_copy(), deep_resize(), and shallow_copy().

std::vector<Number *> libMesh::ParameterVector::_params
private

Pointers to parameters which may exist elsewhere

Definition at line 126 of file parameter_vector.h.

Referenced by clear(), deep_copy(), deep_resize(), operator*=(), operator+=(), operator[](), resize(), shallow_copy(), size(), and value_copy().


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

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

Hosted By:
SourceForge.net Logo