libMesh
Public Member Functions | Private Attributes | List of all members
libMesh::ParameterMultiAccessor< T > Class Template Reference

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

#include <parameter_multiaccessor.h>

Inheritance diagram for libMesh::ParameterMultiAccessor< T >:
[legend]

Public Member Functions

 ParameterMultiAccessor ()
 Constructor: no parameters attached yet. More...
 
 ParameterMultiAccessor (const ParameterAccessor< T > &param_accessor)
 Constructor: take the first sub-accessor for the parameter. More...
 
 ~ParameterMultiAccessor ()
 
virtual ParameterAccessor< T > & operator= (T *) libmesh_override
 A simple reseater won't work with a multi-accessor. More...
 
virtual void set (const T &new_value) libmesh_override
 Setter: change the value of the parameter we access. More...
 
virtual const T & get () const libmesh_override
 Getter: get the value of the parameter we access. More...
 
virtual UniquePtr< ParameterAccessor< T > > clone () const libmesh_override
 
void push_back (const ParameterAccessor< T > &new_accessor)
 
std::size_t size () const
 
ParameterProxy< T > operator* ()
 Proxy: for backward compatibility, we allow codes to treat a ParameterAccessor as if it were a simple pointer-to-value. More...
 
ConstParameterProxy< T > operator* () const
 

Private Attributes

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

Detailed Description

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

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 Stores a user-provided pointer to a parameter.

Definition at line 47 of file parameter_multiaccessor.h.

Constructor & Destructor Documentation

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

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)

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

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
virtual
Returns
A new copy of the accessor.

Implements libMesh::ParameterAccessor< T >.

Definition at line 119 of file parameter_multiaccessor.h.

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

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

Getter: get the value of the parameter we access.

Implements libMesh::ParameterAccessor< T >.

Definition at line 103 of file parameter_multiaccessor.h.

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

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

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 88 of file parameter_accessor.h.

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

Definition at line 90 of file parameter_accessor.h.

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

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

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

Reimplemented from libMesh::ParameterAccessor< T >.

Definition at line 74 of file parameter_multiaccessor.h.

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

Definition at line 129 of file parameter_multiaccessor.h.

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

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

Setter: change the value of the parameter we access.

Implements libMesh::ParameterAccessor< T >.

Definition at line 84 of file parameter_multiaccessor.h.

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

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

Definition at line 138 of file parameter_multiaccessor.h.

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

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

Member Data Documentation

template<typename T = Number>
std::vector<ParameterAccessor<T> *> libMesh::ParameterMultiAccessor< T >::_accessors
private

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