$extrastylesheet
libMesh::ParameterVector Class Reference

#include <parameter_vector.h>

List of all members.

Public Member Functions

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

Private Attributes

std::vector< ParameterAccessor
< Number > * > 
_params
std::vector< Number_my_data
bool _is_shallow_copy

Detailed Description

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

Definition at line 39 of file parameter_vector.h.


Constructor & Destructor Documentation

Default constructor: "no parameters"

Definition at line 45 of file parameter_vector.h.

: _is_shallow_copy(false) {}
libMesh::ParameterVector::ParameterVector ( const std::vector< Number * > &  params) [inline, explicit]

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

Definition at line 148 of file parameter_vector.h.

References _params.

  : _is_shallow_copy(false)
{
  _params.reserve(params.size());

  for (unsigned int i=0; i != params.size(); ++i)
    _params.push_back(new ParameterPointer<Number>(params[i]));
}

Destructor - deletes ParameterAccessor objects

Definition at line 159 of file parameter_vector.h.

References clear().

{
  this->clear();
}

Member Function Documentation

Resets to "no parameters"

Definition at line 167 of file parameter_vector.h.

References _is_shallow_copy, _my_data, and _params.

Referenced by deep_copy(), and ~ParameterVector().

{
  if (_is_shallow_copy)
    for (unsigned int i=0; i != _params.size(); ++i)
      delete _params[i];

  _params.clear();
  _my_data.clear();
}

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, _params, and clear().

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

{
  const unsigned int Np = cast_int<unsigned int>
    (this->_params.size());
  target.clear();
  target._params.resize(Np);
  target._my_data.resize(Np);
  for (unsigned int i=0; i != Np; ++i)
    {
      target._params[i] =
        new ParameterPointer<Number>(&target._my_data[i]);
      target._my_data[i] = *(*this)[i];
    }
}
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 92 of file parameter_vector.C.

References _is_shallow_copy, _my_data, _params, and libMesh::libmesh_assert().

{
  libmesh_assert(!_is_shallow_copy);

  this->_params.resize(s);
  this->_my_data.resize(s);
  for (unsigned int i=0; i != s; ++i)
    this->_params[i] =
      new ParameterPointer<Number>(&this->_my_data[i]);
}
ParameterVector & libMesh::ParameterVector::operator*= ( const Number  a)

Multiplication operator; acts individually on each parameter.

Definition at line 105 of file parameter_vector.C.

References _params.

{
  const unsigned int Np = cast_int<unsigned int>
    (this->_params.size());
  for (unsigned int i=0; i != Np; ++i)
    *(*this)[i] *= a;
  return *this;
}
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 116 of file parameter_vector.C.

References _params.

{
  const unsigned int Np = cast_int<unsigned int>
    (this->_params.size());
  libmesh_assert_equal_to (a._params.size(), Np);
  for (unsigned int i=0; i != Np; ++i)
    *(*this)[i] += *a[i];
  return *this;
}
const ParameterAccessor< Number > & libMesh::ParameterVector::operator[] ( unsigned int  i) const [inline]

Returns a smart-pointer to a parameter value

Definition at line 180 of file parameter_vector.h.

References _params.

{
  libmesh_assert_greater (_params.size(), i);

  return *_params[i];
}
ParameterAccessor< Number > & libMesh::ParameterVector::operator[] ( unsigned int  i) [inline]

Returns a reference to a smart-pointer to a parameter value, suitable for repointing it to a different address. This method is deprecated and may not work with more sophisticated ParameterAccessor subclasses.

Definition at line 190 of file parameter_vector.h.

References _params.

{
  libmesh_assert_greater (_params.size(), i);

  return *_params[i];
}
void libMesh::ParameterVector::resize ( unsigned int  s)

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 71 of file parameter_vector.C.

References _is_shallow_copy, _params, and libMesh::libmesh_assert().

{
  libmesh_assert(!_is_shallow_copy);

  const std::size_t old_size = this->_params.size();

  // If we're shrinking the vector, we don't want to leak memory.
  // Note that we're using < in these for loops, not !=
  // We don't know a priori if we're shrinking or growing
  for (unsigned int i=s; i < old_size; ++i)
    delete _params[i];

  this->_params.resize(s);

  for (unsigned int i=old_size; i < s; ++i)
    this->_params[i] =
      new ParameterPointer<Number>(NULL);
}

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

Definition at line 50 of file parameter_vector.C.

References _is_shallow_copy, _my_data, and _params.

{
  target._my_data.clear();
  target._params = this->_params;
  target._is_shallow_copy = true;
}

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

{
  const unsigned int Np = cast_int<unsigned int>
    (this->_params.size());
  libmesh_assert_equal_to (target._params.size(), Np);

  for (unsigned int i=0; i != Np; ++i)
    *target[i] = *(*this)[i];
}

Member Data Documentation

Am I a shallow copy? If so then I shouldn't be deleting my ParameterAccessors.

Definition at line 139 of file parameter_vector.h.

Referenced by clear(), deep_resize(), resize(), and shallow_copy().

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

Definition at line 133 of file parameter_vector.h.

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

Pointers to parameters which may exist elsewhere

Definition at line 128 of file parameter_vector.h.

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


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