Public Member Functions | Private Member Functions | Private Attributes | List of all members
oomph::DoubleMultiVector Class Reference

A multi vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this multi vector can be distributed - its distribution is described by the LinearAlgebraDistribution object at Distribution_pt. Data is stored in a C-style pointer vector (double*) More...

#include <double_multi_vector.h>

+ Inheritance diagram for oomph::DoubleMultiVector:

Public Member Functions

 DoubleMultiVector ()
 Constructor for an uninitialized DoubleMultiVector.
 
 DoubleMultiVector (const unsigned &n_vector, const LinearAlgebraDistribution *const &dist_pt, const double &v=0.0)
 Constructor. Assembles a DoubleMultiVector consisting of n_vector vectors, each with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).
 
 DoubleMultiVector (const unsigned &n_vector, const LinearAlgebraDistribution &dist, const double &v=0.0)
 Constructor. Assembles a DoubleMultiVector consisting of n_vector vectors, each with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).
 
 DoubleMultiVector (const unsigned &n_vector, const DoubleMultiVector &old_vector, const double &initial_value=0.0)
 Constructor. Build a multivector using the same distribution of the input vector with n_vector columns and initialised to the value v.
 
 DoubleMultiVector (const DoubleMultiVector &old_vector, const std::vector< int > &index, const bool &deep_copy=true)
 Constructor that builds a multivector from selected columns of the input multivector. The boolean controls whether it is a shallow or deep copy (default deep)
 
 DoubleMultiVector (const DoubleMultiVector &old_vector, const Teuchos::Range1D &index, const bool &deep_copy=true)
 Constructor that builds a multivector from selected columns of the input multivector and the provided range. The optional boolean specifies whether it is a shallow or deep copy. The default is that it is a deep copy.
 
 DoubleMultiVector (const DoubleMultiVector &new_vector)
 Copy constructor.
 
 ~DoubleMultiVector ()
 Destructor - just calls this->clear() to delete the distribution and data.
 
void operator= (const DoubleMultiVector &old_vector)
 assignment operator (deep copy)
 
unsigned nvector () const
 Return the number of vectors.
 
void shallow_build (const DoubleMultiVector &old_vector)
 Provide a (shallow) copy of the old vector.
 
void shallow_build (const unsigned &n_vector, const LinearAlgebraDistribution &dist)
 Build the storage for pointers to vectors with a given distribution, but do not populate the pointers.
 
void shallow_build (const unsigned &n_vector, const LinearAlgebraDistribution *const &dist_pt)
 Build the storage for pointers to vectors with a given distribution, but do not populate the pointers.
 
void build (const DoubleMultiVector &old_vector)
 Provides a (deep) copy of the old_vector.
 
void build (const unsigned &n_vector, const LinearAlgebraDistribution &dist, const double &initial_value=0.0)
 Assembles a DoubleMultiVector with n_vector vectors, a distribution dist, if v is specified each element is set to v, otherwise each element is set to 0.0.
 
void build (const unsigned &n_vector, const LinearAlgebraDistribution *const &dist_pt, const double &initial_value=0.0)
 Assembles a DoubleMultiVector with n_vector vectors, each with a distribution dist, if v is specified each element is set to v, otherwise each element is set to 0.0.
 
void initialise (const double &initial_value)
 initialise the whole vector with value v
 
void clear ()
 initialise the vector with coefficient from the vector v. Note: The vector v must be of length
 
bool built () const
 
void redistribute (const LinearAlgebraDistribution *const &dist_pt)
 Allows are external data to be used by this vector. WARNING: The size of the external data must correspond to the LinearAlgebraDistribution dist_pt argument.
 
doubleoperator() (int v, int i) const
 [] access function to the (local) values of the v-th vector
 
bool operator== (const DoubleMultiVector &vec)
 == operator
 
void operator+= (DoubleMultiVector vec)
 += operator
 
void operator-= (DoubleMultiVector vec)
 -= operator
 
void operator*= (const double &scalar_value)
 Multiply by a scalar.
 
double ** values ()
 access function to the underlying values
 
double ** values () const
 access function to the underlying values (const version)
 
doublevalues (const unsigned &i)
 access function to the i-th vector's data
 
doublevalues (const unsigned &i) const
 access function to the i-th vector's data (const version)
 
DoubleVectordoublevector (const unsigned &i)
 access to the DoubleVector representatoin
 
const DoubleVectordoublevector (const unsigned &i) const
 access to the DoubleVector representation (const version)
 
void output (std::ostream &outfile) const
 output the contents of the vector
 
void output (std::string filename)
 output the contents of the vector
 
void dot (const DoubleMultiVector &vec, std::vector< double > &result) const
 compute the 2 norm of this vector
 
void norm (std::vector< double > &result) const
 compute the 2 norm of this vector
 
- Public Member Functions inherited from oomph::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution.
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)=delete
 Broken copy constructor.
 
void operator= (const DistributableLinearAlgebraObject &)=delete
 Broken assignment operator.
 
virtual ~DistributableLinearAlgebraObject ()
 Destructor.
 
LinearAlgebraDistributiondistribution_pt () const
 access to the LinearAlgebraDistribution
 
unsigned nrow () const
 access function to the number of global rows.
 
unsigned nrow_local () const
 access function for the num of local rows on this processor.
 
unsigned nrow_local (const unsigned &p) const
 access function for the num of local rows on this processor.
 
unsigned first_row () const
 access function for the first row on this processor
 
unsigned first_row (const unsigned &p) const
 access function for the first row on this processor
 
bool distributed () const
 distribution is serial or distributed
 
bool distribution_built () const
 if the communicator_pt is null then the distribution is not setup then false is returned, otherwise return true
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 setup the distribution of this distributable linear algebra object
 
void build_distribution (const LinearAlgebraDistribution &dist)
 setup the distribution of this distributable linear algebra object
 

Private Member Functions

void setup_doublevector_representation ()
 compute the A-norm using the matrix at matrix_pt
 

Private Attributes

double ** Values
 the local data, need a pointer to a pointer so that the individual vectors can be extracted
 
unsigned Nvector
 The number of vectors.
 
bool Internal_values
 Boolean flag to indicate whether the vector's data (values_pt) is owned by this vector.
 
bool Built
 indicates that the vector has been built and is usable
 
Vector< DoubleVectorInternal_doublevector
 Need a vector of DoubleVectors to interface with our linear solvers.
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 clear the distribution of this distributable linear algebra object
 

Detailed Description

A multi vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this multi vector can be distributed - its distribution is described by the LinearAlgebraDistribution object at Distribution_pt. Data is stored in a C-style pointer vector (double*)

Definition at line 55 of file double_multi_vector.h.

Constructor & Destructor Documentation

◆ DoubleMultiVector() [1/7]

oomph::DoubleMultiVector::DoubleMultiVector ( )
inline

Constructor for an uninitialized DoubleMultiVector.

Definition at line 59 of file double_multi_vector.h.

◆ DoubleMultiVector() [2/7]

oomph::DoubleMultiVector::DoubleMultiVector ( const unsigned n_vector,
const LinearAlgebraDistribution *const dist_pt,
const double v = 0.0 
)
inline

Constructor. Assembles a DoubleMultiVector consisting of n_vector vectors, each with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).

Definition at line 68 of file double_multi_vector.h.

References build(), and setup_doublevector_representation().

◆ DoubleMultiVector() [3/7]

oomph::DoubleMultiVector::DoubleMultiVector ( const unsigned n_vector,
const LinearAlgebraDistribution dist,
const double v = 0.0 
)
inline

Constructor. Assembles a DoubleMultiVector consisting of n_vector vectors, each with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).

Definition at line 81 of file double_multi_vector.h.

References build(), and setup_doublevector_representation().

◆ DoubleMultiVector() [4/7]

oomph::DoubleMultiVector::DoubleMultiVector ( const unsigned n_vector,
const DoubleMultiVector old_vector,
const double initial_value = 0.0 
)
inline

Constructor. Build a multivector using the same distribution of the input vector with n_vector columns and initialised to the value v.

Definition at line 93 of file double_multi_vector.h.

References build(), and setup_doublevector_representation().

◆ DoubleMultiVector() [5/7]

oomph::DoubleMultiVector::DoubleMultiVector ( const DoubleMultiVector old_vector,
const std::vector< int > &  index,
const bool deep_copy = true 
)
inline

Constructor that builds a multivector from selected columns of the input multivector. The boolean controls whether it is a shallow or deep copy (default deep)

Definition at line 105 of file double_multi_vector.h.

References build(), i, oomph::DistributableLinearAlgebraObject::nrow_local(), setup_doublevector_representation(), shallow_build(), oomph::FiniteElement::size(), and Values.

◆ DoubleMultiVector() [6/7]

oomph::DoubleMultiVector::DoubleMultiVector ( const DoubleMultiVector old_vector,
const Teuchos::Range1D &  index,
const bool deep_copy = true 
)
inline

Constructor that builds a multivector from selected columns of the input multivector and the provided range. The optional boolean specifies whether it is a shallow or deep copy. The default is that it is a deep copy.

Definition at line 144 of file double_multi_vector.h.

References build(), i, oomph::DistributableLinearAlgebraObject::nrow_local(), setup_doublevector_representation(), shallow_build(), oomph::FiniteElement::size(), and Values.

◆ DoubleMultiVector() [7/7]

oomph::DoubleMultiVector::DoubleMultiVector ( const DoubleMultiVector new_vector)
inline

Copy constructor.

Definition at line 184 of file double_multi_vector.h.

References build(), and setup_doublevector_representation().

◆ ~DoubleMultiVector()

oomph::DoubleMultiVector::~DoubleMultiVector ( )
inline

Destructor - just calls this->clear() to delete the distribution and data.

Definition at line 198 of file double_multi_vector.h.

References clear().

Member Function Documentation

◆ build() [1/3]

void oomph::DoubleMultiVector::build ( const DoubleMultiVector old_vector)
inline

◆ build() [2/3]

void oomph::DoubleMultiVector::build ( const unsigned n_vector,
const LinearAlgebraDistribution dist,
const double initial_value = 0.0 
)
inline

Assembles a DoubleMultiVector with n_vector vectors, a distribution dist, if v is specified each element is set to v, otherwise each element is set to 0.0.

Definition at line 313 of file double_multi_vector.h.

References build().

◆ build() [3/3]

void oomph::DoubleMultiVector::build ( const unsigned n_vector,
const LinearAlgebraDistribution *const dist_pt,
const double initial_value = 0.0 
)
inline

Assembles a DoubleMultiVector with n_vector vectors, each with a distribution dist, if v is specified each element is set to v, otherwise each element is set to 0.0.

Definition at line 323 of file double_multi_vector.h.

References oomph::DistributableLinearAlgebraObject::build_distribution(), Built, clear(), i, Internal_values, oomph::DistributableLinearAlgebraObject::nrow_local(), Nvector, values(), and Values.

◆ built()

bool oomph::DoubleMultiVector::built ( ) const
inline

Definition at line 413 of file double_multi_vector.h.

References Built.

Referenced by dot(), norm(), and operator+=().

◆ clear()

void oomph::DoubleMultiVector::clear ( )
inline

initialise the vector with coefficient from the vector v. Note: The vector v must be of length

wipes the DoubleVector

Definition at line 387 of file double_multi_vector.h.

References Built, oomph::DistributableLinearAlgebraObject::clear_distribution(), Internal_values, and Values.

Referenced by build(), shallow_build(), and ~DoubleMultiVector().

◆ dot()

void oomph::DoubleMultiVector::dot ( const DoubleMultiVector vec,
std::vector< double > &  result 
) const
inline

◆ doublevector() [1/2]

DoubleVector & oomph::DoubleMultiVector::doublevector ( const unsigned i)
inline

◆ doublevector() [2/2]

const DoubleVector & oomph::DoubleMultiVector::doublevector ( const unsigned i) const
inline

access to the DoubleVector representation (const version)

Definition at line 698 of file double_multi_vector.h.

References i, and Internal_doublevector.

◆ initialise()

void oomph::DoubleMultiVector::initialise ( const double initial_value)
inline

initialise the whole vector with value v

Definition at line 364 of file double_multi_vector.h.

References Built, i, oomph::DistributableLinearAlgebraObject::nrow_local(), Nvector, and Values.

Referenced by Anasazi::MultiVecTraits< double, oomph::DoubleMultiVector >::MvInit().

◆ norm()

void oomph::DoubleMultiVector::norm ( std::vector< double > &  result) const
inline

◆ nvector()

unsigned oomph::DoubleMultiVector::nvector ( ) const
inline

◆ operator()()

double & oomph::DoubleMultiVector::operator() ( int  v,
int  i 
) const
inline

[] access function to the (local) values of the v-th vector

Definition at line 484 of file double_multi_vector.h.

References i, oomph::DistributableLinearAlgebraObject::nrow_local(), Nvector, and Values.

◆ operator*=()

void oomph::DoubleMultiVector::operator*= ( const double scalar_value)
inline

◆ operator+=()

void oomph::DoubleMultiVector::operator+= ( DoubleMultiVector  vec)
inline

+= operator

Definition at line 549 of file double_multi_vector.h.

References built(), i, oomph::DistributableLinearAlgebraObject::nrow_local(), nvector(), and Values.

◆ operator-=()

void oomph::DoubleMultiVector::operator-= ( DoubleMultiVector  vec)
inline

◆ operator=()

void oomph::DoubleMultiVector::operator= ( const DoubleMultiVector old_vector)
inline

assignment operator (deep copy)

Definition at line 204 of file double_multi_vector.h.

References build(), and setup_doublevector_representation().

◆ operator==()

bool oomph::DoubleMultiVector::operator== ( const DoubleMultiVector vec)
inline

== operator

Definition at line 514 of file double_multi_vector.h.

References i, oomph::DistributableLinearAlgebraObject::nrow_local(), nvector(), and Values.

◆ output() [1/2]

void oomph::DoubleMultiVector::output ( std::ostream &  outfile) const
inline

◆ output() [2/2]

void oomph::DoubleMultiVector::output ( std::string  filename)
inline

output the contents of the vector

Definition at line 798 of file double_multi_vector.h.

References output().

◆ redistribute()

void oomph::DoubleMultiVector::redistribute ( const LinearAlgebraDistribution *const dist_pt)

Allows are external data to be used by this vector. WARNING: The size of the external data must correspond to the LinearAlgebraDistribution dist_pt argument.

The contents of the vector are redistributed to match the new distribution. In a non-MPI rebuild this method works, but does nothing. NOTE 1: The current distribution and the new distribution must have the same number of global rows. NOTE 2: The current distribution and the new distribution must have the same Communicator.

  1. When a rebuild method is called new internal values are created.
  2. It is not possible to redistribute(...) a vector with external values .
  3. External values are only deleted by this vector if delete_external_values = true. Allows are external data to be used by this vector. WARNING: The size of the external data must correspond to the distribution of this vector.
  1. When a rebuild method is called new internal values are created.
  2. It is not possible to redistribute(...) a vector with external values .
  3. External values are only deleted by this vector if delete_external_values = true. The contents of the vector are redistributed to match the new distribution. In a non-MPI rebuild this method works, but does nothing. NOTE 1: The current distribution and the new distribution must have the same number of global rows. NOTE 2: The current distribution and the new distribution must have the same Communicator.

Definition at line 37 of file double_multi_vector.cc.

References oomph::DistributableLinearAlgebraObject::build_distribution(), oomph::LinearAlgebraDistribution::communicator_pt(), oomph::LinearAlgebraDistribution::distributed(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::DistributableLinearAlgebraObject::first_row(), i, Internal_values, oomph::DistributableLinearAlgebraObject::nrow(), oomph::DistributableLinearAlgebraObject::nrow_local(), Nvector, setup_doublevector_representation(), values(), and Values.

◆ setup_doublevector_representation()

void oomph::DoubleMultiVector::setup_doublevector_representation ( )
inlineprivate

compute the A-norm using the matrix at matrix_pt

Setup the doublevector representation

Definition at line 988 of file double_multi_vector.h.

References oomph::DistributableLinearAlgebraObject::distribution_pt(), Internal_doublevector, nvector(), and values().

Referenced by DoubleMultiVector(), DoubleMultiVector(), DoubleMultiVector(), DoubleMultiVector(), DoubleMultiVector(), DoubleMultiVector(), operator=(), and redistribute().

◆ shallow_build() [1/3]

void oomph::DoubleMultiVector::shallow_build ( const DoubleMultiVector old_vector)
inline

◆ shallow_build() [2/3]

void oomph::DoubleMultiVector::shallow_build ( const unsigned n_vector,
const LinearAlgebraDistribution dist 
)
inline

Build the storage for pointers to vectors with a given distribution, but do not populate the pointers.

Definition at line 243 of file double_multi_vector.h.

References shallow_build().

◆ shallow_build() [3/3]

void oomph::DoubleMultiVector::shallow_build ( const unsigned n_vector,
const LinearAlgebraDistribution *const dist_pt 
)
inline

Build the storage for pointers to vectors with a given distribution, but do not populate the pointers.

Definition at line 252 of file double_multi_vector.h.

References oomph::DistributableLinearAlgebraObject::build_distribution(), Built, clear(), Internal_values, Nvector, and Values.

◆ values() [1/4]

double ** oomph::DoubleMultiVector::values ( )
inline

access function to the underlying values

Definition at line 668 of file double_multi_vector.h.

References Values.

Referenced by build(), redistribute(), and setup_doublevector_representation().

◆ values() [2/4]

double ** oomph::DoubleMultiVector::values ( ) const
inline

access function to the underlying values (const version)

Definition at line 674 of file double_multi_vector.h.

References Values.

◆ values() [3/4]

double * oomph::DoubleMultiVector::values ( const unsigned i)
inline

access function to the i-th vector's data

Definition at line 680 of file double_multi_vector.h.

References i, and Values.

◆ values() [4/4]

double * oomph::DoubleMultiVector::values ( const unsigned i) const
inline

access function to the i-th vector's data (const version)

Definition at line 686 of file double_multi_vector.h.

References i, and Values.

Member Data Documentation

◆ Built

bool oomph::DoubleMultiVector::Built
private

indicates that the vector has been built and is usable

Definition at line 1012 of file double_multi_vector.h.

Referenced by build(), built(), clear(), initialise(), and shallow_build().

◆ Internal_doublevector

Vector<DoubleVector> oomph::DoubleMultiVector::Internal_doublevector
private

Need a vector of DoubleVectors to interface with our linear solvers.

Definition at line 1015 of file double_multi_vector.h.

Referenced by doublevector(), doublevector(), and setup_doublevector_representation().

◆ Internal_values

bool oomph::DoubleMultiVector::Internal_values
private

Boolean flag to indicate whether the vector's data (values_pt) is owned by this vector.

Definition at line 1009 of file double_multi_vector.h.

Referenced by build(), build(), clear(), redistribute(), shallow_build(), and shallow_build().

◆ Nvector

unsigned oomph::DoubleMultiVector::Nvector
private

The number of vectors.

Definition at line 1005 of file double_multi_vector.h.

Referenced by build(), build(), initialise(), nvector(), operator()(), redistribute(), shallow_build(), and shallow_build().

◆ Values

double** oomph::DoubleMultiVector::Values
private

the local data, need a pointer to a pointer so that the individual vectors can be extracted

Definition at line 1002 of file double_multi_vector.h.

Referenced by build(), build(), clear(), dot(), DoubleMultiVector(), DoubleMultiVector(), initialise(), norm(), operator()(), operator*=(), operator+=(), operator-=(), operator==(), output(), redistribute(), shallow_build(), shallow_build(), values(), values(), values(), and values().


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