libMesh::ParameterMultiPointer< T > Class Template Reference

Stores multiple user-provided pointers. More...

#include <parameter_multipointer.h>

Inheritance diagram for libMesh::ParameterMultiPointer< T >:

Public Member Functions

 ParameterMultiPointer ()
 
 ParameterMultiPointer (T *param_ptr)
 
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 (T *new_ptr)
 
std::size_t size () const
 
ParameterProxy< T > operator* ()
 
ConstParameterProxy< T > operator* () const
 

Private Attributes

std::vector< T * > _ptrs
 

Detailed Description

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

Stores multiple user-provided pointers.

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

This is a slightly flexible ParameterAccessor subclass: it stores all user-provided pointers to copies of the parameter, and modifies the value at each location in memory.

Author
Roy Stogner
Date
2015

Definition at line 47 of file parameter_multipointer.h.

Constructor & Destructor Documentation

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

Constructor: no parameters attached yet

Definition at line 53 of file parameter_multipointer.h.

53 {}
template<typename T = Number>
libMesh::ParameterMultiPointer< T >::ParameterMultiPointer ( T *  param_ptr)
inline

Constructor: take the first raw pointer to the parameter

Definition at line 58 of file parameter_multipointer.h.

58 : _ptrs(1, param_ptr) {}

Member Function Documentation

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

Implements libMesh::ParameterAccessor< T >.

Definition at line 108 of file parameter_multipointer.h.

References libMesh::ParameterMultiPointer< T >::_ptrs.

109  {
110  ParameterMultiPointer * pmp = new ParameterMultiPointer<T>();
111  pmp->_ptrs = _ptrs;
112 
113  return UniquePtr<ParameterAccessor<T> >(pmp);
114  }
template<typename T = Number>
virtual const T& libMesh::ParameterMultiPointer< T >::get ( ) const
inlinevirtual

Getter: get the value of the parameter we access.

Implements libMesh::ParameterAccessor< T >.

Definition at line 92 of file parameter_multipointer.h.

References libMesh::ParameterMultiPointer< T >::_ptrs, and libMesh::libmesh_assert().

93  {
94  libmesh_assert(!_ptrs.empty());
95  T & val = *_ptrs[0];
96 #ifndef NDEBUG
97  // If you're already using inconsistent parameters we can't help
98  // you.
99  for (std::size_t i=1; i < _ptrs.size(); ++i)
100  libmesh_assert_equal_to(*_ptrs[i], val);
101 #endif
102  return val;
103  }
libmesh_assert(j)
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::ParameterMultiPointer< T >::operator= ( T *  )
inlinevirtual

A simple reseater won't work with a multipointer

Reimplemented from libMesh::ParameterAccessor< T >.

Definition at line 64 of file parameter_multipointer.h.

65  {
66  libmesh_error();
67  return *this;
68  }
template<typename T = Number>
void libMesh::ParameterMultiPointer< T >::push_back ( T *  new_ptr)
inline

Definition at line 116 of file parameter_multipointer.h.

References libMesh::ParameterMultiPointer< T >::_ptrs.

116 { _ptrs.push_back(new_ptr); }
template<typename T = Number>
virtual void libMesh::ParameterMultiPointer< T >::set ( const T &  new_value)
inlinevirtual

Setter: change the value of the parameter we access.

Implements libMesh::ParameterAccessor< T >.

Definition at line 73 of file parameter_multipointer.h.

References libMesh::ParameterMultiPointer< T >::_ptrs, and libMesh::libmesh_assert().

74  {
75  libmesh_assert(!_ptrs.empty());
76 #ifndef NDEBUG
77  // Compare other values to the last one we'll change
78  const T & val = *_ptrs.back();
79 #endif
80  for (std::size_t i=0; i != _ptrs.size(); ++i)
81  {
82  // If you're already using inconsistent parameters we can't
83  // help you.
84  libmesh_assert_equal_to(*_ptrs[i], val);
85  *_ptrs[i] = new_value;
86  }
87  }
libmesh_assert(j)
template<typename T = Number>
std::size_t libMesh::ParameterMultiPointer< T >::size ( ) const
inline
Returns
The number of data associated with this parameter. Useful for testing if the multipointer is empty/invalid.

Definition at line 122 of file parameter_multipointer.h.

References libMesh::ParameterMultiPointer< T >::_ptrs.

122 { return _ptrs.size(); }

Member Data Documentation


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