Go to the documentation of this file.
21 #ifndef LIBMESH_LASPACK_VECTOR_H
22 #define LIBMESH_LASPACK_VECTOR_H
26 #include "libmesh/libmesh_common.h"
28 #ifdef LIBMESH_HAVE_LASPACK
31 #include "libmesh/numeric_vector.h"
44 template <
typename T>
class LaspackLinearSolver;
45 template <
typename T>
class SparseMatrix;
56 class LaspackVector final :
public NumericVector<T>
92 const std::vector<numeric_index_type> & ghost,
100 LaspackVector<T> &
operator= (
const LaspackVector<T> & v);
112 virtual void close ()
override;
114 virtual void clear ()
override;
116 virtual void zero ()
override;
118 virtual std::unique_ptr<NumericVector<T>>
zero_clone ()
const override;
120 virtual std::unique_ptr<NumericVector<T>>
clone ()
const override;
124 const bool fast=
false,
128 const bool fast=
false,
133 const std::vector<numeric_index_type> & ghost,
134 const bool fast =
false,
137 virtual void init (
const NumericVector<T> & other,
138 const bool fast =
false)
override;
140 virtual NumericVector<T> &
operator= (
const T s)
override;
142 virtual NumericVector<T> &
operator= (
const NumericVector<T> & v)
override;
144 virtual NumericVector<T> &
operator= (
const std::vector<T> & v)
override;
146 virtual Real min ()
const override;
148 virtual Real max ()
const override;
150 virtual T
sum ()
const override;
168 virtual NumericVector<T> &
operator += (
const NumericVector<T> & v)
override;
170 virtual NumericVector<T> &
operator -= (
const NumericVector<T> & v)
override;
172 virtual NumericVector<T> &
operator *= (
const NumericVector<T> & v)
override;
174 virtual NumericVector<T> &
operator /= (
const NumericVector<T> & v)
override;
184 virtual void add (
const T s)
override;
186 virtual void add (
const NumericVector<T> & v)
override;
188 virtual void add (
const T a,
const NumericVector<T> & v)
override;
196 virtual void add_vector (
const NumericVector<T> & v,
197 const SparseMatrix<T> &
A)
override;
200 const SparseMatrix<T> &
A)
override;
202 virtual void scale (
const T factor)
override;
204 virtual void abs()
override;
206 virtual T
dot(
const NumericVector<T> & v)
const override;
208 virtual void localize (std::vector<T> & v_local)
const override;
210 virtual void localize (NumericVector<T> & v_local)
const override;
212 virtual void localize (NumericVector<T> & v_local,
213 const std::vector<numeric_index_type> & send_list)
const override;
215 virtual void localize (std::vector<T> & v_local,
216 const std::vector<numeric_index_type> & indices)
const override;
220 const std::vector<numeric_index_type> & send_list)
override;
226 const NumericVector<T> & vec2)
override;
228 virtual void swap (NumericVector<T> & v)
override;
248 template <
typename T>
259 template <
typename T>
266 this->
init(n, n,
false, ptype);
271 template <
typename T>
279 this->
init(n, n_local,
false, ptype);
284 template <
typename T>
289 const std::vector<numeric_index_type> & ghost,
293 this->
init(N, n_local, ghost,
false, ptype);
298 template <
typename T>
307 template <
typename T>
316 libmesh_assert_equal_to (n, n_local);
328 std::sprintf(foo,
"Vec-%d", cnt++);
330 V_Constr(&_vec, const_cast<char *>(foo), n, Normal, _LPTrue);
334 this->_is_closed =
true;
346 template <
typename T>
352 this->
init(n,n,fast,ptype);
356 template <
typename T>
360 const std::vector<numeric_index_type> & libmesh_dbg_var(ghost),
365 this->
init(n,n_local,fast,ptype);
381 template <
typename T>
388 this->_is_closed =
true;
394 template <
typename T>
405 this->_is_closed =
false;
411 template <
typename T>
inline
417 V_SetAllCmp (&_vec, 0.);
422 template <
typename T>
428 cloned_vector->
init(*
this);
430 return std::unique_ptr<NumericVector<T>>(cloned_vector);
435 template <
typename T>
441 cloned_vector->
init(*
this,
true);
443 *cloned_vector = *
this;
445 return std::unique_ptr<NumericVector<T>>(cloned_vector);
450 template <
typename T>
456 return static_cast<numeric_index_type>(V_GetDim(const_cast<QVector*>(&_vec)));
461 template <
typename T>
472 template <
typename T>
483 template <
typename T>
494 template <
typename T>
499 libmesh_assert_less (i, this->size());
501 V_SetCmp (&_vec, i+1,
value);
504 this->_is_closed =
false;
510 template <
typename T>
515 libmesh_assert_less (i, this->size());
517 V_AddCmp (&_vec, i+1,
value);
520 this->_is_closed =
false;
526 template <
typename T>
532 (i < this->last_local_index())) );
535 return static_cast<T>(V_GetCmp(const_cast<QVector*>(&_vec), i+1));
540 template <
typename T>
550 std::swap(_vec.Instance, v._vec.Instance);
551 std::swap(_vec.LockLevel, v._vec.LockLevel);
565 #endif // #ifdef LIBMESH_HAVE_LASPACK
566 #endif // LIBMESH_LASPACK_VECTOR_H
virtual void localize(std::vector< T > &v_local) const override
Creates a copy of the global vector in the local vector v_local.
virtual Real l2_norm() const override
virtual Real l1_norm() const override
virtual numeric_index_type last_local_index() const override
virtual T dot(const NumericVector< T > &v) const override
The libMesh namespace provides an interface to certain functionality in the library.
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
const Parallel::Communicator & comm() const
virtual Real max() const override
virtual numeric_index_type size() const =0
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
ParallelType _type
Type of vector.
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i].
virtual void add(const numeric_index_type i, const T value) override
Adds value to each entry of the vector.
virtual numeric_index_type local_size() const override
virtual NumericVector< T > & operator/=(const NumericVector< T > &v) override
Computes the component-wise division of this vector's entries by another's, .
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const override
Creates a local copy of the global vector in v_local only on processor proc_id.
This class provides a nice interface to the Laspack C-based data structures for serial vectors.
virtual void abs() override
Sets for each entry in the vector.
uint8_t processor_id_type
virtual void reciprocal() override
Computes the component-wise reciprocal, .
virtual void scale(const T factor) override
Scale each element of the vector by the given factor.
virtual numeric_index_type local_size() const =0
virtual numeric_index_type first_local_index() const override
LaspackVector(const Parallel::Communicator &comm, const ParallelType=AUTOMATIC)
Dummy-Constructor.
static PetscErrorCode Mat * A
virtual std::unique_ptr< NumericVector< T > > zero_clone() const override
dof_id_type numeric_index_type
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
virtual NumericVector< T > & operator*=(const NumericVector< T > &v) override
Computes the component-wise multiplication of this vector's entries by another's, .
bool initialized()
Checks that library initialization has been done.
virtual std::unique_ptr< NumericVector< T > > clone() const override
void swap(Iterator &lhs, Iterator &rhs)
swap, used to implement op=
virtual void clear() override
Restores the NumericVector<T> to a pristine state.
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
Change the dimension of the vector to n.
virtual void close() override
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
bool _is_initialized
Flag that tells if init() has been called.
QVector _vec
Actual Laspack vector datatype to hold vector entries.
This class provides an interface to Laspack iterative solvers that is compatible with the libMesh Lin...
virtual numeric_index_type size() const override
virtual Real min() const override
virtual void zero() override
Set all entries to zero.
virtual T operator()(const numeric_index_type i) const override
virtual Real linfty_norm() const override
ParallelType
Defines an enum for parallel data structure types.
virtual void set(const numeric_index_type i, const T value) override
Sets v(i) = value.
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
Subtracts v from *this, .
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
LaspackVector< T > & operator=(const LaspackVector< T > &v)
Copy assignment operator.
virtual void swap(NumericVector< T > &v) override
Swaps the contents of this with v.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
virtual void conjugate() override
Negates the imaginary component of each entry in the vector.
ParallelType type() const
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
Adds v to *this, .
bool closed()
Checks that the library has been closed.
virtual T sum() const override
virtual void add_vector(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.