18#ifdef DEAL_II_WITH_TRILINOS
24# include <boost/io/ios_state.hpp>
26# include <Epetra_Import.h>
27# include <Epetra_Map.h>
28# include <Epetra_MpiComm.h>
37 namespace EpetraWrappers
41 , vector(new Epetra_FEVector(
42 Epetra_Map(0, 0, 0,
Utilities::Trilinos::comm_self())))
49 , vector(new Epetra_FEVector(V.trilinos_vector()))
57 , vector(new Epetra_FEVector(
58 parallel_partitioner.make_trilinos_map(communicator, false)))
66 const bool omit_zeroing_entries)
68 Epetra_Map input_map =
70 if (
vector->Map().SameAs(input_map) ==
false)
71 vector = std::make_unique<Epetra_FEVector>(input_map);
72 else if (omit_zeroing_entries ==
false)
74 const int ierr =
vector->PutScalar(0.);
84 const bool omit_zeroing_entries)
95 omit_zeroing_entries);
113 Epetra_Import data_exchange(
vector->Map(),
135 const int ierr =
vector->PutScalar(s);
148 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
149 communication_pattern)
153 if (communication_pattern ==
nullptr)
164 dynamic_cast<const Epetra_MpiComm &
>(
vector->Comm()).Comm());
170 std::dynamic_pointer_cast<const CommunicationPattern>(
171 communication_pattern);
175 std::string(
"The communication pattern is not of type ") +
176 "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
182 Epetra_FEVector source_vector(
import.TargetMap());
183 double * values = source_vector.Values();
184 std::copy(V.
begin(), V.
end(), values);
187 vector->Export(source_vector,
import, Insert);
189 vector->Export(source_vector,
import, Add);
191 vector->Export(source_vector,
import, Epetra_Max);
193 vector->Export(source_vector,
import, Epetra_Min);
216 *
this *= 1. / factor;
244# if DEAL_II_TRILINOS_VERSION_GTE(11, 11, 0)
245 Epetra_Import data_exchange(
vector->Map(),
249 Epetra_AddLocalAlso);
256 Epetra_MultiVector dummy(
vector->Map(), 1,
false);
257 Epetra_Import data_exchange(dummy.Map(),
264 ierr =
vector->Update(1.0, dummy, 1.0);
313 const unsigned local_size(
vector->MyLength());
314 for (
unsigned int i = 0; i < local_size; ++i)
364 const int ierr =
vector->Update(
395 Assert(
dynamic_cast<const Vector *
>(&scaling_factors) !=
nullptr,
399 const Vector &down_scaling_factors =
400 dynamic_cast<const Vector &
>(scaling_factors);
404 const int ierr =
vector->Multiply(1.0,
425 this->
sadd(0., a, V);
442 double * start_ptr = (*vector)[0];
443 const double *ptr = start_ptr, *eptr = start_ptr +
vector->MyLength();
444 unsigned int flag = 0;
456 const Epetra_MpiComm *mpi_comm =
457 dynamic_cast<const Epetra_MpiComm *
>(&
vector->Map().Comm());
461 return num_nonzero == 0;
484 int ierr =
vector->Norm1(&norm);
497 int ierr =
vector->Norm2(&norm);
510 int ierr =
vector->NormInf(&norm);
534# ifndef DEAL_II_WITH_64BIT_INDICES
535 return vector->GlobalLength();
537 return vector->GlobalLength64();
546 return vector->MyLength();
554 const Epetra_MpiComm *epetra_comm =
555 dynamic_cast<const Epetra_MpiComm *
>(&(
vector->Comm()));
557 return epetra_comm->GetMpiComm();
568 if (
vector->Map().LinearMap())
570# ifndef DEAL_II_WITH_64BIT_INDICES
574 vector->Map().MaxMyGID64() + 1);
577 else if (
vector->Map().NumMyElements() > 0)
580# ifndef DEAL_II_WITH_64BIT_INDICES
581 unsigned int *vector_indices =
582 reinterpret_cast<unsigned int *
>(
vector->Map().MyGlobalElements());
587 is.
add_indices(vector_indices, vector_indices + n_indices);
596 const Epetra_FEVector &
614 const unsigned int precision,
615 const bool scientific,
616 const bool across)
const
619 boost::io::ios_flags_saver restore_flags(out);
624 int leading_dimension;
625 int ierr =
vector->ExtractView(&val, &leading_dimension);
629 out.precision(precision);
631 out.setf(std::ios::scientific, std::ios::floatfield);
633 out.setf(std::ios::fixed, std::ios::floatfield);
636 for (
int i = 0; i <
vector->MyLength(); ++i)
637 out << val[i] <<
' ';
639 for (
int i = 0; i <
vector->MyLength(); ++i)
640 out << val[i] << std::endl;
653 return sizeof(*this) +
Epetra_Map make_trilinos_map(const MPI_Comm &communicator=MPI_COMM_WORLD, const bool overlapping=false) const
void add_range(const size_type begin, const size_type end)
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
virtual double mean_value() const override
virtual Vector & operator/=(const double factor) override
virtual double l2_norm() const override
Vector & operator=(const Vector &V)
MPI_Comm get_mpi_communicator() const
std::unique_ptr< Epetra_FEVector > vector
const Epetra_FEVector & trilinos_vector() const
virtual double l1_norm() const override
virtual ::IndexSet locally_owned_elements() const override
virtual double add_and_dot(const double a, const VectorSpaceVector< double > &V, const VectorSpaceVector< double > &W) override
virtual void scale(const VectorSpaceVector< double > &scaling_factors) override
void create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
virtual double operator*(const VectorSpaceVector< double > &V) const override
void reinit(const IndexSet ¶llel_partitioner, const MPI_Comm &communicator, const bool omit_zeroing_entries=false)
virtual size_type size() const override
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
virtual Vector & operator-=(const VectorSpaceVector< double > &V) override
size_type locally_owned_size() const
virtual double linfty_norm() const override
virtual bool all_zero() const override
virtual void import(const ReadWriteVector< double > &V, VectorOperation::values operation, std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > communication_pattern={}) override
virtual void add(const double a) override
::IndexSet source_stored_elements
virtual void equ(const double a, const VectorSpaceVector< double > &V) override
virtual std::size_t memory_consumption() const override
std::shared_ptr< const CommunicationPattern > epetra_comm_pattern
virtual Vector & operator*=(const double factor) override
virtual Vector & operator+=(const VectorSpaceVector< double > &V) override
virtual void sadd(const double s, const double a, const VectorSpaceVector< double > &V) override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcVectorTypeNotCompatible()
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcZero()
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertIsFinite(number)
static ::ExceptionBase & ExcDifferentParallelPartitioning()
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
const IndexSet & get_stored_elements() const
T sum(const T &t, const MPI_Comm &mpi_communicator)