libMesh
Public Member Functions | Friends | List of all members
libMesh::DenseVectorBase< T > Class Template Referenceabstract

Defines an abstract dense vector base class for use in Finite Element-type computations. More...

#include <dof_map.h>

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

Public Member Functions

 DenseVectorBase ()=default
 Constructor. More...
 
 DenseVectorBase (DenseVectorBase &&)=default
 The 5 special functions can be defaulted for this class, as it does not manage any memory itself. More...
 
 DenseVectorBase (const DenseVectorBase &)=default
 
DenseVectorBaseoperator= (const DenseVectorBase &)=default
 
DenseVectorBaseoperator= (DenseVectorBase &&)=default
 
virtual ~DenseVectorBase ()=default
 
virtual void zero ()=0
 Set every element in the vector to 0. More...
 
virtual T el (const unsigned int i) const =0
 
virtual T & el (const unsigned int i)=0
 
virtual unsigned int size () const =0
 
virtual bool empty () const
 
void print (std::ostream &os) const
 Pretty-print the vector to stdout. More...
 
void print_scientific (std::ostream &os, unsigned precision=8) const
 Prints the entries of the vector with additional decimal places in scientific notation. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const DenseVectorBase< T > &v)
 Same as above, but allows you to print using the usual stream syntax. More...
 

Detailed Description

template<typename T>
class libMesh::DenseVectorBase< T >

Defines an abstract dense vector base class for use in Finite Element-type computations.

Specialized dense vectors, for example DenseSubVectors, can be derived from this class.

Author
John W. Peterson
Date
2003

Definition at line 63 of file dof_map.h.

Constructor & Destructor Documentation

◆ DenseVectorBase() [1/3]

template<typename T>
libMesh::DenseVectorBase< T >::DenseVectorBase ( )
default

Constructor.

◆ DenseVectorBase() [2/3]

template<typename T>
libMesh::DenseVectorBase< T >::DenseVectorBase ( DenseVectorBase< T > &&  )
default

The 5 special functions can be defaulted for this class, as it does not manage any memory itself.

◆ DenseVectorBase() [3/3]

template<typename T>
libMesh::DenseVectorBase< T >::DenseVectorBase ( const DenseVectorBase< T > &  )
default

◆ ~DenseVectorBase()

template<typename T>
virtual libMesh::DenseVectorBase< T >::~DenseVectorBase ( )
virtualdefault

Member Function Documentation

◆ el() [1/2]

template<typename T>
virtual T libMesh::DenseVectorBase< T >::el ( const unsigned int  i) const
pure virtual

◆ el() [2/2]

template<typename T>
virtual T& libMesh::DenseVectorBase< T >::el ( const unsigned int  i)
pure virtual
Returns
The (i) element of the vector as a writable reference.

Implemented in libMesh::DenseVector< T >, libMesh::DenseVector< Number >, libMesh::DenseVector< Output >, and libMesh::DenseSubVector< T >.

◆ empty()

template<typename T>
virtual bool libMesh::DenseVectorBase< T >::empty ( ) const
inlinevirtual
Returns
true iff size() is 0.

Reimplemented in libMesh::DenseVector< T >, libMesh::DenseVector< Number >, libMesh::DenseVector< Output >, and libMesh::DenseSubVector< T >.

Definition at line 84 of file dense_vector_base.h.

References libMesh::DenseVectorBase< T >::size().

84 { return (this->size() == 0); }
virtual unsigned int size() const =0

◆ operator=() [1/2]

template<typename T>
DenseVectorBase& libMesh::DenseVectorBase< T >::operator= ( const DenseVectorBase< T > &  )
default

◆ operator=() [2/2]

template<typename T>
DenseVectorBase& libMesh::DenseVectorBase< T >::operator= ( DenseVectorBase< T > &&  )
default

◆ print()

template<typename T >
void libMesh::DenseVectorBase< T >::print ( std::ostream &  os) const

Pretty-print the vector to stdout.

Definition at line 51 of file dense_vector_base.C.

References libMesh::make_range().

52 {
53  for (auto i : make_range(this->size()))
54  os << std::setw(8)
55  << this->el(i)
56  << std::endl;
57 }
virtual unsigned int size() const =0
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
virtual T el(const unsigned int i) const =0

◆ print_scientific()

template<typename T >
void libMesh::DenseVectorBase< T >::print_scientific ( std::ostream &  os,
unsigned  precision = 8 
) const

Prints the entries of the vector with additional decimal places in scientific notation.

Definition at line 31 of file dense_vector_base.C.

References libMesh::make_range().

32 {
33  // save the initial format flags
34  std::ios_base::fmtflags os_flags = os.flags();
35 
36  // Print the vector entries.
37  for (auto i : make_range(this->size()))
38  os << std::setw(10)
39  << std::scientific
40  << std::setprecision(precision)
41  << this->el(i)
42  << std::endl;
43 
44  // reset the original format flags
45  os.flags(os_flags);
46 }
virtual unsigned int size() const =0
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
virtual T el(const unsigned int i) const =0

◆ size()

template<typename T>
virtual unsigned int libMesh::DenseVectorBase< T >::size ( ) const
pure virtual

◆ zero()

template<typename T>
virtual void libMesh::DenseVectorBase< T >::zero ( )
pure virtual

Set every element in the vector to 0.

Needs to be pure virtual since the storage method may be different in derived classes.

Implemented in libMesh::DenseVector< T >, libMesh::DenseVector< Number >, libMesh::DenseVector< Output >, and libMesh::DenseSubVector< T >.

Referenced by libMesh::DofMap::extract_local_vector().

Friends And Related Function Documentation

◆ operator<<

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const DenseVectorBase< T > &  v 
)
friend

Same as above, but allows you to print using the usual stream syntax.

Definition at line 95 of file dense_vector_base.h.

96  {
97  v.print(os);
98  return os;
99  }

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