24 #ifndef LIBMESH_DISTRIBUTED_VECTOR_H 25 #define LIBMESH_DISTRIBUTED_VECTOR_H 88 const std::vector<numeric_index_type> & ghost,
109 virtual void close ()
override;
111 virtual void clear ()
override;
113 virtual void zero ()
override;
115 virtual std::unique_ptr<NumericVector<T>>
zero_clone ()
const override;
117 virtual std::unique_ptr<NumericVector<T>>
clone ()
const override;
121 const bool fast=
false,
125 const bool fast=
false,
130 const std::vector<numeric_index_type> & ghost,
131 const bool fast =
false,
135 const bool fast =
false)
override;
143 virtual Real min ()
const override;
145 virtual Real max ()
const override;
147 virtual T
sum()
const override;
179 virtual void add (
const T s)
override;
193 { libmesh_not_implemented(); }
197 { libmesh_not_implemented(); }
199 virtual void scale (
const T factor)
override;
201 virtual void abs()
override;
205 virtual void localize (std::vector<T> & v_local)
const override;
210 const std::vector<numeric_index_type> & send_list)
const override;
212 virtual void localize (std::vector<T> & v_local,
213 const std::vector<numeric_index_type> & indices)
const override;
217 const std::vector<numeric_index_type> & send_list)
override;
258 template <
typename T>
265 _first_local_index(0),
266 _last_local_index (0)
273 template <
typename T>
280 this->
init(n, n,
false, ptype);
285 template <
typename T>
293 this->
init(n, n_local,
false, ptype);
298 template <
typename T>
303 const std::vector<numeric_index_type> & ghost,
307 this->
init(n, n_local, ghost,
false, ptype);
312 template <
typename T>
320 parallel_object_only();
322 libmesh_assert_less_equal (n_local, n);
334 libmesh_assert ((this->_type==
SERIAL && n==n_local) ||
342 _values.resize(n_local);
343 _local_size = n_local;
346 _first_local_index = 0;
348 #ifdef LIBMESH_HAVE_MPI 350 std::vector<numeric_index_type> local_sizes (this->n_processors(), 0);
352 local_sizes[this->processor_id()] = n_local;
354 this->comm().sum(local_sizes);
359 _first_local_index += local_sizes[p];
368 dbg_sum += local_sizes[p];
370 libmesh_assert_equal_to (dbg_sum, n);
378 libmesh_error_msg(
"ERROR: MPI is required for n != n_local!");
382 _last_local_index = _first_local_index + n_local;
393 template <
typename T>
397 const std::vector<numeric_index_type> & ,
402 this->
init(n, n_local, fast, ptype);
418 template <
typename T>
424 this->
init(n,n,fast,ptype);
429 template <
typename T>
435 this->_is_closed =
true;
440 template <
typename T>
449 _last_local_index = 0;
457 template <
typename T>
462 libmesh_assert_equal_to (_values.size(), _local_size);
463 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
465 std::fill (_values.begin(),
472 template <
typename T>
477 cloned_vector->
init(*
this);
478 return std::unique_ptr<NumericVector<T>>(cloned_vector);
483 template <
typename T>
488 cloned_vector->
init(*
this,
true);
489 *cloned_vector = *
this;
490 return std::unique_ptr<NumericVector<T>>(cloned_vector);
495 template <
typename T>
500 libmesh_assert_equal_to (_values.size(), _local_size);
501 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
508 template <
typename T>
513 libmesh_assert_equal_to (_values.size(), _local_size);
514 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
521 template <
typename T>
526 libmesh_assert_equal_to (_values.size(), _local_size);
527 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
529 return _first_local_index;
534 template <
typename T>
539 libmesh_assert_equal_to (_values.size(), _local_size);
540 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
542 return _last_local_index;
547 template <
typename T>
552 libmesh_assert_equal_to (_values.size(), _local_size);
553 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
554 libmesh_assert ( ((i >= first_local_index()) &&
555 (i < last_local_index())) );
557 return _values[i - _first_local_index];
562 template <
typename T>
567 libmesh_assert_equal_to (_values.size(), _local_size);
568 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
569 libmesh_assert_less (i, size());
570 libmesh_assert_less (i-first_local_index(), local_size());
572 _values[i - _first_local_index] =
value;
577 template <
typename T>
582 libmesh_assert_equal_to (_values.size(), _local_size);
583 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
584 libmesh_assert_less (i, size());
585 libmesh_assert_less (i-first_local_index(), local_size());
587 _values[i - _first_local_index] +=
value;
592 template <
typename T>
597 parallel_object_only();
600 libmesh_assert_equal_to (_values.size(), _local_size);
601 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
603 Real local_min = _values.size() ?
608 this->comm().min(local_min);
615 template <
typename T>
620 parallel_object_only();
623 libmesh_assert_equal_to (_values.size(), _local_size);
624 libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
626 Real local_max = _values.size() ?
631 this->comm().max(local_max);
637 template <
typename T>
655 #endif // LIBMESH_DISTRIBUTED_VECTOR_H
virtual Real max() const override
virtual T dot(const NumericVector< T > &V) const override
numeric_index_type _last_local_index
virtual void scale(const T factor) override
virtual void add_vector(const NumericVector< T > &, const SparseMatrix< T > &) override
virtual numeric_index_type last_local_index() const override
virtual void close() override
virtual numeric_index_type size() const =0
virtual void set(const numeric_index_type i, const T value) override
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
DistributedVector & operator=(const DistributedVector &)
uint8_t processor_id_type
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
const Parallel::Communicator & comm() const
virtual NumericVector< T > & operator/=(const NumericVector< T > &v) override
virtual void add(const numeric_index_type i, const T value) override
virtual Real linfty_norm() const override
numeric_index_type _global_size
virtual std::unique_ptr< NumericVector< T > > zero_clone() const override
long double max(long double a, double b)
virtual numeric_index_type local_size() const override
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
virtual void reciprocal() override
virtual void zero() override
virtual Real l1_norm() const override
dof_id_type numeric_index_type
virtual ~DistributedVector()=default
virtual numeric_index_type size() const override
void init(triangulateio &t)
virtual std::unique_ptr< NumericVector< T > > clone() const override
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
virtual void conjugate() override
ParallelType type() const
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const override
numeric_index_type _local_size
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual numeric_index_type first_local_index() const override
virtual void localize(std::vector< T > &v_local) const override
void swap(Iterator &lhs, Iterator &rhs)
virtual Real l2_norm() const override
virtual numeric_index_type local_size() const =0
virtual void abs() override
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
virtual void clear() override
virtual Real min() const override
long double min(long double a, double b)
virtual T sum() const override
virtual void swap(NumericVector< T > &v) override
virtual void add_vector_transpose(const NumericVector< T > &, const SparseMatrix< T > &) override
DistributedVector(const Parallel::Communicator &comm, const ParallelType=AUTOMATIC)
numeric_index_type _first_local_index
virtual T operator()(const numeric_index_type i) const override