17#ifdef DEAL_II_WITH_TRILINOS
27# include <boost/io/ios_state.hpp>
29# include <Epetra_Export.h>
30# include <Epetra_Import.h>
31# include <Epetra_Vector.h>
53 vector.vector->Map().LID(
55# ifndef DEAL_II_WITH_64BIT_INDICES
59 vector.vector->Map().NumMyElements(),
60 vector.vector->Map().MinMyGID(),
61 vector.vector->Map().MaxMyGID()));
66 vector.vector->Map().NumMyElements(),
67 vector.vector->Map().MinMyGID64(),
68 vector.vector->Map().MaxMyGID64()));
72 return (*(vector.vector))[0][local_index];
83 , vector(new Epetra_FEVector(
84 Epetra_Map(0, 0, 0,
Utilities::Trilinos::comm_self())))
131 vector = std::make_unique<Epetra_FEVector>(
143 reinit(local, ghost, communicator,
false);
156 vector = std::make_unique<Epetra_FEVector>(map);
175 vector = std::make_unique<Epetra_FEVector>(map);
205 const bool omit_zeroing_entries,
206 const bool allow_different_maps)
219 const Epetra_MpiComm *
my_comm =
220 dynamic_cast<const Epetra_MpiComm *
>(&
vector->Comm());
221 const Epetra_MpiComm *
v_comm =
222 dynamic_cast<const Epetra_MpiComm *
>(&v.
vector->Comm());
229 vector = std::make_unique<Epetra_FEVector>(v.
vector->Map());
258 "It is not possible to exchange data with the "
259 "option 'omit_zeroing_entries' set, which would not write "
274 dynamic_cast<const Epetra_MpiComm *
>(&(v.
vector->Comm()));
301 n_elements += v.
block(block).vector->Map().NumMyElements();
302 std::vector<TrilinosWrappers::types::int_type>
global_ids(n_elements, -1);
307 v.
block(block).trilinos_partitioner());
321 v.
block(0).trilinos_partitioner().Comm());
328 v.
block(block).trilinos_vector().ExtractCopy(entries, 0);
329 entries += v.
block(block).vector->Map().NumMyElements();
332 if (import_data ==
true)
351 dynamic_cast<const Epetra_MpiComm *
>(&(
vector->Comm()));
366 const bool vector_writable)
376 vector = std::make_unique<Epetra_FEVector>(map);
383 ExcMessage(
"A writable vector must not have ghost entries in "
384 "its parallel partitioning"));
386 if (
vector->Map().SameAs(map) ==
false)
387 vector = std::make_unique<Epetra_FEVector>(map);
422 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
423 const bool make_ghosted,
424 const bool vector_writable)
428 Assert(partitioner->ghost_indices_initialized(),
429 ExcMessage(
"You asked to create a ghosted vector, but the "
430 "partitioner does not provide ghost indices."));
432 this->
reinit(partitioner->locally_owned_range(),
433 partitioner->ghost_indices(),
434 partitioner->get_mpi_communicator(),
439 this->
reinit(partitioner->locally_owned_range(),
440 partitioner->get_mpi_communicator());
450 ExcMessage(
"Vector is not constructed properly."));
454 const Epetra_MpiComm *
my_comm =
455 dynamic_cast<const Epetra_MpiComm *
>(&
vector->Comm());
456 const Epetra_MpiComm *
v_comm =
457 dynamic_cast<const Epetra_MpiComm *
>(&v.
vector->Comm());
499 (v.
vector->Map().UniqueGIDs() ||
vector->Map().UniqueGIDs()))
533 template <
typename number>
559 "Cannot find exchange information!"));
561 ExcMessage(
"The input vector has overlapping data, "
562 "which is not allowed."));
584 "Both vectors need to have the same size for import_elements() to work!"));
594 (*
this)[idx] =
rwv[idx];
599 (*
this)[idx] +=
rwv[idx];
613 "Calling compress() is only useful if a vector "
614 "has been written into, but this is a vector with ghost "
615 "elements and consequently is read-only. It does "
616 "not make sense to call compress() for such "
635 "compress() can only be called with VectorOperation add, insert, or unknown"));
645 "The last operation on the Vector and the given last action in the compress() call do not agree!"));
662 "Not all processors agree whether the last operation on "
663 "this vector was an addition or a set operation. This will "
664 "prevent the compress() operation from succeeding."));
671 const auto ierr =
vector->GlobalAssemble(mode);
703# ifndef DEAL_II_WITH_64BIT_INDICES
706 vector->Map().NumMyElements(),
708 vector->Map().MaxMyGID()));
712 vector->Map().NumMyElements(),
713 vector->Map().MinMyGID64(),
714 vector->Map().MaxMyGID64()));
736# if DEAL_II_TRILINOS_VERSION_GTE(11, 11, 0)
746 Epetra_MultiVector dummy(
vector->Map(), 1,
false);
764 if (
vector->Map().NumMyElements() != v.
vector->Map().NumMyElements())
782 return (!(*
this == v));
795 unsigned int flag = 0;
808 const Epetra_MpiComm *mpi_comm =
809 dynamic_cast<const Epetra_MpiComm *
>(&
vector->Map().Comm());
825 unsigned int flag = 0;
847 const unsigned int precision,
848 const bool scientific,
849 const bool across)
const
855 out.precision(precision);
857 out.setf(std::ios::scientific, std::ios::floatfield);
859 out.setf(std::ios::fixed, std::ios::floatfield);
867 out <<
"size:" <<
size()
868 <<
" locally_owned_size:" <<
vector->Map().NumMyElements() <<
" :"
883 out <<
static_cast<double>(val[i]) <<
' ';
886 out <<
static_cast<double>(val[i]) << std::endl;
898 std::swap(last_action, v.last_action);
899 std::swap(compressed, v.compressed);
900 std::swap(has_ghosts, v.has_ghosts);
901 std::swap(vector, v.vector);
902 std::swap(nonlocal_vector, v.nonlocal_vector);
903 std::swap(owned_elements, v.owned_elements);
916 return sizeof(*this) +
917 this->
vector->Map().NumMyElements() *
923# include "trilinos_vector.inst"
virtual size_type size() const override
unsigned int n_blocks() const
BlockType & block(const unsigned int i)
size_type n_elements() const
void set_size(const size_type size)
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
size_type size() const override
const IndexSet & get_stored_elements() const
void compress(VectorOperation::values operation)
void add(const std::vector< size_type > &indices, const std::vector< TrilinosScalar > &values)
std::unique_ptr< Epetra_MultiVector > nonlocal_vector
void import_elements(const LinearAlgebra::ReadWriteVector< double > &rwv, const VectorOperation::values operation)
MPI_Comm get_mpi_communicator() const
void swap(Vector &v) noexcept
const Epetra_BlockMap & trilinos_partitioner() const
reference operator()(const size_type index)
void import_nonlocal_data_for_fe(const ::TrilinosWrappers::SparseMatrix &matrix, const Vector &vector)
std::unique_ptr< Epetra_FEVector > vector
size_type size() const override
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
IndexSet locally_owned_elements() const
void reinit(const Vector &v, const bool omit_zeroing_entries=false, const bool allow_different_maps=false)
bool has_ghost_elements() const
std::pair< size_type, size_type > local_range() const
bool operator!=(const Vector &v) const
bool operator==(const Vector &v) const
Epetra_CombineMode last_action
Vector & operator=(const TrilinosScalar s)
bool is_non_negative() const
std::size_t memory_consumption() const
const Epetra_CrsMatrix & trilinos_matrix() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcGhostsPresent()
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void swap(BlockVector &u, BlockVector &v) noexcept
TrilinosWrappers::types::int_type global_length(const Epetra_MultiVector &vector)
int gid(const Epetra_BlockMap &map, int i)
TrilinosWrappers::types::int_type * my_global_elements(const Epetra_BlockMap &map)
TrilinosWrappers::types::int64_type n_global_elements(const Epetra_BlockMap &map)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
T max(const T &t, const MPI_Comm mpi_communicator)
MinMaxAvg min_max_avg(const double my_value, const MPI_Comm mpi_communicator)