Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
trilinos_tpetra_vector.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2018 - 2020 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_trilinos_tpetra_vector_h
17 #define dealii_trilinos_tpetra_vector_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #if defined(DEAL_II_TRILINOS_WITH_TPETRA) && defined(DEAL_II_WITH_MPI)
23 
24 # include <deal.II/base/index_set.h>
26 
31 
32 # include <Teuchos_Comm.hpp>
33 # include <Teuchos_OrdinalTraits.hpp>
34 # include <Tpetra_Core.hpp>
35 # include <Tpetra_Vector.hpp>
36 # include <Tpetra_Version.hpp>
37 # include <mpi.h>
38 
39 # include <memory>
40 
42 
43 namespace LinearAlgebra
44 {
45  // Forward declaration
46 # ifndef DOXYGEN
47  template <typename Number>
48  class ReadWriteVector;
49 # endif
50 
58  namespace TpetraWrappers
59  {
83  template <typename Number>
84  class Vector : public VectorSpaceVector<Number>, public Subscriptor
85  {
86  public:
87  using value_type = Number;
88 
90 
94  Vector();
95 
100  Vector(const Vector &V);
101 
108  explicit Vector(const IndexSet &parallel_partitioner,
109  const MPI_Comm &communicator);
110 
117  void
118  reinit(const IndexSet &parallel_partitioner,
119  const MPI_Comm &communicator,
120  const bool omit_zeroing_entries = false);
121 
126  virtual void
128  const bool omit_zeroing_entries = false) override;
129 
135  Vector &
136  operator=(const Vector &V);
137 
142  virtual Vector &
143  operator=(const Number s) override;
144 
153  virtual void
154  import(
155  const ReadWriteVector<Number> & V,
156  VectorOperation::values operation,
157  std::shared_ptr<const CommunicationPatternBase> communication_pattern =
158  std::shared_ptr<const CommunicationPatternBase>()) override;
159 
163  virtual Vector &
164  operator*=(const Number factor) override;
165 
169  virtual Vector &
170  operator/=(const Number factor) override;
171 
175  virtual Vector &
176  operator+=(const VectorSpaceVector<Number> &V) override;
177 
181  virtual Vector &
182  operator-=(const VectorSpaceVector<Number> &V) override;
183 
188  virtual Number
189  operator*(const VectorSpaceVector<Number> &V) const override;
190 
194  virtual void
195  add(const Number a) override;
196 
201  virtual void
202  add(const Number a, const VectorSpaceVector<Number> &V) override;
203 
208  virtual void
209  add(const Number a,
211  const Number b,
212  const VectorSpaceVector<Number> &W) override;
213 
218  virtual void
219  sadd(const Number s,
220  const Number a,
221  const VectorSpaceVector<Number> &V) override;
222 
229  virtual void
230  scale(const VectorSpaceVector<Number> &scaling_factors) override;
231 
235  virtual void
236  equ(const Number a, const VectorSpaceVector<Number> &V) override;
237 
241  virtual bool
242  all_zero() const override;
243 
247  virtual Number
248  mean_value() const override;
249 
255  l1_norm() const override;
256 
262  l2_norm() const override;
263 
269  linfty_norm() const override;
270 
293  virtual Number
294  add_and_dot(const Number a,
296  const VectorSpaceVector<Number> &W) override;
301  bool
302  has_ghost_elements() const;
303 
308  virtual size_type
309  size() const override;
310 
314  MPI_Comm
315  get_mpi_communicator() const;
316 
328  virtual ::IndexSet
329  locally_owned_elements() const override;
330 
335  const Tpetra::Vector<Number, int, types::global_dof_index> &
336  trilinos_vector() const;
337 
342  Tpetra::Vector<Number, int, types::global_dof_index> &
343  trilinos_vector();
344 
348  virtual void
349  print(std::ostream & out,
350  const unsigned int precision = 3,
351  const bool scientific = true,
352  const bool across = true) const override;
353 
357  virtual std::size_t
358  memory_consumption() const override;
359 
365 
372 
379  int,
380  << "An error with error number " << arg1
381  << " occurred while calling a Trilinos function");
382 
383  private:
389  void
390  create_tpetra_comm_pattern(const IndexSet &source_index_set,
391  const MPI_Comm &mpi_comm);
392 
396  std::unique_ptr<Tpetra::Vector<Number, int, types::global_dof_index>>
398 
403 
408  std::shared_ptr<const TpetraWrappers::CommunicationPattern>
410  };
411 
412 
413  template <typename Number>
414  inline bool
416  {
417  return false;
418  }
419  } // namespace TpetraWrappers
420 } // namespace LinearAlgebra
421 
422 
426 template <typename Number>
428  : std::false_type
429 {};
430 
432 
433 #endif
434 
435 #endif
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type linfty_norm() const override
virtual Vector & operator-=(const VectorSpaceVector< Number > &V) override
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type l2_norm() const override
Vector & operator=(const Vector &V)
static const char V
virtual ::IndexSet locally_owned_elements() const override
virtual bool all_zero() const override
virtual Vector & operator/=(const Number factor) override
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
virtual void equ(const Number a, const VectorSpaceVector< Number > &V) override
static ::ExceptionBase & ExcVectorTypeNotCompatible()
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
#define DeclException0(Exception0)
Definition: exceptions.h:473
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
virtual Number mean_value() const override
static ::ExceptionBase & ExcTrilinosError(int arg1)
virtual void add(const Number a) override
std::shared_ptr< const TpetraWrappers::CommunicationPattern > tpetra_comm_pattern
void reinit(const IndexSet &parallel_partitioner, const MPI_Comm &communicator, const bool omit_zeroing_entries=false)
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type l1_norm() const override
static ::ExceptionBase & ExcDifferentParallelPartitioning()
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
typename numbers::NumberTraits< Number >::real_type real_type
const Tpetra::Vector< Number, int, types::global_dof_index > & trilinos_vector() const
virtual void sadd(const Number s, const Number a, const VectorSpaceVector< Number > &V) override
typename VectorSpaceVector< Number >::size_type size_type
virtual Vector & operator*=(const Number factor) override
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
std::unique_ptr< Tpetra::Vector< Number, int, types::global_dof_index > > vector
virtual Vector & operator+=(const VectorSpaceVector< Number > &V) override
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override
virtual std::size_t memory_consumption() const override
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
void create_tpetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
virtual size_type size() const override