libMesh::ParameterMultiAccessor< T > Class Template Reference

Stores a user-provided pointer to a parameter. More...

#include <parameter_multiaccessor.h>

Inheritance diagram for libMesh::ParameterMultiAccessor< T >:

Public Member Functions

 ParameterMultiAccessor ()
 
 ParameterMultiAccessor (const ParameterAccessor< T > &param_accessor)
 
 ~ParameterMultiAccessor ()
 
virtual ParameterAccessor< T > & operator= (T *) libmesh_override
 
virtual void set (const T &new_value) libmesh_override
 
virtual const T & get () const libmesh_override
 
virtual UniquePtr< ParameterAccessor< T > > clone () const libmesh_override
 
void push_back (const ParameterAccessor< T > &new_accessor)
 
std::size_t size () const
 
ParameterProxy< T > operator* ()
 
ConstParameterProxy< T > operator* () const
 

Private Attributes

std::vector< ParameterAccessor< T > * > _accessors
 

Detailed Description

template<typename T = Number>
class libMesh::ParameterMultiAccessor< T >

Stores a user-provided pointer to a parameter.

Accessor object allowing reading and modification of the independent variables in a parameter sensitivity calculation.

This is the "default" ParameterAccessor subclass: it simply stores a user-provided pointer to the parameter, and modifies the value at that location in memory.

Author
Roy Stogner
Date
2015

Definition at line 47 of file parameter_multiaccessor.h.

Constructor & Destructor Documentation

template<typename T = Number>
libMesh::ParameterMultiAccessor< T >::ParameterMultiAccessor ( )
inline

Constructor: no parameters attached yet

Definition at line 53 of file parameter_multiaccessor.h.

53 {}
template<typename T = Number>
libMesh::ParameterMultiAccessor< T >::ParameterMultiAccessor ( const ParameterAccessor< T > &  param_accessor)
inline

Constructor: take the first sub-accessor for the parameter

Definition at line 58 of file parameter_multiaccessor.h.

58  :
59  _accessors(1, param_accessor.clone()) {}
std::vector< ParameterAccessor< T > * > _accessors
template<typename T = Number>
libMesh::ParameterMultiAccessor< T >::~ParameterMultiAccessor ( )
inline

Definition at line 64 of file parameter_multiaccessor.h.

References libMesh::ParameterMultiAccessor< T >::_accessors.

64  {
65  for (std::size_t i=0; i != _accessors.size(); ++i)
66  delete _accessors[i];
67  }
std::vector< ParameterAccessor< T > * > _accessors

Member Function Documentation

template<typename T = Number>
virtual UniquePtr<ParameterAccessor<T> > libMesh::ParameterMultiAccessor< T >::clone ( ) const
inlinevirtual
Returns
A new copy of the accessor.

Implements libMesh::ParameterAccessor< T >.

Definition at line 117 of file parameter_multiaccessor.h.

References libMesh::ParameterMultiAccessor< T >::_accessors.

118  {
119  ParameterMultiAccessor * pmp = new ParameterMultiAccessor<T>();
120  for (std::size_t i=0; i != _accessors.size(); ++i)
121  pmp->_accessors.push_back(_accessors[i]->clone().release());
122 
123  return UniquePtr<ParameterAccessor<T> >(pmp);
124  }
std::vector< ParameterAccessor< T > * > _accessors
template<typename T = Number>
virtual const T& libMesh::ParameterMultiAccessor< T >::get ( ) const
inlinevirtual

Getter: get the value of the parameter we access.

Implements libMesh::ParameterAccessor< T >.

Definition at line 101 of file parameter_multiaccessor.h.

References libMesh::ParameterMultiAccessor< T >::_accessors, and libMesh::libmesh_assert().

102  {
103  libmesh_assert(!_accessors.empty());
104  const T & val = _accessors[0]->get();
105 #ifndef NDEBUG
106  // If you're already using inconsistent parameters we can't help
107  // you.
108  for (std::size_t i=1; i < _accessors.size(); ++i)
109  libmesh_assert_equal_to(_accessors[i]->get(), val);
110 #endif
111  return val;
112  }
libmesh_assert(j)
std::vector< ParameterAccessor< T > * > _accessors
template<typename T = Number>
ParameterProxy<T> libMesh::ParameterAccessor< T >::operator* ( )
inlineinherited

Proxy: for backward compatibility, we allow codes to treat a ParameterAccessor as if it were a simple pointer-to-value. We can't safely allow "Number * n = parameter_vector[p]" to compile, but we can allow "*parameter_vector[p] += deltap" to work.

Definition at line 86 of file parameter_accessor.h.

86 { return ParameterProxy<T>(*this); }
template<typename T = Number>
ConstParameterProxy<T> libMesh::ParameterAccessor< T >::operator* ( ) const
inlineinherited

Definition at line 88 of file parameter_accessor.h.

References libMesh::ParameterAccessor< T >::clone().

88 { return ConstParameterProxy<T>(*this); }
template<typename T = Number>
virtual ParameterAccessor<T>& libMesh::ParameterMultiAccessor< T >::operator= ( T *  )
inlinevirtual

A simple reseater won't work with a multi-accessor

Reimplemented from libMesh::ParameterAccessor< T >.

Definition at line 73 of file parameter_multiaccessor.h.

74  {
75  libmesh_error();
76  return *this;
77  }
template<typename T = Number>
void libMesh::ParameterMultiAccessor< T >::push_back ( const ParameterAccessor< T > &  new_accessor)
inline

Definition at line 127 of file parameter_multiaccessor.h.

References libMesh::ParameterMultiAccessor< T >::_accessors, and libMesh::ParameterAccessor< T >::clone().

127  {
128  _accessors.push_back(new_accessor.clone().release());
129  }
std::vector< ParameterAccessor< T > * > _accessors
template<typename T = Number>
virtual void libMesh::ParameterMultiAccessor< T >::set ( const T &  new_value)
inlinevirtual

Setter: change the value of the parameter we access.

Implements libMesh::ParameterAccessor< T >.

Definition at line 82 of file parameter_multiaccessor.h.

References libMesh::ParameterMultiAccessor< T >::_accessors, and libMesh::libmesh_assert().

83  {
84  libmesh_assert(!_accessors.empty());
85 #ifndef NDEBUG
86  // Compare other values to the last one we'll change
87  const T & val = _accessors.back()->get();
88 #endif
89  for (std::size_t i=0; i != _accessors.size(); ++i)
90  {
91  // If you're already using inconsistent parameters we can't
92  // help you.
93  libmesh_assert_equal_to(_accessors[i]->get(), val);
94  _accessors[i]->set(new_value);
95  }
96  }
libmesh_assert(j)
std::vector< ParameterAccessor< T > * > _accessors
template<typename T = Number>
std::size_t libMesh::ParameterMultiAccessor< T >::size ( ) const
inline
Returns
The number of sub-accessors associated with this parameter. Useful for testing if the multi-accessor is empty/invalid.

Definition at line 136 of file parameter_multiaccessor.h.

References libMesh::ParameterMultiAccessor< T >::_accessors.

136 { return _accessors.size(); }
std::vector< ParameterAccessor< T > * > _accessors

Member Data Documentation


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