DistributedVector< T > Class Template Reference
#include <distributed_vector.h>

Public Member Functions | |
| DistributedVector (const ParallelType=AUTOMATIC) | |
| DistributedVector (const unsigned int n, const ParallelType type=AUTOMATIC) | |
| DistributedVector (const unsigned int n, const unsigned int n_local, const ParallelType type=AUTOMATIC) | |
| DistributedVector (const unsigned int N, const unsigned int n_local, const std::vector< unsigned int > &ghost, const ParallelType type=AUTOMATIC) | |
| ~DistributedVector () | |
| void | close () |
| void | clear () |
| void | zero () |
| virtual AutoPtr< NumericVector < T > > | zero_clone () const |
| AutoPtr< NumericVector< T > > | clone () const |
| void | init (const unsigned int N, const unsigned int n_local, const bool fast=false, const ParallelType type=AUTOMATIC) |
| void | init (const unsigned int N, const bool fast=false, const ParallelType type=AUTOMATIC) |
| virtual void | init (const unsigned int, const unsigned int, const std::vector< unsigned int > &, 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 |
| T | sum () const |
| Real | l1_norm () const |
| Real | l2_norm () const |
| Real | linfty_norm () const |
| unsigned int | size () const |
| unsigned int | local_size () const |
| unsigned int | first_local_index () const |
| unsigned int | last_local_index () const |
| T | operator() (const unsigned int i) const |
| NumericVector< T > & | operator+= (const NumericVector< T > &V) |
| NumericVector< T > & | operator-= (const NumericVector< T > &V) |
| void | set (const unsigned int i, const T value) |
| void | add (const unsigned int 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< unsigned int > &dof_indices) |
| void | add_vector (const NumericVector< T > &V, const std::vector< unsigned int > &dof_indices) |
| void | add_vector (const NumericVector< T > &, const SparseMatrix< T > &) |
| void | add_vector (const DenseVector< T > &V, const std::vector< unsigned int > &dof_indices) |
| virtual void | insert (const std::vector< T > &v, const std::vector< unsigned int > &dof_indices) |
| virtual void | insert (const NumericVector< T > &V, const std::vector< unsigned int > &dof_indices) |
| virtual void | insert (const DenseVector< T > &V, const std::vector< unsigned int > &dof_indices) |
| virtual void | insert (const DenseSubVector< T > &V, const std::vector< unsigned int > &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< unsigned int > &send_list) const |
| void | localize (const unsigned int first_local_idx, const unsigned int last_local_idx, const std::vector< unsigned int > &send_list) |
| void | localize_to_one (std::vector< T > &v_local, const unsigned int 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 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 T | el (const unsigned int i) const |
| virtual void | get (const std::vector< unsigned int > &index, std::vector< T > &values) const |
| NumericVector< T > & | operator*= (const T a) |
| NumericVector< T > & | operator/= (const T a) |
| void | add_vector (const NumericVector< T > &v, const ShellMatrix< T > &a) |
| virtual int | compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const |
| 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 |
| virtual void | print (std::ostream &os=std::cout) const |
| template<> | |
| void | print (std::ostream &os) const |
| virtual void | print_global (std::ostream &os=std::cout) 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< unsigned int > &) 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 |
Private Attributes | |
| std::vector< T > | _values |
| unsigned int | _global_size |
| unsigned int | _local_size |
| unsigned int | _first_local_index |
| unsigned int | _last_local_index |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const NumericVector< T > &v) |
Detailed Description
template<typename T>
class 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.
Definition at line 55 of file distributed_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
| DistributedVector< T >::DistributedVector | ( | const ParallelType | type = AUTOMATIC |
) | [inline, explicit] |
Dummy-Constructor. Dimension=0
Definition at line 467 of file distributed_vector.h.
References NumericVector< T >::_type.
00467 : 00468 _global_size (0), 00469 _local_size (0), 00470 _first_local_index(0), 00471 _last_local_index (0) 00472 { 00473 this->_type = type; 00474 }
| DistributedVector< T >::DistributedVector | ( | const unsigned int | n, | |
| const ParallelType | type = AUTOMATIC | |||
| ) | [inline, explicit] |
Constructor. Set dimension to n and initialize all elements with zero.
Definition at line 480 of file distributed_vector.h.
References DistributedVector< T >::init().
| DistributedVector< T >::DistributedVector | ( | const unsigned int | 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 490 of file distributed_vector.h.
References DistributedVector< T >::init().
| DistributedVector< T >::DistributedVector | ( | 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 501 of file distributed_vector.h.
References DistributedVector< T >::init().
| DistributedVector< T >::~DistributedVector | ( | ) | [inline] |
Destructor, deallocates memory. Made virtual to allow for derived classes to behave properly.
Definition at line 513 of file distributed_vector.h.
References DistributedVector< T >::clear().
00514 { 00515 this->clear (); 00516 }
Member Function Documentation
| void DistributedVector< T >::abs | ( | ) | [inline, virtual] |
v = abs(v)... that is, each entry in v is replaced by its absolute value.
Implements NumericVector< T >.
Definition at line 315 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DistributedVector< T >::local_size().
00316 { 00317 libmesh_assert (this->initialized()); 00318 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00319 00320 for (unsigned int i=0; i<local_size(); i++) 00321 this->set(i,std::abs(_values[i])); 00322 }
| void DistributedVector< T >::add | ( | const T | a, | |
| const NumericVector< T > & | v | |||
| ) | [inline, virtual] |
. Simple vector addition, equal to the operator +=.
Implements NumericVector< T >.
Definition at line 231 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
00232 { 00233 libmesh_assert (this->initialized()); 00234 libmesh_assert (_values.size() == _local_size); 00235 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00236 00237 add(a, v); 00238 }
| void DistributedVector< T >::add | ( | const NumericVector< T > & | V | ) | [inline, virtual] |
. Simple vector addition, equal to the operator +=.
Implements NumericVector< T >.
Definition at line 219 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
00220 { 00221 libmesh_assert (this->initialized()); 00222 libmesh_assert (_values.size() == _local_size); 00223 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00224 00225 add (1., v); 00226 }
| void DistributedVector< T >::add | ( | const T | s | ) | [inline, virtual] |
. Addition of s to all components. Note that s is a scalar and not a vector.
Implements NumericVector< T >.
Definition at line 206 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DistributedVector< T >::local_size().
00207 { 00208 libmesh_assert (this->initialized()); 00209 libmesh_assert (_values.size() == _local_size); 00210 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00211 00212 for (unsigned int i=0; i<local_size(); i++) 00213 _values[i] += v; 00214 }
| void DistributedVector< T >::add | ( | const unsigned int | i, | |
| const T | value | |||
| ) | [inline, virtual] |
v(i) += value
Implements NumericVector< T >.
Definition at line 801 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, DistributedVector< T >::first_local_index(), NumericVector< T >::initialized(), DistributedVector< T >::local_size(), and DistributedVector< T >::size().
00802 { 00803 libmesh_assert (this->initialized()); 00804 libmesh_assert (_values.size() == _local_size); 00805 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00806 libmesh_assert (i<size()); 00807 libmesh_assert (i-first_local_index() < local_size()); 00808 00809 _values[i - _first_local_index] += value; 00810 }
| void NumericVector< T >::add_vector | ( | const NumericVector< T > & | v, | |
| const ShellMatrix< T > & | a | |||
| ) | [inline, inherited] |
, 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 }
| void DistributedVector< T >::add_vector | ( | const DenseVector< T > & | V, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
where U and V are type DenseVector<T> and you want to specify WHERE to add the DenseVector<T> V
Implements NumericVector< T >.
Definition at line 191 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DenseVector< T >::size().
00193 { 00194 libmesh_assert (V.size() == dof_indices.size()); 00195 libmesh_assert (this->initialized()); 00196 libmesh_assert (_values.size() == _local_size); 00197 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00198 00199 for (unsigned int i=0; i<V.size(); i++) 00200 add (dof_indices[i], V(i)); 00201 }
| void DistributedVector< T >::add_vector | ( | const NumericVector< T > & | , | |
| const SparseMatrix< T > & | ||||
| ) | [inline, virtual] |
. Add the product of a Sparse matrix A and a Numeric vector V to this Numeric vector. Not implemented.
Implements NumericVector< T >.
Definition at line 322 of file distributed_vector.h.
| void DistributedVector< T >::add_vector | ( | const NumericVector< T > & | V, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
where U and V are type NumericVector<T> and you want to specify WHERE to add the NumericVector<T> V
Implements NumericVector< T >.
Definition at line 176 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and NumericVector< T >::size().
00178 { 00179 libmesh_assert (V.size() == dof_indices.size()); 00180 libmesh_assert (this->initialized()); 00181 libmesh_assert (_values.size() == _local_size); 00182 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00183 00184 for (unsigned int i=0; i<V.size(); i++) 00185 add (dof_indices[i], V(i)); 00186 }
| void DistributedVector< T >::add_vector | ( | const std::vector< T > & | v, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
where v is a std::vector<T> and you want to specify WHERE to add it
Implements NumericVector< T >.
Definition at line 160 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
00162 { 00163 libmesh_assert (!v.empty()); 00164 libmesh_assert (v.size() == dof_indices.size()); 00165 libmesh_assert (this->initialized()); 00166 libmesh_assert (_values.size() == _local_size); 00167 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00168 00169 for (unsigned int i=0; i<v.size(); i++) 00170 add (dof_indices[i], v[i]); 00171 }
| AutoPtr< NumericVector< T > > 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 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 }
| void DistributedVector< T >::clear | ( | ) | [inline, virtual] |
- Returns:
- the
DistributedVectorto a pristine state.
Reimplemented from NumericVector< T >.
Definition at line 659 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_global_size, NumericVector< T >::_is_closed, NumericVector< T >::_is_initialized, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, and DistributedVector< T >::_values.
Referenced by DistributedVector< T >::init(), and DistributedVector< T >::~DistributedVector().
00660 { 00661 _values.clear(); 00662 00663 _global_size = 00664 _local_size = 00665 _first_local_index = 00666 _last_local_index = 0; 00667 00668 00669 this->_is_closed = this->_is_initialized = false; 00670 }
| AutoPtr< NumericVector< T > > DistributedVector< T >::clone | ( | ) | const [inline, virtual] |
Creates a copy of this vector and returns it in an AutoPtr.
Implements NumericVector< T >.
Definition at line 704 of file distributed_vector.h.
00705 { 00706 AutoPtr<NumericVector<T> > cloned_vector (new DistributedVector<T>); 00707 00708 cloned_vector->init(*this, true); 00709 00710 *cloned_vector = *this; 00711 00712 return cloned_vector; 00713 }
| void DistributedVector< T >::close | ( | ) | [inline, virtual] |
Call the assemble functions
Implements NumericVector< T >.
Definition at line 648 of file distributed_vector.h.
References NumericVector< T >::_is_closed, and NumericVector< T >::initialized().
00649 { 00650 libmesh_assert (this->initialized()); 00651 00652 this->_is_closed = true; 00653 }
| virtual bool NumericVector< T >::closed | ( | ) | const [inline, virtual, inherited] |
- Returns:
- true if the vector is closed and ready for computation, false otherwise.
Definition at line 125 of file numeric_vector.h.
Referenced by DofMap::enforce_constraints_exactly(), EpetraVector< T >::l1_norm(), PetscVector< T >::l1_norm(), LaspackVector< T >::l1_norm(), EpetraVector< T >::l2_norm(), PetscVector< T >::l2_norm(), LaspackVector< T >::l2_norm(), EpetraVector< T >::linfty_norm(), PetscVector< T >::linfty_norm(), LaspackVector< T >::linfty_norm(), DofMap::max_constraint_error(), EpetraVector< T >::operator+=(), PetscVector< T >::operator+=(), LaspackVector< T >::operator+=(), DistributedVector< T >::operator+=(), EpetraVector< T >::operator-=(), PetscVector< T >::operator-=(), LaspackVector< T >::operator-=(), DistributedVector< T >::operator-=(), PetscVector< T >::operator=(), PetscVector< T >::print_matlab(), EpetraVector< T >::sum(), PetscVector< T >::sum(), and LaspackVector< T >::sum().
00125 { return _is_closed; }
| int NumericVector< Complex >::compare | ( | const NumericVector< Complex > & | other_vector, | |
| const Real | threshold | |||
| ) | const [inline, inherited] |
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 }
| int NumericVector< long double >::compare | ( | const NumericVector< long double > & | other_vector, | |
| const Real | threshold | |||
| ) | const [inline, inherited] |
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 }
| int NumericVector< double >::compare | ( | const NumericVector< double > & | other_vector, | |
| const Real | threshold | |||
| ) | const [inline, inherited] |
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 }
| int NumericVector< float >::compare | ( | const NumericVector< float > & | other_vector, | |
| const Real | threshold | |||
| ) | const [inline, inherited] |
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 }
| virtual int NumericVector< T >::compare | ( | const NumericVector< T > & | other_vector, | |
| const Real | threshold = TOLERANCE | |||
| ) | const [virtual, inherited] |
- Returns:
-1whenthisis equivalent toother_vector, up to the giventhreshold. When differences occur, the return value contains the first index where the difference exceeded the threshold. When no threshold is given, thelibMeshTOLERANCEis used.
| virtual void NumericVector< T >::create_subvector | ( | NumericVector< T > & | , | |
| const std::vector< unsigned int > & | ||||
| ) | 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.
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 }
| T DistributedVector< T >::dot | ( | const NumericVector< T > & | V | ) | const [inline, virtual] |
Computes the dot product, p = U.V
Implements NumericVector< T >.
Definition at line 329 of file distributed_vector.C.
References DistributedVector< T >::_values, DistributedVector< T >::first_local_index(), DistributedVector< T >::last_local_index(), and DistributedVector< T >::local_size().
00330 { 00331 // This function must be run on all processors at once 00332 parallel_only(); 00333 00334 // Make sure the NumericVector passed in is really a DistributedVector 00335 const DistributedVector<T>* v = libmesh_cast_ptr<const DistributedVector<T>*>(&V); 00336 00337 // Make sure that the two vectors are distributed in the same way. 00338 libmesh_assert ( this->first_local_index() == v->first_local_index() ); 00339 libmesh_assert ( this->last_local_index() == v->last_local_index() ); 00340 00341 // The result of dotting together the local parts of the vector. 00342 T local_dot = 0; 00343 00344 for (unsigned int i=0; i<this->local_size(); i++) 00345 local_dot += this->_values[i] * v->_values[i]; 00346 00347 // The local dot products are now summed via MPI 00348 Parallel::sum(local_dot); 00349 00350 return local_dot; 00351 }
| virtual T NumericVector< T >::el | ( | const unsigned int | i | ) | const [inline, virtual, inherited] |
| unsigned int DistributedVector< T >::first_local_index | ( | ) | const [inline, virtual] |
- Returns:
- the index of the first vector element actually stored on this processor
Implements NumericVector< T >.
Definition at line 745 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
Referenced by DistributedVector< T >::add(), DistributedVector< T >::dot(), DistributedVector< T >::operator()(), DistributedVector< T >::operator=(), and DistributedVector< T >::set().
00746 { 00747 libmesh_assert (this->initialized()); 00748 libmesh_assert (_values.size() == _local_size); 00749 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00750 00751 return _first_local_index; 00752 }
| void NumericVector< T >::get | ( | const std::vector< unsigned int > & | 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 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 }
| void 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.
Implements NumericVector< T >.
Definition at line 627 of file distributed_vector.h.
References DistributedVector< T >::init(), NumericVector< T >::local_size(), NumericVector< T >::size(), and NumericVector< T >::type().
00629 { 00630 this->init(other.size(),other.local_size(),fast,other.type()); 00631 }
| void DistributedVector< T >::init | ( | const unsigned int | n, | |
| const unsigned int | n_local, | |||
| const std::vector< unsigned int > & | , | |||
| const bool | fast = false, |
|||
| const ParallelType | type = AUTOMATIC | |||
| ) | [inline, virtual] |
Create a vector that holds tha local indices plus those specified in the ghost argument.
Implements NumericVector< T >.
Definition at line 612 of file distributed_vector.h.
References DistributedVector< T >::init().
00617 { 00618 // TODO: we shouldn't ignore the ghost sparsity pattern 00619 this->init(n, n_local, fast, type); 00620 }
| void DistributedVector< T >::init | ( | const unsigned int | N, | |
| const bool | fast = false, |
|||
| const ParallelType | type = AUTOMATIC | |||
| ) | [inline, virtual] |
call init with n_local = N,
Implements NumericVector< T >.
Definition at line 637 of file distributed_vector.h.
References DistributedVector< T >::init().
| void DistributedVector< T >::init | ( | const unsigned int | N, | |
| const unsigned int | n_local, | |||
| const bool | fast = false, |
|||
| const ParallelType | type = 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 NumericVector< T >.
Definition at line 522 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_global_size, NumericVector< T >::_is_initialized, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, NumericVector< T >::_type, DistributedVector< T >::_values, libMeshEnums::AUTOMATIC, DistributedVector< T >::clear(), libMesh::COMM_WORLD, NumericVector< T >::initialized(), libMeshEnums::PARALLEL, libMeshEnums::SERIAL, DistributedVector< T >::sum(), and DistributedVector< T >::zero().
Referenced by DistributedVector< T >::DistributedVector(), DistributedVector< T >::init(), and DistributedVector< T >::localize().
00526 { 00527 // This function must be run on all processors at once 00528 parallel_only(); 00529 00530 libmesh_assert (n_local <= n); 00531 00532 if (type == AUTOMATIC) 00533 { 00534 if (n == n_local) 00535 this->_type = SERIAL; 00536 else 00537 this->_type = PARALLEL; 00538 } 00539 else 00540 this->_type = type; 00541 00542 libmesh_assert ((this->_type==SERIAL && n==n_local) || 00543 this->_type==PARALLEL); 00544 00545 // Clear the data structures if already initialized 00546 if (this->initialized()) 00547 this->clear(); 00548 00549 // Initialize data structures 00550 _values.resize(n_local); 00551 _local_size = n_local; 00552 _global_size = n; 00553 00554 _first_local_index = 0; 00555 00556 #ifdef LIBMESH_HAVE_MPI 00557 00558 int n_proc=0, proc_id=0; 00559 00560 MPI_Comm_rank (libMesh::COMM_WORLD, &proc_id); 00561 MPI_Comm_size (libMesh::COMM_WORLD, &n_proc); 00562 00563 std::vector<int> local_sizes (n_proc, 0); 00564 00565 local_sizes[proc_id] = n_local; 00566 00567 Parallel::sum(local_sizes); 00568 00569 // _first_local_index is the sum of _local_size 00570 // for all processor ids less than ours 00571 for (int p=0; p<proc_id; p++) 00572 _first_local_index += local_sizes[p]; 00573 00574 00575 # ifdef DEBUG 00576 // Make sure all the local sizes sum up to the global 00577 // size, otherwise there is big trouble! 00578 int sum=0; 00579 00580 for (int p=0; p<n_proc; p++) 00581 sum += local_sizes[p]; 00582 00583 libmesh_assert (sum == static_cast<int>(n)); 00584 00585 # endif 00586 00587 #else 00588 00589 // No other options without MPI! 00590 if (n != n_local) 00591 { 00592 std::cerr << "ERROR: MPI is required for n != n_local!" 00593 << std::endl; 00594 libmesh_error(); 00595 } 00596 00597 #endif 00598 00599 _last_local_index = _first_local_index + n_local; 00600 00601 // Set the initialized flag 00602 this->_is_initialized = true; 00603 00604 // Zero the components unless directed otherwise 00605 if (!fast) 00606 this->zero(); 00607 }
| virtual bool NumericVector< T >::initialized | ( | ) | const [inline, virtual, inherited] |
- 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; }
| void DistributedVector< T >::insert | ( | const DenseSubVector< T > & | V, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
where V is type DenseSubVector<T> and you want to specify WHERE to insert it
Implements NumericVector< T >.
Definition at line 289 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DenseVectorBase< T >::size().
00291 { 00292 libmesh_assert (V.size() == dof_indices.size()); 00293 libmesh_assert (this->initialized()); 00294 libmesh_assert (_values.size() == _local_size); 00295 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00296 00297 for (unsigned int i=0; i<V.size(); i++) 00298 this->set (dof_indices[i], V(i)); 00299 }
| void DistributedVector< T >::insert | ( | const DenseVector< T > & | V, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
where V is type DenseVector<T> and you want to specify WHERE to insert it
Implements NumericVector< T >.
Definition at line 274 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DenseVector< T >::size().
00276 { 00277 libmesh_assert (V.size() == dof_indices.size()); 00278 libmesh_assert (this->initialized()); 00279 libmesh_assert (_values.size() == _local_size); 00280 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00281 00282 for (unsigned int i=0; i<V.size(); i++) 00283 this->set (dof_indices[i], V(i)); 00284 }
| void DistributedVector< T >::insert | ( | const NumericVector< T > & | V, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
, where U and V are type NumericVector<T> and you want to specify WHERE to insert the NumericVector<T> V
Implements NumericVector< T >.
Definition at line 259 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and NumericVector< T >::size().
00261 { 00262 libmesh_assert (V.size() == dof_indices.size()); 00263 libmesh_assert (this->initialized()); 00264 libmesh_assert (_values.size() == _local_size); 00265 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00266 00267 for (unsigned int i=0; i<V.size(); i++) 00268 this->set (dof_indices[i], V(i)); 00269 }
| void DistributedVector< T >::insert | ( | const std::vector< T > & | v, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [inline, virtual] |
where v is a DenseVector<T> and you want to specify WHERE to insert it
Implements NumericVector< T >.
Definition at line 243 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
00245 { 00246 libmesh_assert (!v.empty()); 00247 libmesh_assert (v.size() == dof_indices.size()); 00248 libmesh_assert (this->initialized()); 00249 libmesh_assert (_values.size() == _local_size); 00250 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00251 00252 for (unsigned int i=0; i<v.size(); i++) 00253 this->set (dof_indices[i], v[i]); 00254 }
| Real DistributedVector< T >::l1_norm | ( | ) | const [inline, virtual] |
- Returns:
- the
-norm of the vector, i.e. the sum of the absolute values.
Implements NumericVector< T >.
Definition at line 60 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), DistributedVector< T >::local_size(), and DistributedVector< T >::sum().
00061 { 00062 // This function must be run on all processors at once 00063 parallel_only(); 00064 00065 libmesh_assert (this->initialized()); 00066 libmesh_assert (_values.size() == _local_size); 00067 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00068 00069 double local_l1 = 0.; 00070 00071 for (unsigned int i=0; i<local_size(); i++) 00072 local_l1 += std::abs(_values[i]); 00073 00074 Parallel::sum(local_l1); 00075 00076 return local_l1; 00077 }
| Real DistributedVector< T >::l2_norm | ( | ) | const [inline, virtual] |
- Returns:
- the
-norm of the vector, i.e. the square root of the sum of the squares of the elements.
Implements NumericVector< T >.
Definition at line 82 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), libmesh_norm(), DistributedVector< T >::local_size(), and DistributedVector< T >::sum().
00083 { 00084 // This function must be run on all processors at once 00085 parallel_only(); 00086 00087 libmesh_assert (this->initialized()); 00088 libmesh_assert (_values.size() == _local_size); 00089 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00090 00091 double local_l2 = 0.; 00092 00093 for (unsigned int i=0; i<local_size(); i++) 00094 local_l2 += libmesh_norm(_values[i]); 00095 00096 Parallel::sum(local_l2); 00097 00098 return std::sqrt(local_l2); 00099 }
| unsigned int DistributedVector< T >::last_local_index | ( | ) | const [inline, virtual] |
- Returns:
- the index of the last vector element actually stored on this processor
Implements NumericVector< T >.
Definition at line 758 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
Referenced by DistributedVector< T >::dot(), DistributedVector< T >::operator()(), and DistributedVector< T >::operator=().
00759 { 00760 libmesh_assert (this->initialized()); 00761 libmesh_assert (_values.size() == _local_size); 00762 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00763 00764 return _last_local_index; 00765 }
| Real DistributedVector< T >::linfty_norm | ( | ) | const [inline, virtual] |
- Returns:
- the maximum absolute value of the elements of this vector, which is the
-norm of a vector.
Implements NumericVector< T >.
Definition at line 104 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), DistributedVector< T >::local_size(), DistributedVector< T >::max(), and std::max().
00105 { 00106 // This function must be run on all processors at once 00107 parallel_only(); 00108 00109 libmesh_assert (this->initialized()); 00110 libmesh_assert (_values.size() == _local_size); 00111 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00112 00113 Real local_linfty = 0.; 00114 00115 for (unsigned int i=0; i<local_size(); i++) 00116 local_linfty = std::max(local_linfty, 00117 static_cast<Real>(std::abs(_values[i])) 00118 ); // Note we static_cast so that both 00119 // types are the same, as required 00120 // by std::max 00121 00122 Parallel::max(local_linfty); 00123 00124 return local_linfty; 00125 }
| unsigned int DistributedVector< T >::local_size | ( | ) | const [inline, virtual] |
- Returns:
- the local size of the vector (index_stop-index_start)
Implements NumericVector< T >.
Definition at line 732 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
Referenced by DistributedVector< T >::abs(), DistributedVector< T >::add(), DistributedVector< T >::dot(), DistributedVector< T >::l1_norm(), DistributedVector< T >::l2_norm(), DistributedVector< T >::linfty_norm(), DistributedVector< T >::localize(), DistributedVector< T >::localize_to_one(), DistributedVector< T >::operator=(), DistributedVector< T >::scale(), DistributedVector< T >::set(), and DistributedVector< T >::sum().
00733 { 00734 libmesh_assert (this->initialized()); 00735 libmesh_assert (_values.size() == _local_size); 00736 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00737 00738 return _local_size; 00739 }
| void DistributedVector< T >::localize | ( | const unsigned int | first_local_idx, | |
| const unsigned int | last_local_idx, | |||
| const std::vector< unsigned int > & | send_list | |||
| ) | [inline, virtual] |
Updates a local vector with selected values from neighboring processors, as defined by send_list.
Implements NumericVector< T >.
Definition at line 484 of file distributed_vector.C.
References DistributedVector< T >::_values, DistributedVector< T >::init(), DistributedVector< T >::local_size(), DistributedVector< T >::localize(), libMeshEnums::PARALLEL, and DistributedVector< T >::size().
00487 { 00488 // Only good for serial vectors 00489 libmesh_assert (this->size() == this->local_size()); 00490 libmesh_assert (last_local_idx > first_local_idx); 00491 libmesh_assert (send_list.size() <= this->size()); 00492 libmesh_assert (last_local_idx < this->size()); 00493 00494 const unsigned int size = this->size(); 00495 const unsigned int local_size = (last_local_idx - first_local_idx + 1); 00496 00497 // Don't bother for serial cases 00498 if ((first_local_idx == 0) && 00499 (local_size == size)) 00500 return; 00501 00502 00503 // Build a parallel vector, initialize it with the local 00504 // parts of (*this) 00505 DistributedVector<T> parallel_vec; 00506 00507 parallel_vec.init (size, local_size, true, PARALLEL); 00508 00509 // Copy part of *this into the parallel_vec 00510 for (unsigned int i=first_local_idx; i<=last_local_idx; i++) 00511 parallel_vec._values[i-first_local_idx] = _values[i]; 00512 00513 // localize like normal 00514 parallel_vec.localize (*this, send_list); 00515 }
| void DistributedVector< T >::localize | ( | NumericVector< T > & | v_local, | |
| const std::vector< unsigned int > & | send_list | |||
| ) | const [inline, virtual] |
Creates a local vector v_local containing only information relevant to this processor, as defined by the send_list.
Implements NumericVector< T >.
Definition at line 470 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DistributedVector< T >::localize().
00472 { 00473 libmesh_assert (this->initialized()); 00474 libmesh_assert (_values.size() == _local_size); 00475 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00476 00477 // TODO: We don't yet support the send list; this is inefficient: 00478 localize (v_local_in); 00479 }
| void DistributedVector< T >::localize | ( | NumericVector< T > & | v_local | ) | const [inline, virtual] |
Same, but fills a NumericVector<T> instead of a std::vector.
Implements NumericVector< T >.
Definition at line 438 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_global_size, NumericVector< T >::_is_closed, NumericVector< T >::_is_initialized, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), DistributedVector< T >::local_size(), DistributedVector< T >::localize(), and DistributedVector< T >::size().
00440 { 00441 libmesh_assert (this->initialized()); 00442 libmesh_assert (_values.size() == _local_size); 00443 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00444 00445 DistributedVector<T>* v_local = libmesh_cast_ptr<DistributedVector<T>*>(&v_local_in); 00446 00447 v_local->_first_local_index = 0; 00448 00449 v_local->_global_size = 00450 v_local->_local_size = 00451 v_local->_last_local_index = size(); 00452 00453 v_local->_is_initialized = 00454 v_local->_is_closed = true; 00455 00456 // Call localize on the vector's values. This will help 00457 // prevent code duplication 00458 localize (v_local->_values); 00459 00460 #ifndef LIBMESH_HAVE_MPI 00461 00462 libmesh_assert (local_size() == size()); 00463 00464 #endif 00465 }
| void 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 NumericVector< T >.
Definition at line 520 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), DistributedVector< T >::local_size(), and DistributedVector< T >::size().
Referenced by DistributedVector< T >::localize().
00521 { 00522 // This function must be run on all processors at once 00523 parallel_only(); 00524 00525 libmesh_assert (this->initialized()); 00526 libmesh_assert (_values.size() == _local_size); 00527 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00528 00529 v_local = this->_values; 00530 00531 Parallel::allgather (v_local); 00532 00533 #ifndef LIBMESH_HAVE_MPI 00534 libmesh_assert (local_size() == size()); 00535 #endif 00536 }
| void DistributedVector< T >::localize_to_one | ( | std::vector< T > & | v_local, | |
| const unsigned int | 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 NumericVector< T >.
Definition at line 541 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), DistributedVector< T >::local_size(), and DistributedVector< T >::size().
00543 { 00544 // This function must be run on all processors at once 00545 parallel_only(); 00546 00547 libmesh_assert (this->initialized()); 00548 libmesh_assert (_values.size() == _local_size); 00549 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00550 00551 v_local = this->_values; 00552 00553 Parallel::gather (pid, v_local); 00554 00555 #ifndef LIBMESH_HAVE_MPI 00556 libmesh_assert (local_size() == size()); 00557 #endif 00558 }
| Real 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 NumericVector< T >.
Definition at line 839 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), libmesh_real(), and std::max().
Referenced by DistributedVector< T >::linfty_norm(), and DistributedVector< T >::min().
00840 { 00841 // This function must be run on all processors at once 00842 parallel_only(); 00843 00844 libmesh_assert (this->initialized()); 00845 libmesh_assert (_values.size() == _local_size); 00846 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00847 00848 Real local_max = _values.size() ? 00849 libmesh_real(_values[0]) : -std::numeric_limits<Real>::max(); 00850 for (unsigned int i = 1; i < _values.size(); ++i) 00851 local_max = std::max(libmesh_real(_values[i]), local_max); 00852 00853 Parallel::max(local_max); 00854 00855 return local_max; 00856 }
| Real 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 NumericVector< T >.
Definition at line 816 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), libmesh_real(), DistributedVector< T >::max(), and std::min().
00817 { 00818 // This function must be run on all processors at once 00819 parallel_only(); 00820 00821 libmesh_assert (this->initialized()); 00822 libmesh_assert (_values.size() == _local_size); 00823 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00824 00825 Real local_min = _values.size() ? 00826 libmesh_real(_values[0]) : std::numeric_limits<Real>::max(); 00827 for (unsigned int i = 1; i < _values.size(); ++i) 00828 local_min = std::min(libmesh_real(_values[i]), local_min); 00829 00830 Parallel::min(local_min); 00831 00832 return local_min; 00833 }
| 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; }
| T DistributedVector< T >::operator() | ( | const unsigned int | i | ) | const [inline, virtual] |
Access components, returns U(i).
Implements NumericVector< T >.
Definition at line 771 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, DistributedVector< T >::first_local_index(), NumericVector< T >::initialized(), and DistributedVector< T >::last_local_index().
00772 { 00773 libmesh_assert (this->initialized()); 00774 libmesh_assert (_values.size() == _local_size); 00775 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00776 libmesh_assert ( ((i >= first_local_index()) && 00777 (i < last_local_index())) ); 00778 00779 return _values[i - _first_local_index]; 00780 }
| NumericVector<T>& NumericVector< T >::operator*= | ( | const T | a | ) | [inline, inherited] |
Multiplication operator. Equivalent to U.scale(a)
Definition at line 348 of file numeric_vector.h.
00348 { this->scale(a); return *this; }
| NumericVector< T > & DistributedVector< T >::operator+= | ( | const NumericVector< T > & | V | ) | [inline, virtual] |
Addition operator. Fast equivalent to U.add(1, V).
Implements NumericVector< T >.
Definition at line 130 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::closed(), and NumericVector< T >::initialized().
00131 { 00132 libmesh_assert (this->closed()); 00133 libmesh_assert (this->initialized()); 00134 libmesh_assert (_values.size() == _local_size); 00135 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00136 00137 add(1., v); 00138 00139 return *this; 00140 }
| NumericVector< T > & DistributedVector< T >::operator-= | ( | const NumericVector< T > & | V | ) | [inline, virtual] |
Subtraction operator. Fast equivalent to U.add(-1, V).
Implements NumericVector< T >.
Definition at line 145 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::closed(), and NumericVector< T >::initialized().
00146 { 00147 libmesh_assert (this->closed()); 00148 libmesh_assert (this->initialized()); 00149 libmesh_assert (_values.size() == _local_size); 00150 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00151 00152 add(-1., v); 00153 00154 return *this; 00155 }
| NumericVector<T>& NumericVector< T >::operator/= | ( | const T | a | ) | [inline, inherited] |
Division operator. Equivalent to U.scale(1./a)
Definition at line 354 of file numeric_vector.h.
00354 { this->scale(1./a); return *this; }
| NumericVector< T > & DistributedVector< T >::operator= | ( | const std::vector< T > & | v | ) | [inline, virtual] |
: copy all components.
Implements NumericVector< T >.
Definition at line 413 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, DistributedVector< T >::first_local_index(), NumericVector< T >::initialized(), DistributedVector< T >::last_local_index(), DistributedVector< T >::local_size(), and DistributedVector< T >::size().
00414 { 00415 libmesh_assert (this->initialized()); 00416 libmesh_assert (_values.size() == _local_size); 00417 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00418 00419 if (v.size() == local_size()) 00420 _values = v; 00421 00422 else if (v.size() == size()) 00423 for (unsigned int i=first_local_index(); i<last_local_index(); i++) 00424 _values[i-first_local_index()] = v[i]; 00425 00426 else 00427 { 00428 libmesh_error(); 00429 } 00430 00431 00432 return *this; 00433 }
| DistributedVector< T > & DistributedVector< T >::operator= | ( | const DistributedVector< T > & | V | ) | [inline] |
: copy all components.
Definition at line 387 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_global_size, NumericVector< T >::_is_closed, NumericVector< T >::_is_initialized, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and DistributedVector< T >::local_size().
00388 { 00389 this->_is_initialized = v._is_initialized; 00390 this->_is_closed = v._is_closed; 00391 00392 _global_size = v._global_size; 00393 _local_size = v._local_size; 00394 _first_local_index = v._first_local_index; 00395 _last_local_index = v._last_local_index; 00396 00397 if (v.local_size() == this->local_size()) 00398 { 00399 _values = v._values; 00400 } 00401 else 00402 { 00403 libmesh_error(); 00404 } 00405 00406 return *this; 00407 }
| NumericVector< T > & DistributedVector< T >::operator= | ( | const NumericVector< T > & | V | ) | [inline, virtual] |
: copy all components.
Implements NumericVector< T >.
Definition at line 373 of file distributed_vector.C.
00374 { 00375 // Make sure the NumericVector passed in is really a DistributedVector 00376 const DistributedVector<T>* v = libmesh_cast_ptr<const DistributedVector<T>*>(&v_in); 00377 00378 *this = *v; 00379 00380 return *this; 00381 }
| NumericVector< T > & DistributedVector< T >::operator= | ( | const T | s | ) | [inline, virtual] |
: fill all components.
Implements NumericVector< T >.
Definition at line 357 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DistributedVector< T >::local_size().
00358 { 00359 libmesh_assert (this->initialized()); 00360 libmesh_assert (_values.size() == _local_size); 00361 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00362 00363 for (unsigned int i=0; i<local_size(); i++) 00364 _values[i] = s; 00365 00366 return *this; 00367 }
| void 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.
Implements NumericVector< T >.
Definition at line 563 of file distributed_vector.C.
| void NumericVector< Complex >::print | ( | std::ostream & | os | ) | const [inline, inherited] |
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 }
| void NumericVector< T >::print | ( | std::ostream & | os = std::cout |
) | const [inline, virtual, inherited] |
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 }
| void NumericVector< Complex >::print_global | ( | std::ostream & | os | ) | const [inline, inherited] |
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 }
| void NumericVector< T >::print_global | ( | std::ostream & | os = std::cout |
) | const [inline, virtual, inherited] |
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 }
| virtual void 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 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 }
| void DistributedVector< T >::scale | ( | const T | factor | ) | [inline, virtual] |
Scale each element of the vector by the given factor.
Implements NumericVector< T >.
Definition at line 304 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DistributedVector< T >::local_size().
00305 { 00306 libmesh_assert (this->initialized()); 00307 libmesh_assert (_values.size() == _local_size); 00308 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00309 00310 for (unsigned int i=0; i<local_size(); i++) 00311 _values[i] *= factor; 00312 }
| void DistributedVector< T >::set | ( | const unsigned int | i, | |
| const T | value | |||
| ) | [inline, virtual] |
v(i) = value
Implements NumericVector< T >.
Definition at line 786 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, DistributedVector< T >::first_local_index(), NumericVector< T >::initialized(), DistributedVector< T >::local_size(), and DistributedVector< T >::size().
00787 { 00788 libmesh_assert (this->initialized()); 00789 libmesh_assert (_values.size() == _local_size); 00790 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00791 libmesh_assert (i<size()); 00792 libmesh_assert (i-first_local_index() < local_size()); 00793 00794 _values[i - _first_local_index] = value; 00795 }
| unsigned int DistributedVector< T >::size | ( | ) | const [inline, virtual] |
- Returns:
- dimension of the vector. This function was formerly called
n(), but was renamed to get theDistributedVectorclass closer to the C++ standard library'sstd::vectorcontainer.
Implements NumericVector< T >.
Definition at line 719 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_global_size, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
Referenced by DistributedVector< T >::add(), DistributedVector< T >::localize(), DistributedVector< T >::localize_to_one(), DistributedVector< T >::operator=(), and DistributedVector< T >::set().
00720 { 00721 libmesh_assert (this->initialized()); 00722 libmesh_assert (_values.size() == _local_size); 00723 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00724 00725 return _global_size; 00726 }
| Real NumericVector< T >::subset_l1_norm | ( | const std::set< unsigned int > & | indices | ) | [inline, virtual, inherited] |
- Returns:
- the
-norm of the vector, i.e. the sum of the absolute values for the specified entries in the vector.
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 }
| Real NumericVector< T >::subset_l2_norm | ( | const std::set< unsigned int > & | indices | ) | [inline, virtual, inherited] |
- Returns:
- the
-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.
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 }
| Real NumericVector< T >::subset_linfty_norm | ( | const std::set< unsigned int > & | indices | ) | [inline, virtual, inherited] |
- Returns:
- the maximum absolute value of the specified entries of this vector, which is the
-norm of a vector.
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 }
| T DistributedVector< T >::sum | ( | ) | const [inline, virtual] |
- Returns:
- the sum of all values in the vector
Implements NumericVector< T >.
Definition at line 38 of file distributed_vector.C.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, NumericVector< T >::initialized(), and DistributedVector< T >::local_size().
Referenced by DistributedVector< T >::init(), DistributedVector< T >::l1_norm(), and DistributedVector< T >::l2_norm().
00039 { 00040 // This function must be run on all processors at once 00041 parallel_only(); 00042 00043 libmesh_assert (this->initialized()); 00044 libmesh_assert (_values.size() == _local_size); 00045 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00046 00047 T local_sum = 0.; 00048 00049 for (unsigned int i=0; i<local_size(); i++) 00050 local_sum += _values[i]; 00051 00052 Parallel::sum(local_sum); 00053 00054 return local_sum; 00055 }
| void DistributedVector< T >::swap | ( | NumericVector< T > & | v | ) | [inline, virtual] |
Swaps the vector data and metadata
Reimplemented from NumericVector< T >.
Definition at line 861 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_global_size, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, and DistributedVector< T >::_values.
00862 { 00863 DistributedVector<T>& v = libmesh_cast_ref<DistributedVector<T>&>(other); 00864 00865 std::swap(_global_size, v._global_size); 00866 std::swap(_local_size, v._local_size); 00867 std::swap(_first_local_index, v._first_local_index); 00868 std::swap(_last_local_index, v._last_local_index); 00869 00870 // This should be O(1) with any reasonable STL implementation 00871 std::swap(_values, v._values); 00872 }
| ParallelType& NumericVector< T >::type | ( | ) | [inline, inherited] |
- Returns:
- the type (SERIAL, PARALLEL, GHOSTED) of the vector.
Definition at line 119 of file numeric_vector.h.
00119 { return _type; }
| ParallelType NumericVector< T >::type | ( | ) | const [inline, inherited] |
- Returns:
- the type (SERIAL, PARALLEL, GHOSTED) of the vector.
Definition at line 114 of file numeric_vector.h.
Referenced by PetscVector< T >::_get_array(), PetscVector< T >::_restore_array(), PetscVector< T >::abs(), PetscVector< T >::add(), PetscVector< T >::close(), DofMap::enforce_constraints_exactly(), PetscVector< T >::get(), EpetraVector< T >::init(), LaspackVector< T >::init(), DistributedVector< T >::init(), PetscVector< T >::localize(), PetscVector< T >::operator()(), PetscVector< T >::operator=(), PetscVector< T >::pointwise_mult(), System::project_vector(), System::read_serialized_vector(), PetscVector< T >::scale(), and PetscVector< T >::zero().
00114 { return _type; }
| void DistributedVector< T >::zero | ( | ) | [inline, virtual] |
Set all entries to zero. Equivalent to v = 0, but more obvious and faster.
Implements NumericVector< T >.
Definition at line 676 of file distributed_vector.h.
References DistributedVector< T >::_first_local_index, DistributedVector< T >::_last_local_index, DistributedVector< T >::_local_size, DistributedVector< T >::_values, and NumericVector< T >::initialized().
Referenced by DistributedVector< T >::init().
00677 { 00678 libmesh_assert (this->initialized()); 00679 libmesh_assert (_values.size() == _local_size); 00680 libmesh_assert ((_last_local_index - _first_local_index) == _local_size); 00681 00682 std::fill (_values.begin(), 00683 _values.end(), 00684 0.); 00685 }
| AutoPtr< NumericVector< T > > 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 NumericVector< T >.
Definition at line 691 of file distributed_vector.h.
00692 { 00693 AutoPtr<NumericVector<T> > cloned_vector (new DistributedVector<T>); 00694 00695 cloned_vector->init(*this); 00696 00697 return cloned_vector; 00698 }
Friends And Related Function Documentation
| 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 545 of file numeric_vector.h.
00546 { 00547 v.print_global(os); 00548 return os; 00549 }
Member Data Documentation
ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited] |
Actually holds the data.
Definition at line 110 of file reference_counter.h.
Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().
unsigned int DistributedVector< T >::_first_local_index [private] |
The first component stored locally
Definition at line 454 of file distributed_vector.h.
Referenced by DistributedVector< T >::abs(), DistributedVector< T >::add(), DistributedVector< T >::add_vector(), DistributedVector< T >::clear(), DistributedVector< T >::first_local_index(), DistributedVector< T >::init(), DistributedVector< T >::insert(), DistributedVector< T >::l1_norm(), DistributedVector< T >::l2_norm(), DistributedVector< T >::last_local_index(), DistributedVector< T >::linfty_norm(), DistributedVector< T >::local_size(), DistributedVector< T >::localize(), DistributedVector< T >::localize_to_one(), DistributedVector< T >::max(), DistributedVector< T >::min(), DistributedVector< T >::operator()(), DistributedVector< T >::operator+=(), DistributedVector< T >::operator-=(), DistributedVector< T >::operator=(), DistributedVector< T >::scale(), DistributedVector< T >::set(), DistributedVector< T >::size(), DistributedVector< T >::sum(), DistributedVector< T >::swap(), and DistributedVector< T >::zero().
unsigned int DistributedVector< T >::_global_size [private] |
The global vector size
Definition at line 444 of file distributed_vector.h.
Referenced by DistributedVector< T >::clear(), DistributedVector< T >::init(), DistributedVector< T >::localize(), DistributedVector< T >::operator=(), DistributedVector< T >::size(), and DistributedVector< T >::swap().
bool NumericVector< T >::_is_closed [protected, inherited] |
Flag to see if the Numeric assemble routines have been called yet
Definition at line 590 of file numeric_vector.h.
Referenced by EpetraVector< T >::add(), PetscVector< T >::add(), EpetraVector< T >::clear(), PetscVector< T >::clear(), NumericVector< T >::clear(), LaspackVector< T >::clear(), DistributedVector< T >::clear(), EpetraVector< T >::close(), PetscVector< T >::close(), LaspackVector< T >::close(), DistributedVector< T >::close(), NumericVector< Real >::closed(), PetscVector< T >::init(), DistributedVector< T >::localize(), LaspackVector< T >::operator=(), DistributedVector< T >::operator=(), PetscVector< T >::PetscVector(), EpetraVector< T >::set(), PetscVector< T >::set(), and NumericVector< T >::swap().
bool NumericVector< T >::_is_initialized [protected, inherited] |
Flag to tell if init has been called yet
Definition at line 596 of file numeric_vector.h.
Referenced by EpetraVector< T >::clear(), PetscVector< T >::clear(), NumericVector< T >::clear(), LaspackVector< T >::clear(), DistributedVector< T >::clear(), PetscVector< T >::create_subvector(), EpetraVector< T >::EpetraVector(), EpetraVector< T >::init(), PetscVector< T >::init(), LaspackVector< T >::init(), DistributedVector< T >::init(), NumericVector< Real >::initialized(), DistributedVector< T >::localize(), DistributedVector< T >::operator=(), PetscVector< T >::PetscVector(), and NumericVector< T >::swap().
unsigned int DistributedVector< T >::_last_local_index [private] |
The last component (+1) stored locally
Definition at line 459 of file distributed_vector.h.
Referenced by DistributedVector< T >::abs(), DistributedVector< T >::add(), DistributedVector< T >::add_vector(), DistributedVector< T >::clear(), DistributedVector< T >::first_local_index(), DistributedVector< T >::init(), DistributedVector< T >::insert(), DistributedVector< T >::l1_norm(), DistributedVector< T >::l2_norm(), DistributedVector< T >::last_local_index(), DistributedVector< T >::linfty_norm(), DistributedVector< T >::local_size(), DistributedVector< T >::localize(), DistributedVector< T >::localize_to_one(), DistributedVector< T >::max(), DistributedVector< T >::min(), DistributedVector< T >::operator()(), DistributedVector< T >::operator+=(), DistributedVector< T >::operator-=(), DistributedVector< T >::operator=(), DistributedVector< T >::scale(), DistributedVector< T >::set(), DistributedVector< T >::size(), DistributedVector< T >::sum(), DistributedVector< T >::swap(), and DistributedVector< T >::zero().
unsigned int DistributedVector< T >::_local_size [private] |
The local vector size
Definition at line 449 of file distributed_vector.h.
Referenced by DistributedVector< T >::abs(), DistributedVector< T >::add(), DistributedVector< T >::add_vector(), DistributedVector< T >::clear(), DistributedVector< T >::first_local_index(), DistributedVector< T >::init(), DistributedVector< T >::insert(), DistributedVector< T >::l1_norm(), DistributedVector< T >::l2_norm(), DistributedVector< T >::last_local_index(), DistributedVector< T >::linfty_norm(), DistributedVector< T >::local_size(), DistributedVector< T >::localize(), DistributedVector< T >::localize_to_one(), DistributedVector< T >::max(), DistributedVector< T >::min(), DistributedVector< T >::operator()(), DistributedVector< T >::operator+=(), DistributedVector< T >::operator-=(), DistributedVector< T >::operator=(), DistributedVector< T >::scale(), DistributedVector< T >::set(), DistributedVector< T >::size(), DistributedVector< T >::sum(), DistributedVector< T >::swap(), and DistributedVector< T >::zero().
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().
ParallelType NumericVector< T >::_type [protected, inherited] |
Type of vector
Definition at line 601 of file numeric_vector.h.
Referenced by DistributedVector< T >::DistributedVector(), EpetraVector< T >::EpetraVector(), EpetraVector< T >::init(), PetscVector< T >::init(), LaspackVector< T >::init(), DistributedVector< T >::init(), LaspackVector< T >::LaspackVector(), PetscVector< T >::operator=(), PetscVector< T >::PetscVector(), NumericVector< T >::swap(), and NumericVector< Real >::type().
std::vector<T> DistributedVector< T >::_values [private] |
Actual vector datatype to hold vector entries
Definition at line 439 of file distributed_vector.h.
Referenced by DistributedVector< T >::abs(), DistributedVector< T >::add(), DistributedVector< T >::add_vector(), DistributedVector< T >::clear(), DistributedVector< T >::dot(), DistributedVector< T >::first_local_index(), DistributedVector< T >::init(), DistributedVector< T >::insert(), DistributedVector< T >::l1_norm(), DistributedVector< T >::l2_norm(), DistributedVector< T >::last_local_index(), DistributedVector< T >::linfty_norm(), DistributedVector< T >::local_size(), DistributedVector< T >::localize(), DistributedVector< T >::localize_to_one(), DistributedVector< T >::max(), DistributedVector< T >::min(), DistributedVector< T >::operator()(), DistributedVector< T >::operator+=(), DistributedVector< T >::operator-=(), DistributedVector< T >::operator=(), DistributedVector< T >::scale(), DistributedVector< T >::set(), DistributedVector< T >::size(), DistributedVector< T >::sum(), DistributedVector< T >::swap(), and DistributedVector< T >::zero().
The documentation for this class was generated from the following files: