Reference documentation for deal.II version Git 180c135554 2021-06-23 17:42:41 -0400
\(\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 - 2021 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 #ifdef DEAL_II_TRILINOS_WITH_TPETRA
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(const ReadWriteVector<Number> &V,
154  VectorOperation::values operation,
155  std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
156  communication_pattern = {}) override;
157 
161  virtual Vector &
162  operator*=(const Number factor) override;
163 
167  virtual Vector &
168  operator/=(const Number factor) override;
169 
173  virtual Vector &
174  operator+=(const VectorSpaceVector<Number> &V) override;
175 
179  virtual Vector &
180  operator-=(const VectorSpaceVector<Number> &V) override;
181 
186  virtual Number
187  operator*(const VectorSpaceVector<Number> &V) const override;
188 
192  virtual void
193  add(const Number a) override;
194 
199  virtual void
200  add(const Number a, const VectorSpaceVector<Number> &V) override;
201 
206  virtual void
207  add(const Number a,
208  const VectorSpaceVector<Number> &V,
209  const Number b,
210  const VectorSpaceVector<Number> &W) override;
211 
216  virtual void
217  sadd(const Number s,
218  const Number a,
219  const VectorSpaceVector<Number> &V) override;
220 
227  virtual void
228  scale(const VectorSpaceVector<Number> &scaling_factors) override;
229 
233  virtual void
234  equ(const Number a, const VectorSpaceVector<Number> &V) override;
235 
239  virtual bool
240  all_zero() const override;
241 
245  virtual Number
246  mean_value() const override;
247 
253  l1_norm() const override;
254 
260  l2_norm() const override;
261 
267  linfty_norm() const override;
268 
291  virtual Number
292  add_and_dot(const Number a,
293  const VectorSpaceVector<Number> &V,
294  const VectorSpaceVector<Number> &W) override;
299  bool
300  has_ghost_elements() const;
301 
306  virtual size_type
307  size() const override;
308 
313  size_type
314  locally_owned_size() const;
315 
319  MPI_Comm
320  get_mpi_communicator() const;
321 
333  virtual ::IndexSet
334  locally_owned_elements() const override;
335 
340  const Tpetra::Vector<Number, int, types::global_dof_index> &
341  trilinos_vector() const;
342 
347  Tpetra::Vector<Number, int, types::global_dof_index> &
348  trilinos_vector();
349 
353  virtual void
354  print(std::ostream & out,
355  const unsigned int precision = 3,
356  const bool scientific = true,
357  const bool across = true) const override;
358 
362  virtual std::size_t
363  memory_consumption() const override;
364 
370 
377 
384  int,
385  << "An error with error number " << arg1
386  << " occurred while calling a Trilinos function");
387 
388  private:
394  void
395  create_tpetra_comm_pattern(const IndexSet &source_index_set,
396  const MPI_Comm &mpi_comm);
397 
401  std::unique_ptr<Tpetra::Vector<Number, int, types::global_dof_index>>
403 
408 
413  std::shared_ptr<const TpetraWrappers::CommunicationPattern>
415  };
416 
417 
418  template <typename Number>
419  inline bool
421  {
422  return false;
423  }
424  } // namespace TpetraWrappers
425 } // namespace LinearAlgebra
426 
427 
431 template <typename Number>
433  : std::false_type
434 {};
435 
437 
438 #endif
439 
440 #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:399
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:398
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