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"
45template <
typename T>
class LaspackLinearSolver;
46template <
typename T>
class SparseMatrix;
93 const std::vector<numeric_index_type> & ghost,
113 virtual void close ()
override;
115 virtual void clear ()
override;
117 virtual void zero ()
override;
119 virtual std::unique_ptr<NumericVector<T>>
zero_clone ()
const override;
121 virtual std::unique_ptr<NumericVector<T>>
clone ()
const override;
125 const bool fast=
false,
129 const bool fast=
false,
134 const std::vector<numeric_index_type> & ghost,
135 const bool fast =
false,
139 const bool fast =
false)
override;
147 virtual Real min ()
const override;
149 virtual Real max ()
const override;
151 virtual T
sum ()
const override;
185 virtual void add (
const T s)
override;
203 virtual void scale (
const T factor)
override;
205 virtual void abs()
override;
209 virtual void localize (std::vector<T> & v_local)
const override;
214 const std::vector<numeric_index_type> & send_list)
const override;
216 virtual void localize (std::vector<T> & v_local,
217 const std::vector<numeric_index_type> & indices)
const override;
221 const std::vector<numeric_index_type> & send_list)
override;
272 this->
init(n, n,
false, ptype);
285 this->
init(n, n_local,
false, ptype);
295 const std::vector<numeric_index_type> & ghost,
299 this->
init(N, n_local, ghost,
false, ptype);
322 libmesh_assert_equal_to (n, n_local);
333 std::string foo{
"Vec-"};
334 foo += std::to_string(cnt++);
336 V_Constr(&_vec,
const_cast<char *
>(foo.c_str()), n, Normal, _LPTrue);
338 this->_is_initialized =
true;
340 this->_is_closed =
true;
358 this->init(n,n,fast,ptype);
366 const std::vector<numeric_index_type> & libmesh_dbg_var(ghost),
371 this->init(n,n_local,fast,ptype);
394 this->_is_closed =
true;
409 this->_is_initialized =
false;
411 this->_is_closed =
false;
417template <
typename T>
inline
423 V_SetAllCmp (&_vec, 0.);
432 std::unique_ptr<NumericVector<T>> cloned_vector =
433 std::make_unique<LaspackVector<T>>(this->comm());
435 cloned_vector->init(*
this);
437 return cloned_vector;
446 std::unique_ptr<NumericVector<T>> cloned_vector =
447 std::make_unique<LaspackVector<T>>(this->comm());
449 cloned_vector->init(*
this,
true);
451 *cloned_vector = *
this;
453 return cloned_vector;
507 libmesh_assert_less (i, this->size());
509 std::scoped_lock lock(this->_numeric_vector_mutex);
510 V_SetCmp (&_vec, i+1,
value);
513 this->_is_closed =
false;
524 libmesh_assert_less (i, this->size());
526 std::scoped_lock lock(this->_numeric_vector_mutex);
527 V_AddCmp (&_vec, i+1,
value);
530 this->_is_closed =
false;
542 (i < this->last_local_index())) );
545 return static_cast<T
>(V_GetCmp(
const_cast<QVector*
>(&_vec), i+1));
558 std::swap(_vec.Name, v.
_vec.Name);
559 std::swap(_vec.Dim, v.
_vec.Dim);
560 std::swap(_vec.Instance, v.
_vec.Instance);
561 std::swap(_vec.LockLevel, v.
_vec.LockLevel);
562 std::swap(_vec.Multipl, v.
_vec.Multipl);
563 std::swap(_vec.OwnData, v.
_vec.OwnData);
568 std::swap(_vec.Cmp, v.
_vec.Cmp);
578 return std::numeric_limits<std::size_t>::max();
This class provides an interface to Laspack iterative solvers that is compatible with the libMesh Lin...
This class provides a nice interface to the Laspack C-based data structures for serial vectors.
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
Subtracts v from *this, .
virtual std::unique_ptr< NumericVector< T > > clone() const override
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
QVector _vec
Actual Laspack vector datatype to hold vector entries.
virtual void localize(std::vector< T > &v_local) const override
Creates a copy of the global vector in the local vector v_local.
virtual numeric_index_type size() const override
virtual void add_vector(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
virtual std::size_t max_allowed_id() const override
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.
LaspackVector(const Parallel::Communicator &comm, const ParallelType=AUTOMATIC)
Dummy-Constructor.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
virtual NumericVector< T > & operator/=(const NumericVector< T > &v) override
Computes the component-wise division of this vector's entries by another's, .
virtual T sum() const override
virtual Real linfty_norm() const override
virtual Real l2_norm() const override
LaspackVector(LaspackVector &&)=delete
This class manages a C-style struct (QVector) manually, so we don't want to allow any automatic copy/...
virtual Real l1_norm() const override
virtual void conjugate() override
Negates the imaginary component of each entry in the vector.
virtual void clear() override
Restores the NumericVector<T> to a pristine state.
virtual Real min() const override
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
virtual void reciprocal() override
Computes the component-wise reciprocal, .
virtual void abs() override
Sets for each entry in the vector.
virtual void add(const numeric_index_type i, const T value) override
Adds value to the vector entry specified by i.
virtual void zero() override
Set all entries to zero.
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 numeric_index_type last_local_index() const override
virtual T operator()(const numeric_index_type i) const override
virtual T dot(const NumericVector< T > &v) const override
LaspackVector(const LaspackVector &)=delete
virtual numeric_index_type first_local_index() const override
virtual void scale(const T factor) override
Scale each element of the vector by the given factor.
virtual void localize(NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const override
Creates a local vector v_local containing only information relevant to this processor,...
virtual std::unique_ptr< NumericVector< T > > zero_clone() const override
virtual NumericVector< T > & operator*=(const NumericVector< T > &v) override
Computes the component-wise multiplication of this vector's entries by another's, .
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 Real max() const override
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
Adds v to *this, .
virtual numeric_index_type local_size() const 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) override
Updates a local vector with selected values from neighboring processors, as defined by send_list.
virtual void set(const numeric_index_type i, const T value) override
Sets v(i) = value.
virtual void close() override
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
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) override
Create a vector that holds the local indices plus those specified in the ghost argument.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
ParallelType type() const
ParallelType _type
Type of vector.
virtual numeric_index_type size() const =0
virtual numeric_index_type local_size() const =0
const Parallel::Communicator & comm() const
The libMesh namespace provides an interface to certain functionality in the library.
ParallelType
Defines an enum for parallel data structure types.
bool closed()
Checks that the library has been closed.
dof_id_type numeric_index_type
bool initialized()
Checks that library initialization has been done.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type