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
LinearAlgebra::TpetraWrappers::Vector::operator*=
virtual Vector & operator*=(const Number factor) override
LinearAlgebra::TpetraWrappers::Vector::size_type
typename VectorSpaceVector< Number >::size_type size_type
Definition: trilinos_tpetra_vector.h:89
IndexSet
Definition: index_set.h:74
LinearAlgebraDealII::Vector
Vector< double > Vector
Definition: generic_linear_algebra.h:43
LinearAlgebra::TpetraWrappers::Vector::operator*
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
LinearAlgebra::TpetraWrappers::Vector::has_ghost_elements
bool has_ghost_elements() const
Definition: trilinos_tpetra_vector.h:415
LinearAlgebra::TpetraWrappers::Vector::locally_owned_elements
virtual ::IndexSet locally_owned_elements() const override
LinearAlgebra
Definition: communication_pattern_base.h:30
LinearAlgebra::TpetraWrappers::Vector::scale
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
LinearAlgebra::TpetraWrappers::Vector::operator/=
virtual Vector & operator/=(const Number factor) override
LAPACKSupport::V
static const char V
Definition: lapack_support.h:175
MPI_Comm
LinearAlgebra::TpetraWrappers::Vector::ExcVectorTypeNotCompatible
static ::ExceptionBase & ExcVectorTypeNotCompatible()
LinearAlgebra::VectorSpaceVector::real_type
typename numbers::NumberTraits< Number >::real_type real_type
Definition: vector_space_vector.h:62
LinearAlgebra::TpetraWrappers::Vector::get_mpi_communicator
MPI_Comm get_mpi_communicator() const
LinearAlgebra::TpetraWrappers::Vector::print
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
vector_space_vector.h
LinearAlgebra::TpetraWrappers::Vector::l1_norm
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type l1_norm() const override
Subscriptor
Definition: subscriptor.h:62
is_serial_vector
Definition: vector_type_traits.h:49
vector_operation.h
mpi.h
index_set.h
subscriptor.h
vector_type_traits.h
LinearAlgebra::TpetraWrappers::Vector::equ
virtual void equ(const Number a, const VectorSpaceVector< Number > &V) override
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
Physics::Elasticity::Kinematics::b
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
LinearAlgebra::TpetraWrappers::Vector
Definition: trilinos_tpetra_vector.h:84
LinearAlgebra::TpetraWrappers::Vector::vector
std::unique_ptr< Tpetra::Vector< Number, int, types::global_dof_index > > vector
Definition: trilinos_tpetra_vector.h:397
LinearAlgebra::TpetraWrappers::Vector::all_zero
virtual bool all_zero() const override
DeclException1
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
LinearAlgebra::TpetraWrappers::Vector::trilinos_vector
const Tpetra::Vector< Number, int, types::global_dof_index > & trilinos_vector() const
VectorOperation::values
values
Definition: vector_operation.h:40
LinearAlgebra::TpetraWrappers::Vector::add_and_dot
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override
LinearAlgebra::TpetraWrappers::Vector::ExcTrilinosError
static ::ExceptionBase & ExcTrilinosError(int arg1)
LinearAlgebra::TpetraWrappers::Vector::sadd
virtual void sadd(const Number s, const Number a, const VectorSpaceVector< Number > &V) override
LinearAlgebra::TpetraWrappers::Vector::memory_consumption
virtual std::size_t memory_consumption() const override
LinearAlgebra::ReadWriteVector
Definition: read_write_vector.h:131
unsigned int
LinearAlgebra::TpetraWrappers::Vector::mean_value
virtual Number mean_value() const override
LinearAlgebra::TpetraWrappers::Vector::size
virtual size_type size() const override
LinearAlgebra::VectorSpaceVector
Definition: vector_space_vector.h:57
LinearAlgebra::TpetraWrappers::Vector::tpetra_comm_pattern
std::shared_ptr< const TpetraWrappers::CommunicationPattern > tpetra_comm_pattern
Definition: trilinos_tpetra_vector.h:409
DeclException0
#define DeclException0(Exception0)
Definition: exceptions.h:473
LinearAlgebra::TpetraWrappers::Vector::reinit
void reinit(const IndexSet &parallel_partitioner, const MPI_Comm &communicator, const bool omit_zeroing_entries=false)
LinearAlgebra::TpetraWrappers::Vector::create_tpetra_comm_pattern
void create_tpetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
config.h
LinearAlgebra::TpetraWrappers::Vector::operator-=
virtual Vector & operator-=(const VectorSpaceVector< Number > &V) override
LinearAlgebra::TpetraWrappers::Vector::add
virtual void add(const Number a) override
LinearAlgebra::TpetraWrappers::Vector::linfty_norm
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type linfty_norm() const override
trilinos_tpetra_communication_pattern.h
LinearAlgebra::TpetraWrappers::Vector::operator=
Vector & operator=(const Vector &V)
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
LinearAlgebra::TpetraWrappers::Vector::source_stored_elements
::IndexSet source_stored_elements
Definition: trilinos_tpetra_vector.h:402
LinearAlgebra::TpetraWrappers::Vector::l2_norm
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type l2_norm() const override
LinearAlgebra::TpetraWrappers::Vector::Vector
Vector()
LinearAlgebra::TpetraWrappers::Vector::ExcDifferentParallelPartitioning
static ::ExceptionBase & ExcDifferentParallelPartitioning()
LinearAlgebra::TpetraWrappers::Vector::operator+=
virtual Vector & operator+=(const VectorSpaceVector< Number > &V) override
LinearAlgebra::TpetraWrappers::Vector::value_type
Number value_type
Definition: trilinos_tpetra_vector.h:87