libMesh
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
libMesh::NumericVector< T > Class Template Referenceabstract

Provides a uniform interface to vector storage schemes for different linear algebra libraries. More...

#include <dof_map.h>

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

Public Member Functions

 NumericVector (const Parallel::Communicator &comm_in, const ParallelType ptype=AUTOMATIC)
 Dummy-Constructor. More...
 
 NumericVector (const Parallel::Communicator &comm_in, const numeric_index_type n, const ParallelType ptype=AUTOMATIC)
 Constructor. More...
 
 NumericVector (const Parallel::Communicator &comm_in, const numeric_index_type n, const numeric_index_type n_local, const ParallelType ptype=AUTOMATIC)
 Constructor. More...
 
 NumericVector (const Parallel::Communicator &comm_in, const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType ptype=AUTOMATIC)
 Constructor. More...
 
virtual NumericVector< T > & operator= (const NumericVector< T > &v)=0
 This looks like a copy assignment operator, but note that, unlike normal copy assignment operators, it is pure virtual. More...
 
 NumericVector (NumericVector &&)=default
 The 5 special functions can be defaulted for this class, as it does not manage any memory itself. More...
 
 NumericVector (const NumericVector &)=default
 
NumericVectoroperator= (NumericVector &&)=default
 
virtual bool initialized () const
 
ParallelType type () const
 
ParallelTypetype ()
 
virtual bool closed () const
 
virtual void close ()=0
 Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across processors. More...
 
virtual void clear ()
 Restores the NumericVector<T> to a pristine state. More...
 
virtual void zero ()=0
 Set all entries to zero. More...
 
virtual std::unique_ptr< NumericVector< T > > zero_clone () const =0
 
virtual std::unique_ptr< NumericVector< T > > clone () const =0
 
virtual void init (const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
 Change the dimension of the vector to n. More...
 
virtual void init (const numeric_index_type n, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
 Call init() with n_local = N. More...
 
virtual void init (const numeric_index_type n, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
 Create a vector that holds tha local indices plus those specified in the ghost argument. More...
 
virtual void init (const NumericVector< T > &other, const bool fast=false)=0
 Creates a vector that has the same dimension and storage type as other, including ghost dofs. More...
 
virtual NumericVector< T > & operator= (const T s)=0
 Sets all entries of the vector to the value s. More...
 
virtual NumericVector< T > & operator= (const std::vector< T > &v)=0
 Sets (*this)(i) = v(i) for each entry of the vector. More...
 
virtual Real min () const =0
 
virtual Real max () const =0
 
virtual T sum () const =0
 
virtual Real l1_norm () const =0
 
virtual Real l2_norm () const =0
 
virtual Real linfty_norm () const =0
 
virtual Real subset_l1_norm (const std::set< numeric_index_type > &indices) const
 
virtual Real subset_l2_norm (const std::set< numeric_index_type > &indices) const
 
virtual Real subset_linfty_norm (const std::set< numeric_index_type > &indices) const
 
virtual numeric_index_type size () const =0
 
virtual numeric_index_type local_size () const =0
 
virtual numeric_index_type first_local_index () const =0
 
virtual numeric_index_type last_local_index () const =0
 
virtual T operator() (const numeric_index_type i) const =0
 
virtual T el (const numeric_index_type i) const
 
virtual void get (const std::vector< numeric_index_type > &index, T *values) const
 Access multiple components at once. More...
 
void get (const std::vector< numeric_index_type > &index, std::vector< T > &values) const
 Access multiple components at once. More...
 
virtual NumericVector< T > & operator+= (const NumericVector< T > &v)=0
 Adds v to *this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $. More...
 
virtual NumericVector< T > & operator-= (const NumericVector< T > &v)=0
 Subtracts v from *this, $ \vec{u} \leftarrow \vec{u} - \vec{v} $. More...
 
NumericVector< T > & operator*= (const T a)
 Scales the vector by a, $ \vec{u} \leftarrow a\vec{u} $. More...
 
NumericVector< T > & operator/= (const T a)
 Scales the vector by 1/a, $ \vec{u} \leftarrow \frac{1}{a}\vec{u} $. More...
 
virtual NumericVector< T > & operator/= (const NumericVector< T > &)=0
 Computes the pointwise division of this vector's entries by another's, $ u_i \leftarrow \frac{u_i}{v_i} \, \forall i$. More...
 
virtual void reciprocal ()=0
 Computes the pointwise reciprocal, $ u_i \leftarrow \frac{1}{u_i} \, \forall i$. More...
 
virtual void conjugate ()=0
 Negates the imaginary component of each entry in the vector. More...
 
virtual void set (const numeric_index_type i, const T value)=0
 Sets v(i) = value. More...
 
virtual void add (const numeric_index_type i, const T value)=0
 Adds value to each entry of the vector. More...
 
virtual void add (const T s)=0
 Adds s to each entry of the vector, $ u_i \leftarrow u_i + s $. More...
 
virtual void add (const NumericVector< T > &v)=0
 Adds v to this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $. More...
 
virtual void add (const T a, const NumericVector< T > &v)=0
 Vector addition with a scalar multiple, $ \vec{u} \leftarrow \vec{u} + a\vec{v} $. More...
 
virtual void add_vector (const T *v, const std::vector< numeric_index_type > &dof_indices)
 Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a pointer and each dof_indices[i] specifies where to add value v[i]. More...
 
void add_vector (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a std::vector and each dof_indices[i] specifies where to add value v[i]. More...
 
virtual void add_vector (const NumericVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a NumericVector and each dof_indices[i] specifies where to add value v(i). More...
 
void add_vector (const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a DenseVector and each dof_indices[i] specifies where to add value v(i). More...
 
virtual void add_vector (const NumericVector< T > &v, const SparseMatrix< T > &A)=0
 Computes $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, i.e. More...
 
void add_vector (const NumericVector< T > &v, const ShellMatrix< T > &A)
 Computes $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, i.e. More...
 
virtual void add_vector_transpose (const NumericVector< T > &v, const SparseMatrix< T > &A)=0
 Computes $ \vec{u} \leftarrow \vec{u} + A^T \vec{v} $, i.e. More...
 
virtual void insert (const T *v, const std::vector< numeric_index_type > &dof_indices)
 Inserts the entries of v in *this at the locations specified by v. More...
 
void insert (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Inserts the entries of v in *this at the locations specified by v. More...
 
virtual void insert (const NumericVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Inserts the entries of v in *this at the locations specified by v. More...
 
void insert (const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Inserts the entries of v in *this at the locations specified by v. More...
 
void insert (const DenseSubVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 Inserts the entries of v in *this at the locations specified by v. More...
 
virtual void scale (const T factor)=0
 Scale each element of the vector by the given factor. More...
 
virtual void abs ()=0
 Sets $ u_i \leftarrow |u_i| $ for each entry in the vector. More...
 
virtual T dot (const NumericVector< T > &v) const =0
 
virtual void localize (std::vector< T > &v_local) const =0
 Creates a copy of the global vector in the local vector v_local. More...
 
virtual void localize (NumericVector< T > &v_local) const =0
 Same, but fills a NumericVector<T> instead of a std::vector. More...
 
virtual void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const =0
 Creates a local vector v_local containing only information relevant to this processor, as defined by the send_list. More...
 
virtual void localize (std::vector< T > &v_local, const std::vector< numeric_index_type > &indices) const =0
 
Fill in the local std::vector "v_local" with the global indices given in "indices". More...
 
virtual void localize (const numeric_index_type first_local_idx, const numeric_index_type last_local_idx, const std::vector< numeric_index_type > &send_list)=0
 Updates a local vector with selected values from neighboring processors, as defined by send_list. More...
 
virtual void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const =0
 Creates a local copy of the global vector in v_local only on processor proc_id. More...
 
virtual int compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
 
virtual int local_relative_compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
 
virtual int global_relative_compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
 
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
 Computes $ u_i \leftarrow u_i v_i $ (summation not implied) i.e. More...
 
virtual void print (std::ostream &os=libMesh::out) const
 Prints the local contents of the vector, by default to libMesh::out. More...
 
virtual void print_global (std::ostream &os=libMesh::out) const
 Prints the global contents of the vector, by default to libMesh::out. More...
 
virtual void print_matlab (const std::string &="") const
 Print the contents of the vector in Matlab's sparse matrix format. More...
 
virtual void create_subvector (NumericVector< T > &, const std::vector< numeric_index_type > &) const
 Fills in subvector from this vector using the indices in rows. More...
 
virtual void swap (NumericVector< T > &v)
 Swaps the contents of this with v. More...
 
template<>
void print (std::ostream &os) const
 
template<>
void print_global (std::ostream &os) const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::unique_ptr< NumericVector< T > > build (const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
 Builds a NumericVector on the processors in communicator comm using the linear solver package specified by solver_package. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

bool _is_closed
 Flag which tracks whether the vector's values are consistent on all processors after insertion or addition of values has occurred on some or all processors. More...
 
bool _is_initialized
 true once init() has been called. More...
 
ParallelType _type
 Type of vector. More...
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int > _n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter
 Flag to control whether reference count information is printed when print_info is called. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const NumericVector< T > &v)
 Same as above but allows you to use stream syntax. More...
 

Detailed Description

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

Provides a uniform interface to vector storage schemes for different linear algebra libraries.

Note
This class is the abstract base class for different implementations of numeric vectors. Most of the time you should use a System object to create numeric vectors. If this is not desired, you can instantiate one of the derived classes (PetscVector, EigenSparseVector, etc.) or use the NumericVector::build method. When creating the vector yourself, make sure that you initialize the vector properly (NumericVector::init).
Author
Benjamin S. Kirk
Date
2003

Definition at line 76 of file dof_map.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

Constructor & Destructor Documentation

◆ NumericVector() [1/6]

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator comm_in,
const ParallelType  ptype = AUTOMATIC 
)
explicit

Dummy-Constructor.

Dimension=0

Definition at line 732 of file numeric_vector.h.

733  :
734  ParallelObject(comm_in),
735  _is_closed(false),
736  _is_initialized(false),
737  _type(ptype)
738 {
739 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _is_initialized
true once init() has been called.
ParallelType _type
Type of vector.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ NumericVector() [2/6]

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator comm_in,
const numeric_index_type  n,
const ParallelType  ptype = AUTOMATIC 
)
explicit

Constructor.

Set dimension to n and initialize all elements with zero.

Definition at line 745 of file numeric_vector.h.

747  :
748  ParallelObject(comm_in),
749  _is_closed(false),
750  _is_initialized(false),
751  _type(ptype)
752 {
753  libmesh_not_implemented(); // Abstract base class!
754  // init(n, n, false, ptype);
755 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _is_initialized
true once init() has been called.
ParallelType _type
Type of vector.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ NumericVector() [3/6]

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator comm_in,
const numeric_index_type  n,
const numeric_index_type  n_local,
const ParallelType  ptype = AUTOMATIC 
)

Constructor.

Set local dimension to n_local, the global dimension to n, and initialize all elements with zero.

Definition at line 761 of file numeric_vector.h.

764  :
765  ParallelObject(comm_in),
766  _is_closed(false),
767  _is_initialized(false),
768  _type(ptype)
769 {
770  libmesh_not_implemented(); // Abstract base class!
771  // init(n, n_local, false, ptype);
772 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _is_initialized
true once init() has been called.
ParallelType _type
Type of vector.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ NumericVector() [4/6]

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator comm_in,
const numeric_index_type  N,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const ParallelType  ptype = AUTOMATIC 
)

Constructor.

Set local dimension to n_local, the global dimension to n, but additionally reserve memory for the indices specified by the ghost argument.

Definition at line 778 of file numeric_vector.h.

782  :
783  ParallelObject(comm_in),
784  _is_closed(false),
785  _is_initialized(false),
786  _type(ptype)
787 {
788  libmesh_not_implemented(); // Abstract base class!
789  // init(n, n_local, ghost, false, ptype);
790 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _is_initialized
true once init() has been called.
ParallelType _type
Type of vector.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ NumericVector() [5/6]

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

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

◆ NumericVector() [6/6]

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

Member Function Documentation

◆ abs()

template<typename T>
virtual void libMesh::NumericVector< T >::abs ( )
pure virtual

◆ add() [1/4]

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const numeric_index_type  i,
const T  value 
)
pure virtual

◆ add() [2/4]

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const T  s)
pure virtual

◆ add() [3/4]

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const NumericVector< T > &  v)
pure virtual

◆ add() [4/4]

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const T  a,
const NumericVector< T > &  v 
)
pure virtual

◆ add_vector() [1/6]

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a pointer and each dof_indices[i] specifies where to add value v[i].

This should be overridden in subclasses for efficiency.

Reimplemented in libMesh::PetscVector< T >, and libMesh::EpetraVector< T >.

◆ add_vector() [2/6]

template<typename T>
void libMesh::NumericVector< T >::add_vector ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a std::vector and each dof_indices[i] specifies where to add value v[i].

Definition at line 835 of file numeric_vector.h.

837 {
838  libmesh_assert(v.size() == dof_indices.size());
839  if (!v.empty())
840  this->add_vector(v.data(), dof_indices);
841 }
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...

◆ add_vector() [3/6]

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a NumericVector and each dof_indices[i] specifies where to add value v(i).

◆ add_vector() [4/6]

template<typename T>
void libMesh::NumericVector< T >::add_vector ( const DenseVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a DenseVector and each dof_indices[i] specifies where to add value v(i).

Definition at line 847 of file numeric_vector.h.

849 {
850  libmesh_assert(v.size() == dof_indices.size());
851  if (!v.empty())
852  this->add_vector(&v(0), dof_indices);
853 }
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...

◆ add_vector() [5/6]

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
pure virtual

◆ add_vector() [6/6]

template<typename T>
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  A 
)

Computes $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, i.e.

adds the product of a ShellMatrix A and a NumericVector v to this.

◆ add_vector_transpose()

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector_transpose ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
pure virtual

◆ build()

template<typename T>
static std::unique_ptr<NumericVector<T> > libMesh::NumericVector< T >::build ( const Parallel::Communicator comm,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
static

Builds a NumericVector on the processors in communicator comm using the linear solver package specified by solver_package.

◆ clear()

template<typename T >
void libMesh::NumericVector< T >::clear ( )
virtual

Restores the NumericVector<T> to a pristine state.

Reimplemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

Definition at line 796 of file numeric_vector.h.

797 {
798  _is_closed = false;
799  _is_initialized = false;
800 }
bool _is_initialized
true once init() has been called.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ clone()

template<typename T>
virtual std::unique_ptr<NumericVector<T> > libMesh::NumericVector< T >::clone ( ) const
pure virtual
Returns
A copy of this vector wrapped in a smart pointer.
Note
This must be overridden in the derived classes.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ close()

template<typename T>
virtual void libMesh::NumericVector< T >::close ( )
pure virtual

Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across processors.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ closed()

template<typename T>
virtual bool libMesh::NumericVector< T >::closed ( ) const
virtual
Returns
true if the vector is closed and ready for computation, false otherwise.

Definition at line 165 of file numeric_vector.h.

165 { return _is_closed; }
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ compare()

template<typename T>
virtual int libMesh::NumericVector< T >::compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtual
Returns
-1 when this is equivalent to other_vector (up to the given threshold), or the first index where abs(a[i]-b[i]) exceeds the threshold.

◆ conjugate()

template<typename T>
virtual void libMesh::NumericVector< T >::conjugate ( )
pure virtual

◆ create_subvector()

template<typename T>
virtual void libMesh::NumericVector< T >::create_subvector ( NumericVector< T > &  ,
const std::vector< numeric_index_type > &   
) const
virtual

Fills in subvector from this vector using the indices in rows.

Similar to the create_submatrix() routine for the SparseMatrix class, it is currently only implemented for PetscVectors.

Reimplemented in libMesh::PetscVector< T >, and libMesh::EpetraVector< T >.

Definition at line 692 of file numeric_vector.h.

694  {
695  libmesh_not_implemented();
696  }

◆ disable_print_counter_info()

static void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

◆ dot()

template<typename T>
virtual T libMesh::NumericVector< T >::dot ( const NumericVector< T > &  v) const
pure virtual
Returns
$ \vec{u} \cdot \vec{v} $, the dot product of (*this) with the vector v.

Uses the complex-conjugate of v in the complex-valued case.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ el()

template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i) const
virtual
Returns
(*this)(i).

Definition at line 346 of file numeric_vector.h.

346 { return (*this)(i); }

◆ enable_print_counter_info()

static void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

◆ first_local_index()

template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::first_local_index ( ) const
pure virtual
Returns
The index of the first vector element actually stored on this processor.
Note
The minimum for this index is 0.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

Referenced by libMesh::index_range(), and libMesh::VectorSetAction< Val >::insert().

◆ get() [1/2]

template<typename T>
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
T *  values 
) const
virtual

Access multiple components at once.

values will not be reallocated; it should already have enough space. The default implementation calls operator() for each index, but some implementations may supply faster methods here.

Reimplemented in libMesh::PetscVector< T >.

Definition at line 806 of file numeric_vector.h.

808 {
809  const std::size_t num = index.size();
810  for (std::size_t i=0; i<num; i++)
811  {
812  values[i] = (*this)(index[i]);
813  }
814 }

◆ get() [2/2]

template<typename T>
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
std::vector< T > &  values 
) const

Access multiple components at once.

values will be resized, if necessary, and filled. The default implementation calls operator() for each index, but some implementations may supply faster methods here.

Definition at line 820 of file numeric_vector.h.

822 {
823  const std::size_t num = index.size();
824  values.resize(num);
825  if (!num)
826  return;
827 
828  this->get(index, values.data());
829 }

◆ get_info()

static std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

◆ global_relative_compare()

template<typename T>
virtual int libMesh::NumericVector< T >::global_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtual
Returns
-1 when this is equivalent to other_vector (up to the given global relative threshold), or the first index where abs(a[i]-b[i])/max_j(a[j],b[j]) exceeds the threshold.

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 181 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 194 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ init() [1/4]

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const numeric_index_type  n,
const numeric_index_type  n_local,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
pure virtual

Change the dimension of the vector to n.

The reserved memory for this vector remains unchanged if possible. If n==0, all memory is freed. Therefore, if you want to resize the vector and release the memory not needed, you have to first call init(0) and then init(n). This behaviour is analogous to that of the STL containers.

On fast==false, the vector is filled by zeros.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

Referenced by libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::DistributedVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

◆ init() [2/4]

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const numeric_index_type  n,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
pure virtual

◆ init() [3/4]

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const numeric_index_type  n,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
pure virtual

Create a vector that holds tha local indices plus those specified in the ghost argument.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ init() [4/4]

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
)
pure virtual

Creates a vector that has the same dimension and storage type as other, including ghost dofs.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ initialized()

template<typename T>
virtual bool libMesh::NumericVector< T >::initialized ( ) const
virtual
Returns
true if the vector has been initialized, false otherwise.

Definition at line 149 of file numeric_vector.h.

Referenced by libMesh::PetscVector< T >::init().

149 { return _is_initialized; }
bool _is_initialized
true once init() has been called.

◆ insert() [1/5]

template<typename T>
virtual void libMesh::NumericVector< T >::insert ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

Inserts the entries of v in *this at the locations specified by v.

Reimplemented in libMesh::PetscVector< T >, and libMesh::EpetraVector< T >.

◆ insert() [2/5]

template<typename T>
void libMesh::NumericVector< T >::insert ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

Inserts the entries of v in *this at the locations specified by v.

Definition at line 859 of file numeric_vector.h.

861 {
862  libmesh_assert(v.size() == dof_indices.size());
863  if (!v.empty())
864  this->insert(v.data(), dof_indices);
865 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.

◆ insert() [3/5]

template<typename T>
virtual void libMesh::NumericVector< T >::insert ( const NumericVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

Inserts the entries of v in *this at the locations specified by v.

◆ insert() [4/5]

template<typename T>
void libMesh::NumericVector< T >::insert ( const DenseVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

Inserts the entries of v in *this at the locations specified by v.

Definition at line 871 of file numeric_vector.h.

873 {
874  libmesh_assert(v.size() == dof_indices.size());
875  if (!v.empty())
876  this->insert(&v(0), dof_indices);
877 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.

◆ insert() [5/5]

template<typename T>
void libMesh::NumericVector< T >::insert ( const DenseSubVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

Inserts the entries of v in *this at the locations specified by v.

Definition at line 883 of file numeric_vector.h.

885 {
886  libmesh_assert(v.size() == dof_indices.size());
887  if (!v.empty())
888  this->insert(&v(0), dof_indices);
889 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.

◆ l1_norm()

template<typename T>
virtual Real libMesh::NumericVector< T >::l1_norm ( ) const
pure virtual
Returns
The $ \ell_1 $-norm of the vector, i.e. the sum of the absolute values of the entries.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ l2_norm()

template<typename T>
virtual Real libMesh::NumericVector< T >::l2_norm ( ) const
pure virtual
Returns
The $ \ell_2 $-norm of the vector, i.e. the square root of the sum of the squares of the entries.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ last_local_index()

template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::last_local_index ( ) const
pure virtual
Returns
The index+1 of the last vector element actually stored on this processor.
Note
The maximum for this index is size().

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

Referenced by libMesh::index_range(), and libMesh::VectorSetAction< Val >::insert().

◆ linfty_norm()

template<typename T>
virtual Real libMesh::NumericVector< T >::linfty_norm ( ) const
pure virtual
Returns
The $ \ell_{\infty} $-norm of the vector, i.e. the maximum absolute value of the entries of the vector.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ local_relative_compare()

template<typename T>
virtual int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtual
Returns
-1 when this is equivalent to other_vector, (up to the given local relative threshold), or the first index where abs(a[i]-b[i])/max(a[i],b[i]) exceeds the threshold.

◆ local_size()

template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::local_size ( ) const
pure virtual

◆ localize() [1/5]

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( std::vector< T > &  v_local) const
pure virtual

Creates a copy of the global vector in the local vector v_local.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ localize() [2/5]

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( NumericVector< T > &  v_local) const
pure virtual

◆ localize() [3/5]

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const
pure virtual

Creates a local vector v_local containing only information relevant to this processor, as defined by the send_list.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ localize() [4/5]

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( std::vector< T > &  v_local,
const std::vector< numeric_index_type > &  indices 
) const
pure virtual


Fill in the local std::vector "v_local" with the global indices given in "indices".

Note
The indices can be different on every processor, and the same index can be localized to more than one processor. The resulting v_local can be shorter than the original, and the entries will be in the order specified by indices.

Example:

*   On 4 procs *this = {a, b, c, d, e, f, g, h, i} is a parallel vector.
*   On each proc, the indices arrays are set up as:
*   proc0, indices = {1,2,4,5}
*   proc1, indices = {2,5,6,8}
*   proc2, indices = {2,3,6,7}
*   proc3, indices = {0,1,2,3}
*
*   After calling this version of localize, the v_local vectors are:
*   proc0, v_local = {b,c,e,f}
*   proc1, v_local = {c,f,g,i}
*   proc2, v_local = {c,d,g,h}
*   proc3, v_local = {a,b,c,d}
* 

This function is useful in parallel I/O routines, when you have a parallel vector of solution values which you want to write a subset of.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ localize() [5/5]

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( const numeric_index_type  first_local_idx,
const numeric_index_type  last_local_idx,
const std::vector< numeric_index_type > &  send_list 
)
pure virtual

Updates a local vector with selected values from neighboring processors, as defined by send_list.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ localize_to_one()

template<typename T>
virtual void libMesh::NumericVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const
pure virtual

Creates a local copy of the global vector in v_local only on processor proc_id.

By default the data is sent to processor 0. This method is useful for outputting data from one processor.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ max()

template<typename T>
virtual Real libMesh::NumericVector< T >::max ( ) const
pure virtual
Returns
The maximum entry in the vector, or the maximum real part in the case of complex numbers.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ min()

template<typename T>
virtual Real libMesh::NumericVector< T >::min ( ) const
pure virtual
Returns
The minimum entry in the vector, or the minimum real part in the case of complex numbers.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 83 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

84  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 95 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::MeshBase::partition().

96  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ operator()()

template<typename T>
virtual T libMesh::NumericVector< T >::operator() ( const numeric_index_type  i) const
pure virtual

◆ operator*=()

template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a)

Scales the vector by a, $ \vec{u} \leftarrow a\vec{u} $.

Equivalent to u.scale(a)

Returns
A reference to *this.

Definition at line 391 of file numeric_vector.h.

391 { this->scale(a); return *this; }
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.

◆ operator+=()

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator+= ( const NumericVector< T > &  v)
pure virtual

Adds v to *this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $.

Equivalent to u.add(1, v).

Returns
A reference to *this.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ operator-=()

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator-= ( const NumericVector< T > &  v)
pure virtual

Subtracts v from *this, $ \vec{u} \leftarrow \vec{u} - \vec{v} $.

Equivalent to u.add(-1, v).

Returns
A reference to *this.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ operator/=() [1/2]

template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const T  a)

Scales the vector by 1/a, $ \vec{u} \leftarrow \frac{1}{a}\vec{u} $.

Equivalent to u.scale(1./a)

Returns
A reference to *this.

Definition at line 400 of file numeric_vector.h.

400 { this->scale(1./a); return *this; }
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.

◆ operator/=() [2/2]

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const NumericVector< T > &  )
pure virtual

Computes the pointwise division of this vector's entries by another's, $ u_i \leftarrow \frac{u_i}{v_i} \, \forall i$.

Returns
A reference to *this.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ operator=() [1/4]

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const NumericVector< T > &  v)
pure virtual

This looks like a copy assignment operator, but note that, unlike normal copy assignment operators, it is pure virtual.

This function should be overridden in derived classes so that they can be copied correctly via references to the base class. This design usually isn't a good idea in general, but in this context it works because we usually don't have a mix of different kinds of NumericVectors active in the library at a single time.

Returns
A reference to *this as the base type.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ operator=() [2/4]

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

◆ operator=() [3/4]

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const T  s)
pure virtual

Sets all entries of the vector to the value s.

Returns
A reference to *this.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ operator=() [4/4]

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const std::vector< T > &  v)
pure virtual

Sets (*this)(i) = v(i) for each entry of the vector.

Returns
A reference to *this as the base type.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ pointwise_mult()

template<typename T>
virtual void libMesh::NumericVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
pure virtual

Computes $ u_i \leftarrow u_i v_i $ (summation not implied) i.e.

the pointwise (component-wise) product of vec1 and vec2, and stores the result in *this.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

◆ print() [1/2]

template<typename T >
void libMesh::NumericVector< T >::print ( std::ostream &  os = libMesh::out) const
virtual

Prints the local contents of the vector, by default to libMesh::out.

Definition at line 916 of file numeric_vector.h.

917 {
918  libmesh_assert (this->initialized());
919  os << "Size\tglobal = " << this->size()
920  << "\t\tlocal = " << this->local_size() << std::endl;
921 
922  os << "#\tValue" << std::endl;
923  for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
924  os << i << "\t" << (*this)(i) << std::endl;
925 }
virtual bool initialized() const
virtual numeric_index_type size() const =0
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type first_local_index() const =0
virtual numeric_index_type local_size() const =0
virtual numeric_index_type last_local_index() const =0

◆ print() [2/2]

template<>
void libMesh::NumericVector< Complex >::print ( std::ostream &  os) const

Definition at line 898 of file numeric_vector.h.

899 {
900  libmesh_assert (this->initialized());
901  os << "Size\tglobal = " << this->size()
902  << "\t\tlocal = " << this->local_size() << std::endl;
903 
904  // std::complex<>::operator<<() is defined, but use this form
905  os << "#\tReal part\t\tImaginary part" << std::endl;
906  for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
907  os << i << "\t"
908  << (*this)(i).real() << "\t\t"
909  << (*this)(i).imag() << std::endl;
910 }
virtual bool initialized() const
virtual numeric_index_type size() const =0
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type first_local_index() const =0
virtual numeric_index_type local_size() const =0
virtual numeric_index_type last_local_index() const =0

◆ print_global() [1/2]

template<typename T >
void libMesh::NumericVector< T >::print_global ( std::ostream &  os = libMesh::out) const
virtual

Prints the global contents of the vector, by default to libMesh::out.

Definition at line 953 of file numeric_vector.h.

954 {
955  libmesh_assert (this->initialized());
956 
957  std::vector<T> v(this->size());
958  this->localize(v);
959 
960  // Right now we only want one copy of the output
961  if (this->processor_id())
962  return;
963 
964  os << "Size\tglobal = " << this->size() << std::endl;
965  os << "#\tValue" << std::endl;
966  for (numeric_index_type i=0; i!=v.size(); i++)
967  os << i << "\t" << v[i] << std::endl;
968 }
virtual bool initialized() const
virtual numeric_index_type size() const =0
dof_id_type numeric_index_type
Definition: id_types.h:92
processor_id_type processor_id() const
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ print_global() [2/2]

template<>
void libMesh::NumericVector< Complex >::print_global ( std::ostream &  os) const

Definition at line 931 of file numeric_vector.h.

932 {
933  libmesh_assert (this->initialized());
934 
935  std::vector<Complex> v(this->size());
936  this->localize(v);
937 
938  // Right now we only want one copy of the output
939  if (this->processor_id())
940  return;
941 
942  os << "Size\tglobal = " << this->size() << std::endl;
943  os << "#\tReal part\t\tImaginary part" << std::endl;
944  for (numeric_index_type i=0; i!=v.size(); i++)
945  os << i << "\t"
946  << v[i].real() << "\t\t"
947  << v[i].imag() << std::endl;
948 }
virtual bool initialized() const
virtual numeric_index_type size() const =0
dof_id_type numeric_index_type
Definition: id_types.h:92
processor_id_type processor_id() const
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ print_info()

static void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

◆ print_matlab()

template<typename T>
virtual void libMesh::NumericVector< T >::print_matlab ( const std::string &  = "") const
virtual

Print the contents of the vector in Matlab's sparse matrix format.

Optionally prints the vector to the file named name. If name is not specified it is dumped to the screen.

Reimplemented in libMesh::PetscVector< T >.

Definition at line 681 of file numeric_vector.h.

682  {
683  libmesh_not_implemented();
684  }

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ reciprocal()

template<typename T>
virtual void libMesh::NumericVector< T >::reciprocal ( )
pure virtual

◆ scale()

template<typename T>
virtual void libMesh::NumericVector< T >::scale ( const T  factor)
pure virtual

◆ set()

template<typename T>
virtual void libMesh::NumericVector< T >::set ( const numeric_index_type  i,
const T  value 
)
pure virtual

◆ size()

template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::size ( ) const
pure virtual

◆ subset_l1_norm()

template<typename T>
virtual Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices) const
virtual
Returns
The $ \ell_1 $-norm of the vector, i.e. the sum of the absolute values for the specified entries in the vector.
Note
The indices must necessarily live on this processor.

◆ subset_l2_norm()

template<typename T>
virtual Real libMesh::NumericVector< T >::subset_l2_norm ( const std::set< numeric_index_type > &  indices) const
virtual
Returns
The $ \ell_2 $-norm of the vector, i.e. the square root of the sum of the squares of the elements for the specified entries in the vector.
Note
The indices must necessarily live on this processor.

◆ subset_linfty_norm()

template<typename T>
virtual Real libMesh::NumericVector< T >::subset_linfty_norm ( const std::set< numeric_index_type > &  indices) const
virtual
Returns
The maximum absolute value of the specified entries of this vector, which is the $ \ell_{\infty} $-norm of a vector.
Note
The indices must necessarily live on this processor.

◆ sum()

template<typename T>
virtual T libMesh::NumericVector< T >::sum ( ) const
pure virtual

◆ swap()

template<typename T>
void libMesh::NumericVector< T >::swap ( NumericVector< T > &  v)
virtual

Swaps the contents of this with v.

There should be enough indirection in subclasses to make this an O(1) header-swap operation.

Reimplemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::DistributedVector< T >, and libMesh::EigenSparseVector< T >.

Definition at line 974 of file numeric_vector.h.

Referenced by libMesh::EpetraVector< T >::swap(), and libMesh::PetscVector< T >::swap().

975 {
976  std::swap(_is_closed, v._is_closed);
977  std::swap(_is_initialized, v._is_initialized);
978  std::swap(_type, v._type);
979 }
bool _is_initialized
true once init() has been called.
ParallelType _type
Type of vector.
void swap(Iterator &lhs, Iterator &rhs)
swap, used to implement op=
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...

◆ type() [1/2]

template<typename T>
ParallelType libMesh::NumericVector< T >::type ( ) const
Returns
The type (SERIAL, PARALLEL, GHOSTED) of the vector.

Definition at line 154 of file numeric_vector.h.

Referenced by libMesh::EpetraVector< T >::EpetraVector(), libMesh::DistributedVector< T >::init(), libMesh::EigenSparseVector< T >::init(), libMesh::LaspackVector< T >::init(), and libMesh::EpetraVector< T >::init().

154 { return _type; }
ParallelType _type
Type of vector.

◆ type() [2/2]

template<typename T>
ParallelType& libMesh::NumericVector< T >::type ( )
Returns
The type (SERIAL, PARALLEL, GHOSTED) of the vector.

Definition at line 159 of file numeric_vector.h.

159 { return _type; }
ParallelType _type
Type of vector.

◆ zero()

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

Set all entries to zero.

Equivalent to v = 0, but more obvious and faster.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

◆ zero_clone()

template<typename T>
virtual std::unique_ptr<NumericVector<T> > libMesh::NumericVector< T >::zero_clone ( ) const
pure virtual
Returns
A smart pointer to a copy of this vector with the same type, size, and partitioning, but with all zero entries.
Note
This must be overridden in the derived classes.

Implemented in libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T >, and libMesh::DistributedVector< T >.

Friends And Related Function Documentation

◆ operator<<

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

Same as above but allows you to use stream syntax.

Definition at line 670 of file numeric_vector.h.

671  {
672  v.print_global(os);
673  return os;
674  }

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts

Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 141 of file reference_counter.h.

◆ _is_closed

template<typename T>
bool libMesh::NumericVector< T >::_is_closed
protected

Flag which tracks whether the vector's values are consistent on all processors after insertion or addition of values has occurred on some or all processors.

Definition at line 712 of file numeric_vector.h.

Referenced by libMesh::NumericVector< Number >::closed(), libMesh::EpetraVector< T >::EpetraVector(), and libMesh::PetscVector< T >::PetscVector().

◆ _is_initialized

template<typename T>
bool libMesh::NumericVector< T >::_is_initialized
protected

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_objects

Threads::atomic<unsigned int> libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 130 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _type

template<typename T>
ParallelType libMesh::NumericVector< T >::_type
protected

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