libMesh::DistributedVector< T > Class Template Reference

#include <distributed_vector.h>

Inheritance diagram for libMesh::DistributedVector< T >:

List of all members.

Public Member Functions

 DistributedVector (const ParallelType=AUTOMATIC)
 DistributedVector (const numeric_index_type n, const ParallelType ptype=AUTOMATIC)
 DistributedVector (const numeric_index_type n, const numeric_index_type n_local, const ParallelType ptype=AUTOMATIC)
 DistributedVector (const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType ptype=AUTOMATIC)
 ~DistributedVector ()
void close ()
void clear ()
void zero ()
virtual AutoPtr< NumericVector
< T > > 
zero_clone () const
AutoPtr< NumericVector< T > > clone () const
void init (const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)
void init (const numeric_index_type N, const bool fast=false, const ParallelType ptype=AUTOMATIC)
virtual void init (const numeric_index_type, const numeric_index_type, const std::vector< numeric_index_type > &, const bool=false, const ParallelType=AUTOMATIC)
virtual void init (const NumericVector< T > &other, const bool fast=false)
NumericVector< T > & operator= (const T s)
NumericVector< T > & operator= (const NumericVector< T > &V)
DistributedVector< T > & operator= (const DistributedVector< T > &V)
NumericVector< T > & operator= (const std::vector< T > &v)
Real min () const
Real max () const
sum () const
Real l1_norm () const
Real l2_norm () const
Real linfty_norm () const
numeric_index_type size () const
numeric_index_type local_size () const
numeric_index_type first_local_index () const
numeric_index_type last_local_index () const
operator() (const numeric_index_type i) const
NumericVector< T > & operator+= (const NumericVector< T > &V)
NumericVector< T > & operator-= (const NumericVector< T > &V)
virtual void reciprocal ()
void set (const numeric_index_type i, const T value)
void add (const numeric_index_type i, const T value)
void add (const T s)
void add (const NumericVector< T > &V)
void add (const T a, const NumericVector< T > &v)
void add_vector (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
void add_vector (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
void add_vector (const NumericVector< T > &, const SparseMatrix< T > &)
void add_vector (const DenseVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
void add_vector_transpose (const NumericVector< T > &, const SparseMatrix< T > &)
virtual void insert (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
virtual void insert (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
virtual void insert (const DenseVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
virtual void insert (const DenseSubVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
void scale (const T factor)
virtual void abs ()
virtual T dot (const NumericVector< T > &V) const
void localize (std::vector< T > &v_local) const
void localize (NumericVector< T > &v_local) const
void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const
void localize (const numeric_index_type first_local_idx, const numeric_index_type last_local_idx, const std::vector< numeric_index_type > &send_list)
void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2)
virtual void swap (NumericVector< T > &v)
virtual bool initialized () const
ParallelType type () const
ParallelType & type ()
virtual bool closed () const
virtual void init (const NumericVector< T > &other, const bool fast=false)=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 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 add (const NumericVector< T > &V)=0
virtual void add (const T a, const NumericVector< T > &v)=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_transpose (const NumericVector< T > &, const SparseMatrix< T > &)=0
virtual void insert (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual T dot (const NumericVector< T > &) 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 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
template<>
void print (std::ostream &os) const
virtual void print_global (std::ostream &os=libMesh::out) const
template<>
void print_global (std::ostream &os) 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)

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

Private Attributes

std::vector< T > _values
numeric_index_type _global_size
numeric_index_type _local_size
numeric_index_type _first_local_index
numeric_index_type _last_local_index

Friends

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

Detailed Description

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

Distributed vector. Provides an interface for simple parallel, distributed vectors. Offers some collective communication capabilities. Note that the class will sill function without MPI, but only on one processor. This lets us keep the parallel details behind the scenes.

Author:
Benjamin S. Kirk, 2003

Definition at line 52 of file distributed_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::DistributedVector< T >::DistributedVector ( const ParallelType  ptype = AUTOMATIC  )  [inline, explicit]

Dummy-Constructor. Dimension=0

Definition at line 479 of file distributed_vector.h.

References libMesh::NumericVector< T >::_type.

00479                                                                  :
00480   _global_size      (0),
00481   _local_size       (0),
00482   _first_local_index(0),
00483   _last_local_index (0)
00484 {
00485   this->_type = ptype;
00486 }

template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( 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 492 of file distributed_vector.h.

References libMesh::DistributedVector< T >::init().

00494 {
00495   this->init(n, n, false, ptype);
00496 }

template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( 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 502 of file distributed_vector.h.

References libMesh::DistributedVector< T >::init().

00505 {
00506   this->init(n, n_local, false, ptype);
00507 }

template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( 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 513 of file distributed_vector.h.

References libMesh::DistributedVector< T >::init().

00517 {
00518   this->init(n, n_local, ghost, false, ptype);
00519 }

template<typename T >
libMesh::DistributedVector< T >::~DistributedVector (  )  [inline]

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

Definition at line 525 of file distributed_vector.h.

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

00526 {
00527   this->clear ();
00528 }


Member Function Documentation

template<typename T >
void libMesh::DistributedVector< T >::abs (  )  [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 335 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, std::abs(), libMesh::NumericVector< T >::initialized(), and libMesh::DistributedVector< T >::local_size().

00336 {
00337   libmesh_assert (this->initialized());
00338   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00339 
00340   for (std::size_t i=0; i<local_size(); i++)
00341     this->set(i,std::abs(_values[i]));
00342 }

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

$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, inherited]

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

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

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

Definition at line 251 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), and libMesh::NumericVector< T >::initialized().

00252 {
00253   libmesh_assert (this->initialized());
00254   libmesh_assert_equal_to (_values.size(), _local_size);
00255   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00256 
00257   add(a, v);
00258 }

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

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

Definition at line 239 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), and libMesh::NumericVector< T >::initialized().

00240 {
00241   libmesh_assert (this->initialized());
00242   libmesh_assert_equal_to (_values.size(), _local_size);
00243   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00244 
00245   add (1., v);
00246 }

template<typename T >
void libMesh::DistributedVector< T >::add ( const T  s  )  [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 226 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::DistributedVector< T >::local_size().

00227 {
00228   libmesh_assert (this->initialized());
00229   libmesh_assert_equal_to (_values.size(), _local_size);
00230   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00231 
00232   for (numeric_index_type i=0; i<local_size(); i++)
00233     _values[i] += v;
00234 }

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

$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, inherited]

$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, inherited]

$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 >
void libMesh::DistributedVector< T >::add_vector ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 195 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), libMesh::NumericVector< T >::initialized(), and libMesh::DenseVector< T >::size().

00197 {
00198   libmesh_assert_equal_to (V.size(), dof_indices.size());
00199   libmesh_assert (this->initialized());
00200   libmesh_assert_equal_to (_values.size(), _local_size);
00201   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00202 
00203   for (unsigned int i=0; i<V.size(); i++)
00204     add (dof_indices[i], V(i));
00205 }

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

$U+=A*V$. Add the product of a Sparse matrix A and a Numeric vector V to this Numeric vector. Not implemented.

Definition at line 324 of file distributed_vector.h.

00326   { libmesh_error(); }

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

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

Definition at line 180 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), libMesh::NumericVector< T >::initialized(), and libMesh::NumericVector< T >::size().

00182 {
00183   libmesh_assert_equal_to (V.size(), dof_indices.size());
00184   libmesh_assert (this->initialized());
00185   libmesh_assert_equal_to (_values.size(), _local_size);
00186   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00187 
00188   for (std::size_t i=0; i<V.size(); i++)
00189     add (dof_indices[i], V(i));
00190 }

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

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

Implements libMesh::NumericVector< T >.

Definition at line 164 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), and libMesh::NumericVector< T >::initialized().

00166 {
00167   libmesh_assert (!v.empty());
00168   libmesh_assert_equal_to (v.size(), dof_indices.size());
00169   libmesh_assert (this->initialized());
00170   libmesh_assert_equal_to (_values.size(), _local_size);
00171   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00172 
00173   for (std::size_t i=0; i<v.size(); i++)
00174     add (dof_indices[i], v[i]);
00175 }

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

$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>
void libMesh::DistributedVector< T >::add_vector_transpose ( const NumericVector< T > &  ,
const SparseMatrix< T > &   
) [inline]

$U+=A^T*V$. Add the product of the transpose of a Sparse matrix A_trans and a Numeric vector V to this Numeric vector. Not implemented.

Definition at line 343 of file distributed_vector.h.

00345   { libmesh_error(); }

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

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 >
AutoPtr< NumericVector< T > > libMesh::DistributedVector< T >::clone (  )  const [inline, virtual]

Creates a copy of this vector and returns it in an AutoPtr.

Implements libMesh::NumericVector< T >.

Definition at line 711 of file distributed_vector.h.

00712 {
00713   AutoPtr<NumericVector<T> > cloned_vector (new DistributedVector<T>);
00714 
00715   cloned_vector->init(*this, true);
00716 
00717   *cloned_vector = *this;
00718 
00719   return cloned_vector;
00720 }

template<typename T >
void libMesh::DistributedVector< T >::close (  )  [inline, virtual]

Call the assemble functions

Implements libMesh::NumericVector< T >.

Definition at line 655 of file distributed_vector.h.

References libMesh::NumericVector< T >::_is_closed, and libMesh::NumericVector< T >::initialized().

00656 {
00657   libmesh_assert (this->initialized());
00658 
00659   this->_is_closed = true;
00660 }

template<typename T>
int libMesh::NumericVector< T >::compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual, inherited]
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, inherited]

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 >::dot ( const NumericVector< T > &   )  const [pure virtual, inherited]
template<typename T >
T libMesh::DistributedVector< T >::dot ( const NumericVector< T > &  V  )  const [inline, virtual]

Computes the dot product, p = U.V

Definition at line 349 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_values, libMesh::CommWorld, libMesh::DistributedVector< T >::first_local_index(), libMesh::DistributedVector< T >::last_local_index(), libMesh::DistributedVector< T >::local_size(), and libMesh::Parallel::Communicator::sum().

00350 {
00351   // This function must be run on all processors at once
00352   parallel_only();
00353 
00354   // Make sure the NumericVector passed in is really a DistributedVector
00355   const DistributedVector<T>* v = libmesh_cast_ptr<const DistributedVector<T>*>(&V);
00356 
00357   // Make sure that the two vectors are distributed in the same way.
00358   libmesh_assert_equal_to ( this->first_local_index(), v->first_local_index() );
00359   libmesh_assert_equal_to ( this->last_local_index(), v->last_local_index()  );
00360 
00361   // The result of dotting together the local parts of the vector.
00362   T local_dot = 0;
00363 
00364   for (std::size_t i=0; i<this->local_size(); i++)
00365     local_dot += this->_values[i] * v->_values[i];
00366 
00367   // The local dot products are now summed via MPI
00368   CommWorld.sum(local_dot);
00369 
00370   return local_dot;
00371 }

template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i  )  const [inline, virtual, inherited]
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, inherited]

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, inherited]
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, inherited]

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

template<class T >
void libMesh::DistributedVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
) [inline, virtual]

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

Definition at line 634 of file distributed_vector.h.

References libMesh::DistributedVector< T >::init(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::size(), and libMesh::NumericVector< T >::type().

00636 {
00637   this->init(other.size(),other.local_size(),fast,other.type());
00638 }

template<typename T >
void libMesh::DistributedVector< T >::init ( const numeric_index_type  n,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
) [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 619 of file distributed_vector.h.

References libMesh::DistributedVector< T >::init().

00624 {
00625   // TODO: we shouldn't ignore the ghost sparsity pattern
00626   this->init(n, n_local, fast, ptype);
00627 }

template<typename T >
void libMesh::DistributedVector< T >::init ( const numeric_index_type  N,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
) [inline, virtual]

call init with n_local = N,

Implements libMesh::NumericVector< T >.

Definition at line 644 of file distributed_vector.h.

References libMesh::DistributedVector< T >::init().

00647 {
00648   this->init(n,n,fast,ptype);
00649 }

template<typename T >
void libMesh::DistributedVector< T >::init ( const numeric_index_type  N,
const numeric_index_type  n_local,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
) [inline, 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.

Implements libMesh::NumericVector< T >.

Definition at line 534 of file distributed_vector.h.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::NumericVector< T >::_is_initialized, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::NumericVector< T >::_type, libMesh::DistributedVector< T >::_values, libMeshEnums::AUTOMATIC, libMesh::DistributedVector< T >::clear(), libMesh::CommWorld, libMesh::err, libMesh::NumericVector< T >::initialized(), libMesh::n_processors(), libMeshEnums::PARALLEL, libMesh::processor_id(), libMeshEnums::SERIAL, libMesh::Parallel::Communicator::sum(), and libMesh::DistributedVector< T >::zero().

Referenced by libMesh::DistributedVector< T >::DistributedVector(), libMesh::DistributedVector< T >::init(), and libMesh::DistributedVector< T >::localize().

00538 {
00539   // This function must be run on all processors at once
00540   parallel_only();
00541 
00542   libmesh_assert_less_equal (n_local, n);
00543 
00544   if (ptype == AUTOMATIC)
00545     {
00546       if (n == n_local)
00547         this->_type = SERIAL;
00548       else
00549         this->_type = PARALLEL;
00550     }
00551   else
00552     this->_type = ptype;
00553 
00554   libmesh_assert ((this->_type==SERIAL && n==n_local) ||
00555                   this->_type==PARALLEL);
00556 
00557   // Clear the data structures if already initialized
00558   if (this->initialized())
00559     this->clear();
00560 
00561   // Initialize data structures
00562   _values.resize(n_local);
00563   _local_size  = n_local;
00564   _global_size = n;
00565 
00566   _first_local_index = 0;
00567 
00568 #ifdef LIBMESH_HAVE_MPI
00569 
00570   std::vector<numeric_index_type> local_sizes (libMesh::n_processors(), 0);
00571 
00572   local_sizes[libMesh::processor_id()] = n_local;
00573 
00574   CommWorld.sum(local_sizes);
00575 
00576   // _first_local_index is the sum of _local_size
00577   // for all processor ids less than ours
00578   for (processor_id_type p=0; p!=libMesh::processor_id(); p++)
00579     _first_local_index += local_sizes[p];
00580 
00581 
00582 #  ifdef DEBUG
00583   // Make sure all the local sizes sum up to the global
00584   // size, otherwise there is big trouble!
00585   numeric_index_type dbg_sum=0;
00586 
00587   for (processor_id_type p=0; p!=libMesh::n_processors(); p++)
00588     dbg_sum += local_sizes[p];
00589 
00590   libmesh_assert_equal_to (dbg_sum, n);
00591 
00592 #  endif
00593 
00594 #else
00595 
00596   // No other options without MPI!
00597   if (n != n_local)
00598     {
00599       libMesh::err << "ERROR:  MPI is required for n != n_local!"
00600                     << std::endl;
00601       libmesh_error();
00602     }
00603 
00604 #endif
00605 
00606   _last_local_index = _first_local_index + n_local;
00607 
00608   // Set the initialized flag
00609   this->_is_initialized = true;
00610 
00611   // Zero the components unless directed otherwise
00612   if (!fast)
00613     this->zero();
00614 }

template<typename T>
virtual bool libMesh::NumericVector< T >::initialized (  )  const [inline, virtual, inherited]
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 NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [pure virtual, inherited]

$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 >
void libMesh::DistributedVector< T >::insert ( const DenseSubVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 309 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::DenseVectorBase< T >::size().

00311 {
00312   libmesh_assert_equal_to (V.size(), dof_indices.size());
00313   libmesh_assert (this->initialized());
00314   libmesh_assert_equal_to (_values.size(), _local_size);
00315   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00316 
00317   for (unsigned int i=0; i<V.size(); i++)
00318     this->set (dof_indices[i], V(i));
00319 }

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

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

Implements libMesh::NumericVector< T >.

Definition at line 294 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::DenseVector< T >::size().

00296 {
00297   libmesh_assert_equal_to (V.size(), dof_indices.size());
00298   libmesh_assert (this->initialized());
00299   libmesh_assert_equal_to (_values.size(), _local_size);
00300   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00301 
00302   for (unsigned int i=0; i<V.size(); i++)
00303     this->set (dof_indices[i], V(i));
00304 }

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

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

Definition at line 279 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::NumericVector< T >::size().

00281 {
00282   libmesh_assert_equal_to (V.size(), dof_indices.size());
00283   libmesh_assert (this->initialized());
00284   libmesh_assert_equal_to (_values.size(), _local_size);
00285   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00286 
00287   for (std::size_t i=0; i<V.size(); i++)
00288     this->set (dof_indices[i], V(i));
00289 }

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

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

Implements libMesh::NumericVector< T >.

Definition at line 263 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, and libMesh::NumericVector< T >::initialized().

00265 {
00266   libmesh_assert (!v.empty());
00267   libmesh_assert_equal_to (v.size(), dof_indices.size());
00268   libmesh_assert (this->initialized());
00269   libmesh_assert_equal_to (_values.size(), _local_size);
00270   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00271 
00272   for (std::size_t i=0; i<v.size(); i++)
00273     this->set (dof_indices[i], v[i]);
00274 }

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

Implements libMesh::NumericVector< T >.

Definition at line 64 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), and libMesh::Parallel::Communicator::sum().

00065 {
00066   // This function must be run on all processors at once
00067   parallel_only();
00068 
00069   libmesh_assert (this->initialized());
00070   libmesh_assert_equal_to (_values.size(), _local_size);
00071   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00072 
00073   double local_l1 = 0.;
00074 
00075   for (numeric_index_type i=0; i<local_size(); i++)
00076     local_l1 += std::abs(_values[i]);
00077 
00078   CommWorld.sum(local_l1);
00079 
00080   return local_l1;
00081 }

template<typename T >
Real libMesh::DistributedVector< T >::l2_norm (  )  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.

Implements libMesh::NumericVector< T >.

Definition at line 86 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), libMesh::TensorTools::norm_sq(), and libMesh::Parallel::Communicator::sum().

00087 {
00088   // This function must be run on all processors at once
00089   parallel_only();
00090 
00091   libmesh_assert (this->initialized());
00092   libmesh_assert_equal_to (_values.size(), _local_size);
00093   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00094 
00095   double local_l2 = 0.;
00096 
00097   for (numeric_index_type i=0; i<local_size(); i++)
00098     local_l2 += TensorTools::norm_sq(_values[i]);
00099 
00100   CommWorld.sum(local_l2);
00101 
00102   return std::sqrt(local_l2);
00103 }

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

Implements libMesh::NumericVector< T >.

Definition at line 108 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), libMesh::Parallel::Communicator::max(), std::max(), and libMesh::Real.

00109 {
00110   // This function must be run on all processors at once
00111   parallel_only();
00112 
00113   libmesh_assert (this->initialized());
00114   libmesh_assert_equal_to (_values.size(), _local_size);
00115   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00116 
00117   Real local_linfty = 0.;
00118 
00119   for (numeric_index_type i=0; i<local_size(); i++)
00120     local_linfty  = std::max(local_linfty,
00121                              static_cast<Real>(std::abs(_values[i]))
00122                              ); // Note we static_cast so that both
00123                                 // types are the same, as required
00124                                 // by std::max
00125 
00126   CommWorld.max(local_linfty);
00127 
00128   return local_linfty;
00129 }

template<typename T>
int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual, inherited]
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 ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const [pure virtual, inherited]

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, inherited]

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

template<typename T >
void libMesh::DistributedVector< T >::localize ( const numeric_index_type  first_local_idx,
const numeric_index_type  last_local_idx,
const std::vector< numeric_index_type > &  send_list 
) [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 504 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::init(), libMesh::DistributedVector< T >::local_size(), libMesh::DistributedVector< T >::localize(), libMeshEnums::PARALLEL, and libMesh::DistributedVector< T >::size().

00507 {
00508   // Only good for serial vectors
00509   libmesh_assert_equal_to (this->size(), this->local_size());
00510   libmesh_assert_greater (last_local_idx, first_local_idx);
00511   libmesh_assert_less_equal (send_list.size(), this->size());
00512   libmesh_assert_less (last_local_idx, this->size());
00513 
00514   const numeric_index_type my_size       = this->size();
00515   const numeric_index_type my_local_size = (last_local_idx - first_local_idx + 1);
00516 
00517     // Don't bother for serial cases
00518   if ((first_local_idx == 0) &&
00519       (my_local_size == my_size))
00520     return;
00521 
00522 
00523   // Build a parallel vector, initialize it with the local
00524   // parts of (*this)
00525   DistributedVector<T> parallel_vec;
00526 
00527   parallel_vec.init (my_size, my_local_size, true, PARALLEL);
00528 
00529   // Copy part of *this into the parallel_vec
00530   for (numeric_index_type i=first_local_idx; i<=last_local_idx; i++)
00531     parallel_vec._values[i-first_local_idx] = _values[i];
00532 
00533   // localize like normal
00534   parallel_vec.localize (*this, send_list);
00535 }

template<typename T >
void libMesh::DistributedVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const [inline]

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

Definition at line 490 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::DistributedVector< T >::localize().

00492 {
00493   libmesh_assert (this->initialized());
00494   libmesh_assert_equal_to (_values.size(), _local_size);
00495   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00496 
00497   // TODO: We don't yet support the send list; this is inefficient:
00498   localize (v_local_in);
00499 }

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

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

Definition at line 458 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), libMesh::DistributedVector< T >::localize(), and libMesh::DistributedVector< T >::size().

00460 {
00461   libmesh_assert (this->initialized());
00462   libmesh_assert_equal_to (_values.size(), _local_size);
00463   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00464 
00465   DistributedVector<T>* v_local = libmesh_cast_ptr<DistributedVector<T>*>(&v_local_in);
00466 
00467   v_local->_first_local_index = 0;
00468 
00469   v_local->_global_size =
00470     v_local->_local_size =
00471     v_local->_last_local_index = size();
00472 
00473   v_local->_is_initialized =
00474     v_local->_is_closed = true;
00475 
00476   // Call localize on the vector's values.  This will help
00477   // prevent code duplication
00478   localize (v_local->_values);
00479 
00480 #ifndef LIBMESH_HAVE_MPI
00481 
00482   libmesh_assert_equal_to (local_size(), size());
00483 
00484 #endif
00485 }

template<typename T >
void libMesh::DistributedVector< T >::localize ( std::vector< T > &  v_local  )  const [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 540 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::Parallel::Communicator::allgather(), libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), and libMesh::DistributedVector< T >::size().

Referenced by libMesh::DistributedVector< T >::localize().

00541 {
00542   // This function must be run on all processors at once
00543   parallel_only();
00544 
00545   libmesh_assert (this->initialized());
00546   libmesh_assert_equal_to (_values.size(), _local_size);
00547   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00548 
00549   v_local = this->_values;
00550 
00551   CommWorld.allgather (v_local);
00552 
00553 #ifndef LIBMESH_HAVE_MPI
00554   libmesh_assert_equal_to (local_size(), size());
00555 #endif
00556 }

template<typename T >
void libMesh::DistributedVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const [inline, 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.

Implements libMesh::NumericVector< T >.

Definition at line 561 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::CommWorld, libMesh::Parallel::Communicator::gather(), libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), and libMesh::DistributedVector< T >::size().

00563 {
00564   // This function must be run on all processors at once
00565   parallel_only();
00566 
00567   libmesh_assert (this->initialized());
00568   libmesh_assert_equal_to (_values.size(), _local_size);
00569   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00570 
00571   v_local = this->_values;
00572 
00573   CommWorld.gather (pid, v_local);
00574 
00575 #ifndef LIBMESH_HAVE_MPI
00576   libmesh_assert_equal_to (local_size(), size());
00577 #endif
00578 }

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

Implements libMesh::NumericVector< T >.

Definition at line 846 of file distributed_vector.h.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::libmesh_real(), libMesh::Parallel::Communicator::max(), std::max(), and libMesh::Real.

Referenced by libMesh::DistributedVector< T >::min().

00847 {
00848   // This function must be run on all processors at once
00849   parallel_only();
00850 
00851   libmesh_assert (this->initialized());
00852   libmesh_assert_equal_to (_values.size(), _local_size);
00853   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00854 
00855   Real local_max = _values.size() ?
00856     libmesh_real(_values[0]) : -std::numeric_limits<Real>::max();
00857   for (numeric_index_type i = 1; i < _values.size(); ++i)
00858     local_max = std::max(libmesh_real(_values[i]), local_max);
00859 
00860   CommWorld.max(local_max);
00861 
00862   return local_max;
00863 }

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

Implements libMesh::NumericVector< T >.

Definition at line 823 of file distributed_vector.h.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::libmesh_real(), libMesh::DistributedVector< T >::max(), libMesh::Parallel::Communicator::min(), std::min(), and libMesh::Real.

00824 {
00825   // This function must be run on all processors at once
00826   parallel_only();
00827 
00828   libmesh_assert (this->initialized());
00829   libmesh_assert_equal_to (_values.size(), _local_size);
00830   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00831 
00832   Real local_min = _values.size() ?
00833     libmesh_real(_values[0]) : std::numeric_limits<Real>::max();
00834   for (numeric_index_type i = 1; i < _values.size(); ++i)
00835     local_min = std::min(libmesh_real(_values[i]), local_min);
00836 
00837   CommWorld.min(local_min);
00838 
00839   return local_min;
00840 }

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 >
T libMesh::DistributedVector< T >::operator() ( const numeric_index_type  i  )  const [inline, virtual]
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a  )  [inline, inherited]

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, inherited]

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

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

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

Definition at line 134 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), libMesh::NumericVector< T >::closed(), and libMesh::NumericVector< T >::initialized().

00135 {
00136   libmesh_assert (this->closed());
00137   libmesh_assert (this->initialized());
00138   libmesh_assert_equal_to (_values.size(), _local_size);
00139   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00140 
00141   add(1., v);
00142 
00143   return *this;
00144 }

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

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

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

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

Definition at line 149 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::add(), libMesh::NumericVector< T >::closed(), and libMesh::NumericVector< T >::initialized().

00150 {
00151   libmesh_assert (this->closed());
00152   libmesh_assert (this->initialized());
00153   libmesh_assert_equal_to (_values.size(), _local_size);
00154   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00155 
00156   add(-1., v);
00157 
00158   return *this;
00159 }

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

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 >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const std::vector< T > &  v  )  [inline, virtual]

$U = V$: copy all components.

Implements libMesh::NumericVector< T >.

Definition at line 433 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::last_local_index(), libMesh::DistributedVector< T >::local_size(), and libMesh::DistributedVector< T >::size().

00434 {
00435   libmesh_assert (this->initialized());
00436   libmesh_assert_equal_to (_values.size(), _local_size);
00437   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00438 
00439   if (v.size() == local_size())
00440     _values = v;
00441 
00442   else if (v.size() == size())
00443     for (std::size_t i=first_local_index(); i<last_local_index(); i++)
00444       _values[i-first_local_index()] = v[i];
00445 
00446   else
00447     {
00448       libmesh_error();
00449     }
00450 
00451 
00452   return *this;
00453 }

template<typename T >
DistributedVector< T > & libMesh::DistributedVector< T >::operator= ( const DistributedVector< T > &  V  )  [inline, virtual]

$U = V$: copy all components.

Implements libMesh::NumericVector< T >.

Definition at line 407 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, and libMesh::DistributedVector< T >::local_size().

00408 {
00409   this->_is_initialized    = v._is_initialized;
00410   this->_is_closed         = v._is_closed;
00411 
00412   _global_size       = v._global_size;
00413   _local_size        = v._local_size;
00414   _first_local_index = v._first_local_index;
00415   _last_local_index  = v._last_local_index;
00416 
00417   if (v.local_size() == this->local_size())
00418     {
00419       _values = v._values;
00420     }
00421   else
00422     {
00423       libmesh_error();
00424     }
00425 
00426   return *this;
00427 }

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

$U = V$: copy all components.

Definition at line 393 of file distributed_vector.C.

00394 {
00395   // Make sure the NumericVector passed in is really a DistributedVector
00396   const DistributedVector<T>* v = libmesh_cast_ptr<const DistributedVector<T>*>(&v_in);
00397 
00398   *this = *v;
00399 
00400   return *this;
00401 }

template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const T  s  )  [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 377 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::DistributedVector< T >::local_size().

00378 {
00379   libmesh_assert (this->initialized());
00380   libmesh_assert_equal_to (_values.size(), _local_size);
00381   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00382 
00383   for (std::size_t i=0; i<local_size(); i++)
00384     _values[i] = s;
00385 
00386   return *this;
00387 }

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

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<typename T >
void libMesh::DistributedVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
) [inline, virtual]

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

Definition at line 583 of file distributed_vector.C.

00587 {
00588   libmesh_not_implemented();
00589 }

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

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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 >
void libMesh::DistributedVector< T >::reciprocal (  )  [inline, virtual]

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

Implements libMesh::NumericVector< T >.

Definition at line 211 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_values, and libMesh::DistributedVector< T >::local_size().

00212 {
00213   for (numeric_index_type i=0; i<local_size(); i++)
00214     {
00215       // Don't divide by zero
00216       libmesh_assert_not_equal_to (_values[i], T(0));
00217 
00218       _values[i] = 1. / _values[i];
00219     }
00220 }

template<typename T >
void libMesh::DistributedVector< T >::scale ( const T  factor  )  [inline, virtual]

Scale each element of the vector by the given factor.

Implements libMesh::NumericVector< T >.

Definition at line 324 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::NumericVector< T >::initialized(), and libMesh::DistributedVector< T >::local_size().

00325 {
00326   libmesh_assert (this->initialized());
00327   libmesh_assert_equal_to (_values.size(), _local_size);
00328   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00329 
00330   for (std::size_t i=0; i<local_size(); i++)
00331     _values[i] *= factor;
00332 }

template<typename T >
void libMesh::DistributedVector< T >::set ( const numeric_index_type  i,
const T  value 
) [inline, virtual]
template<typename T >
numeric_index_type libMesh::DistributedVector< T >::size (  )  const [inline, virtual]
template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual, inherited]
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, inherited]
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, inherited]
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 >
T libMesh::DistributedVector< T >::sum (  )  const [inline, virtual]
Returns:
the sum of all values in the vector

Implements libMesh::NumericVector< T >.

Definition at line 42 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, libMesh::CommWorld, libMesh::NumericVector< T >::initialized(), libMesh::DistributedVector< T >::local_size(), and libMesh::Parallel::Communicator::sum().

00043 {
00044   // This function must be run on all processors at once
00045   parallel_only();
00046 
00047   libmesh_assert (this->initialized());
00048   libmesh_assert_equal_to (_values.size(), _local_size);
00049   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00050 
00051   T local_sum = 0.;
00052 
00053   for (numeric_index_type i=0; i<local_size(); i++)
00054     local_sum += _values[i];
00055 
00056   CommWorld.sum(local_sum);
00057 
00058   return local_sum;
00059 }

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

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 >
void libMesh::DistributedVector< T >::swap ( NumericVector< T > &  v  )  [inline, virtual]

Swaps the vector data and metadata

Definition at line 868 of file distributed_vector.h.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, and libMesh::DistributedVector< T >::_values.

00869 {
00870   DistributedVector<T>& v = libmesh_cast_ref<DistributedVector<T>&>(other);
00871 
00872   std::swap(_global_size, v._global_size);
00873   std::swap(_local_size, v._local_size);
00874   std::swap(_first_local_index, v._first_local_index);
00875   std::swap(_last_local_index, v._last_local_index);
00876 
00877   // This should be O(1) with any reasonable STL implementation
00878   std::swap(_values, v._values);
00879 }

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

Definition at line 121 of file numeric_vector.h.

00121 { return _type; }

template<typename T >
void libMesh::DistributedVector< T >::zero (  )  [inline, virtual]

Set all entries to zero. Equivalent to v = 0, but more obvious and faster.

Implements libMesh::NumericVector< T >.

Definition at line 683 of file distributed_vector.h.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values, and libMesh::NumericVector< T >::initialized().

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

00684 {
00685   libmesh_assert (this->initialized());
00686   libmesh_assert_equal_to (_values.size(), _local_size);
00687   libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
00688 
00689   std::fill (_values.begin(),
00690              _values.end(),
00691              0.);
00692 }

template<typename T >
AutoPtr< NumericVector< T > > libMesh::DistributedVector< T >::zero_clone (  )  const [inline, 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.

Implements libMesh::NumericVector< T >.

Definition at line 698 of file distributed_vector.h.

00699 {
00700   AutoPtr<NumericVector<T> > cloned_vector (new DistributedVector<T>);
00701 
00702   cloned_vector->init(*this);
00703 
00704   return cloned_vector;
00705 }


Friends And Related Function Documentation

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

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:14 UTC

Hosted By:
SourceForge.net Logo