Reference documentation for deal.II version Git e12e976e47 2020-11-24 09:52:11 +0100
\(\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  {
82  template <typename Number>
83  class Vector : public VectorSpaceVector<Number>, public Subscriptor
84  {
85  public:
86  using value_type = Number;
87 
89 
93  Vector();
94 
99  Vector(const Vector &V);
100 
107  explicit Vector(const IndexSet &parallel_partitioner,
108  const MPI_Comm &communicator);
109 
116  void
117  reinit(const IndexSet &parallel_partitioner,
118  const MPI_Comm &communicator,
119  const bool omit_zeroing_entries = false);
120 
125  virtual void
127  const bool omit_zeroing_entries = false) override;
128 
134  Vector &
135  operator=(const Vector &V);
136 
141  virtual Vector &
142  operator=(const Number s) override;
143 
152  virtual void
153  import(
154  const ReadWriteVector<Number> & V,
155  VectorOperation::values operation,
156  std::shared_ptr<const CommunicationPatternBase> communication_pattern =
157  std::shared_ptr<const CommunicationPatternBase>()) override;
158 
162  virtual Vector &
163  operator*=(const Number factor) override;
164 
168  virtual Vector &
169  operator/=(const Number factor) override;
170 
174  virtual Vector &
175  operator+=(const VectorSpaceVector<Number> &V) override;
176 
180  virtual Vector &
181  operator-=(const VectorSpaceVector<Number> &V) override;
182 
187  virtual Number
188  operator*(const VectorSpaceVector<Number> &V) const override;
189 
193  virtual void
194  add(const Number a) override;
195 
200  virtual void
201  add(const Number a, const VectorSpaceVector<Number> &V) override;
202 
207  virtual void
208  add(const Number a,
210  const Number b,
211  const VectorSpaceVector<Number> &W) override;
212 
217  virtual void
218  sadd(const Number s,
219  const Number a,
220  const VectorSpaceVector<Number> &V) override;
221 
228  virtual void
229  scale(const VectorSpaceVector<Number> &scaling_factors) override;
230 
234  virtual void
235  equ(const Number a, const VectorSpaceVector<Number> &V) override;
236 
240  virtual bool
241  all_zero() const override;
242 
246  virtual Number
247  mean_value() const override;
248 
254  l1_norm() const override;
255 
261  l2_norm() const override;
262 
268  linfty_norm() const override;
269 
292  virtual Number
293  add_and_dot(const Number a,
295  const VectorSpaceVector<Number> &W) override;
300  bool
301  has_ghost_elements() const;
302 
307  virtual size_type
308  size() const override;
309 
313  MPI_Comm
314  get_mpi_communicator() const;
315 
327  virtual ::IndexSet
328  locally_owned_elements() const override;
329 
334  const Tpetra::Vector<Number, int, types::global_dof_index> &
335  trilinos_vector() const;
336 
341  Tpetra::Vector<Number, int, types::global_dof_index> &
342  trilinos_vector();
343 
347  virtual void
348  print(std::ostream & out,
349  const unsigned int precision = 3,
350  const bool scientific = true,
351  const bool across = true) const override;
352 
356  virtual std::size_t
357  memory_consumption() const override;
358 
364 
371 
378  int,
379  << "An error with error number " << arg1
380  << " occurred while calling a Trilinos function");
381 
382  private:
388  void
389  create_tpetra_comm_pattern(const IndexSet &source_index_set,
390  const MPI_Comm &mpi_comm);
391 
395  std::unique_ptr<Tpetra::Vector<Number, int, types::global_dof_index>>
397 
402 
407  std::shared_ptr<const TpetraWrappers::CommunicationPattern>
409  };
410 
411 
412  template <typename Number>
413  inline bool
415  {
416  return false;
417  }
418  } // namespace TpetraWrappers
419 } // namespace LinearAlgebra
420 
421 
425 template <typename Number>
427  : std::false_type
428 {};
429 
431 
432 #endif
433 
434 #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:515
#define DeclException0(Exception0)
Definition: exceptions.h:470
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:372
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:371
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