NumericVector< T > Class Template Reference

#include <numeric_vector.h>

Inheritance diagram for NumericVector< T >:

List of all members.

Public Member Functions

 NumericVector (const ParallelType type=AUTOMATIC)
 NumericVector (const unsigned int n, const ParallelType type=AUTOMATIC)
 NumericVector (const unsigned n, const unsigned int n_local, const ParallelType type=AUTOMATIC)
 NumericVector (const unsigned int N, const unsigned int n_local, const std::vector< unsigned int > &ghost, const ParallelType type=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 unsigned int, const unsigned int, const bool=false, const ParallelType=AUTOMATIC)=0
virtual void init (const unsigned int, const bool=false, const ParallelType=AUTOMATIC)=0
virtual void init (const unsigned int, const unsigned int, const std::vector< unsigned int > &, 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< unsigned int > &indices)
virtual Real subset_l2_norm (const std::set< unsigned int > &indices)
virtual Real subset_linfty_norm (const std::set< unsigned int > &indices)
virtual unsigned int size () const =0
virtual unsigned int local_size () const =0
virtual unsigned int first_local_index () const =0
virtual unsigned int last_local_index () const =0
virtual T operator() (const unsigned int i) const =0
virtual T el (const unsigned int i) const
virtual void get (const std::vector< unsigned int > &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 set (const unsigned int i, const T value)=0
virtual void add (const unsigned int 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< unsigned int > &dof_indices)=0
virtual void add_vector (const NumericVector< T > &V, const std::vector< unsigned int > &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< unsigned int > &dof_indices)=0
virtual void insert (const std::vector< T > &v, const std::vector< unsigned int > &dof_indices)=0
virtual void insert (const NumericVector< T > &V, const std::vector< unsigned int > &dof_indices)=0
virtual void insert (const DenseVector< T > &V, const std::vector< unsigned int > &dof_indices)=0
virtual void insert (const DenseSubVector< T > &V, const std::vector< unsigned int > &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< unsigned int > &send_list) const =0
virtual void localize (const unsigned int first_local_idx, const unsigned int last_local_idx, const std::vector< unsigned int > &send_list)=0
virtual void localize_to_one (std::vector< T > &v_local, const unsigned int proc_id=0) const =0
virtual int 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=std::cout) const
virtual void print_global (std::ostream &os=std::cout) const
virtual void print_matlab (const std::string name="NULL") const
virtual void create_subvector (NumericVector< T > &, const std::vector< unsigned int > &) const
virtual void swap (NumericVector< T > &v)
template<>
int compare (const NumericVector< float > &other_vector, const Real threshold) const
template<>
int compare (const NumericVector< double > &other_vector, const Real threshold) const
template<>
int compare (const NumericVector< long double > &other_vector, const Real threshold) const
template<>
int compare (const NumericVector< Complex > &other_vector, const Real threshold) const
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 ()
static unsigned int n_objects ()

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

Friends

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


Detailed Description

template<typename T>
class 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 55 of file numeric_vector.h.


Member Typedef Documentation

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

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

Definition at line 105 of file reference_counter.h.


Constructor & Destructor Documentation

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

Dummy-Constructor. Dimension=0

Definition at line 611 of file numeric_vector.h.

00611                                                         :
00612   _is_closed(false),
00613   _is_initialized(false),
00614   _type(type)
00615 {
00616 }

template<typename T >
NumericVector< T >::NumericVector ( const unsigned int  n,
const ParallelType  type = AUTOMATIC 
) [inline, explicit]

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

Definition at line 622 of file numeric_vector.h.

00623                                                           :
00624   _is_closed(false),
00625   _is_initialized(false),
00626   _type(type)
00627 {
00628   libmesh_error(); // Abstract base class!
00629   // init(n, n, false, type);
00630 }

template<typename T >
NumericVector< T >::NumericVector ( const unsigned  n,
const unsigned int  n_local,
const ParallelType  type = AUTOMATIC 
) [inline]

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

Definition at line 636 of file numeric_vector.h.

00638                                                           :
00639   _is_closed(false),
00640   _is_initialized(false),
00641   _type(type)
00642 {
00643   libmesh_error(); // Abstract base class!
00644   // init(n, n_local, false, type);
00645 }

template<typename T >
NumericVector< T >::NumericVector ( const unsigned int  N,
const unsigned int  n_local,
const std::vector< unsigned int > &  ghost,
const ParallelType  type = 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 651 of file numeric_vector.h.

00654                                                           :
00655   _is_closed(false),
00656   _is_initialized(false),
00657   _type(type)
00658 {
00659   libmesh_error(); // Abstract base class!
00660   // init(n, n_local, ghost, false, type);
00661 }

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

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

Definition at line 667 of file numeric_vector.h.

References NumericVector< T >::clear().

00668 {
00669   clear ();
00670 }


Member Function Documentation

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

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

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

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

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

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

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

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

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

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

template<typename T >
virtual void 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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

template<typename T >
virtual void NumericVector< T >::add ( const unsigned int  i,
const T  value 
) [pure virtual]

template<typename T >
virtual void NumericVector< T >::add_vector ( const DenseVector< T > &  V,
const std::vector< unsigned int > &  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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

template<typename T >
void 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 253 of file numeric_vector.C.

References ShellMatrix< T >::vector_mult_add().

00255 {
00256   a.vector_mult_add(*this,v);
00257 }

template<typename T >
virtual void 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.

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

template<typename T >
virtual void NumericVector< T >::add_vector ( const NumericVector< T > &  V,
const std::vector< unsigned int > &  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

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

template<typename T >
virtual void NumericVector< T >::add_vector ( const std::vector< T > &  v,
const std::vector< unsigned int > &  dof_indices 
) [pure virtual]

$ U+=v $ where v is a DenseVector<T> and you want to specify WHERE to add it

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

Referenced by NewmarkSystem::update_rhs(), and SparseMatrix< T >::vector_mult_add().

template<typename T >
AutoPtr< NumericVector< T > > 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 41 of file numeric_vector.C.

References LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and TRILINOS_SOLVERS.

Referenced by ExactErrorEstimator::estimate_error().

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

template<typename T >
void NumericVector< T >::clear (  )  [inline, virtual]

Returns:
the NumericVector<T> to a pristine state.

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

Definition at line 712 of file numeric_vector.h.

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

Referenced by System::project_vector(), and NumericVector< T >::~NumericVector().

00713 {
00714   _is_closed      = false;
00715   _is_initialized = false;
00716 }

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

Creates a copy of this vector and returns it in an AutoPtr. This must be overloaded in the derived classes.

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

Referenced by SumShellMatrix< T >::get_diagonal(), and System::project_vector().

template<>
int NumericVector< Complex >::compare ( const NumericVector< Complex > &  other_vector,
const Real  threshold 
) const [inline]

Definition at line 167 of file numeric_vector.C.

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

00169 {
00170   libmesh_assert (this->initialized());
00171   libmesh_assert (other_vector.initialized());
00172   libmesh_assert (this->first_local_index() == other_vector.first_local_index());
00173   libmesh_assert (this->last_local_index()  == other_vector.last_local_index());
00174 
00175   int rvalue     = -1;
00176   unsigned int i = first_local_index();
00177 
00178   do
00179     {
00180       if (( std::abs( (*this)(i).real() - other_vector(i).real() ) > threshold ) ||
00181           ( std::abs( (*this)(i).imag() - other_vector(i).imag() ) > threshold ))
00182         rvalue = i;
00183       else
00184         i++;
00185     }
00186   while (rvalue==-1 && i<this->last_local_index());
00187 
00188   return rvalue;
00189 }

template<>
int NumericVector< long double >::compare ( const NumericVector< long double > &  other_vector,
const Real  threshold 
) const [inline]

Definition at line 140 of file numeric_vector.C.

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

00142 {
00143   libmesh_assert (this->initialized());
00144   libmesh_assert (other_vector.initialized());
00145   libmesh_assert (this->first_local_index() == other_vector.first_local_index());
00146   libmesh_assert (this->last_local_index()  == other_vector.last_local_index());
00147 
00148   int rvalue     = -1;
00149   unsigned int i = first_local_index();
00150 
00151   do
00152     {
00153       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
00154         rvalue = i;
00155       else
00156         i++;
00157     }
00158   while (rvalue==-1 && i<last_local_index());
00159 
00160   return rvalue;
00161 }

template<>
int NumericVector< double >::compare ( const NumericVector< double > &  other_vector,
const Real  threshold 
) const [inline]

Definition at line 114 of file numeric_vector.C.

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

00116 {
00117   libmesh_assert (this->initialized());
00118   libmesh_assert (other_vector.initialized());
00119   libmesh_assert (this->first_local_index() == other_vector.first_local_index());
00120   libmesh_assert (this->last_local_index()  == other_vector.last_local_index());
00121 
00122   int rvalue     = -1;
00123   unsigned int i = first_local_index();
00124 
00125   do
00126     {
00127       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
00128         rvalue = i;
00129       else
00130         i++;
00131     }
00132   while (rvalue==-1 && i<last_local_index());
00133 
00134   return rvalue;
00135 }

template<>
int NumericVector< float >::compare ( const NumericVector< float > &  other_vector,
const Real  threshold 
) const [inline]

Definition at line 89 of file numeric_vector.C.

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

00091 {
00092   libmesh_assert (this->initialized());
00093   libmesh_assert (other_vector.initialized());
00094   libmesh_assert (this->first_local_index() == other_vector.first_local_index());
00095   libmesh_assert (this->last_local_index()  == other_vector.last_local_index());
00096 
00097   int rvalue     = -1;
00098   unsigned int i = first_local_index();
00099 
00100   do
00101     {
00102       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
00103         rvalue = i;
00104       else
00105         i++;
00106     }
00107   while (rvalue==-1 && i<last_local_index());
00108 
00109   return rvalue;
00110 }

template<typename T >
virtual int 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. When differences occur, the return value contains the first index where the difference exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

template<typename T >
virtual void NumericVector< T >::create_subvector ( NumericVector< T > &  ,
const std::vector< unsigned int > &   
) 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.

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

Definition at line 570 of file numeric_vector.h.

00572   {
00573     std::cerr << "ERROR: Not Implemented in base class yet!" << std::endl;
00574     libmesh_error();
00575   }

template<typename T >
virtual T NumericVector< T >::dot ( const NumericVector< T > &   )  const [pure virtual]

Computes the dot product, p = U.V

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

template<typename T >
virtual T NumericVector< T >::el ( const unsigned int  i  )  const [inline, virtual]

Returns:
the element U(i)

Definition at line 322 of file numeric_vector.h.

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

template<typename T >
virtual unsigned int NumericVector< T >::first_local_index (  )  const [pure virtual]

template<typename T >
void NumericVector< T >::get ( const std::vector< unsigned int > &  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 PetscVector< T >.

Definition at line 722 of file numeric_vector.h.

00723 {
00724   const unsigned int num = index.size();
00725   values.resize(num);
00726   for(unsigned int i=0; i<num; i++)
00727     {
00728       values[i] = (*this)(index[i]);
00729     }
00730 }

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

Gets a string containing the reference information.

Definition at line 45 of file reference_counter.C.

References ReferenceCounter::_counts, and QuadratureRules::name().

Referenced by ReferenceCounter::print_info().

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

void 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 149 of file reference_counter.h.

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

Referenced by ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().

00150 {
00151   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00152   std::pair<unsigned int, unsigned int>& p = _counts[name];
00153 
00154   p.first++;
00155 }

void 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 167 of file reference_counter.h.

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

Referenced by ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().

00168 {
00169   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00170   std::pair<unsigned int, unsigned int>& p = _counts[name];
00171 
00172   p.second++;
00173 }

template<typename T >
virtual void 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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

template<typename T >
virtual void NumericVector< T >::init ( const unsigned  int,
const unsigned  int,
const std::vector< unsigned int > &  ,
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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

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

call init with n_local = N,

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

template<typename T >
virtual void NumericVector< T >::init ( const unsigned  int,
const unsigned  int,
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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

Referenced by System::add_vector(), System::project_vector(), and System::restrict_vectors().

template<typename T >
virtual bool NumericVector< T >::initialized (  )  const [inline, virtual]

Returns:
true if the vector has been initialized, false otherwise.

Definition at line 109 of file numeric_vector.h.

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

00109 { return _is_initialized; }

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

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

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

template<typename T >
virtual void NumericVector< T >::insert ( const DenseVector< T > &  V,
const std::vector< unsigned int > &  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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

template<typename T >
virtual void NumericVector< T >::insert ( const NumericVector< T > &  V,
const std::vector< unsigned int > &  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

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

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

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

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

template<typename T >
virtual Real 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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

Referenced by System::calculate_norm().

template<typename T >
virtual Real NumericVector< T >::l2_norm (  )  const [pure virtual]

Returns:
the $l_2$-norm of the vector, i.e. the square root of the sum of the squares of the elements.

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

Referenced by System::calculate_norm(), NewtonSolver::line_search(), and NewtonSolver::solve().

template<typename T >
virtual unsigned int NumericVector< T >::last_local_index (  )  const [pure virtual]

template<typename T >
virtual Real 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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

Referenced by System::calculate_norm().

template<typename T >
virtual unsigned int NumericVector< T >::local_size (  )  const [pure virtual]

Returns:
the local size of the vector (index_stop-index_start). In ghost cell mode, this does *not* include the ghost cells.

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

Referenced by EpetraVector< T >::init(), LaspackVector< T >::init(), DistributedVector< T >::init(), NumericVector< T >::print(), System::project_vector(), and PetscLinearSolver< T >::solve().

template<typename T >
virtual void NumericVector< T >::localize ( const unsigned int  first_local_idx,
const unsigned int  last_local_idx,
const std::vector< unsigned int > &  send_list 
) [pure virtual]

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

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

template<typename T >
virtual void NumericVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< unsigned int > &  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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

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

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

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

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

template<typename T >
virtual void NumericVector< T >::localize_to_one ( std::vector< T > &  v_local,
const unsigned int  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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

template<typename T >
virtual Real NumericVector< T >::max (  )  const [pure virtual]

Returns:
the maximum element in the vector. In case of complex numbers, this returns the maximum Real part.

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

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

template<typename T >
virtual Real 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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

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

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

Definition at line 76 of file reference_counter.h.

References ReferenceCounter::_n_objects.

00077   { return _n_objects; }

template<typename T >
virtual T NumericVector< T >::operator() ( const unsigned int  i  )  const [pure virtual]

Access components, returns U(i).

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

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

Multiplication operator. Equivalent to U.scale(a)

Definition at line 348 of file numeric_vector.h.

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

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

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

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

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

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

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

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

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

Definition at line 354 of file numeric_vector.h.

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

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

$U = V$: copy all components.

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

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

$U = V$: copy all components.

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

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

$U(0-N) = s$: fill all components.

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

template<typename T >
virtual void 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.

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

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

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

Definition at line 739 of file numeric_vector.h.

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

00740 {
00741   libmesh_assert (this->initialized());
00742   os << "Size\tglobal =  " << this->size()
00743      << "\t\tlocal =  " << this->local_size() << std::endl;
00744   
00745   // std::complex<>::operator<<() is defined, but use this form
00746   os << "#\tReal part\t\tImaginary part" << std::endl;
00747   for (unsigned int i=this->first_local_index(); i<this->last_local_index(); i++)
00748     os << i << "\t" 
00749        << (*this)(i).real() << "\t\t" 
00750        << (*this)(i).imag() << std::endl;
00751 }

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

Prints the local contents of the vector to the screen.

Definition at line 757 of file numeric_vector.h.

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

00758 {
00759   libmesh_assert (this->initialized());
00760   os << "Size\tglobal =  " << this->size()
00761      << "\t\tlocal =  " << this->local_size() << std::endl;
00762 
00763   os << "#\tValue" << std::endl;
00764   for (unsigned int i=this->first_local_index(); i<this->last_local_index(); i++)
00765     os << i << "\t" << (*this)(i) << std::endl;
00766 }

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

Definition at line 772 of file numeric_vector.h.

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

00773 {
00774   libmesh_assert (this->initialized());
00775 
00776   std::vector<Complex> v(this->size());
00777   this->localize(v);
00778 
00779   // Right now we only want one copy of the output
00780   if (libMesh::processor_id())
00781     return;
00782   
00783   os << "Size\tglobal =  " << this->size() << std::endl;
00784   os << "#\tReal part\t\tImaginary part" << std::endl;
00785   for (unsigned int i=0; i!=v.size(); i++)
00786     os << i << "\t" 
00787        << v[i].real() << "\t\t" 
00788        << v[i].imag() << std::endl;
00789 }

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

Prints the global contents of the vector to the screen.

Definition at line 794 of file numeric_vector.h.

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

00795 {
00796   libmesh_assert (this->initialized());
00797 
00798   std::vector<T> v(this->size());
00799   this->localize(v);
00800 
00801   // Right now we only want one copy of the output
00802   if (libMesh::processor_id())
00803     return;
00804 
00805   os << "Size\tglobal =  " << this->size() << std::endl;
00806   os << "#\tValue" << std::endl;
00807   for (unsigned int i=0; i!=v.size(); i++)
00808     os << i << "\t" << v[i] << std::endl;
00809 }

void ReferenceCounter::print_info (  )  [static, inherited]

Prints the reference information to std::cout.

Definition at line 83 of file reference_counter.C.

References ReferenceCounter::get_info().

00084 {
00085 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00086   
00087   std::cout << ReferenceCounter::get_info();
00088   
00089 #endif
00090 }

template<typename T >
virtual void 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 PetscVector< T >, and EpetraVector< T >.

Definition at line 557 of file numeric_vector.h.

00558   {
00559     std::cerr << "ERROR: Not Implemented in base class yet!" << std::endl;
00560     std::cerr << "ERROR writing MATLAB file " << name << std::endl;
00561     libmesh_error();
00562   }

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

template<typename T >
virtual void NumericVector< T >::set ( const unsigned int  i,
const T  value 
) [pure virtual]

template<class T >
Real NumericVector< T >::subset_l1_norm ( const std::set< unsigned int > &  indices  )  [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 193 of file numeric_vector.C.

References NumericVector< T >::sum().

Referenced by System::discrete_var_norm().

00194 {
00195   NumericVector<T> & v = *this;
00196   
00197   std::set<unsigned int>::iterator it = indices.begin();
00198   const std::set<unsigned int>::iterator it_end = indices.end();
00199 
00200   Real norm = 0;
00201   
00202   for(; it!=it_end; ++it)
00203     norm += std::abs(v(*it));
00204 
00205   Parallel::sum(norm);
00206 
00207   return norm;
00208 }

template<class T >
Real NumericVector< T >::subset_l2_norm ( const std::set< unsigned int > &  indices  )  [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 211 of file numeric_vector.C.

References libmesh_norm(), and NumericVector< T >::sum().

Referenced by System::discrete_var_norm().

00212 {
00213   NumericVector<T> & v = *this;
00214 
00215   std::set<unsigned int>::iterator it = indices.begin();
00216   const std::set<unsigned int>::iterator it_end = indices.end();
00217 
00218   Real norm = 0;
00219   
00220   for(; it!=it_end; ++it)
00221     norm += libmesh_norm(v(*it));
00222 
00223   Parallel::sum(norm);
00224 
00225   return std::sqrt(norm);
00226 }

template<class T >
Real NumericVector< T >::subset_linfty_norm ( const std::set< unsigned int > &  indices  )  [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 229 of file numeric_vector.C.

References NumericVector< T >::abs(), and NumericVector< T >::max().

Referenced by System::discrete_var_norm().

00230 {
00231   NumericVector<T> & v = *this;
00232 
00233   std::set<unsigned int>::iterator it = indices.begin();
00234   const std::set<unsigned int>::iterator it_end = indices.end();
00235 
00236   Real norm = 0;
00237   
00238   for(; it!=it_end; ++it)
00239     {
00240       Real value = std::abs(v(*it));
00241       if(value > norm)
00242         norm = value;
00243     }
00244 
00245   Parallel::max(norm);
00246 
00247   return norm;
00248 }

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

template<typename T >
void 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.

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

Definition at line 815 of file numeric_vector.h.

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

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

00816 {
00817   std::swap(_is_closed, v._is_closed);
00818   std::swap(_is_initialized, v._is_initialized);
00819   std::swap(_type, v._type);
00820 }

template<typename T >
ParallelType& NumericVector< T >::type (  )  [inline]

Returns:
the type (SERIAL, PARALLEL, GHOSTED) of the vector.

Definition at line 119 of file numeric_vector.h.

00119 { return _type; }

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

template<typename T >
virtual AutoPtr<NumericVector<T> > 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 DistributedVector< T >, LaspackVector< T >, PetscVector< T >, and EpetraVector< T >.

Referenced by NewtonSolver::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 545 of file numeric_vector.h.

00546   {
00547     v.print_global(os);
00548     return os;
00549   }


Member Data Documentation

Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 123 of file reference_counter.h.

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

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

Definition at line 118 of file reference_counter.h.

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


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

Site Created By: libMesh Developers
Last modified: November 25 2009 03:44:42.

Hosted By:
SourceForge.net Logo