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

A vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this 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_vector.h>

+ Inheritance diagram for oomph::DoubleVector:

Public Member Functions

 DoubleVector ()
 Constructor for an uninitialized DoubleVector.
 
 DoubleVector (const LinearAlgebraDistribution *const &dist_pt, const double &v=0.0)
 Constructor. Assembles a DoubleVector with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).
 
 DoubleVector (const LinearAlgebraDistribution &dist, const double &v=0.0)
 Constructor. Assembles a DoubleVector with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).
 
 ~DoubleVector ()
 Destructor - just calls this->clear() to delete the distribution and data.
 
 DoubleVector (const DoubleVector &new_vector)
 Copy constructor.
 
void operator= (const DoubleVector &old_vector)
 assignment operator
 
void build (const DoubleVector &old_vector)
 Just copys the argument DoubleVector.
 
void build (const LinearAlgebraDistribution &dist, const double &v)
 Assembles a DoubleVector with distribution dist, if v is specified each element is set to v, otherwise each element is set to 0.0.
 
void build (const LinearAlgebraDistribution *const &dist_pt, const double &v)
 Assembles a DoubleVector with distribution dist, if v is specified each element is set to v, otherwise each element is set to 0.0.
 
void build (const LinearAlgebraDistribution &dist, const Vector< double > &v)
 Assembles a DoubleVector with a distribution dist and coefficients taken from the vector v. Note. The vector v MUST be of length nrow()
 
void build (const LinearAlgebraDistribution *const &dist_pt, const Vector< double > &v)
 Assembles a DoubleVector with a distribution dist and coefficients taken from the vector v. Note. The vector v MUST be of length nrow()
 
void initialise (const double &v)
 initialise the whole vector with value v
 
void initialise (const Vector< double > v)
 initialise the vector with coefficient from the vector v. Note: The vector v must be of length
 
void clear ()
 wipes the DoubleVector
 
bool built () const
 
void set_external_values (const LinearAlgebraDistribution *const &dist_pt, double *external_values, bool delete_external_values)
 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.
 
void set_external_values (double *external_values, bool delete_external_values)
 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.
 
void redistribute (const LinearAlgebraDistribution *const &dist_pt)
 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.
 
doubleoperator[] (int i)
 [] access function to the (local) values of this vector
 
bool operator== (const DoubleVector &v)
 == operator
 
void operator+= (const DoubleVector &v)
 += operator with another vector
 
void operator-= (const DoubleVector &v)
 -= operator with another vector
 
void operator*= (const double &d)
 multiply by a double
 
void operator/= (const double &d)
 divide by a double
 
const doubleoperator[] (int i) const
 [] access function to the (local) values of this vector
 
double max () const
 returns the maximum coefficient
 
doublevalues_pt ()
 access function to the underlying values
 
doublevalues_pt () const
 access function to the underlying values (const version)
 
void output (std::ostream &outfile, const int &output_precision=-1) const
 output the global contents of the vector
 
void output (std::string filename, const int &output_precision=-1) const
 output the global contents of the vector
 
void output_local_values (std::ostream &outfile, const int &output_precision=-1) const
 output the local contents of the vector
 
void output_local_values (std::string filename, const int &output_precision=-1) const
 output the local contents of the vector
 
void output_local_values_with_offset (std::ostream &outfile, const int &output_precision=-1) const
 output the local contents of the vector
 
void output_local_values_with_offset (std::string filename, const int &output_precision=-1) const
 output the local contents of the vector
 
double dot (const DoubleVector &vec) const
 compute the dot product of this vector with the vector vec.
 
double norm () const
 compute the 2 norm of this vector
 
double norm (const CRDoubleMatrix *matrix_pt) const
 compute the A-norm using the matrix at matrix_pt
 
- 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 Attributes

doubleValues_pt
 the local vector
 
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
 

Friends

std::ostream & operator<< (std::ostream &out, const DoubleVector &v)
 Ouput operator for DoubleVector.
 

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 vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this 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 57 of file double_vector.h.

Constructor & Destructor Documentation

◆ DoubleVector() [1/4]

oomph::DoubleVector::DoubleVector ( )
inline

Constructor for an uninitialized DoubleVector.

Definition at line 61 of file double_vector.h.

◆ DoubleVector() [2/4]

oomph::DoubleVector::DoubleVector ( const LinearAlgebraDistribution *const dist_pt,
const double v = 0.0 
)
inline

Constructor. Assembles a DoubleVector with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).

Definition at line 66 of file double_vector.h.

References build().

◆ DoubleVector() [3/4]

oomph::DoubleVector::DoubleVector ( const LinearAlgebraDistribution dist,
const double v = 0.0 
)
inline

Constructor. Assembles a DoubleVector with a prescribed distribution. Additionally every entry can be set (with argument v - defaults to 0).

Definition at line 76 of file double_vector.h.

References build().

◆ ~DoubleVector()

oomph::DoubleVector::~DoubleVector ( )
inline

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

Definition at line 84 of file double_vector.h.

References clear().

◆ DoubleVector() [4/4]

oomph::DoubleVector::DoubleVector ( const DoubleVector new_vector)
inline

Copy constructor.

Definition at line 90 of file double_vector.h.

References build().

Member Function Documentation

◆ build() [1/5]

void oomph::DoubleVector::build ( const DoubleVector old_vector)

Just copys the argument DoubleVector.

Definition at line 35 of file double_vector.cc.

References build(), oomph::DistributableLinearAlgebraObject::distribution_built(), oomph::DistributableLinearAlgebraObject::distribution_pt(), Internal_values, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

Referenced by build(), build(), build(), DoubleVector(), DoubleVector(), DoubleVector(), oomph::BlockPreconditioner< MATRIX >::get_block_vector(), oomph::BlockPreconditioner< MATRIX >::internal_get_block_ordered_preconditioner_vector(), oomph::BlockPreconditioner< MATRIX >::internal_get_block_vector(), oomph::MatrixVectorProduct::multiply(), oomph::MatrixVectorProduct::multiply_transpose(), operator=(), oomph::DoubleVectorWithHaloEntries::operator=(), oomph::PitchForkHandler::PitchForkHandler(), oomph::BlockDiagonalPreconditioner< MATRIX >::preconditioner_solve(), oomph::DummyBlockPreconditioner< MATRIX >::preconditioner_solve(), oomph::MatrixBasedDiagPreconditioner::preconditioner_solve(), oomph::MatrixBasedLumpedPreconditioner< MATRIX >::preconditioner_solve(), oomph::TrilinosPreconditionerBase::preconditioner_solve(), oomph::FSIPreconditioner::preconditioner_solve(), oomph::LagrangeEnforcedFlowPreconditioner::preconditioner_solve(), oomph::NavierStokesSchurComplementPreconditioner::preconditioner_solve(), oomph::PressureBasedSolidLSCPreconditioner::preconditioner_solve(), oomph::SpaceTimeNavierStokesSubsidiaryPreconditioner::preconditioner_solve(), oomph::Problem::setup_element_count_per_dof(), oomph::GS< CRDoubleMatrix >::solve(), oomph::GMRES< MATRIX >::solve(), oomph::AugmentedProblemGMRES::solve(), oomph::HelmholtzGMRESMG< MATRIX >::solve(), and oomph::HelmholtzFGMRESMG< MATRIX >::solve().

◆ build() [2/5]

void oomph::DoubleVector::build ( const LinearAlgebraDistribution dist,
const double v 
)
inline

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

Definition at line 110 of file double_vector.h.

References build().

◆ build() [3/5]

void oomph::DoubleVector::build ( const LinearAlgebraDistribution dist,
const Vector< double > &  v 
)
inline

Assembles a DoubleVector with a distribution dist and coefficients taken from the vector v. Note. The vector v MUST be of length nrow()

Definition at line 123 of file double_vector.h.

References build().

◆ build() [4/5]

void oomph::DoubleVector::build ( const LinearAlgebraDistribution *const dist_pt,
const double v 
)

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

Assembles a DoubleVector with distribution dist, if v is specified each row is set to v.

Definition at line 59 of file double_vector.cc.

References oomph::DistributableLinearAlgebraObject::build_distribution(), Built, clear(), Internal_values, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

◆ build() [5/5]

void oomph::DoubleVector::build ( const LinearAlgebraDistribution *const dist_pt,
const Vector< double > &  v 
)

Assembles a DoubleVector with a distribution dist and coefficients taken from the vector v. Note. The vector v MUST be of length nrow()

Definition at line 91 of file double_vector.cc.

References oomph::DistributableLinearAlgebraObject::build_distribution(), Built, clear(), initialise(), Internal_values, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

◆ built()

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

◆ clear()

void oomph::DoubleVector::clear ( )
inline

◆ dot()

double oomph::DoubleVector::dot ( const DoubleVector vec) const

◆ initialise() [1/2]

void oomph::DoubleVector::initialise ( const double v)

◆ initialise() [2/2]

void oomph::DoubleVector::initialise ( const Vector< double v)

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

Definition at line 138 of file double_vector.cc.

References oomph::DistributableLinearAlgebraObject::first_row(), oomph::DistributableLinearAlgebraObject::nrow_local(), oomph::FiniteElement::size(), and Values_pt.

◆ max()

double oomph::DoubleVector::max ( ) const

◆ norm() [1/2]

double oomph::DoubleVector::norm ( ) const

◆ norm() [2/2]

double oomph::DoubleVector::norm ( const CRDoubleMatrix matrix_pt) const

compute the A-norm using the matrix at matrix_pt

Definition at line 914 of file double_vector.cc.

References built(), oomph::CRDoubleMatrix::built(), oomph::DistributableLinearAlgebraObject::distribution_pt(), dot(), and oomph::CRDoubleMatrix::multiply().

◆ operator*=()

void oomph::DoubleVector::operator*= ( const double d)

multiply by a double

Multiply by double.

Definition at line 550 of file double_vector.cc.

References oomph::DistributableLinearAlgebraObject::distribution_built(), i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

Referenced by operator/=().

◆ operator+=()

void oomph::DoubleVector::operator+= ( const DoubleVector v)

+= operator with another vector

+= operator

Definition at line 459 of file double_vector.cc.

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

◆ operator-=()

void oomph::DoubleVector::operator-= ( const DoubleVector v)

-= operator with another vector

-= operator

Definition at line 504 of file double_vector.cc.

References oomph::DistributableLinearAlgebraObject::distribution_built(), i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

◆ operator/=()

void oomph::DoubleVector::operator/= ( const double d)

divide by a double

Divide by double.

Definition at line 573 of file double_vector.cc.

References operator*=().

◆ operator=()

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

assignment operator

Definition at line 100 of file double_vector.h.

References build().

◆ operator==()

bool oomph::DoubleVector::operator== ( const DoubleVector v)

== operator

Definition at line 426 of file double_vector.cc.

References i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

◆ operator[]() [1/2]

double & oomph::DoubleVector::operator[] ( int  i)

[] access function to the (local) values of this vector

Definition at line 408 of file double_vector.cc.

References i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

◆ operator[]() [2/2]

const double & oomph::DoubleVector::operator[] ( int  i) const

[] access function to the (local) values of this vector

Definition at line 586 of file double_vector.cc.

References i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

◆ output() [1/2]

void oomph::DoubleVector::output ( std::ostream &  outfile,
const int output_precision = -1 
) const

◆ output() [2/2]

void oomph::DoubleVector::output ( std::string  filename,
const int output_precision = -1 
) const
inline

output the global contents of the vector

Definition at line 269 of file double_vector.h.

References output().

◆ output_local_values() [1/2]

void oomph::DoubleVector::output_local_values ( std::ostream &  outfile,
const int output_precision = -1 
) const

output the local contents of the vector

Definition at line 742 of file double_vector.cc.

References i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

Referenced by output_local_values().

◆ output_local_values() [2/2]

void oomph::DoubleVector::output_local_values ( std::string  filename,
const int output_precision = -1 
) const
inline

output the local contents of the vector

Definition at line 283 of file double_vector.h.

References output_local_values().

◆ output_local_values_with_offset() [1/2]

void oomph::DoubleVector::output_local_values_with_offset ( std::ostream &  outfile,
const int output_precision = -1 
) const

output the local contents of the vector

output the local contents of the vector with the first row offset.

Definition at line 772 of file double_vector.cc.

References oomph::DistributableLinearAlgebraObject::first_row(), i, oomph::DistributableLinearAlgebraObject::nrow_local(), and Values_pt.

Referenced by output_local_values_with_offset().

◆ output_local_values_with_offset() [2/2]

void oomph::DoubleVector::output_local_values_with_offset ( std::string  filename,
const int output_precision = -1 
) const
inline

output the local contents of the vector

Definition at line 298 of file double_vector.h.

References output_local_values_with_offset().

◆ redistribute()

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

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.

The contents of the vector are redistributed to match the new distribution. In a non-MPI build 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 164 of file double_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(), and Values_pt.

Referenced by oomph::Problem::newton_solve_continuation(), oomph::ILUZeroPreconditioner< CCDoubleMatrix >::preconditioner_solve(), and oomph::ILUZeroPreconditioner< CRDoubleMatrix >::preconditioner_solve().

◆ set_external_values() [1/2]

void oomph::DoubleVector::set_external_values ( const LinearAlgebraDistribution *const dist_pt,
double external_values,
bool  delete_external_values 
)
inline

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.

  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.

Definition at line 167 of file double_vector.h.

References oomph::DistributableLinearAlgebraObject::build_distribution(), Built, clear(), and set_external_values().

Referenced by set_external_values().

◆ set_external_values() [2/2]

void oomph::DoubleVector::set_external_values ( double external_values,
bool  delete_external_values 
)
inline

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.

Definition at line 191 of file double_vector.h.

References oomph::DistributableLinearAlgebraObject::distribution_built(), Internal_values, and Values_pt.

◆ values_pt() [1/2]

double * oomph::DoubleVector::values_pt ( )
inline

◆ values_pt() [2/2]

double * oomph::DoubleVector::values_pt ( ) const
inline

access function to the underlying values (const version)

Definition at line 260 of file double_vector.h.

References Values_pt.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const DoubleVector v 
)
friend

Ouput operator for DoubleVector.

Definition at line 949 of file double_vector.cc.

Member Data Documentation

◆ Built

bool oomph::DoubleVector::Built
private

indicates that the vector has been built and is usable

Definition at line 326 of file double_vector.h.

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

◆ Internal_values

bool oomph::DoubleVector::Internal_values
private

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

Definition at line 323 of file double_vector.h.

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

◆ Values_pt

double* oomph::DoubleVector::Values_pt
private

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