libMesh::NumericVector< T > Class Template Reference

#include <numeric_vector.h>

Inheritance diagram for libMesh::NumericVector< T >:

List of all members.

Public Member Functions

 NumericVector (const ParallelType ptype=AUTOMATIC)
 NumericVector (const numeric_index_type n, const ParallelType ptype=AUTOMATIC)
 NumericVector (const numeric_index_type n, const numeric_index_type n_local, const ParallelType ptype=AUTOMATIC)
 NumericVector (const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType ptype=AUTOMATIC)
virtual ~NumericVector ()
virtual bool initialized () const
ParallelType type () const
ParallelType & type ()
virtual bool closed () const
virtual void close ()=0
virtual void clear ()
virtual void zero ()=0
virtual AutoPtr< NumericVector
< T > > 
zero_clone () const =0
virtual AutoPtr< NumericVector
< T > > 
clone () const =0
virtual void init (const numeric_index_type, const numeric_index_type, const bool=false, const ParallelType=AUTOMATIC)=0
virtual void init (const numeric_index_type, const bool=false, const ParallelType=AUTOMATIC)=0
virtual void init (const numeric_index_type, const numeric_index_type, const std::vector< numeric_index_type > &, const bool=false, const ParallelType=AUTOMATIC)=0
virtual void init (const NumericVector< T > &other, const bool fast=false)=0
virtual NumericVector< T > & operator= (const T s)=0
virtual NumericVector< T > & operator= (const NumericVector< T > &V)=0
virtual NumericVector< T > & operator= (const std::vector< T > &v)=0
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, std::vector< T > &values) const
virtual NumericVector< T > & operator+= (const NumericVector< T > &V)=0
virtual NumericVector< T > & operator-= (const NumericVector< T > &V)=0
NumericVector< T > & operator*= (const T a)
NumericVector< T > & operator/= (const T a)
virtual void reciprocal ()=0
virtual void set (const numeric_index_type i, const T value)=0
virtual void add (const numeric_index_type i, const T value)=0
virtual void add (const T s)=0
virtual void add (const NumericVector< T > &V)=0
virtual void add (const T a, const NumericVector< T > &v)=0
virtual void add_vector (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)=0
virtual void add_vector (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual void add_vector (const NumericVector< T > &, const SparseMatrix< T > &)=0
void add_vector (const NumericVector< T > &v, const ShellMatrix< T > &a)
virtual void add_vector (const DenseVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual void add_vector_transpose (const NumericVector< T > &, const SparseMatrix< T > &)=0
virtual void insert (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)=0
virtual void insert (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual void insert (const DenseVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual void insert (const DenseSubVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual void scale (const T factor)=0
virtual void abs ()=0
virtual T dot (const NumericVector< T > &) const =0
virtual void localize (std::vector< T > &v_local) const =0
virtual void localize (NumericVector< T > &v_local) const =0
virtual void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const =0
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
virtual void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const =0
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
virtual void print (std::ostream &os=libMesh::out) const
virtual void print_global (std::ostream &os=libMesh::out) const
virtual void print_matlab (const std::string name="NULL") const
virtual void create_subvector (NumericVector< T > &, const std::vector< numeric_index_type > &) const
virtual void swap (NumericVector< T > &v)
template<>
void print (std::ostream &os) const
template<>
void print_global (std::ostream &os) const

Static Public Member Functions

static AutoPtr< NumericVector
< T > > 
build (const SolverPackage solver_package=libMesh::default_solver_package())
static std::string get_info ()
static void print_info (std::ostream &out=libMesh::out)
static unsigned int n_objects ()
static void enable_print_counter_info ()
static void disable_print_counter_info ()

Protected Types

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

Protected Member Functions

void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)

Protected Attributes

bool _is_closed
bool _is_initialized
ParallelType _type

Static Protected Attributes

static Counts _counts
static Threads::atomic
< unsigned int > 
_n_objects
static Threads::spin_mutex _mutex
static bool _enable_print_counter = true

Friends

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

Detailed Description

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

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

Author:
Benjamin S. Kirk, 2003

Definition at line 57 of file numeric_vector.h.


Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited]

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.


Constructor & Destructor Documentation

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const ParallelType  ptype = AUTOMATIC  )  [inline, explicit]

Dummy-Constructor. Dimension=0

Definition at line 649 of file numeric_vector.h.

00649                                                          :
00650   _is_closed(false),
00651   _is_initialized(false),
00652   _type(ptype)
00653 {
00654 }

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const numeric_index_type  n,
const ParallelType  ptype = AUTOMATIC 
) [inline, explicit]

Constructor. Set dimension to n and initialize all elements with zero.

Definition at line 660 of file numeric_vector.h.

00661                                                            :
00662   _is_closed(false),
00663   _is_initialized(false),
00664   _type(ptype)
00665 {
00666   libmesh_error(); // Abstract base class!
00667   // init(n, n, false, ptype);
00668 }

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const numeric_index_type  n,
const numeric_index_type  n_local,
const ParallelType  ptype = AUTOMATIC 
) [inline]

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

Definition at line 674 of file numeric_vector.h.

00676                                                            :
00677   _is_closed(false),
00678   _is_initialized(false),
00679   _type(ptype)
00680 {
00681   libmesh_error(); // Abstract base class!
00682   // init(n, n_local, false, ptype);
00683 }

template<typename T >
libMesh::NumericVector< T >::NumericVector ( const numeric_index_type  N,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const ParallelType  ptype = AUTOMATIC 
) [inline]

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 689 of file numeric_vector.h.

00692                                                            :
00693   _is_closed(false),
00694   _is_initialized(false),
00695   _type(ptype)
00696 {
00697   libmesh_error(); // Abstract base class!
00698   // init(n, n_local, ghost, false, ptype);
00699 }

template<typename T >
libMesh::NumericVector< T >::~NumericVector (  )  [inline, virtual]

Destructor, deallocates memory. Made virtual to allow for derived classes to behave properly.

Definition at line 705 of file numeric_vector.h.

References libMesh::NumericVector< T >::clear().

00706 {
00707   clear ();
00708 }


Member Function Documentation

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

v = abs(v)... that is, each entry in v is replaced by its absolute value.

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

Referenced by libMesh::NumericVector< T >::subset_linfty_norm().

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

$U+=a*V$. Simple vector addition, equal to the operator +=.

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

$U+=V$: Simple vector addition, equal to the operator +=.

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

$U(0-LIBMESH_DIM)+=s$. Addition of s to all components. Note that s is a scalar and not a vector.

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

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [pure virtual]

$ U+=V $ where U and V are type DenseVector<T> and you want to specify WHERE to add the DenseVector<T> V

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

template<typename T>
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  a 
) [inline]

$U+=A*V$, add the product of a ShellMatrix A and a NumericVector V to this, where this=U.

Definition at line 358 of file numeric_vector.C.

References libMesh::ShellMatrix< T >::vector_mult_add().

00360 {
00361   a.vector_mult_add(*this,v);
00362 }

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

$U+=A*V$, add the product of a SparseMatrix A and a NumericVector V to this, where this=U.

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

$U+=V$, where U and V are type NumericVector<T> and you want to specify WHERE to add the NumericVector<T> V

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

$U+=A^T*V$, add the product of the transpose of a SparseMatrix A_trans and a NumericVector V to this, where this=U.

template<typename T >
AutoPtr< NumericVector< T > > libMesh::NumericVector< T >::build ( const SolverPackage  solver_package = libMesh::default_solver_package()  )  [inline, static]

Builds a NumericVector using the linear solver package specified by solver_package

Definition at line 45 of file numeric_vector.C.

References libMesh::LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and libMesh::TRILINOS_SOLVERS.

Referenced by libMesh::ExactErrorEstimator::estimate_error().

00046 {
00047   // Build the appropriate vector
00048   switch (solver_package)
00049     {
00050 
00051 
00052 #ifdef LIBMESH_HAVE_LASPACK
00053     case LASPACK_SOLVERS:
00054       {
00055         AutoPtr<NumericVector<T> > ap(new LaspackVector<T>);
00056         return ap;
00057       }
00058 #endif
00059 
00060 
00061 #ifdef LIBMESH_HAVE_PETSC
00062     case PETSC_SOLVERS:
00063       {
00064         AutoPtr<NumericVector<T> > ap(new PetscVector<T>);
00065         return ap;
00066       }
00067 #endif
00068 
00069 
00070 #ifdef LIBMESH_HAVE_TRILINOS
00071     case TRILINOS_SOLVERS:
00072       {
00073         AutoPtr<NumericVector<T> > ap(new EpetraVector<T>);
00074         return ap;
00075       }
00076 #endif
00077 
00078 
00079     default:
00080       AutoPtr<NumericVector<T> > ap(new DistributedVector<T>);
00081       return ap;
00082     }
00083 
00084   AutoPtr<NumericVector<T> > ap(NULL);
00085   return ap;
00086 }

template<typename T >
void libMesh::NumericVector< T >::clear (  )  [inline, virtual]
template<typename T>
virtual AutoPtr<NumericVector<T> > libMesh::NumericVector< T >::clone (  )  const [pure virtual]
template<typename T>
int libMesh::NumericVector< T >::compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual]
Returns:
-1 when this is equivalent to other_vector, up to the given threshold. When differences occur, the return value contains the first index i where the difference (a[i]-b[i]) exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

Definition at line 90 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), std::max(), libMesh::NumericVector< T >::max(), and libMesh::Parallel::Communicator::min().

00092 {
00093   libmesh_assert (this->initialized());
00094   libmesh_assert (other_vector.initialized());
00095   libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
00096   libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
00097 
00098   int first_different_i = std::numeric_limits<int>::max();
00099   numeric_index_type i = first_local_index();
00100 
00101   do
00102     {
00103       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
00104         first_different_i = i;
00105       else
00106         i++;
00107     }
00108   while (first_different_i==std::numeric_limits<int>::max()
00109          && i<last_local_index());
00110 
00111   // Find the correct first differing index in parallel
00112   CommWorld.min(first_different_i);
00113 
00114   if (first_different_i == std::numeric_limits<int>::max())
00115     return -1;
00116 
00117   return first_different_i;
00118 }

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

Creates the subvector "subvector" from the indices in the "rows" array. Similar to the create_submatrix routine for the SparseMatrix class, it is currently only implemented for PetscVectors.

Definition at line 608 of file numeric_vector.h.

00610   {
00611     libMesh::err << "ERROR: Not Implemented in base class yet!" << std::endl;
00612     libmesh_error();
00613   }

void libMesh::ReferenceCounter::disable_print_counter_info (  )  [static, inherited]

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00107 {
00108   _enable_print_counter = false;
00109   return;
00110 }

template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i  )  const [inline, virtual]
Returns:
the element U(i)

Definition at line 324 of file numeric_vector.h.

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

void libMesh::ReferenceCounter::enable_print_counter_info (  )  [static, inherited]

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

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00101 {
00102   _enable_print_counter = true;
00103   return;
00104 }

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

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.

Reimplemented in libMesh::PetscVector< T >.

Definition at line 760 of file numeric_vector.h.

00761 {
00762   const std::size_t num = index.size();
00763   values.resize(num);
00764   for(std::size_t i=0; i<num; i++)
00765     {
00766       values[i] = (*this)(index[i]);
00767     }
00768 }

std::string libMesh::ReferenceCounter::get_info (  )  [static, inherited]

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

Referenced by libMesh::ReferenceCounter::print_info().

00048 {
00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00050 
00051   std::ostringstream oss;
00052 
00053   oss << '\n'
00054       << " ---------------------------------------------------------------------------- \n"
00055       << "| Reference count information                                                |\n"
00056       << " ---------------------------------------------------------------------------- \n";
00057 
00058   for (Counts::iterator it = _counts.begin();
00059        it != _counts.end(); ++it)
00060     {
00061       const std::string name(it->first);
00062       const unsigned int creations    = it->second.first;
00063       const unsigned int destructions = it->second.second;
00064 
00065       oss << "| " << name << " reference count information:\n"
00066           << "|  Creations:    " << creations    << '\n'
00067           << "|  Destructions: " << destructions << '\n';
00068     }
00069 
00070   oss << " ---------------------------------------------------------------------------- \n";
00071 
00072   return oss.str();
00073 
00074 #else
00075 
00076   return "";
00077 
00078 #endif
00079 }

template<typename T>
int libMesh::NumericVector< T >::global_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual]
Returns:
-1 when this is equivalent to other_vector, up to the given local relative threshold. When differences occur, the return value contains the first index where the difference (a[i]-b[i])/max_j(a[j],b[j]) exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

Definition at line 155 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::linfty_norm(), std::max(), libMesh::NumericVector< T >::max(), libMesh::Parallel::Communicator::min(), and libMesh::Real.

00157 {
00158   libmesh_assert (this->initialized());
00159   libmesh_assert (other_vector.initialized());
00160   libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
00161   libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
00162 
00163   int first_different_i = std::numeric_limits<int>::max();
00164   numeric_index_type i = first_local_index();
00165 
00166   const Real my_norm = this->linfty_norm();
00167   const Real other_norm = other_vector.linfty_norm();
00168   const Real abs_threshold = std::max(my_norm, other_norm) * threshold;
00169 
00170   do
00171     {
00172       if ( std::abs( (*this)(i) - other_vector(i) ) > abs_threshold )
00173         first_different_i = i;
00174       else
00175         i++;
00176     }
00177   while (first_different_i==std::numeric_limits<int>::max()
00178          && i<last_local_index());
00179 
00180   // Find the correct first differing index in parallel
00181   CommWorld.min(first_different_i);
00182 
00183   if (first_different_i == std::numeric_limits<int>::max())
00184     return -1;
00185 
00186   return first_different_i;
00187 }

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name  )  [inline, protected, inherited]

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

Definition at line 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

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

00164 {
00165   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00166   std::pair<unsigned int, unsigned int>& p = _counts[name];
00167 
00168   p.first++;
00169 }

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name  )  [inline, protected, inherited]

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

Definition at line 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

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

00177 {
00178   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00179   std::pair<unsigned int, unsigned int>& p = _counts[name];
00180 
00181   p.second++;
00182 }

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.

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const   numeric_index_type,
const   numeric_index_type,
const std::vector< numeric_index_type > &  ,
const   bool = false,
const   ParallelType = AUTOMATIC 
) [pure virtual]

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

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

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

Change the dimension of the vector to N. The reserved memory for this vector remains unchanged if possible, to make things faster, but this may waste some memory, so take this in the back of your head. However, if N==0 all memory is freed, i.e. 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 cited behaviour is analogous to that of the STL containers.

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

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

Referenced by libMesh::System::add_vector(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::System::project_vector().

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

Definition at line 111 of file numeric_vector.h.

Referenced by libMesh::PetscVector< T >::_get_array(), libMesh::PetscVector< T >::_restore_array(), libMesh::LaspackVector< T >::abs(), libMesh::DistributedVector< T >::abs(), libMesh::LaspackVector< T >::add(), libMesh::DistributedVector< T >::add(), libMesh::DistributedVector< T >::add_vector(), libMesh::ImplicitSystem::assemble(), libMesh::EpetraVector< T >::clear(), libMesh::PetscVector< T >::clear(), libMesh::LaspackVector< T >::clear(), libMesh::EpetraVector< T >::close(), libMesh::LaspackVector< T >::close(), libMesh::DistributedVector< T >::close(), libMesh::NumericVector< T >::compare(), libMesh::PetscVector< T >::create_subvector(), libMesh::LaspackVector< T >::dot(), libMesh::EpetraVector< T >::first_local_index(), libMesh::PetscVector< T >::first_local_index(), libMesh::LaspackVector< T >::first_local_index(), libMesh::DistributedVector< T >::first_local_index(), libMesh::NumericVector< T >::global_relative_compare(), libMesh::PetscVector< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::DistributedVector< T >::insert(), libMesh::DistributedVector< T >::l1_norm(), libMesh::DistributedVector< T >::l2_norm(), libMesh::EpetraVector< T >::last_local_index(), libMesh::PetscVector< T >::last_local_index(), libMesh::LaspackVector< T >::last_local_index(), libMesh::DistributedVector< T >::last_local_index(), libMesh::DistributedVector< T >::linfty_norm(), libMesh::NumericVector< T >::local_relative_compare(), libMesh::EpetraVector< T >::local_size(), libMesh::PetscVector< T >::local_size(), libMesh::LaspackVector< T >::local_size(), libMesh::DistributedVector< T >::local_size(), libMesh::DistributedVector< T >::localize(), libMesh::DistributedVector< T >::localize_to_one(), libMesh::PetscVector< T >::map_global_to_local_index(), libMesh::EpetraVector< T >::max(), libMesh::LaspackVector< T >::max(), libMesh::DistributedVector< T >::max(), libMesh::EpetraVector< T >::min(), libMesh::LaspackVector< T >::min(), libMesh::DistributedVector< T >::min(), libMesh::EpetraVector< T >::operator()(), libMesh::LaspackVector< T >::operator()(), libMesh::DistributedVector< T >::operator()(), libMesh::DistributedVector< T >::operator+=(), libMesh::DistributedVector< T >::operator-=(), libMesh::LaspackVector< T >::operator=(), libMesh::DistributedVector< T >::operator=(), libMesh::NumericVector< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::LaspackVector< T >::scale(), libMesh::DistributedVector< T >::scale(), libMesh::LaspackVector< T >::set(), libMesh::DistributedVector< T >::set(), libMesh::EpetraVector< T >::size(), libMesh::PetscVector< T >::size(), libMesh::LaspackVector< T >::size(), libMesh::DistributedVector< T >::size(), libMesh::DistributedVector< T >::sum(), libMesh::EpetraVector< T >::zero(), libMesh::LaspackVector< T >::zero(), and libMesh::DistributedVector< T >::zero().

00111 { return _is_initialized; }

template<typename T>
virtual void libMesh::NumericVector< T >::insert ( const DenseSubVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [pure virtual]

$ U=V $ where V is a DenseSubVector<T> and you want to specify WHERE to insert it

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

template<typename T>
virtual void libMesh::NumericVector< T >::insert ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [pure virtual]

$ U=V $ where U and V are type DenseVector<T> and you want to specify WHERE to insert the DenseVector<T> V

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

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

$U=V$, where U and V are type NumericVector<T> and you want to specify WHERE to insert the NumericVector<T> V

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

$ U=v $ where v is a std::vector<T> and you want to specify WHERE to insert it

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

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

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

Referenced by libMesh::FEMSystem::assembly(), and libMesh::System::calculate_norm().

template<typename T>
virtual Real libMesh::NumericVector< T >::linfty_norm (  )  const [pure virtual]
Returns:
the maximum absolute value of the elements of this vector, which is the $l_\infty$-norm of a vector.

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

Referenced by libMesh::System::calculate_norm(), and libMesh::NumericVector< T >::global_relative_compare().

template<typename T>
int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual]
Returns:
-1 when this is equivalent to other_vector, up to the given local relative threshold. When differences occur, the return value contains the first index where the difference (a[i]-b[i])/max(a[i],b[i]) exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

Definition at line 122 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), std::max(), libMesh::NumericVector< T >::max(), and libMesh::Parallel::Communicator::min().

00124 {
00125   libmesh_assert (this->initialized());
00126   libmesh_assert (other_vector.initialized());
00127   libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
00128   libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
00129 
00130   int first_different_i = std::numeric_limits<int>::max();
00131   numeric_index_type i = first_local_index();
00132 
00133   do
00134     {
00135       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold *
00136            std::max(std::abs((*this)(i)), std::abs(other_vector(i))))
00137         first_different_i = i;
00138       else
00139         i++;
00140     }
00141   while (first_different_i==std::numeric_limits<int>::max()
00142          && i<last_local_index());
00143 
00144   // Find the correct first differing index in parallel
00145   CommWorld.min(first_different_i);
00146 
00147   if (first_different_i == std::numeric_limits<int>::max())
00148     return -1;
00149 
00150   return first_different_i;
00151 }

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::DistributedVector< T >, libMesh::LaspackVector< T >, libMesh::PetscVector< T >, and libMesh::EpetraVector< T >.

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.

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

Same, but fills a NumericVector<T> instead of a std::vector.

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::DistributedVector< T >, libMesh::LaspackVector< T >, libMesh::PetscVector< T >, and libMesh::EpetraVector< T >.

template<typename T>
virtual Real libMesh::NumericVector< T >::max (  )  const [pure virtual]
template<typename T>
virtual Real libMesh::NumericVector< T >::min (  )  const [pure virtual]
Returns:
the minimum element in the vector. In case of complex numbers, this returns the minimum Real part.

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

static unsigned int libMesh::ReferenceCounter::n_objects (  )  [inline, static, inherited]

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

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

00080   { return _n_objects; }

template<typename T>
virtual T libMesh::NumericVector< T >::operator() ( const numeric_index_type  i  )  const [pure virtual]
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a  )  [inline]

Multiplication operator. Equivalent to U.scale(a)

Definition at line 350 of file numeric_vector.h.

00350 { this->scale(a); return *this; }

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

Addition operator. Fast equivalent to U.add(1, V).

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

Subtraction operator. Fast equivalent to U.add(-1, V).

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

Division operator. Equivalent to U.scale(1./a)

Definition at line 356 of file numeric_vector.h.

00356 { this->scale(1./a); return *this; }

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const std::vector< T > &  v  )  [pure virtual]
template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const NumericVector< T > &  V  )  [pure virtual]
template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const T  s  )  [pure virtual]
template<typename T>
virtual void libMesh::NumericVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
) [pure virtual]

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

Referenced by libMesh::TensorShellMatrix< T >::get_diagonal().

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

Definition at line 777 of file numeric_vector.h.

References libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::local_size(), and libMesh::NumericVector< T >::size().

00778 {
00779   libmesh_assert (this->initialized());
00780   os << "Size\tglobal =  " << this->size()
00781      << "\t\tlocal =  " << this->local_size() << std::endl;
00782 
00783   // std::complex<>::operator<<() is defined, but use this form
00784   os << "#\tReal part\t\tImaginary part" << std::endl;
00785   for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
00786     os << i << "\t"
00787        << (*this)(i).real() << "\t\t"
00788        << (*this)(i).imag() << std::endl;
00789 }

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

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

Definition at line 795 of file numeric_vector.h.

References libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::local_size(), and libMesh::NumericVector< T >::size().

00796 {
00797   libmesh_assert (this->initialized());
00798   os << "Size\tglobal =  " << this->size()
00799      << "\t\tlocal =  " << this->local_size() << std::endl;
00800 
00801   os << "#\tValue" << std::endl;
00802   for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
00803     os << i << "\t" << (*this)(i) << std::endl;
00804 }

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

Definition at line 810 of file numeric_vector.h.

References libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::localize(), libMesh::processor_id(), and libMesh::NumericVector< T >::size().

00811 {
00812   libmesh_assert (this->initialized());
00813 
00814   std::vector<Complex> v(this->size());
00815   this->localize(v);
00816 
00817   // Right now we only want one copy of the output
00818   if (libMesh::processor_id())
00819     return;
00820 
00821   os << "Size\tglobal =  " << this->size() << std::endl;
00822   os << "#\tReal part\t\tImaginary part" << std::endl;
00823   for (numeric_index_type i=0; i!=v.size(); i++)
00824     os << i << "\t"
00825        << v[i].real() << "\t\t"
00826        << v[i].imag() << std::endl;
00827 }

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

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

Definition at line 832 of file numeric_vector.h.

References libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::localize(), libMesh::processor_id(), and libMesh::NumericVector< T >::size().

00833 {
00834   libmesh_assert (this->initialized());
00835 
00836   std::vector<T> v(this->size());
00837   this->localize(v);
00838 
00839   // Right now we only want one copy of the output
00840   if (libMesh::processor_id())
00841     return;
00842 
00843   os << "Size\tglobal =  " << this->size() << std::endl;
00844   os << "#\tValue" << std::endl;
00845   for (numeric_index_type i=0; i!=v.size(); i++)
00846     os << i << "\t" << v[i] << std::endl;
00847 }

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out  )  [static, inherited]

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

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

00089 {
00090   if( _enable_print_counter ) out_stream << ReferenceCounter::get_info();
00091 }

template<typename T>
virtual void libMesh::NumericVector< T >::print_matlab ( const std::string  name = "NULL"  )  const [inline, virtual]

Print the contents of the matrix in Matlab's sparse matrix format. Optionally prints the matrix to the file named name. If name is not specified it is dumped to the screen.

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

Definition at line 595 of file numeric_vector.h.

00596   {
00597     libMesh::err << "ERROR: Not Implemented in base class yet!" << std::endl;
00598     libMesh::err << "ERROR writing MATLAB file " << name << std::endl;
00599     libmesh_error();
00600   }

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

Replace each entry v_i of this vector by its reciprocal, 1/v_i.

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

template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual]
Returns:
the $l_1$-norm of the vector, i.e. the sum of the absolute values for the specified entries in the vector.

Note that the indices must necessary live on this processor.

Definition at line 298 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::System::discrete_var_norm().

00299 {
00300   const NumericVector<T> & v = *this;
00301 
00302   std::set<numeric_index_type>::const_iterator it = indices.begin();
00303   const std::set<numeric_index_type>::const_iterator it_end = indices.end();
00304 
00305   Real norm = 0;
00306 
00307   for(; it!=it_end; ++it)
00308     norm += std::abs(v(*it));
00309 
00310   CommWorld.sum(norm);
00311 
00312   return norm;
00313 }

template<class T >
Real libMesh::NumericVector< T >::subset_l2_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual]
Returns:
the $l_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 that the indices must necessary live on this processor.

Definition at line 316 of file numeric_vector.C.

References libMesh::CommWorld, libMesh::TensorTools::norm_sq(), libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::System::discrete_var_norm().

00317 {
00318   const NumericVector<T> & v = *this;
00319 
00320   std::set<numeric_index_type>::const_iterator it = indices.begin();
00321   const std::set<numeric_index_type>::const_iterator it_end = indices.end();
00322 
00323   Real norm = 0;
00324 
00325   for(; it!=it_end; ++it)
00326     norm += TensorTools::norm_sq(v(*it));
00327 
00328   CommWorld.sum(norm);
00329 
00330   return std::sqrt(norm);
00331 }

template<class T >
Real libMesh::NumericVector< T >::subset_linfty_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual]
Returns:
the maximum absolute value of the specified entries of this vector, which is the $l_\infty$-norm of a vector.

Note that the indices must necessary live on this processor.

Definition at line 334 of file numeric_vector.C.

References libMesh::NumericVector< T >::abs(), libMesh::CommWorld, libMesh::Parallel::Communicator::max(), and libMesh::Real.

Referenced by libMesh::System::discrete_var_norm().

00335 {
00336   const NumericVector<T> & v = *this;
00337 
00338   std::set<numeric_index_type>::const_iterator it = indices.begin();
00339   const std::set<numeric_index_type>::const_iterator it_end = indices.end();
00340 
00341   Real norm = 0;
00342 
00343   for(; it!=it_end; ++it)
00344     {
00345       Real value = std::abs(v(*it));
00346       if(value > norm)
00347         norm = value;
00348     }
00349 
00350   CommWorld.max(norm);
00351 
00352   return norm;
00353 }

template<typename T>
virtual T libMesh::NumericVector< T >::sum (  )  const [pure virtual]
template<typename T>
void libMesh::NumericVector< T >::swap ( NumericVector< T > &  v  )  [inline, virtual]

Exchanges the values/sizes of two vectors. There should be enough indirection in subclasses to make this an O(1) header-swap operation.

Definition at line 853 of file numeric_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, and libMesh::NumericVector< T >::_type.

Referenced by libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), and libMesh::AdjointRefinementEstimator::estimate_error().

00854 {
00855   std::swap(_is_closed, v._is_closed);
00856   std::swap(_is_initialized, v._is_initialized);
00857   std::swap(_type, v._type);
00858 }

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

Definition at line 121 of file numeric_vector.h.

00121 { return _type; }

template<typename T>
virtual AutoPtr<NumericVector<T> > libMesh::NumericVector< T >::zero_clone (  )  const [pure virtual]

Creates a vector which has the same type, size and partitioning as this vector, but whose data is all zero. Returns it in an AutoPtr. This must be overloaded in the derived classes.

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

Referenced by libMesh::NewtonSolver::solve(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().


Friends And Related Function Documentation

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 583 of file numeric_vector.h.

00584   {
00585     v.print_global(os);
00586     return os;
00587   }


Member Data Documentation

bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited]

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

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited]

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

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


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:32 UTC

Hosted By:
SourceForge.net Logo