libMesh::DistributedVector< T > Class Template Reference

#include <distributed_vector.h>

Inheritance diagram for libMesh::DistributedVector< T >:

Public Member Functions

 DistributedVector (const Parallel::Communicator &comm, const ParallelType=AUTOMATIC)
 
 DistributedVector (const Parallel::Communicator &comm, const numeric_index_type n, const ParallelType ptype=AUTOMATIC)
 
 DistributedVector (const Parallel::Communicator &comm, const numeric_index_type n, const numeric_index_type n_local, const ParallelType ptype=AUTOMATIC)
 
 DistributedVector (const Parallel::Communicator &comm, 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 NumericVector< T > & operator/= (NumericVector< T > &v)
 
virtual void reciprocal ()
 
virtual void conjugate ()
 
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 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
 
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
 
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 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
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static AutoPtr< NumericVector
< T > > 
build (const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
 
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
 
const Parallel::Communicator_communicator
 

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
 

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
protectedinherited

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 Parallel::Communicator comm,
const ParallelType  ptype = AUTOMATIC 
)
inlineexplicit

Dummy-Constructor. Dimension=0

Definition at line 494 of file distributed_vector.h.

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

496  : NumericVector<T>(comm, ptype),
497  _global_size (0),
498  _local_size (0),
501 {
502  this->_type = ptype;
503 }
template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( const Parallel::Communicator comm,
const numeric_index_type  n,
const ParallelType  ptype = AUTOMATIC 
)
inlineexplicit

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

Definition at line 509 of file distributed_vector.h.

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

512  : NumericVector<T>(comm, ptype)
513 {
514  this->init(n, n, false, ptype);
515 }
template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( const Parallel::Communicator comm,
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 521 of file distributed_vector.h.

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

525  : NumericVector<T>(comm, ptype)
526 {
527  this->init(n, n_local, false, ptype);
528 }
template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( const Parallel::Communicator comm,
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 534 of file distributed_vector.h.

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

539  : NumericVector<T>(comm, ptype)
540 {
541  this->init(n, n_local, ghost, false, ptype);
542 }
template<typename T >
libMesh::DistributedVector< T >::~DistributedVector ( )
inline

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

Definition at line 548 of file distributed_vector.h.

549 {
550  this->clear ();
551 }

Member Function Documentation

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

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

Implements libMesh::NumericVector< T >.

Definition at line 367 of file distributed_vector.C.

References std::abs(), libMesh::initialized(), and libMesh::libmesh_assert().

368 {
369  libmesh_assert (this->initialized());
370  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
371 
372  for (std::size_t i=0; i<local_size(); i++)
373  this->set(i,std::abs(_values[i]));
374 }
template<typename T >
void libMesh::DistributedVector< T >::add ( const numeric_index_type  i,
const T  value 
)
inlinevirtual

v(i) += value

Implements libMesh::NumericVector< T >.

Definition at line 833 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

834 {
835  libmesh_assert (this->initialized());
836  libmesh_assert_equal_to (_values.size(), _local_size);
837  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
838  libmesh_assert_less (i, size());
839  libmesh_assert_less (i-first_local_index(), local_size());
840 
841  _values[i - _first_local_index] += value;
842 }
template<typename T >
void libMesh::DistributedVector< T >::add ( const T  s)
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 258 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

259 {
260  libmesh_assert (this->initialized());
261  libmesh_assert_equal_to (_values.size(), _local_size);
262  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
263 
264  for (numeric_index_type i=0; i<local_size(); i++)
265  _values[i] += v;
266 }
template<typename T >
void libMesh::DistributedVector< T >::add ( const NumericVector< T > &  V)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 271 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

272 {
273  libmesh_assert (this->initialized());
274  libmesh_assert_equal_to (_values.size(), _local_size);
275  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
276 
277  add (1., v);
278 }
template<typename T >
void libMesh::DistributedVector< T >::add ( const T  a,
const NumericVector< T > &  v 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 283 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

284 {
285  libmesh_assert (this->initialized());
286  libmesh_assert_equal_to (_values.size(), _local_size);
287  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
288 
289  add(a, v);
290 }
template<typename T >
void libMesh::DistributedVector< T >::add_vector ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
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 182 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

184 {
185  libmesh_assert (!v.empty());
186  libmesh_assert_equal_to (v.size(), dof_indices.size());
187  libmesh_assert (this->initialized());
188  libmesh_assert_equal_to (_values.size(), _local_size);
189  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
190 
191  for (std::size_t i=0; i<v.size(); i++)
192  add (dof_indices[i], v[i]);
193 }
template<typename T >
void libMesh::DistributedVector< T >::add_vector ( const NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 198 of file distributed_vector.C.

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

200 {
201  libmesh_assert_equal_to (V.size(), dof_indices.size());
202  libmesh_assert (this->initialized());
203  libmesh_assert_equal_to (_values.size(), _local_size);
204  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
205 
206  for (std::size_t i=0; i<V.size(); i++)
207  add (dof_indices[i], V(i));
208 }
template<typename T>
void libMesh::DistributedVector< T >::add_vector ( const NumericVector< T > &  ,
const SparseMatrix< T > &   
)
inlinevirtual

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

Implements libMesh::NumericVector< T >.

Definition at line 339 of file distributed_vector.h.

341  { libmesh_error(); }
template<typename T >
void libMesh::DistributedVector< T >::add_vector ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
)
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 213 of file distributed_vector.C.

References libMesh::initialized(), libMesh::libmesh_assert(), and libMesh::DenseVector< T >::size().

215 {
216  libmesh_assert_equal_to (V.size(), dof_indices.size());
217  libmesh_assert (this->initialized());
218  libmesh_assert_equal_to (_values.size(), _local_size);
219  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
220 
221  for (unsigned int i=0; i<V.size(); i++)
222  add (dof_indices[i], V(i));
223 }
template<typename T>
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  a 
)
inherited

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

Definition at line 380 of file numeric_vector.C.

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

382 {
383  a.vector_mult_add(*this,v);
384 }
template<typename T>
void libMesh::DistributedVector< T >::add_vector_transpose ( const NumericVector< T > &  ,
const SparseMatrix< T > &   
)
inlinevirtual

$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.

Implements libMesh::NumericVector< T >.

Definition at line 358 of file distributed_vector.h.

360  { libmesh_error(); }
template<typename T >
AutoPtr< NumericVector< T > > libMesh::NumericVector< T >::build ( const Parallel::Communicator comm,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
staticinherited

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

Definition at line 46 of file numeric_vector.C.

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

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::System::add_vector(), libMesh::NumericVector< T >::build(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::calculate_norm(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EquationSystems::get_solution(), and libMesh::System::project_vector().

47 {
48  // Build the appropriate vector
49  switch (solver_package)
50  {
51 
52 
53 #ifdef LIBMESH_HAVE_LASPACK
54  case LASPACK_SOLVERS:
55  {
56  AutoPtr<NumericVector<T> > ap(new LaspackVector<T>(comm, AUTOMATIC));
57  return ap;
58  }
59 #endif
60 
61 
62 #ifdef LIBMESH_HAVE_PETSC
63  case PETSC_SOLVERS:
64  {
65  AutoPtr<NumericVector<T> > ap(new PetscVector<T>(comm, AUTOMATIC));
66  return ap;
67  }
68 #endif
69 
70 
71 #ifdef LIBMESH_HAVE_TRILINOS
72  case TRILINOS_SOLVERS:
73  {
74  AutoPtr<NumericVector<T> > ap(new EpetraVector<T>(comm, AUTOMATIC));
75  return ap;
76  }
77 #endif
78 
79 
80 #ifdef LIBMESH_HAVE_EIGEN
81  case EIGEN_SOLVERS:
82  {
83  AutoPtr<NumericVector<T> > ap(new EigenSparseVector<T>(comm, AUTOMATIC));
84  return ap;
85  }
86 #endif
87 
88 
89  default:
90  AutoPtr<NumericVector<T> > ap(new DistributedVector<T>(comm, AUTOMATIC));
91  return ap;
92 
93  }
94 
95  AutoPtr<NumericVector<T> > ap(NULL);
96  return ap;
97 }
template<typename T >
AutoPtr< NumericVector< T > > libMesh::NumericVector< T >::build ( const SolverPackage  solver_package = libMesh::default_solver_package())
staticinherited

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

Definition at line 103 of file numeric_vector.C.

References libMesh::NumericVector< T >::build(), and libMesh::CommWorld.

104 {
105  libmesh_deprecated();
106  return NumericVector<T>::build(CommWorld, solver_package);
107 }
template<typename T >
void libMesh::DistributedVector< T >::clear ( )
inlinevirtual
Returns
the DistributedVector to a pristine state.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 689 of file distributed_vector.h.

References libMesh::libMeshPrivateData::_is_initialized.

690 {
691  _values.clear();
692 
693  _global_size =
694  _local_size =
696  _last_local_index = 0;
697 
698 
699  this->_is_closed = this->_is_initialized = false;
700 }
template<typename T >
AutoPtr< NumericVector< T > > libMesh::DistributedVector< T >::clone ( ) const
inlinevirtual

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

Implements libMesh::NumericVector< T >.

Definition at line 735 of file distributed_vector.h.

References libMesh::comm.

736 {
737  AutoPtr<NumericVector<T> > cloned_vector
738  (new DistributedVector<T>(this->comm()));
739 
740  cloned_vector->init(*this, true);
741 
742  *cloned_vector = *this;
743 
744  return cloned_vector;
745 }
template<typename T >
void libMesh::DistributedVector< T >::close ( )
inlinevirtual

Call the assemble functions

Implements libMesh::NumericVector< T >.

Definition at line 678 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

679 {
680  libmesh_assert (this->initialized());
681 
682  this->_is_closed = true;
683 }
template<typename T>
virtual bool libMesh::NumericVector< T >::closed ( ) const
inlinevirtualinherited
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 86 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _communicator; }
template<typename T>
int libMesh::NumericVector< T >::compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtualinherited
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 112 of file numeric_vector.C.

References std::abs(), libMesh::comm, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), and std::max().

114 {
115  libmesh_assert (this->initialized());
116  libmesh_assert (other_vector.initialized());
117  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
118  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
119 
120  int first_different_i = std::numeric_limits<int>::max();
122 
123  do
124  {
125  if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
126  first_different_i = i;
127  else
128  i++;
129  }
130  while (first_different_i==std::numeric_limits<int>::max()
131  && i<last_local_index());
132 
133  // Find the correct first differing index in parallel
134  this->comm().min(first_different_i);
135 
136  if (first_different_i == std::numeric_limits<int>::max())
137  return -1;
138 
139  return first_different_i;
140 }
template<typename T >
void libMesh::DistributedVector< T >::conjugate ( )
virtual

Replace each entry v_i = real(v_i) + imag(v_i) of this vector by its complex conjugate, real(v_i) - imag(v_i)

Implements libMesh::NumericVector< T >.

Definition at line 244 of file distributed_vector.C.

References libMesh::libmesh_conj().

245 {
246  for (numeric_index_type i=0; i<local_size(); i++)
247  {
248  // Replace values by complex conjugate
249  _values[i] = libmesh_conj(_values[i]);
250  }
251 }
template<typename T>
virtual void libMesh::NumericVector< T >::create_subvector ( NumericVector< T > &  ,
const std::vector< numeric_index_type > &   
) const
inlinevirtualinherited

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

Definition at line 637 of file numeric_vector.h.

639  {
640  libMesh::err << "ERROR: Not Implemented in base class yet!" << std::endl;
641  libmesh_error();
642  }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
template<typename T >
T libMesh::DistributedVector< T >::dot ( const NumericVector< T > &  V) const
virtual

Computes the dot product, p = U.V

Implements libMesh::NumericVector< T >.

Definition at line 381 of file distributed_vector.C.

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

382 {
383  // This function must be run on all processors at once
384  parallel_object_only();
385 
386  // Make sure the NumericVector passed in is really a DistributedVector
387  const DistributedVector<T>* v = libmesh_cast_ptr<const DistributedVector<T>*>(&V);
388 
389  // Make sure that the two vectors are distributed in the same way.
390  libmesh_assert_equal_to ( this->first_local_index(), v->first_local_index() );
391  libmesh_assert_equal_to ( this->last_local_index(), v->last_local_index() );
392 
393  // The result of dotting together the local parts of the vector.
394  T local_dot = 0;
395 
396  for (std::size_t i=0; i<this->local_size(); i++)
397  local_dot += this->_values[i] * v->_values[i];
398 
399  // The local dot products are now summed via MPI
400  this->comm().sum(local_dot);
401 
402  return local_dot;
403 }
template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i) const
inlinevirtualinherited
Returns
the element U(i)

Definition at line 342 of file numeric_vector.h.

342 { return (*this)(i); }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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.

101 {
102  _enable_print_counter = true;
103  return;
104 }
template<typename T >
numeric_index_type libMesh::DistributedVector< T >::first_local_index ( ) const
inlinevirtual
Returns
the index of the first vector element actually stored on this processor

Implements libMesh::NumericVector< T >.

Definition at line 777 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

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

778 {
779  libmesh_assert (this->initialized());
780  libmesh_assert_equal_to (_values.size(), _local_size);
781  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
782 
783  return _first_local_index;
784 }
template<typename T>
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
std::vector< T > &  values 
) const
inlinevirtualinherited

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

Referenced by libMesh::FEMContext::pre_fe_reinit().

798 {
799  const std::size_t num = index.size();
800  values.resize(num);
801  for(std::size_t i=0; i<num; i++)
802  {
803  values[i] = (*this)(index[i]);
804  }
805 }
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

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().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
template<typename T>
int libMesh::NumericVector< T >::global_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtualinherited
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 177 of file numeric_vector.C.

References std::abs(), libMesh::comm, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::linfty_norm(), std::max(), and libMesh::Real.

179 {
180  libmesh_assert (this->initialized());
181  libmesh_assert (other_vector.initialized());
182  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
183  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
184 
185  int first_different_i = std::numeric_limits<int>::max();
187 
188  const Real my_norm = this->linfty_norm();
189  const Real other_norm = other_vector.linfty_norm();
190  const Real abs_threshold = std::max(my_norm, other_norm) * threshold;
191 
192  do
193  {
194  if ( std::abs( (*this)(i) - other_vector(i) ) > abs_threshold )
195  first_different_i = i;
196  else
197  i++;
198  }
199  while (first_different_i==std::numeric_limits<int>::max()
200  && i<last_local_index());
201 
202  // Find the correct first differing index in parallel
203  this->comm().min(first_different_i);
204 
205  if (first_different_i == std::numeric_limits<int>::max())
206  return -1;
207 
208  return first_different_i;
209 }
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

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, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

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

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

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, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

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

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
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 
)
inlinevirtual

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 557 of file distributed_vector.h.

References libMesh::libMeshPrivateData::_is_initialized, libMeshEnums::AUTOMATIC, libMesh::comm, libMesh::err, libMesh::initialized(), libMesh::libmesh_assert(), libMesh::n_local, libMesh::n_processors(), libMeshEnums::PARALLEL, libMesh::processor_id(), libMeshEnums::SERIAL, and libMesh::zero.

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

561 {
562  // This function must be run on all processors at once
563  parallel_object_only();
564 
565  libmesh_assert_less_equal (n_local, n);
566 
567  if (ptype == AUTOMATIC)
568  {
569  if (n == n_local)
570  this->_type = SERIAL;
571  else
572  this->_type = PARALLEL;
573  }
574  else
575  this->_type = ptype;
576 
577  libmesh_assert ((this->_type==SERIAL && n==n_local) ||
578  this->_type==PARALLEL);
579 
580  // Clear the data structures if already initialized
581  if (this->initialized())
582  this->clear();
583 
584  // Initialize data structures
585  _values.resize(n_local);
587  _global_size = n;
588 
589  _first_local_index = 0;
590 
591 #ifdef LIBMESH_HAVE_MPI
592 
593  std::vector<numeric_index_type> local_sizes (this->n_processors(), 0);
594 
595  local_sizes[this->processor_id()] = n_local;
596 
597  this->comm().sum(local_sizes);
598 
599  // _first_local_index is the sum of _local_size
600  // for all processor ids less than ours
601  for (processor_id_type p=0; p!=this->processor_id(); p++)
602  _first_local_index += local_sizes[p];
603 
604 
605 # ifdef DEBUG
606  // Make sure all the local sizes sum up to the global
607  // size, otherwise there is big trouble!
608  numeric_index_type dbg_sum=0;
609 
610  for (processor_id_type p=0; p!=this->n_processors(); p++)
611  dbg_sum += local_sizes[p];
612 
613  libmesh_assert_equal_to (dbg_sum, n);
614 
615 # endif
616 
617 #else
618 
619  // No other options without MPI!
620  if (n != n_local)
621  {
622  libMesh::err << "ERROR: MPI is required for n != n_local!"
623  << std::endl;
624  libmesh_error();
625  }
626 
627 #endif
628 
630 
631  // Set the initialized flag
632  this->_is_initialized = true;
633 
634  // Zero the components unless directed otherwise
635  if (!fast)
636  this->zero();
637 }
template<typename T >
void libMesh::DistributedVector< T >::init ( const numeric_index_type  N,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
inlinevirtual

call init with n_local = N,

Implements libMesh::NumericVector< T >.

Definition at line 667 of file distributed_vector.h.

References libMesh::TriangleWrapper::init().

670 {
671  this->init(n,n,fast,ptype);
672 }
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 
)
inlinevirtual

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

Implements libMesh::NumericVector< T >.

Definition at line 642 of file distributed_vector.h.

References libMesh::TriangleWrapper::init().

647 {
648  // TODO: we shouldn't ignore the ghost sparsity pattern
649  this->init(n, n_local, fast, ptype);
650 }
template<class T >
void libMesh::DistributedVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 657 of file distributed_vector.h.

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

659 {
660  this->init(other.size(),other.local_size(),fast,other.type());
661 }
template<typename T>
virtual bool libMesh::NumericVector< T >::initialized ( ) const
inlinevirtualinherited
template<typename T >
void libMesh::DistributedVector< T >::insert ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 295 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

297 {
298  libmesh_assert (!v.empty());
299  libmesh_assert_equal_to (v.size(), dof_indices.size());
300  libmesh_assert (this->initialized());
301  libmesh_assert_equal_to (_values.size(), _local_size);
302  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
303 
304  for (std::size_t i=0; i<v.size(); i++)
305  this->set (dof_indices[i], v[i]);
306 }
template<typename T >
void libMesh::DistributedVector< T >::insert ( const NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 311 of file distributed_vector.C.

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

313 {
314  libmesh_assert_equal_to (V.size(), dof_indices.size());
315  libmesh_assert (this->initialized());
316  libmesh_assert_equal_to (_values.size(), _local_size);
317  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
318 
319  for (std::size_t i=0; i<V.size(); i++)
320  this->set (dof_indices[i], V(i));
321 }
template<typename T >
void libMesh::DistributedVector< T >::insert ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
)
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 326 of file distributed_vector.C.

References libMesh::initialized(), libMesh::libmesh_assert(), and libMesh::DenseVector< T >::size().

328 {
329  libmesh_assert_equal_to (V.size(), dof_indices.size());
330  libmesh_assert (this->initialized());
331  libmesh_assert_equal_to (_values.size(), _local_size);
332  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
333 
334  for (unsigned int i=0; i<V.size(); i++)
335  this->set (dof_indices[i], V(i));
336 }
template<typename T >
void libMesh::DistributedVector< T >::insert ( const DenseSubVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
)
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 341 of file distributed_vector.C.

References libMesh::initialized(), libMesh::libmesh_assert(), and libMesh::DenseVectorBase< T >::size().

343 {
344  libmesh_assert_equal_to (V.size(), dof_indices.size());
345  libmesh_assert (this->initialized());
346  libmesh_assert_equal_to (_values.size(), _local_size);
347  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
348 
349  for (unsigned int i=0; i<V.size(); i++)
350  this->set (dof_indices[i], V(i));
351 }
template<typename T >
Real libMesh::DistributedVector< T >::l1_norm ( ) const
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 std::abs(), libMesh::comm, libMesh::initialized(), and libMesh::libmesh_assert().

65 {
66  // This function must be run on all processors at once
67  parallel_object_only();
68 
69  libmesh_assert (this->initialized());
70  libmesh_assert_equal_to (_values.size(), _local_size);
71  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
72 
73  double local_l1 = 0.;
74 
75  for (numeric_index_type i=0; i<local_size(); i++)
76  local_l1 += std::abs(_values[i]);
77 
78  this->comm().sum(local_l1);
79 
80  return local_l1;
81 }
template<typename T >
Real libMesh::DistributedVector< T >::l2_norm ( ) const
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::comm, libMesh::initialized(), libMesh::libmesh_assert(), and libMesh::TensorTools::norm_sq().

87 {
88  // This function must be run on all processors at once
89  parallel_object_only();
90 
91  libmesh_assert (this->initialized());
92  libmesh_assert_equal_to (_values.size(), _local_size);
93  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
94 
95  double local_l2 = 0.;
96 
97  for (numeric_index_type i=0; i<local_size(); i++)
98  local_l2 += TensorTools::norm_sq(_values[i]);
99 
100  this->comm().sum(local_l2);
101 
102  return std::sqrt(local_l2);
103 }
template<typename T >
numeric_index_type libMesh::DistributedVector< T >::last_local_index ( ) const
inlinevirtual
Returns
the index of the last vector element actually stored on this processor

Implements libMesh::NumericVector< T >.

Definition at line 790 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

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

791 {
792  libmesh_assert (this->initialized());
793  libmesh_assert_equal_to (_values.size(), _local_size);
794  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
795 
796  return _last_local_index;
797 }
template<typename T >
Real libMesh::DistributedVector< T >::linfty_norm ( ) const
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 std::abs(), libMesh::comm, libMesh::initialized(), libMesh::libmesh_assert(), std::max(), and libMesh::Real.

109 {
110  // This function must be run on all processors at once
111  parallel_object_only();
112 
113  libmesh_assert (this->initialized());
114  libmesh_assert_equal_to (_values.size(), _local_size);
115  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
116 
117  Real local_linfty = 0.;
118 
119  for (numeric_index_type i=0; i<local_size(); i++)
120  local_linfty = std::max(local_linfty,
121  static_cast<Real>(std::abs(_values[i]))
122  ); // Note we static_cast so that both
123  // types are the same, as required
124  // by std::max
125 
126  this->comm().max(local_linfty);
127 
128  return local_linfty;
129 }
template<typename T>
int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtualinherited
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 144 of file numeric_vector.C.

References std::abs(), libMesh::comm, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), and std::max().

146 {
147  libmesh_assert (this->initialized());
148  libmesh_assert (other_vector.initialized());
149  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
150  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
151 
152  int first_different_i = std::numeric_limits<int>::max();
154 
155  do
156  {
157  if ( std::abs( (*this)(i) - other_vector(i) ) > threshold *
158  std::max(std::abs((*this)(i)), std::abs(other_vector(i))))
159  first_different_i = i;
160  else
161  i++;
162  }
163  while (first_different_i==std::numeric_limits<int>::max()
164  && i<last_local_index());
165 
166  // Find the correct first differing index in parallel
167  this->comm().min(first_different_i);
168 
169  if (first_different_i == std::numeric_limits<int>::max())
170  return -1;
171 
172  return first_different_i;
173 }
template<typename T >
numeric_index_type libMesh::DistributedVector< T >::local_size ( ) const
inlinevirtual
Returns
the local size of the vector (index_stop-index_start)

Implements libMesh::NumericVector< T >.

Definition at line 764 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

Referenced by libMesh::DistributedVector< T >::operator=().

765 {
766  libmesh_assert (this->initialized());
767  libmesh_assert_equal_to (_values.size(), _local_size);
768  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
769 
770  return _local_size;
771 }
template<typename T >
void libMesh::DistributedVector< T >::localize ( std::vector< T > &  v_local) const
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 572 of file distributed_vector.C.

References libMesh::comm, libMesh::initialized(), and libMesh::libmesh_assert().

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

573 {
574  // This function must be run on all processors at once
575  parallel_object_only();
576 
577  libmesh_assert (this->initialized());
578  libmesh_assert_equal_to (_values.size(), _local_size);
579  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
580 
581  v_local = this->_values;
582 
583  this->comm().allgather (v_local);
584 
585 #ifndef LIBMESH_HAVE_MPI
586  libmesh_assert_equal_to (local_size(), size());
587 #endif
588 }
template<typename T >
void libMesh::DistributedVector< T >::localize ( NumericVector< T > &  v_local) const
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 490 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::initialized(), and libMesh::libmesh_assert().

492 {
493  libmesh_assert (this->initialized());
494  libmesh_assert_equal_to (_values.size(), _local_size);
495  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
496 
497  DistributedVector<T>* v_local = libmesh_cast_ptr<DistributedVector<T>*>(&v_local_in);
498 
499  v_local->_first_local_index = 0;
500 
501  v_local->_global_size =
502  v_local->_local_size =
503  v_local->_last_local_index = size();
504 
505  v_local->_is_initialized =
506  v_local->_is_closed = true;
507 
508  // Call localize on the vector's values. This will help
509  // prevent code duplication
510  localize (v_local->_values);
511 
512 #ifndef LIBMESH_HAVE_MPI
513 
514  libmesh_assert_equal_to (local_size(), size());
515 
516 #endif
517 }
template<typename T >
void libMesh::DistributedVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 522 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

524 {
525  libmesh_assert (this->initialized());
526  libmesh_assert_equal_to (_values.size(), _local_size);
527  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
528 
529  // TODO: We don't yet support the send list; this is inefficient:
530  localize (v_local_in);
531 }
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 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 536 of file distributed_vector.C.

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

539 {
540  // Only good for serial vectors
541  libmesh_assert_equal_to (this->size(), this->local_size());
542  libmesh_assert_greater (last_local_idx, first_local_idx);
543  libmesh_assert_less_equal (send_list.size(), this->size());
544  libmesh_assert_less (last_local_idx, this->size());
545 
546  const numeric_index_type my_size = this->size();
547  const numeric_index_type my_local_size = (last_local_idx - first_local_idx + 1);
548 
549  // Don't bother for serial cases
550  if ((first_local_idx == 0) &&
551  (my_local_size == my_size))
552  return;
553 
554 
555  // Build a parallel vector, initialize it with the local
556  // parts of (*this)
557  DistributedVector<T> parallel_vec(this->comm());
558 
559  parallel_vec.init (my_size, my_local_size, true, PARALLEL);
560 
561  // Copy part of *this into the parallel_vec
562  for (numeric_index_type i=first_local_idx; i<=last_local_idx; i++)
563  parallel_vec._values[i-first_local_idx] = _values[i];
564 
565  // localize like normal
566  parallel_vec.localize (*this, send_list);
567 }
template<typename T >
void libMesh::DistributedVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const
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 593 of file distributed_vector.C.

References libMesh::comm, libMesh::initialized(), and libMesh::libmesh_assert().

595 {
596  // This function must be run on all processors at once
597  parallel_object_only();
598 
599  libmesh_assert (this->initialized());
600  libmesh_assert_equal_to (_values.size(), _local_size);
601  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
602 
603  v_local = this->_values;
604 
605  this->comm().gather (pid, v_local);
606 
607 #ifndef LIBMESH_HAVE_MPI
608  libmesh_assert_equal_to (local_size(), size());
609 #endif
610 }
template<typename T >
Real libMesh::DistributedVector< T >::max ( ) const
inlinevirtual
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 871 of file distributed_vector.h.

References libMesh::comm, libMesh::initialized(), libMesh::libmesh_assert(), libMesh::libmesh_real(), std::max(), and libMesh::Real.

872 {
873  // This function must be run on all processors at once
874  parallel_object_only();
875 
876  libmesh_assert (this->initialized());
877  libmesh_assert_equal_to (_values.size(), _local_size);
878  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
879 
880  Real local_max = _values.size() ?
881  libmesh_real(_values[0]) : -std::numeric_limits<Real>::max();
882  for (numeric_index_type i = 1; i < _values.size(); ++i)
883  local_max = std::max(libmesh_real(_values[i]), local_max);
884 
885  this->comm().max(local_max);
886 
887  return local_max;
888 }
template<typename T >
Real libMesh::DistributedVector< T >::min ( ) const
inlinevirtual
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 848 of file distributed_vector.h.

References libMesh::comm, libMesh::initialized(), libMesh::libmesh_assert(), libMesh::libmesh_real(), std::max(), std::min(), and libMesh::Real.

849 {
850  // This function must be run on all processors at once
851  parallel_object_only();
852 
853  libmesh_assert (this->initialized());
854  libmesh_assert_equal_to (_values.size(), _local_size);
855  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
856 
857  Real local_min = _values.size() ?
858  libmesh_real(_values[0]) : std::numeric_limits<Real>::max();
859  for (numeric_index_type i = 1; i < _values.size(); ++i)
860  local_min = std::min(libmesh_real(_values[i]), local_min);
861 
862  this->comm().min(local_min);
863 
864  return local_min;
865 }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

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.

80  { return _n_objects; }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
template<typename T >
T libMesh::DistributedVector< T >::operator() ( const numeric_index_type  i) const
inlinevirtual

Access components, returns U(i).

Implements libMesh::NumericVector< T >.

Definition at line 803 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

804 {
805  libmesh_assert (this->initialized());
806  libmesh_assert_equal_to (_values.size(), _local_size);
807  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
808  libmesh_assert ( ((i >= first_local_index()) &&
809  (i < last_local_index())) );
810 
811  return _values[i - _first_local_index];
812 }
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a)
inlineinherited

Multiplication operator. Equivalent to U.scale(a)

Definition at line 368 of file numeric_vector.h.

368 { this->scale(a); return *this; }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator+= ( const NumericVector< T > &  V)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 134 of file distributed_vector.C.

References libMesh::closed(), libMesh::initialized(), and libMesh::libmesh_assert().

135 {
136  libmesh_assert (this->closed());
137  libmesh_assert (this->initialized());
138  libmesh_assert_equal_to (_values.size(), _local_size);
139  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
140 
141  add(1., v);
142 
143  return *this;
144 }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator-= ( const NumericVector< T > &  V)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 149 of file distributed_vector.C.

References libMesh::closed(), libMesh::initialized(), and libMesh::libmesh_assert().

150 {
151  libmesh_assert (this->closed());
152  libmesh_assert (this->initialized());
153  libmesh_assert_equal_to (_values.size(), _local_size);
154  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
155 
156  add(-1., v);
157 
158  return *this;
159 }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator/= ( NumericVector< T > &  v)
virtual

Pointwise Division operator. ie divide every entry in this vector by the entry in v

Implements libMesh::NumericVector< T >.

Definition at line 164 of file distributed_vector.C.

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

165 {
166  libmesh_assert_equal_to(size(), v.size());
167 
168  DistributedVector<T> & v_vec = libmesh_cast_ref<DistributedVector<T>&>(v);
169 
170  std::size_t size = _values.size();
171 
172  for(std::size_t i=0; i<size; i++)
173  _values[i] = _values[i] / v_vec._values[i];
174 
175  return *this;
176 }
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const T  a)
inlineinherited

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

Definition at line 374 of file numeric_vector.h.

374 { this->scale(1./a); return *this; }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const T  s)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 409 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

410 {
411  libmesh_assert (this->initialized());
412  libmesh_assert_equal_to (_values.size(), _local_size);
413  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
414 
415  for (std::size_t i=0; i<local_size(); i++)
416  _values[i] = s;
417 
418  return *this;
419 }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const NumericVector< T > &  V)
virtual

$U = V$: copy all components.

Implements libMesh::NumericVector< T >.

Definition at line 425 of file distributed_vector.C.

426 {
427  // Make sure the NumericVector passed in is really a DistributedVector
428  const DistributedVector<T>* v = libmesh_cast_ptr<const DistributedVector<T>*>(&v_in);
429 
430  *this = *v;
431 
432  return *this;
433 }
template<typename T >
DistributedVector< T > & libMesh::DistributedVector< T >::operator= ( const DistributedVector< T > &  V)

$U = V$: copy all components.

Definition at line 439 of file distributed_vector.C.

References libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::NumericVector< T >::_is_closed, libMesh::libMeshPrivateData::_is_initialized, 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().

440 {
441  this->_is_initialized = v._is_initialized;
442  this->_is_closed = v._is_closed;
443 
444  _global_size = v._global_size;
445  _local_size = v._local_size;
446  _first_local_index = v._first_local_index;
447  _last_local_index = v._last_local_index;
448 
449  if (v.local_size() == this->local_size())
450  {
451  _values = v._values;
452  }
453  else
454  {
455  libmesh_error();
456  }
457 
458  return *this;
459 }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const std::vector< T > &  v)
virtual

$U = V$: copy all components.

Implements libMesh::NumericVector< T >.

Definition at line 465 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

466 {
467  libmesh_assert (this->initialized());
468  libmesh_assert_equal_to (_values.size(), _local_size);
469  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
470 
471  if (v.size() == local_size())
472  _values = v;
473 
474  else if (v.size() == size())
475  for (std::size_t i=first_local_index(); i<last_local_index(); i++)
476  _values[i-first_local_index()] = v[i];
477 
478  else
479  {
480  libmesh_error();
481  }
482 
483 
484  return *this;
485 }
template<typename T >
void libMesh::DistributedVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 615 of file distributed_vector.C.

619 {
620  libmesh_not_implemented();
621 }
template<typename T >
void libMesh::NumericVector< T >::print ( std::ostream &  os = libMesh::out) const
inlinevirtualinherited

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

Definition at line 832 of file numeric_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

833 {
834  libmesh_assert (this->initialized());
835  os << "Size\tglobal = " << this->size()
836  << "\t\tlocal = " << this->local_size() << std::endl;
837 
838  os << "#\tValue" << std::endl;
839  for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
840  os << i << "\t" << (*this)(i) << std::endl;
841 }
template<>
void libMesh::NumericVector< Complex >::print ( std::ostream &  os) const
inlineinherited

Definition at line 814 of file numeric_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

815 {
816  libmesh_assert (this->initialized());
817  os << "Size\tglobal = " << this->size()
818  << "\t\tlocal = " << this->local_size() << std::endl;
819 
820  // std::complex<>::operator<<() is defined, but use this form
821  os << "#\tReal part\t\tImaginary part" << std::endl;
822  for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
823  os << i << "\t"
824  << (*this)(i).real() << "\t\t"
825  << (*this)(i).imag() << std::endl;
826 }
template<typename T >
void libMesh::NumericVector< T >::print_global ( std::ostream &  os = libMesh::out) const
inlinevirtualinherited

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

Definition at line 869 of file numeric_vector.h.

References libMesh::initialized(), libMesh::libmesh_assert(), and libMesh::processor_id().

870 {
871  libmesh_assert (this->initialized());
872 
873  std::vector<T> v(this->size());
874  this->localize(v);
875 
876  // Right now we only want one copy of the output
877  if (this->processor_id())
878  return;
879 
880  os << "Size\tglobal = " << this->size() << std::endl;
881  os << "#\tValue" << std::endl;
882  for (numeric_index_type i=0; i!=v.size(); i++)
883  os << i << "\t" << v[i] << std::endl;
884 }
template<>
void libMesh::NumericVector< Complex >::print_global ( std::ostream &  os) const
inlineinherited

Definition at line 847 of file numeric_vector.h.

References libMesh::initialized(), libMesh::libmesh_assert(), and libMesh::processor_id().

848 {
849  libmesh_assert (this->initialized());
850 
851  std::vector<Complex> v(this->size());
852  this->localize(v);
853 
854  // Right now we only want one copy of the output
855  if (this->processor_id())
856  return;
857 
858  os << "Size\tglobal = " << this->size() << std::endl;
859  os << "#\tReal part\t\tImaginary part" << std::endl;
860  for (numeric_index_type i=0; i!=v.size(); i++)
861  os << i << "\t"
862  << v[i].real() << "\t\t"
863  << v[i].imag() << std::endl;
864 }
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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().

89 {
91 }
template<typename T>
virtual void libMesh::NumericVector< T >::print_matlab ( const std::string  name = "NULL") const
inlinevirtualinherited

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

625  {
626  libMesh::err << "ERROR: Not Implemented in base class yet!" << std::endl;
627  libMesh::err << "ERROR writing MATLAB file " << name << std::endl;
628  libmesh_error();
629  }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 98 of file parallel_object.h.

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

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::DofMap::build_sparsity(), libMesh::ParallelMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
template<typename T >
void libMesh::DistributedVector< T >::reciprocal ( )
virtual

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

Implements libMesh::NumericVector< T >.

Definition at line 229 of file distributed_vector.C.

230 {
231  for (numeric_index_type i=0; i<local_size(); i++)
232  {
233  // Don't divide by zero
234  libmesh_assert_not_equal_to (_values[i], T(0));
235 
236  _values[i] = 1. / _values[i];
237  }
238 }
template<typename T >
void libMesh::DistributedVector< T >::scale ( const T  factor)
virtual

Scale each element of the vector by the given factor.

Implements libMesh::NumericVector< T >.

Definition at line 356 of file distributed_vector.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

357 {
358  libmesh_assert (this->initialized());
359  libmesh_assert_equal_to (_values.size(), _local_size);
360  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
361 
362  for (std::size_t i=0; i<local_size(); i++)
363  _values[i] *= factor;
364 }
template<typename T >
void libMesh::DistributedVector< T >::set ( const numeric_index_type  i,
const T  value 
)
inlinevirtual

v(i) = value

Implements libMesh::NumericVector< T >.

Definition at line 818 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

819 {
820  libmesh_assert (this->initialized());
821  libmesh_assert_equal_to (_values.size(), _local_size);
822  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
823  libmesh_assert_less (i, size());
824  libmesh_assert_less (i-first_local_index(), local_size());
825 
826  _values[i - _first_local_index] = value;
827 }
template<typename T >
numeric_index_type libMesh::DistributedVector< T >::size ( ) const
inlinevirtual
Returns
dimension of the vector. This function was formerly called n(), but was renamed to get the DistributedVector class closer to the C++ standard library's std::vector container.

Implements libMesh::NumericVector< T >.

Definition at line 751 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

Referenced by libMesh::DistributedVector< T >::operator/=().

752 {
753  libmesh_assert (this->initialized());
754  libmesh_assert_equal_to (_values.size(), _local_size);
755  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
756 
757  return _global_size;
758 }
template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices) const
virtualinherited
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 320 of file numeric_vector.C.

References std::abs(), libMesh::comm, and libMesh::Real.

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

321 {
322  const NumericVector<T> & v = *this;
323 
324  std::set<numeric_index_type>::const_iterator it = indices.begin();
325  const std::set<numeric_index_type>::const_iterator it_end = indices.end();
326 
327  Real norm = 0;
328 
329  for(; it!=it_end; ++it)
330  norm += std::abs(v(*it));
331 
332  this->comm().sum(norm);
333 
334  return norm;
335 }
template<class T >
Real libMesh::NumericVector< T >::subset_l2_norm ( const std::set< numeric_index_type > &  indices) const
virtualinherited
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 338 of file numeric_vector.C.

References libMesh::comm, libMesh::TensorTools::norm_sq(), and libMesh::Real.

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

339 {
340  const NumericVector<T> & v = *this;
341 
342  std::set<numeric_index_type>::const_iterator it = indices.begin();
343  const std::set<numeric_index_type>::const_iterator it_end = indices.end();
344 
345  Real norm = 0;
346 
347  for(; it!=it_end; ++it)
348  norm += TensorTools::norm_sq(v(*it));
349 
350  this->comm().sum(norm);
351 
352  return std::sqrt(norm);
353 }
template<class T >
Real libMesh::NumericVector< T >::subset_linfty_norm ( const std::set< numeric_index_type > &  indices) const
virtualinherited
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 356 of file numeric_vector.C.

References std::abs(), libMesh::comm, and libMesh::Real.

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

357 {
358  const NumericVector<T> & v = *this;
359 
360  std::set<numeric_index_type>::const_iterator it = indices.begin();
361  const std::set<numeric_index_type>::const_iterator it_end = indices.end();
362 
363  Real norm = 0;
364 
365  for(; it!=it_end; ++it)
366  {
367  Real value = std::abs(v(*it));
368  if(value > norm)
369  norm = value;
370  }
371 
372  this->comm().max(norm);
373 
374  return norm;
375 }
template<typename T >
T libMesh::DistributedVector< T >::sum ( ) const
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::comm, libMesh::initialized(), and libMesh::libmesh_assert().

43 {
44  // This function must be run on all processors at once
45  parallel_object_only();
46 
47  libmesh_assert (this->initialized());
48  libmesh_assert_equal_to (_values.size(), _local_size);
49  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
50 
51  T local_sum = 0.;
52 
53  for (numeric_index_type i=0; i<local_size(); i++)
54  local_sum += _values[i];
55 
56  this->comm().sum(local_sum);
57 
58  return local_sum;
59 }
template<typename T >
void libMesh::DistributedVector< T >::swap ( NumericVector< T > &  v)
inlinevirtual

Swaps the vector data and metadata

Reimplemented from libMesh::NumericVector< T >.

Definition at line 893 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, libMesh::DistributedVector< T >::_values, and swap().

894 {
895  DistributedVector<T>& v = libmesh_cast_ref<DistributedVector<T>&>(other);
896 
897  std::swap(_global_size, v._global_size);
898  std::swap(_local_size, v._local_size);
899  std::swap(_first_local_index, v._first_local_index);
900  std::swap(_last_local_index, v._last_local_index);
901 
902  // This should be O(1) with any reasonable STL implementation
903  std::swap(_values, v._values);
904 }
template<typename T>
ParallelType& libMesh::NumericVector< T >::type ( )
inlineinherited
Returns
the type (SERIAL, PARALLEL, GHOSTED) of the vector.

Definition at line 139 of file numeric_vector.h.

139 { return _type; }
template<typename T >
void libMesh::DistributedVector< T >::zero ( )
inlinevirtual

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

Implements libMesh::NumericVector< T >.

Definition at line 706 of file distributed_vector.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

707 {
708  libmesh_assert (this->initialized());
709  libmesh_assert_equal_to (_values.size(), _local_size);
710  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
711 
712  std::fill (_values.begin(),
713  _values.end(),
714  0.);
715 }
template<typename T >
AutoPtr< NumericVector< T > > libMesh::DistributedVector< T >::zero_clone ( ) const
inlinevirtual

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 721 of file distributed_vector.h.

References libMesh::comm.

722 {
723  AutoPtr<NumericVector<T> > cloned_vector
724  (new DistributedVector<T>(this->comm()));
725 
726  cloned_vector->init(*this);
727 
728  return cloned_vector;
729 }

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

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().

template<typename T>
numeric_index_type libMesh::DistributedVector< T >::_first_local_index
private
template<typename T>
bool libMesh::NumericVector< T >::_is_closed
protectedinherited

Flag to see if the Numeric assemble routines have been called yet

Definition at line 657 of file numeric_vector.h.

Referenced by libMesh::NumericVector< Number >::closed(), libMesh::DistributedVector< T >::localize(), and libMesh::DistributedVector< T >::operator=().

template<typename T>
bool libMesh::NumericVector< T >::_is_initialized
protectedinherited
template<typename T>
numeric_index_type libMesh::DistributedVector< T >::_last_local_index
private
Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

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
staticprotectedinherited

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().

template<typename T>
std::vector<T> libMesh::DistributedVector< T >::_values
private

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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:59 UTC

Hosted By:
SourceForge.net Logo