libMesh::EpetraVector< T > Class Template Reference

#include <trilinos_epetra_vector.h>

Inheritance diagram for libMesh::EpetraVector< T >:

Public Member Functions

 EpetraVector (const Parallel::Communicator &comm, const ParallelType type=AUTOMATIC)
 
 EpetraVector (const Parallel::Communicator &comm, const numeric_index_type n, const ParallelType type=AUTOMATIC)
 
 EpetraVector (const Parallel::Communicator &comm, const numeric_index_type n, const numeric_index_type n_local, const ParallelType type=AUTOMATIC)
 
 EpetraVector (const Parallel::Communicator &comm, const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType type=AUTOMATIC)
 
 EpetraVector (Epetra_Vector &v, const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
 
 ~EpetraVector ()
 
virtual void close () libmesh_override
 
virtual void clear () libmesh_override
 
virtual void zero () libmesh_override
 
virtual UniquePtr< NumericVector< T > > zero_clone () const libmesh_override
 
virtual UniquePtr< NumericVector< T > > clone () const libmesh_override
 
virtual void init (const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
 
virtual void init (const numeric_index_type N, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
 
virtual void init (const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const bool fast=false, const ParallelType=AUTOMATIC) libmesh_override
 
virtual void init (const NumericVector< T > &other, const bool fast=false) libmesh_override
 
virtual NumericVector< T > & operator= (const T s) libmesh_override
 
virtual NumericVector< T > & operator= (const NumericVector< T > &v) libmesh_override
 
EpetraVector< T > & operator= (const EpetraVector< T > &v)
 
virtual NumericVector< T > & operator= (const std::vector< T > &v) libmesh_override
 
virtual Real min () const libmesh_override
 
virtual Real max () const libmesh_override
 
virtual T sum () const libmesh_override
 
virtual Real l1_norm () const libmesh_override
 
virtual Real l2_norm () const libmesh_override
 
virtual Real linfty_norm () const libmesh_override
 
virtual numeric_index_type size () const libmesh_override
 
virtual numeric_index_type local_size () const libmesh_override
 
virtual numeric_index_type first_local_index () const libmesh_override
 
virtual numeric_index_type last_local_index () const libmesh_override
 
virtual T operator() (const numeric_index_type i) const libmesh_override
 
virtual NumericVector< T > & operator+= (const NumericVector< T > &v) libmesh_override
 
virtual NumericVector< T > & operator-= (const NumericVector< T > &v) libmesh_override
 
virtual NumericVector< T > & operator/= (NumericVector< T > &v) libmesh_override
 
virtual void reciprocal () libmesh_override
 
virtual void conjugate () libmesh_override
 
virtual void set (const numeric_index_type i, const T value) libmesh_override
 
virtual void add (const numeric_index_type i, const T value) libmesh_override
 
virtual void add (const T s) libmesh_override
 
virtual void add (const NumericVector< T > &v) libmesh_override
 
virtual void add (const T a, const NumericVector< T > &v) libmesh_override
 
virtual void add_vector (const T *v, const std::vector< numeric_index_type > &dof_indices) libmesh_override
 
virtual void add_vector (const NumericVector< T > &v, const SparseMatrix< T > &A) libmesh_override
 
virtual void add_vector_transpose (const NumericVector< T > &v, const SparseMatrix< T > &A) libmesh_override
 
virtual void insert (const T *v, const std::vector< numeric_index_type > &dof_indices) libmesh_override
 
virtual void scale (const T factor) libmesh_override
 
virtual void abs () libmesh_override
 
virtual T dot (const NumericVector< T > &v) const libmesh_override
 
virtual void localize (std::vector< T > &v_local) const libmesh_override
 
virtual void localize (NumericVector< T > &v_local) const libmesh_override
 
virtual void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const libmesh_override
 
virtual void localize (std::vector< T > &v_local, const std::vector< numeric_index_type > &indices) const libmesh_override
 
virtual void localize (const numeric_index_type first_local_idx, const numeric_index_type last_local_idx, const std::vector< numeric_index_type > &send_list) libmesh_override
 
virtual void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const libmesh_override
 
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2) libmesh_override
 
virtual void create_subvector (NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows) const libmesh_override
 
virtual void swap (NumericVector< T > &v) libmesh_override
 
Epetra_Vector * vec ()
 
virtual bool initialized () const
 
ParallelType type () const
 
ParallelTypetype ()
 
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, T *values) const
 
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 std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 
virtual void add_vector (const NumericVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 
void add_vector (const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 
void add_vector (const NumericVector< T > &v, const ShellMatrix< T > &A)
 
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)
 
void insert (const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 
void insert (const DenseSubVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 
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 &="") const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

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

int SumIntoGlobalValues (int numIDs, const int *GIDs, const double *values)
 
int SumIntoGlobalValues (const Epetra_IntSerialDenseVector &GIDs, const Epetra_SerialDenseVector &values)
 
int ReplaceGlobalValues (int numIDs, const int *GIDs, const double *values)
 
int ReplaceGlobalValues (const Epetra_IntSerialDenseVector &GIDs, const Epetra_SerialDenseVector &values)
 
int SumIntoGlobalValues (int numIDs, const int *GIDs, const int *numValuesPerID, const double *values)
 
int ReplaceGlobalValues (int numIDs, const int *GIDs, const int *numValuesPerID, const double *values)
 
int GlobalAssemble (Epetra_CombineMode mode=Add)
 
void setIgnoreNonLocalEntries (bool flag)
 
void FEoperatorequals (const EpetraVector &source)
 
int inputValues (int numIDs, const int *GIDs, const double *values, bool accumulate)
 
int inputValues (int numIDs, const int *GIDs, const int *numValuesPerID, const double *values, bool accumulate)
 
int inputNonlocalValue (int GID, double value, bool accumulate)
 
int inputNonlocalValues (int GID, int numValues, const double *values, bool accumulate)
 
void destroyNonlocalData ()
 

Private Attributes

Epetra_Vector * _vec
 
UniquePtr< Epetra_Map > _map
 
bool _destroy_vec_on_exit
 
int myFirstID_
 
int myNumIDs_
 
double * myCoefs_
 
int * nonlocalIDs_
 
int * nonlocalElementSize_
 
int numNonlocalIDs_
 
int allocatedNonlocalLength_
 
double ** nonlocalCoefs_
 
unsigned char last_edit
 
bool ignoreNonLocalEntries_
 

Detailed Description

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

This class provides a nice interface to the Trilinos Epetra_Vector object. All overridden virtual functions are documented in numeric_vector.h.

Author
Derek R. Gaston
Date
2008

Definition at line 62 of file trilinos_epetra_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 119 of file reference_counter.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator comm,
const ParallelType  type = AUTOMATIC 
)
inlineexplicit

Dummy-Constructor. Dimension=0

Definition at line 409 of file trilinos_epetra_vector.h.

References libMesh::NumericVector< T >::_type, and libMesh::NumericVector< T >::type().

Referenced by libMesh::EpetraVector< T >::EpetraVector().

410  :
411  NumericVector<T>(comm, type),
412  _destroy_vec_on_exit(true),
413  myFirstID_(0),
414  myNumIDs_(0),
418  numNonlocalIDs_(0),
421  last_edit(0),
423 {
424  this->_type = type;
425 }
const class libmesh_nullptr_t libmesh_nullptr
const Parallel::Communicator & comm() const
ParallelType type() const
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator comm,
const numeric_index_type  n,
const ParallelType  type = AUTOMATIC 
)
inlineexplicit

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

Definition at line 431 of file trilinos_epetra_vector.h.

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

433  :
434  NumericVector<T>(comm, type),
435  _destroy_vec_on_exit(true),
436  myFirstID_(0),
437  myNumIDs_(0),
441  numNonlocalIDs_(0),
444  last_edit(0),
446 
447 {
448  this->init(n, n, false, type);
449 }
const class libmesh_nullptr_t libmesh_nullptr
const Parallel::Communicator & comm() const
ParallelType type() const
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator comm,
const numeric_index_type  n,
const numeric_index_type  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 455 of file trilinos_epetra_vector.h.

References libMesh::EpetraVector< T >::_destroy_vec_on_exit, libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::EpetraVector< T >::_map, libMesh::NumericVector< T >::_type, libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::allocatedNonlocalLength_, libMesh::AUTOMATIC, libMesh::ParallelObject::comm(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::EpetraVector< T >::ignoreNonLocalEntries_, libMesh::EpetraVector< T >::init(), libMesh::EpetraVector< T >::last_edit, libmesh_nullptr, libMesh::EpetraVector< T >::myCoefs_, libMesh::EpetraVector< T >::myFirstID_, libMesh::EpetraVector< T >::myNumIDs_, libMesh::EpetraVector< T >::nonlocalCoefs_, libMesh::EpetraVector< T >::nonlocalElementSize_, libMesh::EpetraVector< T >::nonlocalIDs_, libMesh::EpetraVector< T >::numNonlocalIDs_, and libMesh::PARALLEL.

458  :
459  NumericVector<T>(comm, type),
460  _destroy_vec_on_exit(true),
461  myFirstID_(0),
462  myNumIDs_(0),
466  numNonlocalIDs_(0),
469  last_edit(0),
471 {
472  this->init(n, n_local, false, type);
473 }
const class libmesh_nullptr_t libmesh_nullptr
const Parallel::Communicator & comm() const
ParallelType type() const
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator comm,
const numeric_index_type  N,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  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 520 of file trilinos_epetra_vector.h.

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

524  :
525  NumericVector<T>(comm, AUTOMATIC),
526  _destroy_vec_on_exit(true),
527  myFirstID_(0),
528  myNumIDs_(0),
532  numNonlocalIDs_(0),
535  last_edit(0),
537 {
538  this->init(n, n_local, ghost, false, type);
539 }
const class libmesh_nullptr_t libmesh_nullptr
const Parallel::Communicator & comm() const
ParallelType type() const
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
template<typename T>
libMesh::EpetraVector< T >::EpetraVector ( Epetra_Vector &  v,
const Parallel::Communicator &comm  LIBMESH_CAN_DEFAULT_TO_COMMWORLD 
)

Constructor. Creates a EpetraVector assuming you already have a valid Epetra Vec object. In this case, v is NOT destroyed by the EpetraVector constructor when this object goes out of scope. This allows ownership of v to remain with the original creator, and to simply provide additional functionality with the EpetraVector.

template<typename T >
libMesh::EpetraVector< T >::~EpetraVector ( )
inline

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

Definition at line 556 of file trilinos_epetra_vector.h.

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

557 {
558  this->clear ();
559 }
virtual void clear() libmesh_override

Member Function Documentation

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

Sets $ u_i \leftarrow |u_i| $ for each entry in the vector.

Implements libMesh::NumericVector< T >.

Definition at line 305 of file trilinos_epetra_vector.C.

306 {
307  _vec->Abs(*_vec);
308 }
template<typename T >
void libMesh::EpetraVector< T >::add ( const numeric_index_type  i,
const T  value 
)
virtual

Adds value to each entry of the vector.

Implements libMesh::NumericVector< T >.

Definition at line 198 of file trilinos_epetra_vector.C.

199 {
200  int i = static_cast<int> (i_in);
201  T value = value_in;
202 
203  libmesh_assert_less (i_in, this->size());
204 
205  SumIntoGlobalValues(1, &i, &value);
206 
207  this->_is_closed = false;
208 }
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values)
virtual numeric_index_type size() const libmesh_override
template<typename T >
void libMesh::EpetraVector< T >::add ( const T  s)
virtual

Adds s to each entry of the vector, $ u_i \leftarrow u_i + s $

Implements libMesh::NumericVector< T >.

Definition at line 253 of file trilinos_epetra_vector.C.

254 {
255  const unsigned int nl = _vec->MyLength();
256 
257  T * values = _vec->Values();
258 
259  for (unsigned int i=0; i<nl; i++)
260  values[i]+=v_in;
261 
262  this->_is_closed = false;
263 }
template<typename T >
void libMesh::EpetraVector< T >::add ( const NumericVector< T > &  v)
virtual

Adds v to this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $. Equivalent to calling operator+=().

Implements libMesh::NumericVector< T >.

Definition at line 267 of file trilinos_epetra_vector.C.

268 {
269  this->add (1., v);
270 }
virtual void add(const numeric_index_type i, const T value) libmesh_override
template<typename T >
void libMesh::EpetraVector< T >::add ( const T  a,
const NumericVector< T > &  v 
)
virtual

Vector addition with a scalar multiple, $ \vec{u} \leftarrow \vec{u} + a\vec{v} $. Equivalent to calling operator+=().

Implements libMesh::NumericVector< T >.

Definition at line 274 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec, and libMesh::EpetraVector< T >::size().

275 {
276  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
277 
278  libmesh_assert_equal_to (this->size(), v->size());
279 
280  _vec->Update(a_in,*v->_vec, 1.);
281 }
virtual numeric_index_type size() const libmesh_override
template<typename T >
void libMesh::EpetraVector< T >::add_vector ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a pointer and each dof_indices[i] specifies where to add value v[i]. This should be overridden in subclasses for efficiency.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 213 of file trilinos_epetra_vector.C.

215 {
216  libmesh_assert_equal_to (sizeof(numeric_index_type), sizeof(int));
217 
218  SumIntoGlobalValues (dof_indices.size(),
219  (int *) &dof_indices[0],
220  const_cast<T *>(v));
221 }
dof_id_type numeric_index_type
Definition: id_types.h:92
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values)
template<typename T >
void libMesh::EpetraVector< T >::add_vector ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
virtual

Computes $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, i.e. adds the product of a SparseMatrix A and a NumericVector v to this.

Implements libMesh::NumericVector< T >.

Definition at line 227 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec, A, and libMesh::EpetraVector< T >::zero_clone().

229 {
230  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
231  const EpetraMatrix<T> * A = cast_ptr<const EpetraMatrix<T> *>(&A_in);
232 
233  // FIXME - does Trilinos let us do this *without* memory allocation?
234  UniquePtr<NumericVector<T> > temp = v->zero_clone();
235  EpetraVector<T> * temp_v = cast_ptr<EpetraVector<T> *>(temp.get());
236  A->mat()->Multiply(false, *v->_vec, *temp_v->_vec);
237  *this += *temp;
238 }
static PetscErrorCode Mat * A
template<typename T>
void libMesh::NumericVector< T >::add_vector ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inlineinherited

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a std::vector and each dof_indices[i] specifies where to add value v[i].

Definition at line 837 of file numeric_vector.h.

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

839 {
840  libmesh_assert(v.size() == dof_indices.size());
841  if (!v.empty())
842  this->add_vector(&v[0], dof_indices);
843 }
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
libmesh_assert(j)
template<typename T>
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtualinherited

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a NumericVector and each dof_indices[i] specifies where to add value v(i).

Definition at line 394 of file numeric_vector.C.

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

396 {
397  int n = dof_indices.size();
398  libmesh_assert_equal_to(v.size(), static_cast<unsigned>(n));
399  for (int i=0; i<n; i++)
400  this->add (dof_indices[i], v(i));
401 }
virtual void add(const numeric_index_type i, const T value)=0
template<typename T>
void libMesh::NumericVector< T >::add_vector ( const DenseVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inlineinherited

Computes $ \vec{u} \leftarrow \vec{u} + \vec{v} $, where v is a DenseVector and each dof_indices[i] specifies where to add value v(i).

Definition at line 849 of file numeric_vector.h.

References libMesh::NumericVector< T >::add_vector(), libMesh::DenseVector< T >::empty(), libMesh::libmesh_assert(), and libMesh::DenseVector< T >::size().

851 {
852  libmesh_assert(v.size() == dof_indices.size());
853  if (!v.empty())
854  this->add_vector(&v(0), dof_indices);
855 }
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
libmesh_assert(j)
template<typename T>
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  A 
)
inherited

Computes $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, i.e. adds the product of a ShellMatrix A and a NumericVector v to this.

Definition at line 406 of file numeric_vector.C.

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

408 {
409  a.vector_mult_add(*this,v);
410 }
template<typename T >
void libMesh::EpetraVector< T >::add_vector_transpose ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
virtual

Computes $ \vec{u} \leftarrow \vec{u} + A^T \vec{v} $, i.e. adds the product of the transpose of a SparseMatrix A and a NumericVector v to this.

Implements libMesh::NumericVector< T >.

Definition at line 244 of file trilinos_epetra_vector.C.

246 {
247  libmesh_not_implemented();
248 }
template<typename T >
UniquePtr< 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 libMesh::AUTOMATIC, libMesh::EIGEN_SOLVERS, libMesh::LASPACK_SOLVERS, libMesh::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_parallel_solution_vector(), libMesh::System::calculate_norm(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), 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 #ifdef LIBMESH_HAVE_LASPACK
53  case LASPACK_SOLVERS:
54  return UniquePtr<NumericVector<T> >(new LaspackVector<T>(comm, AUTOMATIC));
55 #endif
56 
57 #ifdef LIBMESH_HAVE_PETSC
58  case PETSC_SOLVERS:
59  return UniquePtr<NumericVector<T> >(new PetscVector<T>(comm, AUTOMATIC));
60 #endif
61 
62 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
63  case TRILINOS_SOLVERS:
64  return UniquePtr<NumericVector<T> >(new EpetraVector<T>(comm, AUTOMATIC));
65 #endif
66 
67 #ifdef LIBMESH_HAVE_EIGEN
68  case EIGEN_SOLVERS:
69  return UniquePtr<NumericVector<T> >(new EigenSparseVector<T>(comm, AUTOMATIC));
70 #endif
71 
72  default:
73  return UniquePtr<NumericVector<T> >(new DistributedVector<T>(comm, AUTOMATIC));
74  }
75 
76  libmesh_error_msg("We'll never get here!");
77  return UniquePtr<NumericVector<T> >();
78 }
EIGEN_SOLVERS
Definition: libmesh.C:262
TRILINOS_SOLVERS
Definition: libmesh.C:260
LASPACK_SOLVERS
Definition: libmesh.C:264
const Parallel::Communicator & comm() const
template<typename T >
UniquePtr< 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:
LIBMESH_DISABLE_COMMWORLD is now the default, use the build() method that takes a Parallel::Communicator instead.

Definition at line 84 of file numeric_vector.C.

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

85 {
86  libmesh_deprecated();
87  return NumericVector<T>::build(CommWorld, solver_package);
88 }
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Parallel::FakeCommunicator CommWorld
Definition: libmesh.C:208
template<typename T >
void libMesh::EpetraVector< T >::clear ( )
inlinevirtual

Restores the NumericVector<T> to a pristine state.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 669 of file trilinos_epetra_vector.h.

References libMesh::EpetraVector< T >::_destroy_vec_on_exit, libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::EpetraVector< T >::_map, libMesh::EpetraVector< T >::_vec, libMesh::NumericVector< T >::initialized(), and libmesh_nullptr.

Referenced by libMesh::EpetraVector< T >::~EpetraVector().

670 {
671  if (this->initialized())
672  {
673  // We might just be an interface to a user-provided _vec
674  if (this->_destroy_vec_on_exit)
675  {
676  delete _vec;
678  }
679 
680  // But we currently always own our own _map
681  _map.reset();
682  }
683 
684  this->_is_closed = this->_is_initialized = false;
685 }
UniquePtr< Epetra_Map > _map
const class libmesh_nullptr_t libmesh_nullptr
virtual bool initialized() const
template<typename T >
UniquePtr< NumericVector< T > > libMesh::EpetraVector< T >::clone ( ) const
inlinevirtual
Returns
A copy of this vector wrapped in a smart pointer.
Note
This must be overridden in the derived classes.

Implements libMesh::NumericVector< T >.

Definition at line 714 of file trilinos_epetra_vector.h.

References libMesh::AUTOMATIC, libMesh::ParallelObject::comm(), and libMesh::NumericVector< T >::init().

715 {
716  NumericVector<T> * cloned_vector = new EpetraVector<T>(this->comm(), AUTOMATIC);
717  cloned_vector->init(*this, true);
718  *cloned_vector = *this;
719  return UniquePtr<NumericVector<T> >(cloned_vector);
720 }
const Parallel::Communicator & comm() const
template<typename T >
void libMesh::EpetraVector< T >::close ( )
inlinevirtual

Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across processors.

Implements libMesh::NumericVector< T >.

Definition at line 645 of file trilinos_epetra_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::ParallelObject::comm(), libMesh::EpetraVector< T >::GlobalAssemble(), libMesh::NumericVector< T >::initialized(), libMesh::EpetraVector< T >::last_edit, libMesh::libmesh_assert(), and libMesh::Parallel::Communicator::max().

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

646 {
647  libmesh_assert (this->initialized());
648 
649  // Are we adding or inserting?
650  unsigned char global_last_edit = last_edit;
651  this->comm().max(global_last_edit);
652  libmesh_assert(!last_edit || last_edit == global_last_edit);
653 
654  if (global_last_edit == 1)
655  this->GlobalAssemble(Insert);
656  else if (global_last_edit == 2)
657  this->GlobalAssemble(Add);
658  else
659  libmesh_assert(!global_last_edit);
660 
661  this->_is_closed = true;
662  this->last_edit = 0;
663 }
virtual bool initialized() const
int GlobalAssemble(Epetra_CombineMode mode=Add)
libmesh_assert(j)
const Parallel::Communicator & comm() const
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), libMesh::DistributedMesh::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::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _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), or the first index where abs(a[i]-b[i]) exceeds the threshold.

Definition at line 116 of file numeric_vector.C.

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

Referenced by libMesh::NumericVector< Number >::operator/=().

118 {
119  libmesh_assert (this->initialized());
120  libmesh_assert (other_vector.initialized());
121  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
122  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
123 
124  int first_different_i = std::numeric_limits<int>::max();
126 
127  do
128  {
129  if (std::abs((*this)(i) - other_vector(i)) > threshold)
130  first_different_i = i;
131  else
132  i++;
133  }
134  while (first_different_i==std::numeric_limits<int>::max()
135  && i<last_local_index());
136 
137  // Find the correct first differing index in parallel
138  this->comm().min(first_different_i);
139 
140  if (first_different_i == std::numeric_limits<int>::max())
141  return -1;
142 
143  return first_different_i;
144 }
double abs(double a)
virtual numeric_index_type last_local_index() const =0
virtual bool initialized() const
long double max(long double a, double b)
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
const Parallel::Communicator & comm() const
virtual numeric_index_type first_local_index() const =0
template<typename T >
void libMesh::EpetraVector< T >::conjugate ( )
virtual

Negates the imaginary component of each entry in the vector.

Implements libMesh::NumericVector< T >.

Definition at line 190 of file trilinos_epetra_vector.C.

191 {
192  // EPetra is real, rendering this a no-op.
193 }
template<typename T >
void libMesh::EpetraVector< T >::create_subvector ( NumericVector< T > &  ,
const std::vector< numeric_index_type > &   
) const
virtual

Fills in subvector from this vector using the indices in rows. Similar to the create_submatrix() routine for the SparseMatrix class, it is currently only implemented for PetscVectors.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 572 of file trilinos_epetra_vector.C.

574 {
575  libmesh_not_implemented();
576 }
template<typename T >
void libMesh::EpetraVector< T >::destroyNonlocalData ( )
private

Definition at line 904 of file trilinos_epetra_vector.C.

References libmesh_nullptr.

Referenced by libMesh::EpetraVector< T >::setIgnoreNonLocalEntries().

905 {
906  if (allocatedNonlocalLength_ > 0) {
907  delete [] nonlocalIDs_;
908  delete [] nonlocalElementSize_;
911  for (int i=0; i<numNonlocalIDs_; ++i) {
912  delete [] nonlocalCoefs_[i];
913  }
914  delete [] nonlocalCoefs_;
916  numNonlocalIDs_ = 0;
918  }
919  return;
920 }
const class libmesh_nullptr_t libmesh_nullptr
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
template<typename T >
T libMesh::EpetraVector< T >::dot ( const NumericVector< T > &  v) const
virtual
Returns
$ \vec{u} \cdot \vec{v} $, the dot product of (*this) with the vector v.

Uses the complex-conjugate of v in the complex-valued case.

Implements libMesh::NumericVector< T >.

Definition at line 312 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec.

313 {
314  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
315 
316  T result=0.0;
317 
318  _vec->Dot(*v->_vec, &result);
319 
320  return result;
321 }
template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i) const
inlinevirtualinherited
Returns
(*this)(i).

Definition at line 339 of file numeric_vector.h.

339 { 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 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

102 {
103  _enable_print_counter = true;
104  return;
105 }
template<typename T >
void libMesh::EpetraVector< T >::FEoperatorequals ( const EpetraVector< T > &  source)
private

Definition at line 877 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::allocatedNonlocalLength_, libMesh::EpetraVector< T >::nonlocalCoefs_, libMesh::EpetraVector< T >::nonlocalElementSize_, libMesh::EpetraVector< T >::nonlocalIDs_, and libMesh::EpetraVector< T >::numNonlocalIDs_.

Referenced by libMesh::EpetraVector< T >::setIgnoreNonLocalEntries().

878 {
879  (*_vec) = *(source._vec);
880 
882 
883  if (source.allocatedNonlocalLength_ > 0) {
884  allocatedNonlocalLength_ = source.allocatedNonlocalLength_;
885  numNonlocalIDs_ = source.numNonlocalIDs_;
889  for (int i=0; i<numNonlocalIDs_; ++i) {
890  int elemSize = source.nonlocalElementSize_[i];
891  nonlocalCoefs_[i] = new double[elemSize];
892  nonlocalIDs_[i] = source.nonlocalIDs_[i];
893  nonlocalElementSize_[i] = elemSize;
894  for (int j=0; j<elemSize; ++j) {
895  nonlocalCoefs_[i][j] = source.nonlocalCoefs_[i][j];
896  }
897  }
898  }
899 }
template<typename T >
numeric_index_type libMesh::EpetraVector< T >::first_local_index ( ) const
inlinevirtual
Returns
The index of the first vector element actually stored on this processor.
Note
The minimum for this index is 0.

Implements libMesh::NumericVector< T >.

Definition at line 746 of file trilinos_epetra_vector.h.

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

Referenced by libMesh::EpetraVector< T >::operator()().

747 {
748  libmesh_assert (this->initialized());
749 
750  return _vec->Map().MinMyGID();
751 }
virtual bool initialized() const
libmesh_assert(j)
template<typename T>
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
T *  values 
) const
inlinevirtualinherited

Access multiple components at once. values will not be reallocated; it should already have enough space. The default implementation calls operator() for each index, but some implementations may supply faster methods here.

Reimplemented in libMesh::PetscVector< T >.

Definition at line 808 of file numeric_vector.h.

Referenced by libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEMContext::pre_fe_reinit(), and libMesh::System::project_vector().

810 {
811  const std::size_t num = index.size();
812  for (std::size_t i=0; i<num; i++)
813  {
814  values[i] = (*this)(index[i]);
815  }
816 }
template<typename T>
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
std::vector< T > &  values 
) const
inlineinherited

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.

Definition at line 822 of file numeric_vector.h.

824 {
825  const std::size_t num = index.size();
826  values.resize(num);
827  if (!num)
828  return;
829 
830  this->get(index, &values[0]);
831 }
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 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
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 global relative threshold), or the first index where abs(a[i]-b[i])/max_j(a[j],b[j]) exceeds the threshold.

Definition at line 181 of file numeric_vector.C.

References std::abs(), 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.

Referenced by libMesh::NumericVector< Number >::operator/=().

183 {
184  libmesh_assert (this->initialized());
185  libmesh_assert (other_vector.initialized());
186  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
187  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
188 
189  int first_different_i = std::numeric_limits<int>::max();
191 
192  const Real my_norm = this->linfty_norm();
193  const Real other_norm = other_vector.linfty_norm();
194  const Real abs_threshold = std::max(my_norm, other_norm) * threshold;
195 
196  do
197  {
198  if (std::abs((*this)(i) - other_vector(i) ) > abs_threshold)
199  first_different_i = i;
200  else
201  i++;
202  }
203  while (first_different_i==std::numeric_limits<int>::max()
204  && i<last_local_index());
205 
206  // Find the correct first differing index in parallel
207  this->comm().min(first_different_i);
208 
209  if (first_different_i == std::numeric_limits<int>::max())
210  return -1;
211 
212  return first_different_i;
213 }
double abs(double a)
virtual numeric_index_type last_local_index() const =0
virtual bool initialized() const
long double max(long double a, double b)
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual Real linfty_norm() const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Parallel::Communicator & comm() const
virtual numeric_index_type first_local_index() const =0
template<typename T >
int libMesh::EpetraVector< T >::GlobalAssemble ( Epetra_CombineMode  mode = Add)
private

Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was passed to this vector at construction time. Data imported from other processors is stored on the owning processor with a "sumInto" or accumulate operation. This is a collective method – every processor must enter it before any will complete it.

Definition at line 832 of file trilinos_epetra_vector.C.

Referenced by libMesh::EpetraVector< T >::close().

833 {
834  //In this method we need to gather all the non-local (overlapping) data
835  //that's been input on each processor, into the (probably) non-overlapping
836  //distribution defined by the map that 'this' vector was constructed with.
837 
838  //We don't need to do anything if there's only one processor or if
839  //ignoreNonLocalEntries_ is true.
840  if (_vec->Map().Comm().NumProc() < 2 || ignoreNonLocalEntries_) {
841  return(0);
842  }
843 
844 
845 
846  //First build a map that describes the data in nonlocalIDs_/nonlocalCoefs_.
847  //We'll use the arbitrary distribution constructor of Map.
848 
849  Epetra_BlockMap sourceMap(-1, numNonlocalIDs_,
851  _vec->Map().IndexBase(), _vec->Map().Comm());
852 
853  //Now build a vector to hold our nonlocalCoefs_, and to act as the source-
854  //vector for our import operation.
855  Epetra_MultiVector nonlocalVector(sourceMap, 1);
856 
857  int i,j;
858  for (i=0; i<numNonlocalIDs_; ++i) {
859  for (j=0; j<nonlocalElementSize_[i]; ++j) {
860  nonlocalVector.ReplaceGlobalValue(nonlocalIDs_[i], j, 0,
861  nonlocalCoefs_[i][j]);
862  }
863  }
864 
865  Epetra_Export exporter(sourceMap, _vec->Map());
866 
867  EPETRA_CHK_ERR( _vec->Export(nonlocalVector, exporter, mode) );
868 
870 
871  return(0);
872 }
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 185 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
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 198 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
template<typename T >
void libMesh::EpetraVector< T >::init ( const numeric_index_type  ,
const numeric_index_type  ,
const bool  = false,
const ParallelType  = AUTOMATIC 
)
inlinevirtual

Change the dimension of the vector to N. The reserved memory for this vector remains unchanged if possible. If N==0, all memory is freed. Therefore, 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 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 565 of file trilinos_epetra_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::EpetraVector< T >::_map, libMesh::NumericVector< T >::_type, libMesh::EpetraVector< T >::_vec, libMesh::AUTOMATIC, libMesh::ParallelObject::comm(), libMesh::GHOSTED, libMesh::EpetraVector< T >::last_edit, libMesh::libmesh_assert(), libMesh::EpetraVector< T >::myCoefs_, libMesh::EpetraVector< T >::myFirstID_, libMesh::EpetraVector< T >::myNumIDs_, libMesh::PARALLEL, libMesh::SERIAL, libMesh::NumericVector< T >::type(), and libMesh::EpetraVector< T >::zero().

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

569 {
570  // We default to allocating n_local local storage
571  numeric_index_type my_n_local = n_local;
572 
573  if (type == AUTOMATIC)
574  {
575  if (n == n_local)
576  this->_type = SERIAL;
577  else
578  this->_type = PARALLEL;
579  }
580  else if (type == GHOSTED)
581  {
582  // We don't yet support GHOSTED Epetra vectors, so to get the
583  // same functionality we need a SERIAL vector with local
584  // storage allocated for every entry.
585  this->_type = SERIAL;
586  my_n_local = n;
587  }
588  else
589  this->_type = type;
590 
591  libmesh_assert ((this->_type==SERIAL && n==my_n_local) ||
592  this->_type==PARALLEL);
593 
594  _map.reset(new Epetra_Map(static_cast<int>(n),
595  my_n_local,
596  0,
597  Epetra_MpiComm (this->comm().get())));
598 
599  _vec = new Epetra_Vector(*_map);
600 
601  myFirstID_ = _vec->Map().MinMyGID();
602  myNumIDs_ = _vec->Map().NumMyElements();
603 
604  // Currently we impose the restriction that NumVectors==1, so we won't
605  // need the LDA argument when calling ExtractView. Hence the "dummy" arg.
606  int dummy;
607  _vec->ExtractView(&myCoefs_, &dummy);
608 
609  this->_is_initialized = true;
610  this->_is_closed = true;
611  this->last_edit = 0;
612 
613  if (fast == false)
614  this->zero ();
615 }
UniquePtr< Epetra_Map > _map
virtual void zero() libmesh_override
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
const Parallel::Communicator & comm() const
ParallelType type() const
template<typename T >
void libMesh::EpetraVector< T >::init ( const numeric_index_type  ,
const bool  = false,
const ParallelType  = AUTOMATIC 
)
inlinevirtual

Call init() with n_local = N.

Implements libMesh::NumericVector< T >.

Definition at line 634 of file trilinos_epetra_vector.h.

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

637 {
638  this->init(n,n,fast,type);
639 }
ParallelType type() const
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
template<typename T >
void libMesh::EpetraVector< T >::init ( const numeric_index_type  ,
const numeric_index_type  ,
const std::vector< numeric_index_type > &  ,
const bool  = false,
const ParallelType  = AUTOMATIC 
)
inlinevirtual

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

Implements libMesh::NumericVector< T >.

Definition at line 620 of file trilinos_epetra_vector.h.

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

625 {
626  // TODO: we shouldn't ignore the ghost sparsity pattern
627  this->init(n, n_local, fast, type);
628 }
ParallelType type() const
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
template<class T >
void libMesh::EpetraVector< 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 546 of file trilinos_epetra_vector.h.

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

548 {
549  this->init(other.size(),other.local_size(),fast,other.type());
550 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) libmesh_override
template<typename T>
virtual bool libMesh::NumericVector< T >::initialized ( ) const
inlinevirtualinherited
Returns
true if the vector has been initialized, false otherwise.

Definition at line 135 of file numeric_vector.h.

Referenced by libMesh::DistributedVector< T >::add(), libMesh::EigenSparseVector< T >::add(), libMesh::LaspackVector< T >::add(), libMesh::ImplicitSystem::assemble(), libMesh::LaspackVector< T >::clear(), libMesh::EpetraVector< T >::clear(), libMesh::PetscVector< T >::clear(), libMesh::DistributedVector< T >::close(), libMesh::EigenSparseVector< T >::close(), libMesh::LaspackVector< T >::close(), libMesh::EpetraVector< T >::close(), libMesh::NumericVector< T >::compare(), libMesh::PetscVector< T >::create_subvector(), libMesh::DistributedVector< T >::first_local_index(), libMesh::EigenSparseVector< T >::first_local_index(), libMesh::LaspackVector< T >::first_local_index(), libMesh::EpetraVector< T >::first_local_index(), libMesh::PetscVector< T >::first_local_index(), libMesh::NumericVector< T >::global_relative_compare(), libMesh::DistributedVector< T >::init(), libMesh::EigenSparseVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::DistributedVector< T >::last_local_index(), libMesh::EigenSparseVector< T >::last_local_index(), libMesh::LaspackVector< T >::last_local_index(), libMesh::EpetraVector< T >::last_local_index(), libMesh::PetscVector< T >::last_local_index(), libMesh::NumericVector< T >::local_relative_compare(), libMesh::DistributedVector< T >::local_size(), libMesh::EigenSparseVector< T >::local_size(), libMesh::LaspackVector< T >::local_size(), libMesh::EpetraVector< T >::local_size(), libMesh::PetscVector< T >::local_size(), libMesh::PetscVector< T >::map_global_to_local_index(), libMesh::DistributedVector< T >::max(), libMesh::EpetraVector< T >::max(), libMesh::DistributedVector< T >::min(), libMesh::EpetraVector< T >::min(), libMesh::DistributedVector< T >::operator()(), libMesh::LaspackVector< T >::operator()(), libMesh::EigenSparseVector< T >::operator()(), libMesh::EpetraVector< T >::operator()(), libMesh::NumericVector< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::DistributedVector< T >::set(), libMesh::EigenSparseVector< T >::set(), libMesh::LaspackVector< T >::set(), libMesh::DistributedVector< T >::size(), libMesh::LaspackVector< T >::size(), libMesh::EigenSparseVector< T >::size(), libMesh::EpetraVector< T >::size(), libMesh::PetscVector< T >::size(), libMesh::DistributedVector< T >::zero(), libMesh::LaspackVector< T >::zero(), libMesh::EigenSparseVector< T >::zero(), libMesh::EpetraVector< T >::zero(), and libMesh::LaspackVector< T >::~LaspackVector().

135 { return _is_initialized; }
template<typename T >
int libMesh::EpetraVector< T >::inputNonlocalValue ( int  GID,
double  value,
bool  accumulate 
)
private

Definition at line 730 of file trilinos_epetra_vector.C.

Referenced by libMesh::EpetraVector< T >::setIgnoreNonLocalEntries().

731 {
732  int insertPoint = -1;
733 
734  //find offset of GID in nonlocalIDs_
735  int offset = Epetra_Util_binary_search(GID, nonlocalIDs_, numNonlocalIDs_,
736  insertPoint);
737  if (offset >= 0) {
738  //if offset >= 0
739  // put value in nonlocalCoefs_[offset][0]
740 
741  if (accumulate) {
742  nonlocalCoefs_[offset][0] += value;
743  }
744  else {
745  nonlocalCoefs_[offset][0] = value;
746  }
747  }
748  else {
749  //else
750  // insert GID in nonlocalIDs_
751  // insert 1 in nonlocalElementSize_
752  // insert value in nonlocalCoefs_
753 
754  int tmp1 = numNonlocalIDs_;
755  int tmp2 = allocatedNonlocalLength_;
756  int tmp3 = allocatedNonlocalLength_;
757  EPETRA_CHK_ERR( Epetra_Util_insert(GID, insertPoint, nonlocalIDs_,
758  tmp1, tmp2) );
759  --tmp1;
760  EPETRA_CHK_ERR( Epetra_Util_insert(1, insertPoint, nonlocalElementSize_,
761  tmp1, tmp3) );
762  double * values = new double[1];
763  values[0] = value;
764  EPETRA_CHK_ERR( Epetra_Util_insert(values, insertPoint, nonlocalCoefs_,
766  }
767 
768  return(0);
769 }
template<typename T >
int libMesh::EpetraVector< T >::inputNonlocalValues ( int  GID,
int  numValues,
const double *  values,
bool  accumulate 
)
private

Definition at line 773 of file trilinos_epetra_vector.C.

References libMesh::err.

Referenced by libMesh::EpetraVector< T >::setIgnoreNonLocalEntries().

777 {
778  int insertPoint = -1;
779 
780  //find offset of GID in nonlocalIDs_
781  int offset = Epetra_Util_binary_search(GID, nonlocalIDs_, numNonlocalIDs_,
782  insertPoint);
783  if (offset >= 0) {
784  //if offset >= 0
785  // put value in nonlocalCoefs_[offset][0]
786 
787  if (numValues != nonlocalElementSize_[offset]) {
788  libMesh::err << "Epetra_FEVector ERROR: block-size for GID " << GID << " is "
789  << numValues<<" which doesn't match previously set block-size of "
790  << nonlocalElementSize_[offset] << std::endl;
791  return(-1);
792  }
793 
794  if (accumulate) {
795  for (int j=0; j<numValues; ++j) {
796  nonlocalCoefs_[offset][j] += values[j];
797  }
798  }
799  else {
800  for (int j=0; j<numValues; ++j) {
801  nonlocalCoefs_[offset][j] = values[j];
802  }
803  }
804  }
805  else {
806  //else
807  // insert GID in nonlocalIDs_
808  // insert numValues in nonlocalElementSize_
809  // insert values in nonlocalCoefs_
810 
811  int tmp1 = numNonlocalIDs_;
812  int tmp2 = allocatedNonlocalLength_;
813  int tmp3 = allocatedNonlocalLength_;
814  EPETRA_CHK_ERR( Epetra_Util_insert(GID, insertPoint, nonlocalIDs_,
815  tmp1, tmp2) );
816  --tmp1;
817  EPETRA_CHK_ERR( Epetra_Util_insert(numValues, insertPoint, nonlocalElementSize_,
818  tmp1, tmp3) );
819  double * newvalues = new double[numValues];
820  for (int j=0; j<numValues; ++j) {
821  newvalues[j] = values[j];
822  }
823  EPETRA_CHK_ERR( Epetra_Util_insert(newvalues, insertPoint, nonlocalCoefs_,
825  }
826 
827  return(0);
828 }
OStreamProxy err(std::cerr)
template<typename T >
int libMesh::EpetraVector< T >::inputValues ( int  numIDs,
const int *  GIDs,
const double *  values,
bool  accumulate 
)
private

Definition at line 650 of file trilinos_epetra_vector.C.

References libMesh::libmesh_assert().

Referenced by libMesh::EpetraVector< T >::setIgnoreNonLocalEntries().

654 {
655  if (accumulate) {
656  libmesh_assert(last_edit == 0 || last_edit == 2);
657  last_edit = 2;
658  } else {
659  libmesh_assert(last_edit == 0 || last_edit == 1);
660  last_edit = 1;
661  }
662 
663  //Important note!! This method assumes that there is only 1 point
664  //associated with each element.
665 
666  for (int i=0; i<numIDs; ++i) {
667  if (_vec->Map().MyGID(GIDs[i])) {
668  if (accumulate) {
669  _vec->SumIntoGlobalValue(GIDs[i], 0, 0, values[i]);
670  }
671  else {
672  _vec->ReplaceGlobalValue(GIDs[i], 0, 0, values[i]);
673  }
674  }
675  else {
676  if (!ignoreNonLocalEntries_) {
677  EPETRA_CHK_ERR( inputNonlocalValue(GIDs[i], values[i], accumulate) );
678  }
679  }
680  }
681 
682  return(0);
683 }
libmesh_assert(j)
int inputNonlocalValue(int GID, double value, bool accumulate)
template<typename T >
int libMesh::EpetraVector< T >::inputValues ( int  numIDs,
const int *  GIDs,
const int *  numValuesPerID,
const double *  values,
bool  accumulate 
)
private

Definition at line 687 of file trilinos_epetra_vector.C.

References libMesh::libmesh_assert().

692 {
693  if (accumulate) {
694  libmesh_assert(last_edit == 0 || last_edit == 2);
695  last_edit = 2;
696  } else {
697  libmesh_assert(last_edit == 0 || last_edit == 1);
698  last_edit = 1;
699  }
700 
701  int offset=0;
702  for (int i=0; i<numIDs; ++i) {
703  int numValues = numValuesPerID[i];
704  if (_vec->Map().MyGID(GIDs[i])) {
705  if (accumulate) {
706  for (int j=0; j<numValues; ++j) {
707  _vec->SumIntoGlobalValue(GIDs[i], j, 0, values[offset+j]);
708  }
709  }
710  else {
711  for (int j=0; j<numValues; ++j) {
712  _vec->ReplaceGlobalValue(GIDs[i], j, 0, values[offset+j]);
713  }
714  }
715  }
716  else {
717  if (!ignoreNonLocalEntries_) {
718  EPETRA_CHK_ERR( inputNonlocalValues(GIDs[i], numValues,
719  &(values[offset]), accumulate) );
720  }
721  }
722  offset += numValues;
723  }
724 
725  return(0);
726 }
int inputNonlocalValues(int GID, int numValues, const double *values, bool accumulate)
libmesh_assert(j)
template<typename T >
void libMesh::EpetraVector< T >::insert ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

Inserts the entries of v in *this at the locations specified by v.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 286 of file trilinos_epetra_vector.C.

288 {
289  libmesh_assert_equal_to (sizeof(numeric_index_type), sizeof(int));
290 
291  ReplaceGlobalValues (dof_indices.size(),
292  (int *) &dof_indices[0],
293  const_cast<T *>(v));
294 }
int ReplaceGlobalValues(int numIDs, const int *GIDs, const double *values)
dof_id_type numeric_index_type
Definition: id_types.h:92
template<typename T>
void libMesh::NumericVector< T >::insert ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inlineinherited

Inserts the entries of v in *this at the locations specified by v.

Definition at line 861 of file numeric_vector.h.

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

863 {
864  libmesh_assert(v.size() == dof_indices.size());
865  if (!v.empty())
866  this->insert(&v[0], dof_indices);
867 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
libmesh_assert(j)
template<typename T>
void libMesh::NumericVector< T >::insert ( const NumericVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtualinherited

Inserts the entries of v in *this at the locations specified by v.

Definition at line 104 of file numeric_vector.C.

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

106 {
107  libmesh_assert_equal_to (V.size(), dof_indices.size());
108 
109  for (numeric_index_type i=0; i<dof_indices.size(); i++)
110  this->set (dof_indices[i], V(i));
111 }
dof_id_type numeric_index_type
Definition: id_types.h:92
template<typename T>
void libMesh::NumericVector< T >::insert ( const DenseVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inlineinherited

Inserts the entries of v in *this at the locations specified by v.

Definition at line 873 of file numeric_vector.h.

References libMesh::DenseVector< T >::empty(), libMesh::NumericVector< T >::insert(), libMesh::libmesh_assert(), and libMesh::DenseVector< T >::size().

875 {
876  libmesh_assert(v.size() == dof_indices.size());
877  if (!v.empty())
878  this->insert(&v(0), dof_indices);
879 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
libmesh_assert(j)
template<typename T>
void libMesh::NumericVector< T >::insert ( const DenseSubVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inlineinherited

Inserts the entries of v in *this at the locations specified by v.

Definition at line 885 of file numeric_vector.h.

References libMesh::DenseSubVector< T >::empty(), libMesh::NumericVector< T >::insert(), libMesh::libmesh_assert(), and libMesh::DenseSubVector< T >::size().

887 {
888  libmesh_assert(v.size() == dof_indices.size());
889  if (!v.empty())
890  this->insert(&v(0), dof_indices);
891 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
libmesh_assert(j)
template<typename T >
Real libMesh::EpetraVector< T >::l1_norm ( ) const
virtual
Returns
The $ \ell_1 $-norm of the vector, i.e. the sum of the absolute values of the entries.

Implements libMesh::NumericVector< T >.

Definition at line 69 of file trilinos_epetra_vector.C.

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

70 {
71  libmesh_assert(this->closed());
72 
73  Real value;
74 
75  _vec->Norm1(&value);
76 
77  return value;
78 }
virtual bool closed() const
libmesh_assert(j)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename T >
Real libMesh::EpetraVector< T >::l2_norm ( ) const
virtual
Returns
The $ \ell_2 $-norm of the vector, i.e. the square root of the sum of the squares of the entries.

Implements libMesh::NumericVector< T >.

Definition at line 81 of file trilinos_epetra_vector.C.

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

82 {
83  libmesh_assert(this->closed());
84 
85  Real value;
86 
87  _vec->Norm2(&value);
88 
89  return value;
90 }
virtual bool closed() const
libmesh_assert(j)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename T >
numeric_index_type libMesh::EpetraVector< T >::last_local_index ( ) const
inlinevirtual
Returns
The index+1 of the last vector element actually stored on this processor.
Note
The maximum for this index is size().

Implements libMesh::NumericVector< T >.

Definition at line 757 of file trilinos_epetra_vector.h.

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

Referenced by libMesh::EpetraVector< T >::operator()().

758 {
759  libmesh_assert (this->initialized());
760 
761  return _vec->Map().MaxMyGID()+1;
762 }
virtual bool initialized() const
libmesh_assert(j)
template<typename T >
Real libMesh::EpetraVector< T >::linfty_norm ( ) const
virtual
Returns
The $ \ell_{\infty} $-norm of the vector, i.e. the maximum absolute value of the entries of the vector.

Implements libMesh::NumericVector< T >.

Definition at line 93 of file trilinos_epetra_vector.C.

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

94 {
95  libmesh_assert(this->closed());
96 
97  Real value;
98 
99  _vec->NormInf(&value);
100 
101  return value;
102 }
virtual bool closed() const
libmesh_assert(j)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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), or the first index where abs(a[i]-b[i])/max(a[i],b[i]) exceeds the threshold.

Definition at line 148 of file numeric_vector.C.

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

Referenced by libMesh::NumericVector< Number >::operator/=().

150 {
151  libmesh_assert (this->initialized());
152  libmesh_assert (other_vector.initialized());
153  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
154  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
155 
156  int first_different_i = std::numeric_limits<int>::max();
158 
159  do
160  {
161  if (std::abs((*this)(i) - other_vector(i)) > threshold *
162  std::max(std::abs((*this)(i)), std::abs(other_vector(i))))
163  first_different_i = i;
164  else
165  i++;
166  }
167  while (first_different_i==std::numeric_limits<int>::max()
168  && i<last_local_index());
169 
170  // Find the correct first differing index in parallel
171  this->comm().min(first_different_i);
172 
173  if (first_different_i == std::numeric_limits<int>::max())
174  return -1;
175 
176  return first_different_i;
177 }
double abs(double a)
virtual numeric_index_type last_local_index() const =0
virtual bool initialized() const
long double max(long double a, double b)
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
const Parallel::Communicator & comm() const
virtual numeric_index_type first_local_index() const =0
template<typename T >
numeric_index_type libMesh::EpetraVector< T >::local_size ( ) const
inlinevirtual
Returns
The local size of the vector, i.e. index_stop - index_start.

Implements libMesh::NumericVector< T >.

Definition at line 737 of file trilinos_epetra_vector.h.

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

738 {
739  libmesh_assert (this->initialized());
740 
741  return _vec->MyLength();
742 }
virtual bool initialized() const
libmesh_assert(j)
template<typename T >
void libMesh::EpetraVector< 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 523 of file trilinos_epetra_vector.C.

References libMesh::libmesh_assert().

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

524 {
525  // This function must be run on all processors at once
526  parallel_object_only();
527 
528  const unsigned int n = this->size();
529  const unsigned int nl = this->local_size();
530 
531  libmesh_assert(this->_vec);
532 
533  v_local.clear();
534  v_local.reserve(n);
535 
536  // build up my local part
537  for (unsigned int i=0; i<nl; i++)
538  v_local.push_back((*this->_vec)[i]);
539 
540  this->comm().allgather (v_local);
541 }
virtual numeric_index_type local_size() const libmesh_override
libmesh_assert(j)
const Parallel::Communicator & comm() const
void allgather(const T &send, std::vector< T > &recv) const
virtual numeric_index_type size() const libmesh_override
template<typename T >
void libMesh::EpetraVector< 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 411 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec.

412 {
413  EpetraVector<T> * v_local = cast_ptr<EpetraVector<T> *>(&v_local_in);
414 
415  Epetra_Map rootMap = Epetra_Util::Create_Root_Map( *_map, -1);
416  v_local->_vec->ReplaceMap(rootMap);
417 
418  Epetra_Import importer(v_local->_vec->Map(), *_map);
419  v_local->_vec->Import(*_vec, importer, Insert);
420 }
UniquePtr< Epetra_Map > _map
template<typename T >
void libMesh::EpetraVector< 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 425 of file trilinos_epetra_vector.C.

427 {
428  // TODO: optimize to sync only the send list values
429  this->localize(v_local_in);
430 
431  // EpetraVector<T> * v_local =
432  // cast_ptr<EpetraVector<T> *>(&v_local_in);
433 
434  // libmesh_assert(this->_map.get());
435  // libmesh_assert(v_local->_map.get());
436  // libmesh_assert_equal_to (v_local->local_size(), this->size());
437  // libmesh_assert_less_equal (send_list.size(), v_local->size());
438 
439  // Epetra_Import importer (*v_local->_map, *this->_map);
440 
441  // v_local->_vec->Import (*this->_vec, importer, Insert);
442 }
virtual void localize(std::vector< T > &v_local) const libmesh_override
template<typename T >
void libMesh::EpetraVector< T >::localize ( std::vector< T > &  v_local,
const std::vector< numeric_index_type > &  indices 
) const
virtual

Fill in the local std::vector "v_local" with the global indices given in "indices".

Note
The indices can be different on every processor, and the same index can be localized to more than one processor. The resulting v_local can be shorter than the original, and the entries will be in the order specified by indices.

Example:

*   On 4 procs *this = {a, b, c, d, e, f, g, h, i} is a parallel vector.
*   On each proc, the indices arrays are set up as:
*   proc0, indices = {1,2,4,5}
*   proc1, indices = {2,5,6,8}
*   proc2, indices = {2,3,6,7}
*   proc3, indices = {0,1,2,3}
*
*   After calling this version of localize, the v_local vectors are:
*   proc0, v_local = {b,c,e,f}
*   proc1, v_local = {c,f,g,i}
*   proc2, v_local = {c,d,g,h}
*   proc3, v_local = {a,b,c,d}
* 

This function is useful in parallel I/O routines, when you have a parallel vector of solution values which you want to write a subset of.

Implements libMesh::NumericVector< T >.

Definition at line 447 of file trilinos_epetra_vector.C.

449 {
450  // Create a "replicated" map for importing values. This is
451  // equivalent to creating a general Epetra_Map with
452  // NumGlobalElements == NumMyElements.
453  Epetra_LocalMap import_map(static_cast<int>(indices.size()),
454  /*IndexBase=*/0,
455  _map->Comm());
456 
457  // Get a pointer to the list of global elements for the map, and set
458  // all the values from indices.
459  int * import_map_global_elements = import_map.MyGlobalElements();
460  for (int i=0; i<import_map.NumMyElements(); ++i)
461  import_map_global_elements[i] = indices[i];
462 
463  // Create a new EpetraVector to import values into.
464  Epetra_Vector import_vector(import_map);
465 
466  // Set up an "Import" object which associates the two maps.
467  Epetra_Import import_object(import_map, *_map);
468 
469  // Import the values
470  import_vector.Import(*_vec, import_object, Insert);
471 
472  // Get a pointer to the imported values array and the length of the
473  // array.
474  T * values = import_vector.Values();
475  int import_vector_length = import_vector.MyLength();
476 
477  // Copy the imported values into v_local
478  v_local.resize(import_vector_length);
479  for (int i=0; i<import_vector_length; ++i)
480  v_local[i] = values[i];
481 }
UniquePtr< Epetra_Map > _map
template<typename T >
void libMesh::EpetraVector< 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 486 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::close(), libMesh::EpetraVector< T >::init(), libMesh::EpetraVector< T >::localize(), libMesh::PARALLEL, and libMesh::EpetraVector< T >::set().

489 {
490  // Only good for serial vectors.
491  libmesh_assert_equal_to (this->size(), this->local_size());
492  libmesh_assert_greater (last_local_idx, first_local_idx);
493  libmesh_assert_less_equal (send_list.size(), this->size());
494  libmesh_assert_less (last_local_idx, this->size());
495 
496  const unsigned int my_size = this->size();
497  const unsigned int my_local_size = (last_local_idx - first_local_idx + 1);
498 
499  // Don't bother for serial cases
500  if ((first_local_idx == 0) &&
501  (my_local_size == my_size))
502  return;
503 
504  // Build a parallel vector, initialize it with the local
505  // parts of (*this)
506  EpetraVector<T> parallel_vec(this->comm(), PARALLEL);
507 
508  parallel_vec.init (my_size, my_local_size, true, PARALLEL);
509 
510  // Copy part of *this into the parallel_vec
511  for (numeric_index_type i=first_local_idx; i<=last_local_idx; i++)
512  parallel_vec.set(i,this->el(i));
513 
514  // localize like normal
515  parallel_vec.close();
516  parallel_vec.localize (*this, send_list);
517  this->close();
518 }
virtual numeric_index_type local_size() const libmesh_override
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual void close() libmesh_override
const Parallel::Communicator & comm() const
virtual numeric_index_type size() const libmesh_override
template<typename T >
void libMesh::EpetraVector< 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 546 of file trilinos_epetra_vector.C.

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

548 {
549  // This function must be run on all processors at once
550  parallel_object_only();
551 
552  const unsigned int n = this->size();
553  const unsigned int nl = this->local_size();
554 
555  libmesh_assert_less (pid, this->n_processors());
556  libmesh_assert(this->_vec);
557 
558  v_local.clear();
559  v_local.reserve(n);
560 
561 
562  // build up my local part
563  for (unsigned int i=0; i<nl; i++)
564  v_local.push_back((*this->_vec)[i]);
565 
566  this->comm().gather (pid, v_local);
567 }
virtual numeric_index_type local_size() const libmesh_override
processor_id_type n_processors() const
libmesh_assert(j)
void gather(const unsigned int root_id, const T &send, std::vector< T > &recv) const
const Parallel::Communicator & comm() const
virtual numeric_index_type size() const libmesh_override
template<typename T >
Real libMesh::EpetraVector< T >::max ( ) const
inlinevirtual
Returns
The maximum entry in the vector, or the maximum real part in the case of complex numbers.

Implements libMesh::NumericVector< T >.

Definition at line 795 of file trilinos_epetra_vector.h.

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

796 {
797  libmesh_assert (this->initialized());
798 
799  T value;
800 
801  _vec->MaxValue(&value);
802 
803  return value;
804 }
virtual bool initialized() const
libmesh_assert(j)
template<typename T >
Real libMesh::EpetraVector< T >::min ( ) const
inlinevirtual
Returns
The minimum entry in the vector, or the minimum real part in the case of complex numbers.

Implements libMesh::NumericVector< T >.

Definition at line 780 of file trilinos_epetra_vector.h.

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

781 {
782  libmesh_assert (this->initialized());
783 
784  T value;
785 
786  _vec->MinValue(&value);
787 
788  return value;
789 }
virtual bool initialized() const
libmesh_assert(j)
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), 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::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:722
const Parallel::Communicator & _communicator
template<typename T >
T libMesh::EpetraVector< T >::operator() ( const numeric_index_type  i) const
inlinevirtual
Returns
A copy of the ith entry of the vector.

Implements libMesh::NumericVector< T >.

Definition at line 767 of file trilinos_epetra_vector.h.

References libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::EpetraVector< T >::last_local_index(), and libMesh::libmesh_assert().

768 {
769  libmesh_assert (this->initialized());
770  libmesh_assert ( ((i >= this->first_local_index()) &&
771  (i < this->last_local_index())) );
772 
773  return (*_vec)[i-this->first_local_index()];
774 }
virtual bool initialized() const
libmesh_assert(j)
virtual numeric_index_type last_local_index() const libmesh_override
virtual numeric_index_type first_local_index() const libmesh_override
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a)
inlineinherited

Scales the vector by a, $ \vec{u} \leftarrow a\vec{u} $. Equivalent to u.scale(a)

Returns
A reference to *this.

Definition at line 384 of file numeric_vector.h.

384 { this->scale(a); return *this; }
virtual void scale(const T factor)=0
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator+= ( const NumericVector< T > &  v)
virtual

Adds v to *this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $. Equivalent to u.add(1, v).

Returns
A reference to *this.

Implements libMesh::NumericVector< T >.

Definition at line 106 of file trilinos_epetra_vector.C.

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

107 {
108  libmesh_assert(this->closed());
109 
110  this->add(1., v);
111 
112  return *this;
113 }
virtual bool closed() const
libmesh_assert(j)
virtual void add(const numeric_index_type i, const T value) libmesh_override
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator-= ( const NumericVector< T > &  v)
virtual

Subtracts v from *this, $ \vec{u} \leftarrow \vec{u} - \vec{v} $. Equivalent to u.add(-1, v).

Returns
A reference to *this.

Implements libMesh::NumericVector< T >.

Definition at line 119 of file trilinos_epetra_vector.C.

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

120 {
121  libmesh_assert(this->closed());
122 
123  this->add(-1., v);
124 
125  return *this;
126 }
virtual bool closed() const
libmesh_assert(j)
virtual void add(const numeric_index_type i, const T value) libmesh_override
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator/= ( NumericVector< T > &  )
virtual

Computes the pointwise division of this vector's entries by another's, $ u_i \leftarrow \frac{u_i}{v_i} \, \forall i$

Returns
A reference to *this.

Implements libMesh::NumericVector< T >.

Definition at line 131 of file trilinos_epetra_vector.C.

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

132 {
133  libmesh_assert(this->closed());
134  libmesh_assert_equal_to(size(), v.size());
135 
136  EpetraVector<T> & v_vec = cast_ref<EpetraVector<T> &>(v);
137 
138  _vec->ReciprocalMultiply(1.0, *v_vec._vec, *_vec, 0.0);
139 
140  return *this;
141 }
virtual bool closed() const
libmesh_assert(j)
virtual numeric_index_type size() const libmesh_override
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const T  a)
inlineinherited

Scales the vector by 1/a, $ \vec{u} \leftarrow \frac{1}{a}\vec{u} $. Equivalent to u.scale(1./a)

Returns
A reference to *this.

Definition at line 393 of file numeric_vector.h.

Referenced by libMesh::NumericVector< Number >::operator/=().

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

Sets all entries of the vector to the value s.

Returns
A reference to *this.

Implements libMesh::NumericVector< T >.

Definition at line 337 of file trilinos_epetra_vector.C.

338 {
339  _vec->PutScalar(s_in);
340 
341  return *this;
342 }
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator= ( const NumericVector< T > &  v)
virtual

Sets (*this)(i) = v(i) for each entry of the vector.

Returns
A reference to *this as the base type.

Implements libMesh::NumericVector< T >.

Definition at line 348 of file trilinos_epetra_vector.C.

349 {
350  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
351 
352  *this = *v;
353 
354  return *this;
355 }
template<typename T >
EpetraVector< T > & libMesh::EpetraVector< T >::operator= ( const EpetraVector< T > &  v)

Sets (*this)(i) = v(i) for each entry of the vector.

Returns
A reference to *this as the derived type.

Definition at line 361 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec.

362 {
363  (*_vec) = *v._vec;
364 
365  // FIXME - what about our communications data?
366 
367  return *this;
368 }
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator= ( const std::vector< T > &  v)
virtual

Sets (*this)(i) = v(i) for each entry of the vector.

Returns
A reference to *this as the base type.

Case 1: The vector is the same size of The global vector. Only add the local components.

Case 2: The vector is the same size as our local piece. Insert directly to the local piece.

Implements libMesh::NumericVector< T >.

Definition at line 374 of file trilinos_epetra_vector.C.

375 {
376  T * values = _vec->Values();
377 
382  if (this->size() == v.size())
383  {
384  const unsigned int nl=this->local_size();
385  const unsigned int fli=this->first_local_index();
386 
387  for (unsigned int i=0;i<nl;i++)
388  values[i]=v[fli+i];
389  }
390 
395  else
396  {
397  libmesh_assert_equal_to (v.size(), this->local_size());
398 
399  const unsigned int nl=this->local_size();
400 
401  for (unsigned int i=0;i<nl;i++)
402  values[i]=v[i];
403  }
404 
405  return *this;
406 }
virtual numeric_index_type local_size() const libmesh_override
virtual numeric_index_type first_local_index() const libmesh_override
virtual numeric_index_type size() const libmesh_override
template<typename T >
void libMesh::EpetraVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
virtual

Computes $ u_i \leftarrow u_i v_i $ (summation not implied) i.e. the pointwise (component-wise) product of vec1 and vec2, and stores the result in *this.

Implements libMesh::NumericVector< T >.

Definition at line 325 of file trilinos_epetra_vector.C.

References libMesh::EpetraVector< T >::_vec.

327 {
328  const EpetraVector<T> * v1 = cast_ptr<const EpetraVector<T> *>(&vec1);
329  const EpetraVector<T> * v2 = cast_ptr<const EpetraVector<T> *>(&vec2);
330 
331  _vec->Multiply(1.0, *v1->_vec, *v2->_vec, 0.0);
332 }
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 918 of file numeric_vector.h.

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

Referenced by libMesh::NumericVector< Number >::operator/=().

919 {
920  libmesh_assert (this->initialized());
921  os << "Size\tglobal = " << this->size()
922  << "\t\tlocal = " << this->local_size() << std::endl;
923 
924  os << "#\tValue" << std::endl;
925  for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
926  os << i << "\t" << (*this)(i) << std::endl;
927 }
virtual numeric_index_type size() const =0
virtual numeric_index_type last_local_index() const =0
virtual bool initialized() const
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type local_size() const =0
virtual numeric_index_type first_local_index() const =0
template<>
void libMesh::NumericVector< Complex >::print ( std::ostream &  os) const
inlineinherited

Definition at line 900 of file numeric_vector.h.

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

901 {
902  libmesh_assert (this->initialized());
903  os << "Size\tglobal = " << this->size()
904  << "\t\tlocal = " << this->local_size() << std::endl;
905 
906  // std::complex<>::operator<<() is defined, but use this form
907  os << "#\tReal part\t\tImaginary part" << std::endl;
908  for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
909  os << i << "\t"
910  << (*this)(i).real() << "\t\t"
911  << (*this)(i).imag() << std::endl;
912 }
virtual numeric_index_type size() const =0
virtual numeric_index_type last_local_index() const =0
virtual bool initialized() const
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type local_size() const =0
virtual numeric_index_type first_local_index() const =0
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 955 of file numeric_vector.h.

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

Referenced by libMesh::NumericVector< Number >::operator/=().

956 {
957  libmesh_assert (this->initialized());
958 
959  std::vector<T> v(this->size());
960  this->localize(v);
961 
962  // Right now we only want one copy of the output
963  if (this->processor_id())
964  return;
965 
966  os << "Size\tglobal = " << this->size() << std::endl;
967  os << "#\tValue" << std::endl;
968  for (numeric_index_type i=0; i!=v.size(); i++)
969  os << i << "\t" << v[i] << std::endl;
970 }
virtual numeric_index_type size() const =0
virtual bool initialized() const
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual void localize(std::vector< T > &v_local) const =0
processor_id_type processor_id() const
template<>
void libMesh::NumericVector< Complex >::print_global ( std::ostream &  os) const
inlineinherited

Definition at line 933 of file numeric_vector.h.

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

934 {
935  libmesh_assert (this->initialized());
936 
937  std::vector<Complex> v(this->size());
938  this->localize(v);
939 
940  // Right now we only want one copy of the output
941  if (this->processor_id())
942  return;
943 
944  os << "Size\tglobal = " << this->size() << std::endl;
945  os << "#\tReal part\t\tImaginary part" << std::endl;
946  for (numeric_index_type i=0; i!=v.size(); i++)
947  os << i << "\t"
948  << v[i].real() << "\t\t"
949  << v[i].imag() << std::endl;
950 }
virtual numeric_index_type size() const =0
virtual bool initialized() const
libmesh_assert(j)
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual void localize(std::vector< T > &v_local) const =0
processor_id_type processor_id() const
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().

Referenced by libMesh::LibMeshInit::LibMeshInit().

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
static std::string get_info()
template<typename T>
virtual void libMesh::NumericVector< T >::print_matlab ( const std::string &  = "") const
inlinevirtualinherited

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

Reimplemented in libMesh::PetscVector< T >.

Definition at line 674 of file numeric_vector.h.

675  {
676  libmesh_not_implemented();
677  }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), 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::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::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::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), 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::DofMap::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::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), 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::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::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::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), 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::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:720
template<typename T >
void libMesh::EpetraVector< T >::reciprocal ( )
virtual

Computes the pointwise reciprocal, $ u_i \leftarrow \frac{1}{u_i} \, \forall i$

Implements libMesh::NumericVector< T >.

Definition at line 162 of file trilinos_epetra_vector.C.

References std::abs(), and std::min().

163 {
164  // The Epetra::reciprocal() function takes a constant reference to *another* vector,
165  // and fills _vec with its reciprocal. Does that mean we can't pass *_vec as the
166  // argument?
167  // _vec->reciprocal( *_vec );
168 
169  // Alternatively, compute the reciprocal by hand... see also the add(T) member that does this...
170  const unsigned int nl = _vec->MyLength();
171 
172  T * values = _vec->Values();
173 
174  for (unsigned int i=0; i<nl; i++)
175  {
176  // Don't divide by zero (maybe only check this in debug mode?)
177  if (std::abs(values[i]) < std::numeric_limits<T>::min())
178  libmesh_error_msg("Error, divide by zero in DistributedVector<T>::reciprocal()!");
179 
180  values[i] = 1. / values[i];
181  }
182 
183  // Leave the vector in a closed state...
184  this->close();
185 }
double abs(double a)
virtual void close() libmesh_override
long double min(long double a, double b)
template<typename T >
int libMesh::EpetraVector< T >::ReplaceGlobalValues ( int  numIDs,
const int *  GIDs,
const double *  values 
)
private

Copy values into the vector overwriting any values that already exist for the specified indices.

Definition at line 619 of file trilinos_epetra_vector.C.

622 {
623  return( inputValues( numIDs, GIDs, values, false) );
624 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
template<typename T >
int libMesh::EpetraVector< T >::ReplaceGlobalValues ( const Epetra_IntSerialDenseVector &  GIDs,
const Epetra_SerialDenseVector &  values 
)
private

Copy values into the vector, replacing any values that already exist for the specified GIDs.

Parameters
GIDsList of global ids. Must be the same length as the accompanying list of values.
valuesList of coefficient values. Must be the same length as the accompanying list of GIDs.

Definition at line 628 of file trilinos_epetra_vector.C.

630 {
631  if (GIDs.Length() != values.Length()) {
632  return(-1);
633  }
634 
635  return( inputValues( GIDs.Length(), GIDs.Values(), values.Values(), false) );
636 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
template<typename T >
int libMesh::EpetraVector< T >::ReplaceGlobalValues ( int  numIDs,
const int *  GIDs,
const int *  numValuesPerID,
const double *  values 
)
private

Definition at line 640 of file trilinos_epetra_vector.C.

644 {
645  return( inputValues( numIDs, GIDs, numValuesPerID, values, false) );
646 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
template<typename T >
void libMesh::EpetraVector< T >::scale ( const T  factor)
virtual

Scale each element of the vector by the given factor.

Implements libMesh::NumericVector< T >.

Definition at line 299 of file trilinos_epetra_vector.C.

300 {
301  _vec->Scale(factor_in);
302 }
template<typename T >
void libMesh::EpetraVector< T >::set ( const numeric_index_type  i,
const T  value 
)
virtual

Sets v(i) = value.

Implements libMesh::NumericVector< T >.

Definition at line 147 of file trilinos_epetra_vector.C.

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

148 {
149  int i = static_cast<int> (i_in);
150  T value = value_in;
151 
152  libmesh_assert_less (i_in, this->size());
153 
154  ReplaceGlobalValues(1, &i, &value);
155 
156  this->_is_closed = false;
157 }
int ReplaceGlobalValues(int numIDs, const int *GIDs, const double *values)
virtual numeric_index_type size() const libmesh_override
template<typename T >
numeric_index_type libMesh::EpetraVector< T >::size ( ) const
inlinevirtual
Returns
The size of the vector.

Implements libMesh::NumericVector< T >.

Definition at line 726 of file trilinos_epetra_vector.h.

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

Referenced by libMesh::EpetraVector< T >::add().

727 {
728  libmesh_assert (this->initialized());
729 
730  return _vec->GlobalLength();
731 }
virtual bool initialized() const
libmesh_assert(j)
template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices) const
virtualinherited
Returns
The $ \ell_1 $-norm of the vector, i.e. the sum of the absolute values for the specified entries in the vector.
Note
The indices must necessarily live on this processor.

Definition at line 323 of file numeric_vector.C.

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

Referenced by libMesh::NumericVector< Number >::closed(), and libMesh::System::discrete_var_norm().

324 {
325  const NumericVector<T> & v = *this;
326 
327  std::set<numeric_index_type>::const_iterator it = indices.begin();
328  const std::set<numeric_index_type>::const_iterator it_end = indices.end();
329 
330  Real norm = 0;
331 
332  for (; it!=it_end; ++it)
333  norm += std::abs(v(*it));
334 
335  this->comm().sum(norm);
336 
337  return norm;
338 }
double abs(double a)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Parallel::Communicator & comm() const
template<class T >
Real libMesh::NumericVector< T >::subset_l2_norm ( const std::set< numeric_index_type > &  indices) const
virtualinherited
Returns
The $ \ell_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
The indices must necessarily live on this processor.

Definition at line 341 of file numeric_vector.C.

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

Referenced by libMesh::NumericVector< Number >::closed(), and libMesh::System::discrete_var_norm().

342 {
343  const NumericVector<T> & v = *this;
344 
345  std::set<numeric_index_type>::const_iterator it = indices.begin();
346  const std::set<numeric_index_type>::const_iterator it_end = indices.end();
347 
348  Real norm = 0;
349 
350  for (; it!=it_end; ++it)
351  norm += TensorTools::norm_sq(v(*it));
352 
353  this->comm().sum(norm);
354 
355  return std::sqrt(norm);
356 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Parallel::Communicator & comm() const
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 $ \ell_{\infty} $-norm of a vector.
Note
The indices must necessarily live on this processor.

Definition at line 359 of file numeric_vector.C.

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

Referenced by libMesh::NumericVector< Number >::closed(), and libMesh::System::discrete_var_norm().

360 {
361  const NumericVector<T> & v = *this;
362 
363  std::set<numeric_index_type>::const_iterator it = indices.begin();
364  const std::set<numeric_index_type>::const_iterator it_end = indices.end();
365 
366  Real norm = 0;
367 
368  for (; it!=it_end; ++it)
369  {
370  Real value = std::abs(v(*it));
371  if (value > norm)
372  norm = value;
373  }
374 
375  this->comm().max(norm);
376 
377  return norm;
378 }
double abs(double a)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Parallel::Communicator & comm() const
template<typename T >
T libMesh::EpetraVector< T >::sum ( ) const
virtual
Returns
The sum of all values in the vector.

Implements libMesh::NumericVector< T >.

Definition at line 50 of file trilinos_epetra_vector.C.

References libMesh::closed(), libMesh::libmesh_assert(), and libMesh::Parallel::sum().

51 {
52  libmesh_assert(this->closed());
53 
54  const unsigned int nl = _vec->MyLength();
55 
56  T sum=0.0;
57 
58  T * values = _vec->Values();
59 
60  for (unsigned int i=0; i<nl; i++)
61  sum += values[i];
62 
63  this->comm().sum(sum);
64 
65  return sum;
66 }
virtual bool closed() const
virtual T sum() const libmesh_override
libmesh_assert(j)
const Parallel::Communicator & comm() const
template<typename T >
int libMesh::EpetraVector< T >::SumIntoGlobalValues ( int  numIDs,
const int *  GIDs,
const double *  values 
)
private

Accumulate values into the vector, adding them to any values that already exist for the specified indices.

Definition at line 588 of file trilinos_epetra_vector.C.

591 {
592  return( inputValues( numIDs, GIDs, values, true) );
593 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
template<typename T >
int libMesh::EpetraVector< T >::SumIntoGlobalValues ( const Epetra_IntSerialDenseVector &  GIDs,
const Epetra_SerialDenseVector &  values 
)
private

Accumulate values into the vector, adding them to any values that already exist for the specified GIDs.

Parameters
GIDsList of global ids. Must be the same length as the accompanying list of values.
valuesList of coefficient values. Must be the same length as the accompanying list of GIDs.

Definition at line 597 of file trilinos_epetra_vector.C.

599 {
600  if (GIDs.Length() != values.Length()) {
601  return(-1);
602  }
603 
604  return( inputValues( GIDs.Length(), GIDs.Values(), values.Values(), true) );
605 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
template<typename T >
int libMesh::EpetraVector< T >::SumIntoGlobalValues ( int  numIDs,
const int *  GIDs,
const int *  numValuesPerID,
const double *  values 
)
private

Definition at line 609 of file trilinos_epetra_vector.C.

613 {
614  return( inputValues( numIDs, GIDs, numValuesPerID, values, true) );
615 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
template<typename T >
void libMesh::EpetraVector< T >::swap ( NumericVector< T > &  v)
inlinevirtual

Swaps the contents of this with v. There should be enough indirection in subclasses to make this an O(1) header-swap operation.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 810 of file trilinos_epetra_vector.h.

References libMesh::EpetraVector< T >::_destroy_vec_on_exit, libMesh::EpetraVector< T >::_map, libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::allocatedNonlocalLength_, libMesh::EpetraVector< T >::ignoreNonLocalEntries_, libMesh::EpetraVector< T >::last_edit, libMesh::EpetraVector< T >::myCoefs_, libMesh::EpetraVector< T >::myFirstID_, libMesh::EpetraVector< T >::myNumIDs_, libMesh::EpetraVector< T >::nonlocalCoefs_, libMesh::EpetraVector< T >::nonlocalElementSize_, libMesh::EpetraVector< T >::nonlocalIDs_, libMesh::EpetraVector< T >::numNonlocalIDs_, swap(), and libMesh::NumericVector< T >::swap().

Referenced by libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), and libMesh::Problem_Interface::computePreconditioner().

811 {
812  NumericVector<T>::swap(other);
813 
814  EpetraVector<T> & v = cast_ref<EpetraVector<T> &>(other);
815 
816  std::swap(_vec, v._vec);
817  _map.swap(v._map);
818  std::swap(_destroy_vec_on_exit, v._destroy_vec_on_exit);
819  std::swap(myFirstID_, v.myFirstID_);
820  std::swap(myNumIDs_, v.myNumIDs_);
821  std::swap(myCoefs_, v.myCoefs_);
822  std::swap(nonlocalIDs_, v.nonlocalIDs_);
823  std::swap(nonlocalElementSize_, v.nonlocalElementSize_);
824  std::swap(numNonlocalIDs_, v.numNonlocalIDs_);
825  std::swap(allocatedNonlocalLength_, v.allocatedNonlocalLength_);
826  std::swap(nonlocalCoefs_, v.nonlocalCoefs_);
827  std::swap(last_edit, v.last_edit);
828  std::swap(ignoreNonLocalEntries_, v.ignoreNonLocalEntries_);
829 }
UniquePtr< Epetra_Map > _map
virtual void swap(NumericVector< T > &v)
void swap(Iterator &lhs, Iterator &rhs)
template<typename T>
ParallelType& libMesh::NumericVector< T >::type ( )
inlineinherited
Returns
The type (SERIAL, PARALLEL, GHOSTED) of the vector.

Definition at line 145 of file numeric_vector.h.

145 { return _type; }
template<typename T>
Epetra_Vector* libMesh::EpetraVector< T >::vec ( )
inline
Returns
The raw Epetra_Vector pointer.
Note
This is generally not required in user-level code.
Don't do anything crazy like deleting the pointer, or very bad things will likely happen!

Definition at line 264 of file trilinos_epetra_vector.h.

References libMesh::EpetraVector< T >::_vec, and libMesh::libmesh_assert().

Referenced by libMesh::EpetraMatrix< T >::get_diagonal(), and libMesh::NoxNonlinearSolver< T >::solve().

264 { libmesh_assert(_vec); return _vec; }
libmesh_assert(j)
template<typename T >
void libMesh::EpetraVector< T >::zero ( )
inlinevirtual

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

Implements libMesh::NumericVector< T >.

Definition at line 691 of file trilinos_epetra_vector.h.

References libMesh::EpetraVector< T >::_vec, libMesh::NumericVector< T >::closed(), libMesh::NumericVector< T >::initialized(), and libMesh::libmesh_assert().

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

692 {
693  libmesh_assert (this->initialized());
694  libmesh_assert (this->closed());
695 
696  _vec->PutScalar(0.0);
697 }
virtual bool closed() const
virtual bool initialized() const
libmesh_assert(j)
template<typename T >
UniquePtr< NumericVector< T > > libMesh::EpetraVector< T >::zero_clone ( ) const
inlinevirtual
Returns
A smart pointer to a copy of this vector with the same type, size, and partitioning, but with all zero entries.
Note
This must be overridden in the derived classes.

Implements libMesh::NumericVector< T >.

Definition at line 703 of file trilinos_epetra_vector.h.

References libMesh::AUTOMATIC, libMesh::ParallelObject::comm(), and libMesh::NumericVector< T >::init().

Referenced by libMesh::EpetraVector< T >::add_vector().

704 {
705  NumericVector<T> * cloned_vector = new EpetraVector<T>(this->comm(), AUTOMATIC);
706  cloned_vector->init(*this);
707  return UniquePtr<NumericVector<T> >(cloned_vector);
708 }
const Parallel::Communicator & comm() const

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
template<typename T>
bool libMesh::EpetraVector< T >::_destroy_vec_on_exit
private

This boolean value should only be set to false for the constructor which takes a Epetra Vec object.

Definition at line 282 of file trilinos_epetra_vector.h.

Referenced by libMesh::EpetraVector< T >::clear(), libMesh::EpetraVector< T >::EpetraVector(), and libMesh::EpetraVector< T >::swap().

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 143 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>
UniquePtr<Epetra_Map> libMesh::EpetraVector< T >::_map
private
Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 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 132 of file reference_counter.h.

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

template<typename T>
int libMesh::EpetraVector< T >::allocatedNonlocalLength_
private
template<typename T>
bool libMesh::EpetraVector< T >::ignoreNonLocalEntries_
private
template<typename T>
unsigned char libMesh::EpetraVector< T >::last_edit
private

Keep track of whether the last write operation on this vector was nothing (0) or a sum (1) or an add (2), so we can decide how to do the GlobalAssemble()

Definition at line 397 of file trilinos_epetra_vector.h.

Referenced by libMesh::EpetraVector< T >::close(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::EpetraVector< T >::init(), and libMesh::EpetraVector< T >::swap().

template<typename T>
double* libMesh::EpetraVector< T >::myCoefs_
private
template<typename T>
int libMesh::EpetraVector< T >::myFirstID_
private
template<typename T>
double** libMesh::EpetraVector< T >::nonlocalCoefs_
private
template<typename T>
int* libMesh::EpetraVector< T >::nonlocalElementSize_
private

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