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" 45 template <
typename T>
class LaspackLinearSolver;
46 template <
typename T>
class SparseMatrix;
57 class LaspackVector final :
public NumericVector<T>
93 const std::vector<numeric_index_type> & ghost,
101 LaspackVector<T> &
operator= (
const LaspackVector<T> & v);
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,
138 virtual void init (
const NumericVector<T> & other,
139 const bool fast =
false)
override;
141 virtual NumericVector<T> &
operator= (
const T s)
override;
143 virtual NumericVector<T> &
operator= (
const NumericVector<T> & v)
override;
145 virtual NumericVector<T> &
operator= (
const std::vector<T> & v)
override;
147 virtual Real min ()
const override;
149 virtual Real max ()
const override;
151 virtual T
sum ()
const override;
169 virtual NumericVector<T> &
operator += (
const NumericVector<T> & v)
override;
171 virtual NumericVector<T> &
operator -= (
const NumericVector<T> & v)
override;
173 virtual NumericVector<T> &
operator *= (
const NumericVector<T> & v)
override;
175 virtual NumericVector<T> &
operator /= (
const NumericVector<T> & v)
override;
185 virtual void add (
const T s)
override;
187 virtual void add (
const NumericVector<T> & v)
override;
189 virtual void add (
const T a,
const NumericVector<T> & v)
override;
197 virtual void add_vector (
const NumericVector<T> & v,
198 const SparseMatrix<T> & A)
override;
201 const SparseMatrix<T> & A)
override;
203 virtual void scale (
const T factor)
override;
205 virtual void abs()
override;
207 virtual T
dot(
const NumericVector<T> & v)
const override;
209 virtual void localize (std::vector<T> & v_local)
const override;
211 virtual void localize (NumericVector<T> & v_local)
const override;
213 virtual void localize (NumericVector<T> & v_local,
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;
227 const NumericVector<T> & vec2)
override;
230 const NumericVector<T> & vec2)
override;
232 virtual void swap (NumericVector<T> & v)
override;
254 template <
typename T>
265 template <
typename T>
272 this->
init(n, n,
false, ptype);
277 template <
typename T>
285 this->
init(n, n_local,
false, ptype);
290 template <
typename T>
295 const std::vector<numeric_index_type> & ghost,
299 this->
init(N, n_local, ghost,
false, ptype);
304 template <
typename T>
313 template <
typename T>
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);
340 this->_is_closed =
true;
352 template <
typename T>
358 this->
init(n,n,fast,ptype);
362 template <
typename T>
366 const std::vector<numeric_index_type> & libmesh_dbg_var(ghost),
371 this->
init(n,n_local,fast,ptype);
387 template <
typename T>
394 this->_is_closed =
true;
400 template <
typename T>
411 this->_is_closed =
false;
417 template <
typename T>
inline 423 V_SetAllCmp (&_vec, 0.);
428 template <
typename T>
434 cloned_vector->
init(*
this);
436 return std::unique_ptr<NumericVector<T>>(cloned_vector);
441 template <
typename T>
447 cloned_vector->
init(*
this,
true);
449 *cloned_vector = *
this;
451 return std::unique_ptr<NumericVector<T>>(cloned_vector);
456 template <
typename T>
467 template <
typename T>
478 template <
typename T>
489 template <
typename T>
500 template <
typename T>
505 libmesh_assert_less (i, this->size());
507 std::scoped_lock lock(this->_numeric_vector_mutex);
508 V_SetCmp (&_vec, i+1,
value);
511 this->_is_closed =
false;
517 template <
typename T>
522 libmesh_assert_less (i, this->size());
524 std::scoped_lock lock(this->_numeric_vector_mutex);
525 V_AddCmp (&_vec, i+1,
value);
528 this->_is_closed =
false;
534 template <
typename T>
540 (i < this->last_local_index())) );
543 return static_cast<T
>(V_GetCmp(const_cast<QVector*>(&_vec), i+1));
548 template <
typename T>
556 std::swap(_vec.Name, v._vec.Name);
557 std::swap(_vec.Dim, v._vec.Dim);
558 std::swap(_vec.Instance, v._vec.Instance);
559 std::swap(_vec.LockLevel, v._vec.LockLevel);
560 std::swap(_vec.Multipl, v._vec.Multipl);
561 std::swap(_vec.OwnData, v._vec.OwnData);
566 std::swap(_vec.Cmp, v._vec.Cmp);
571 template <
typename T>
576 return std::numeric_limits<std::size_t>::max();
583 #endif // #ifdef LIBMESH_HAVE_LASPACK 584 #endif // LIBMESH_LASPACK_VECTOR_H virtual void add_vector(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
bool closed()
Checks that the library has been closed.
virtual void swap(NumericVector< T > &v) override
Swaps the contents of this with v.
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 ...
virtual numeric_index_type size() const override
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
Subtracts v from *this, .
virtual void abs() override
Sets for each entry in the vector.
virtual void scale(const T factor) override
Scale each element of the vector by the given factor.
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
virtual T dot(const NumericVector< T > &v) const override
virtual void set(const numeric_index_type i, const T value) override
Sets v(i) = value.
virtual numeric_index_type size() const =0
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]...
LaspackVector< T > & operator=(const LaspackVector< T > &v)
Copy assignment operator.
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.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
const Parallel::Communicator & comm() const
virtual T operator()(const numeric_index_type i) const override
The libMesh namespace provides an interface to certain functionality in the library.
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
Adds v to *this, .
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)=0
Change the dimension of the vector to n.
virtual std::size_t max_allowed_id() const override
This class provides an interface to Laspack iterative solvers that is compatible with the libMesh Lin...
uint8_t processor_id_type
virtual std::unique_ptr< NumericVector< T > > zero_clone() const override
virtual std::unique_ptr< NumericVector< T > > clone() const override
virtual Real max() const override
virtual Real l2_norm() const override
dof_id_type numeric_index_type
bool _is_initialized
Flag that tells if init() has been called.
virtual void add(const numeric_index_type i, const T value) override
Adds value to the vector entry specified by i.
virtual Real min() const override
virtual void localize(std::vector< T > &v_local) const override
Creates a copy of the global vector in the local vector v_local.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
virtual numeric_index_type last_local_index() 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.
ParallelType _type
Type of vector.
virtual numeric_index_type first_local_index() const override
This class provides a nice interface to the Laspack C-based data structures for serial vectors...
virtual void zero() override
Set all entries to zero.
ParallelType type() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void conjugate() override
Negates the imaginary component of each entry in the vector.
virtual Real linfty_norm() const override
virtual numeric_index_type local_size() const =0
virtual numeric_index_type local_size() const override
virtual void clear() override
Restores the NumericVector<T> to a pristine state.
bool initialized()
Checks that library initialization has been done.
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
QVector _vec
Actual Laspack vector datatype to hold vector entries.
virtual void reciprocal() override
Computes the component-wise reciprocal, .
virtual Real l1_norm() const override
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
ParallelType
Defines an enum for parallel data structure types.