16 #include <deal.II/lac/trilinos_epetra_vector.h> 18 #ifdef DEAL_II_WITH_TRILINOS 20 #ifdef DEAL_II_WITH_MPI 22 #include <deal.II/base/index_set.h> 24 #include <boost/io/ios_state.hpp> 26 #include "Epetra_Import.h" 27 #include "Epetra_Map.h" 28 #include "Epetra_MpiComm.h" 31 DEAL_II_NAMESPACE_OPEN
35 namespace EpetraWrappers
39 vector(new Epetra_FEVector(Epetra_Map(0,0,0,
Utilities::Trilinos::comm_self())))
46 vector(new Epetra_FEVector(V.trilinos_vector()))
52 const MPI_Comm &communicator)
54 vector(new Epetra_FEVector(parallel_partitioner.make_trilinos_map(communicator,false)))
60 const MPI_Comm &communicator,
61 const bool omit_zeroing_entries)
63 Epetra_Map input_map = parallel_partitioner.
make_trilinos_map(communicator,
false);
64 if (
vector->Map().SameAs(input_map)==
false)
65 vector.reset(
new Epetra_FEVector(input_map));
66 else if (omit_zeroing_entries==
false)
68 const int ierr =
vector->PutScalar(0.);
105 std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern)
109 if (communication_pattern == NULL)
119 dynamic_cast<const Epetra_MpiComm &
>(
vector->Comm()).Comm());
127 ExcMessage(std::string(
"The communication pattern is not of type ") +
128 "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
134 Epetra_FEVector source_vector(
import.TargetMap());
135 double *values = source_vector.Values();
136 std::copy(V.
begin(), V.
end(), values);
139 vector->Export(source_vector,
import, Insert);
141 vector->Export(source_vector,
import, Add);
186 #if DEAL_II_TRILINOS_VERSION_GTE(11,11,0) 189 data_exchange, Epetra_AddLocalAlso);
196 Epetra_MultiVector dummy(
vector->Map(), 1,
false);
197 Epetra_Import data_exchange(dummy.Map(), down_V.
trilinos_vector().Map());
199 int ierr = dummy.Import(down_V.
trilinos_vector(), data_exchange, Insert);
202 ierr =
vector->Update(1.0, dummy, 1.0);
225 Assert(dynamic_cast<const Vector *>(&V)!=NULL,
248 const unsigned local_size(
vector->MyLength());
249 for (
unsigned int i=0; i<local_size; ++i)
258 Assert(dynamic_cast<const Vector *>(&V)!=NULL,
278 Assert(dynamic_cast<const Vector *>(&V)!=NULL,
281 Assert(dynamic_cast<const Vector *>(&W)!=NULL,
307 Assert(dynamic_cast<const Vector *>(&V)!=NULL,
323 Assert(dynamic_cast<const Vector *>(&scaling_factors)!=NULL,
327 const Vector &down_scaling_factors =
328 dynamic_cast<const Vector &
>(scaling_factors);
343 Assert(dynamic_cast<const Vector *>(&V)!=NULL,
350 this->
sadd(0., a, V);
378 int ierr =
vector->Norm1(&norm);
390 int ierr =
vector->Norm2(&norm);
402 int ierr =
vector->NormInf(&norm);
424 #ifndef DEAL_II_WITH_64BIT_INDICES 425 return vector->GlobalLength();
427 return vector->GlobalLength64();
435 const Epetra_MpiComm *epetra_comm
436 =
dynamic_cast<const Epetra_MpiComm *
>(&(
vector->Comm()));
438 return epetra_comm->GetMpiComm();
448 if (
vector->Map().LinearMap())
450 #ifndef DEAL_II_WITH_64BIT_INDICES 456 else if (
vector->Map().NumMyElements() > 0)
458 const size_type n_indices =
vector->Map().NumMyElements();
459 #ifndef DEAL_II_WITH_64BIT_INDICES 460 unsigned int *vector_indices = (
unsigned int *)
vector->Map().MyGlobalElements();
462 size_type *vector_indices = (size_type *)
vector->Map().MyGlobalElements64();
464 is.
add_indices(vector_indices, vector_indices+n_indices);
488 const unsigned int precision,
489 const bool scientific,
490 const bool across)
const 493 boost::io::ios_flags_saver restore_flags(out);
498 int leading_dimension;
499 int ierr =
vector->ExtractView(&val, &leading_dimension);
503 out.precision (precision);
505 out.setf(std::ios::scientific, std::ios::floatfield);
507 out.setf(std::ios::fixed, std::ios::floatfield);
510 for (
int i=0; i<
vector->MyLength(); ++i)
511 out << val[i] <<
' ';
513 for (
int i=0; i<
vector->MyLength(); ++i)
514 out << val[i] << std::endl;
527 +
vector->MyLength()*(
sizeof(double)+
528 sizeof(TrilinosWrappers::types::int_type));
534 const MPI_Comm &mpi_comm)
538 source_index_set, mpi_comm));
543 DEAL_II_NAMESPACE_CLOSE
virtual double l1_norm() const
static ::ExceptionBase & ExcDifferentParallelPartitioning()
static ::ExceptionBase & ExcIO()
virtual double l2_norm() const
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
virtual double linfty_norm() const
virtual size_type size() const
virtual Vector & operator+=(const VectorSpaceVector< double > &V)
virtual std::size_t memory_consumption() const
#define AssertThrow(cond, exc)
virtual void scale(const VectorSpaceVector< double > &scaling_factors)
virtual double mean_value() const
Epetra_Map make_trilinos_map(const MPI_Comm &communicator=MPI_COMM_WORLD, const bool overlapping=false) const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
const Epetra_FEVector & trilinos_vector() const
Vector & operator=(const Vector &V)
virtual double operator*(const VectorSpaceVector< double > &V) const
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcVectorTypeNotCompatible()
void reinit(const IndexSet ¶llel_partitioner, const MPI_Comm &communicator, const bool omit_zeroing_entries=false)
virtual ::IndexSet locally_owned_elements() const
void add_range(const size_type begin, const size_type end)
virtual double add_and_dot(const double a, const VectorSpaceVector< double > &V, const VectorSpaceVector< double > &W)
std_cxx11::shared_ptr< Epetra_FEVector > vector
virtual void add(const double a)
MPI_Comm get_mpi_communicator() const
virtual void equ(const double a, const VectorSpaceVector< double > &V)
virtual void sadd(const double s, const double a, const VectorSpaceVector< double > &V)
virtual Vector & operator/=(const double factor)
virtual Vector & operator-=(const VectorSpaceVector< double > &V)
static ::ExceptionBase & ExcZero()
#define AssertIsFinite(number)
virtual Vector & operator*=(const double factor)
const IndexSet & get_stored_elements() const
std_cxx11::shared_ptr< const CommunicationPattern > epetra_comm_pattern
virtual void import(const ReadWriteVector< double > &V, VectorOperation::values operation, std_cxx11::shared_ptr< const CommunicationPatternBase > communication_pattern=std_cxx11::shared_ptr< const CommunicationPatternBase >())
static ::ExceptionBase & ExcInternalError()
::IndexSet source_stored_elements