Reference documentation for deal.II version 9.0.0
trilinos_epetra_vector.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_trilinos_epetra_vector_h
17 #define dealii_trilinos_epetra_vector_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI)
23 
24 #include <deal.II/base/index_set.h>
25 #include <deal.II/base/subscriptor.h>
26 #include <deal.II/lac/trilinos_epetra_communication_pattern.h>
27 #include <deal.II/lac/vector_operation.h>
28 #include <deal.II/lac/vector_space_vector.h>
29 #include <deal.II/lac/vector_type_traits.h>
30 #include <memory>
31 
32 # include <mpi.h>
33 # include <Epetra_FEVector.h>
34 
35 DEAL_II_NAMESPACE_OPEN
36 
37 namespace LinearAlgebra
38 {
39  // Forward declaration
40  template <typename Number>
41  class ReadWriteVector;
42 
43  namespace EpetraWrappers
44  {
55  class Vector : public VectorSpaceVector<double>, public Subscriptor
56  {
57  public:
61  Vector();
62 
67  Vector(const Vector &V);
68 
75  explicit Vector(const IndexSet &parallel_partitioner,
76  const MPI_Comm &communicator);
77 
84  void reinit (const IndexSet &parallel_partitioner,
85  const MPI_Comm &communicator,
86  const bool omit_zeroing_entries = false);
87 
92  virtual void reinit(const VectorSpaceVector<double> &V,
93  const bool omit_zeroing_entries = false) override;
94 
100  Vector &operator= (const Vector &V);
101 
106  virtual Vector &operator= (const double s) override;
107 
116  virtual void import(const ReadWriteVector<double> &V,
117  VectorOperation::values operation,
118  std::shared_ptr<const CommunicationPatternBase> communication_pattern =
119  std::shared_ptr<const CommunicationPatternBase> ()) override;
120 
124  virtual Vector &operator*= (const double factor) override;
125 
129  virtual Vector &operator/= (const double factor) override;
130 
134  virtual Vector &operator+= (const VectorSpaceVector<double> &V) override;
135 
139  virtual Vector &operator-= (const VectorSpaceVector<double> &V) override;
140 
145  virtual double operator* (const VectorSpaceVector<double> &V) const override;
146 
150  virtual void add(const double a) override;
151 
156  virtual void add(const double a, const VectorSpaceVector<double> &V) override;
157 
162  virtual void add(const double a, const VectorSpaceVector<double> &V,
163  const double b, const VectorSpaceVector<double> &W) override;
164 
169  virtual void sadd(const double s, const double a,
170  const VectorSpaceVector<double> &V) override;
171 
178  virtual void scale(const VectorSpaceVector<double> &scaling_factors) override;
179 
183  virtual void equ(const double a, const VectorSpaceVector<double> &V) override;
184 
188  virtual bool all_zero() const override;
189 
193  virtual double mean_value() const override;
194 
199  virtual double l1_norm() const override;
200 
205  virtual double l2_norm() const override;
206 
211  virtual double linfty_norm() const override;
212 
234  virtual double add_and_dot(const double a,
235  const VectorSpaceVector<double> &V,
236  const VectorSpaceVector<double> &W) override;
241  bool has_ghost_elements() const;
242 
247  virtual size_type size() const override;
248 
252  MPI_Comm get_mpi_communicator() const;
253 
264  virtual ::IndexSet locally_owned_elements() const override;
265 
270  const Epetra_FEVector &trilinos_vector() const;
271 
276  Epetra_FEVector &trilinos_vector();
277 
281  virtual void print(std::ostream &out,
282  const unsigned int precision=3,
283  const bool scientific=true,
284  const bool across=true) const override;
285 
289  virtual std::size_t memory_consumption() const override;
290 
296 
303 
310  int,
311  << "An error with error number " << arg1
312  << " occurred while calling a Trilinos function");
313 
314  private:
320  void create_epetra_comm_pattern(const IndexSet &source_index_set,
321  const MPI_Comm &mpi_comm);
322 
326  std::unique_ptr<Epetra_FEVector> vector;
327 
332 
337  std::shared_ptr<const CommunicationPattern> epetra_comm_pattern;
338  };
339 
340 
341  inline
343  {
344  return false;
345  }
346  }
347 }
348 
349 
353 template <>
354 struct is_serial_vector<LinearAlgebra::EpetraWrappers::Vector> : std::false_type
355 {
356 };
357 
358 DEAL_II_NAMESPACE_CLOSE
359 
360 #endif
361 
362 #endif
virtual double l1_norm() const override
static ::ExceptionBase & ExcDifferentParallelPartitioning()
virtual ::IndexSet locally_owned_elements() const override
virtual double l2_norm() const override
virtual size_type size() const override
virtual void scale(const VectorSpaceVector< double > &scaling_factors) override
virtual std::size_t memory_consumption() const override
std::unique_ptr< Epetra_FEVector > vector
virtual void equ(const double a, const VectorSpaceVector< double > &V) override
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:346
void create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
virtual Vector & operator*=(const double factor) override
#define DeclException0(Exception0)
Definition: exceptions.h:323
const Epetra_FEVector & trilinos_vector() const
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcVectorTypeNotCompatible()
void reinit(const IndexSet &parallel_partitioner, const MPI_Comm &communicator, const bool omit_zeroing_entries=false)
std::shared_ptr< const CommunicationPattern > epetra_comm_pattern
virtual void sadd(const double s, const double a, const VectorSpaceVector< double > &V) override
virtual Vector & operator+=(const VectorSpaceVector< double > &V) override
virtual Vector & operator/=(const double factor) override
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
virtual double mean_value() const override
virtual Vector & operator-=(const VectorSpaceVector< double > &V) override
virtual double operator*(const VectorSpaceVector< double > &V) const override
virtual void add(const double a) override
virtual double linfty_norm() const override
virtual double add_and_dot(const double a, const VectorSpaceVector< double > &V, const VectorSpaceVector< double > &W) override