18 #ifndef LIBMESH_TRILINOS_EPETRA_VECTOR_H 19 #define LIBMESH_TRILINOS_EPETRA_VECTOR_H 24 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA 32 #include <Epetra_CombineMode.h> 33 #include <Epetra_Map.h> 34 #include <Epetra_MultiVector.h> 35 #include <Epetra_Vector.h> 36 #include <Epetra_MpiComm.h> 44 class Epetra_IntSerialDenseVector;
45 class Epetra_SerialDenseVector;
51 template <
typename T>
class SparseMatrix;
98 const std::vector<numeric_index_type> & ghost,
122 virtual void close ()
override;
124 virtual void clear ()
override;
126 virtual void zero ()
override;
128 virtual std::unique_ptr<NumericVector<T>>
zero_clone ()
const override;
130 virtual std::unique_ptr<NumericVector<T>>
clone ()
const override;
134 const bool fast=
false,
138 const bool fast=
false,
143 const std::vector<numeric_index_type> & ghost,
144 const bool fast =
false,
148 const bool fast =
false)
override;
156 virtual Real min ()
const override;
158 virtual Real max ()
const override;
160 virtual T
sum ()
const override;
192 virtual void add (
const T s)
override;
205 const std::vector<numeric_index_type> & dof_indices)
override;
219 virtual void insert (
const T * v,
220 const std::vector<numeric_index_type> & dof_indices)
override;
222 virtual void scale (
const T factor)
override;
224 virtual void abs()
override;
228 virtual void localize (std::vector<T> & v_local)
const override;
233 const std::vector<numeric_index_type> & send_list)
const override;
235 virtual void localize (std::vector<T> & v_local,
236 const std::vector<numeric_index_type> & indices)
const override;
240 const std::vector<numeric_index_type> & send_list)
override;
249 const std::vector<numeric_index_type> & rows)
const override;
273 std::unique_ptr<Epetra_Map>
_map;
292 const double * values);
305 const Epetra_SerialDenseVector & values);
313 const double * values);
326 const Epetra_SerialDenseVector & values);
330 const int * numValuesPerID,
331 const double * values);
335 const int * numValuesPerID,
336 const double * values);
359 const double * values,
364 const int * numValuesPerID,
365 const double * values,
374 const double * values,
404 template <
typename T>
409 _destroy_vec_on_exit(true),
413 nonlocalIDs_(nullptr),
414 nonlocalElementSize_(nullptr),
416 allocatedNonlocalLength_(0),
417 nonlocalCoefs_(nullptr),
419 ignoreNonLocalEntries_(false)
426 template <
typename T>
432 _destroy_vec_on_exit(true),
436 nonlocalIDs_(nullptr),
437 nonlocalElementSize_(nullptr),
439 allocatedNonlocalLength_(0),
440 nonlocalCoefs_(nullptr),
442 ignoreNonLocalEntries_(false)
450 template <
typename T>
457 _destroy_vec_on_exit(true),
461 nonlocalIDs_(nullptr),
462 nonlocalElementSize_(nullptr),
464 allocatedNonlocalLength_(0),
465 nonlocalCoefs_(nullptr),
467 ignoreNonLocalEntries_(false)
469 this->
init(n, n_local,
false,
type);
475 template <
typename T>
480 _destroy_vec_on_exit(false),
484 nonlocalIDs_(nullptr),
485 nonlocalElementSize_(nullptr),
487 allocatedNonlocalLength_(0),
488 nonlocalCoefs_(nullptr),
490 ignoreNonLocalEntries_(false)
499 _map.reset(
new Epetra_Map(
_vec->GlobalLength(),
502 Epetra_MpiComm (this->
comm().
get())));
515 template <
typename T>
520 const std::vector<numeric_index_type> & ghost,
523 _destroy_vec_on_exit(true),
527 nonlocalIDs_(nullptr),
528 nonlocalElementSize_(nullptr),
530 allocatedNonlocalLength_(0),
531 nonlocalCoefs_(nullptr),
533 ignoreNonLocalEntries_(false)
535 this->
init(n, n_local, ghost,
false,
type);
551 template <
typename T>
560 template <
typename T>
588 libmesh_assert ((this->_type==
SERIAL && n==my_n_local) ||
591 _map.reset(
new Epetra_Map(static_cast<int>(n),
594 Epetra_MpiComm (this->comm().
get())));
596 _vec =
new Epetra_Vector(*_map);
598 myFirstID_ = _vec->Map().MinMyGID();
599 myNumIDs_ = _vec->Map().NumMyElements();
604 _vec->ExtractView(&myCoefs_, &dummy);
607 this->_is_closed =
true;
615 template <
typename T>
619 const std::vector<numeric_index_type> & ,
624 this->
init(n, n_local, fast, type);
629 template <
typename T>
635 this->
init(n,n,fast,type);
640 template <
typename T>
647 unsigned char global_last_edit = last_edit;
648 this->comm().max(global_last_edit);
649 libmesh_assert(!last_edit || last_edit == global_last_edit);
651 if (global_last_edit == 1)
652 this->GlobalAssemble(Insert);
653 else if (global_last_edit == 2)
654 this->GlobalAssemble(Add);
656 libmesh_assert(!global_last_edit);
658 this->_is_closed =
true;
664 template <
typename T>
671 if (this->_destroy_vec_on_exit)
686 template <
typename T>
691 libmesh_assert (this->
closed());
693 _vec->PutScalar(0.0);
698 template <
typename T>
703 cloned_vector->
init(*
this);
704 return std::unique_ptr<NumericVector<T>>(cloned_vector);
709 template <
typename T>
714 cloned_vector->
init(*
this,
true);
715 *cloned_vector = *
this;
716 return std::unique_ptr<NumericVector<T>>(cloned_vector);
721 template <
typename T>
727 return _vec->GlobalLength();
732 template <
typename T>
738 return _vec->MyLength();
741 template <
typename T>
747 return _vec->Map().MinMyGID();
752 template <
typename T>
758 return _vec->Map().MaxMyGID()+1;
762 template <
typename T>
767 libmesh_assert ( ((i >= this->first_local_index()) &&
768 (i < this->last_local_index())) );
770 return (*_vec)[i-this->first_local_index()];
775 template <
typename T>
783 _vec->MinValue(&
value);
790 template <
typename T>
798 _vec->MaxValue(&
value);
805 template <
typename T>
839 #endif // #ifdef LIBMESH_TRILINOS_HAVE_EPETRA 840 #endif // LIBMESH_TRILINOS_EPETRA_VECTOR_H
virtual NumericVector< T > & operator/=(const NumericVector< T > &v) override
virtual T operator()(const numeric_index_type i) const override
std::unique_ptr< Epetra_Map > _map
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
int allocatedNonlocalLength_
virtual void reciprocal() override
virtual numeric_index_type last_local_index() const override
virtual void add(const numeric_index_type i, const T value) override
virtual void close() override
virtual std::unique_ptr< NumericVector< T > > zero_clone() const override
virtual numeric_index_type size() const =0
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const override
uint8_t processor_id_type
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
const Parallel::Communicator & comm() const
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices) override
int inputNonlocalValues(int GID, int numValues, const double *values, bool accumulate)
virtual void conjugate() override
virtual Real max() const override
virtual void zero() override
int * nonlocalElementSize_
virtual T sum() 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
int GlobalAssemble(Epetra_CombineMode mode=Add)
virtual numeric_index_type size() const override
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
int ReplaceGlobalValues(int numIDs, const int *GIDs, const double *values)
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
bool _destroy_vec_on_exit
void setIgnoreNonLocalEntries(bool flag)
dof_id_type numeric_index_type
EpetraVector(const Parallel::Communicator &comm, const ParallelType type=AUTOMATIC)
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
virtual Real l1_norm() const override
void init(triangulateio &t)
virtual void abs() override
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
int inputNonlocalValue(int GID, double value, bool accumulate)
bool ignoreNonLocalEntries_
virtual Real min() const override
virtual Real linfty_norm() const override
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
void destroyNonlocalData()
ParallelType type() const
virtual void localize(std::vector< T > &v_local) const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void swap(NumericVector< T > &v)
virtual T dot(const NumericVector< T > &v) const override
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values)
static PetscErrorCode Mat * A
virtual Real l2_norm() const override
void swap(Iterator &lhs, Iterator &rhs)
virtual numeric_index_type local_size() const =0
virtual void clear() override
virtual void create_subvector(NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows) const override
virtual numeric_index_type first_local_index() const override
void FEoperatorequals(const EpetraVector &source)
virtual void swap(NumericVector< T > &v) override
virtual std::unique_ptr< NumericVector< T > > clone() const override
int * numeric_trilinos_cast(const numeric_index_type *p)
virtual void scale(const T factor) override
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices) override
virtual numeric_index_type local_size() const override
EpetraVector & operator=(const EpetraVector &)=delete